babylon.module.d.ts 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415166416166417166418166419166420166421166422166423166424166425166426166427166428166429166430166431166432166433166434166435166436166437166438166439166440166441166442166443166444166445166446166447166448166449166450166451166452166453166454166455166456166457166458166459166460166461166462166463166464166465166466166467166468166469166470166471166472166473166474166475166476166477166478166479166480166481166482166483166484166485166486166487166488166489166490166491166492166493166494166495166496166497166498166499166500166501166502166503166504166505166506166507166508166509166510166511166512166513166514166515166516166517166518166519166520166521166522166523166524166525166526166527166528166529166530166531166532166533166534166535166536166537166538166539166540166541166542166543166544166545166546166547166548166549166550166551166552166553166554166555166556166557166558166559166560166561166562166563166564166565166566166567166568166569166570166571166572166573166574166575166576166577166578166579166580166581166582166583166584166585166586166587166588166589166590166591166592166593166594166595166596166597166598166599166600166601166602166603166604166605166606166607166608166609166610166611166612166613166614166615166616166617166618166619166620166621166622166623166624166625166626166627166628166629166630166631166632166633166634166635166636166637166638166639166640166641166642166643166644166645166646166647166648166649166650166651166652166653166654166655166656166657166658166659166660166661166662166663166664166665166666166667166668166669166670166671166672166673166674166675166676166677166678166679166680166681166682166683166684166685166686166687166688166689166690166691166692166693166694166695166696166697166698166699166700166701166702166703166704166705166706166707166708166709166710166711166712166713166714166715166716166717166718166719166720166721166722166723166724166725166726166727166728166729166730166731166732166733166734166735166736166737166738166739166740166741166742166743166744166745166746166747166748166749166750166751166752166753166754166755166756166757166758166759166760166761166762166763166764166765166766166767166768166769166770166771166772166773166774166775166776166777166778166779166780166781166782166783166784166785166786166787166788166789166790166791166792166793166794166795166796166797166798166799166800166801166802166803166804166805166806166807166808166809166810166811166812166813166814166815166816166817166818166819166820166821166822166823166824166825166826166827166828166829166830166831166832166833166834166835166836166837166838166839166840166841166842166843166844166845166846166847166848166849166850166851166852166853166854166855166856166857166858166859166860166861166862166863166864166865166866166867166868166869166870166871166872166873166874166875166876166877166878166879166880166881166882166883166884166885166886166887166888166889166890166891166892166893166894166895166896166897166898166899166900166901166902166903166904166905166906166907166908166909166910166911166912166913166914166915166916166917166918166919166920166921166922166923166924166925166926166927166928166929166930166931166932166933166934166935166936166937166938166939166940166941166942166943166944166945166946166947166948166949166950166951166952166953166954166955166956166957166958166959166960166961166962166963166964166965166966166967166968166969166970166971166972166973166974166975166976166977166978166979166980166981166982166983166984166985166986166987166988166989166990166991166992166993166994166995166996166997166998166999167000167001167002167003167004167005167006167007167008167009167010167011167012167013167014167015167016167017167018167019167020167021167022167023167024167025167026167027167028167029167030167031167032167033167034167035167036167037167038167039167040167041167042167043167044167045167046167047167048167049167050167051167052167053167054167055167056167057167058167059167060167061167062167063167064167065167066167067167068167069167070167071167072167073167074167075167076167077167078167079167080167081167082167083167084167085167086167087167088167089167090167091167092167093167094167095167096167097167098167099167100167101167102167103167104167105167106167107167108167109167110167111167112167113167114167115167116167117167118167119167120167121167122167123167124167125167126167127167128167129167130167131167132167133167134167135167136167137167138167139167140167141167142167143167144167145167146167147167148167149167150167151167152167153167154167155167156167157167158167159167160167161167162167163167164167165167166167167167168167169167170167171167172167173167174167175167176167177167178167179167180167181167182167183167184167185167186
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. /**
  334. * Message to display when a message has been logged too many times
  335. */
  336. static MessageLimitReached: string;
  337. private static _LogCache;
  338. private static _LogLimitOutputs;
  339. /**
  340. * Gets a value indicating the number of loading errors
  341. * @ignorenaming
  342. */
  343. static errorsCount: number;
  344. /**
  345. * Callback called when a new log is added
  346. */
  347. static OnNewCacheEntry: (entry: string) => void;
  348. private static _CheckLimit;
  349. private static _GenerateLimitMessage;
  350. private static _AddLogEntry;
  351. private static _FormatMessage;
  352. private static _LogDisabled;
  353. private static _LogEnabled;
  354. private static _WarnDisabled;
  355. private static _WarnEnabled;
  356. private static _ErrorDisabled;
  357. private static _ErrorEnabled;
  358. /**
  359. * Log a message to the console
  360. */
  361. static Log: (message: string, limit?: number) => void;
  362. /**
  363. * Write a warning message to the console
  364. */
  365. static Warn: (message: string, limit?: number) => void;
  366. /**
  367. * Write an error message to the console
  368. */
  369. static Error: (message: string, limit?: number) => void;
  370. /**
  371. * Gets current log cache (list of logs)
  372. */
  373. static get LogCache(): string;
  374. /**
  375. * Clears the log cache
  376. */
  377. static ClearLogCache(): void;
  378. /**
  379. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  380. */
  381. static set LogLevels(level: number);
  382. }
  383. }
  384. declare module "babylonjs/Misc/typeStore" {
  385. /** @hidden */
  386. export class _TypeStore {
  387. /** @hidden */
  388. static RegisteredTypes: {
  389. [key: string]: Object;
  390. };
  391. /** @hidden */
  392. static GetClass(fqdn: string): any;
  393. }
  394. }
  395. declare module "babylonjs/Misc/stringTools" {
  396. /**
  397. * Helper to manipulate strings
  398. */
  399. export class StringTools {
  400. /**
  401. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static EndsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  409. * @param str Source string
  410. * @param suffix Suffix to search for in the source string
  411. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  412. */
  413. static StartsWith(str: string, suffix: string): boolean;
  414. /**
  415. * Decodes a buffer into a string
  416. * @param buffer The buffer to decode
  417. * @returns The decoded string
  418. */
  419. static Decode(buffer: Uint8Array | Uint16Array): string;
  420. /**
  421. * Encode a buffer to a base64 string
  422. * @param buffer defines the buffer to encode
  423. * @returns the encoded string
  424. */
  425. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  426. /**
  427. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  428. * @param num the number to convert and pad
  429. * @param length the expected length of the string
  430. * @returns the padded string
  431. */
  432. static PadNumber(num: number, length: number): string;
  433. }
  434. }
  435. declare module "babylonjs/Misc/deepCopier" {
  436. /**
  437. * Class containing a set of static utilities functions for deep copy.
  438. */
  439. export class DeepCopier {
  440. /**
  441. * Tries to copy an object by duplicating every property
  442. * @param source defines the source object
  443. * @param destination defines the target object
  444. * @param doNotCopyList defines a list of properties to avoid
  445. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  446. */
  447. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  448. }
  449. }
  450. declare module "babylonjs/Misc/precisionDate" {
  451. /**
  452. * Class containing a set of static utilities functions for precision date
  453. */
  454. export class PrecisionDate {
  455. /**
  456. * Gets either window.performance.now() if supported or Date.now() else
  457. */
  458. static get Now(): number;
  459. }
  460. }
  461. declare module "babylonjs/Misc/devTools" {
  462. /** @hidden */
  463. export class _DevTools {
  464. static WarnImport(name: string): string;
  465. }
  466. }
  467. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  468. /**
  469. * Interface used to define the mechanism to get data from the network
  470. */
  471. export interface IWebRequest {
  472. /**
  473. * Returns client's response url
  474. */
  475. responseURL: string;
  476. /**
  477. * Returns client's status
  478. */
  479. status: number;
  480. /**
  481. * Returns client's status as a text
  482. */
  483. statusText: string;
  484. }
  485. }
  486. declare module "babylonjs/Misc/webRequest" {
  487. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  488. import { Nullable } from "babylonjs/types";
  489. /**
  490. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  491. */
  492. export class WebRequest implements IWebRequest {
  493. private readonly _xhr;
  494. /**
  495. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  496. * i.e. when loading files, where the server/service expects an Authorization header
  497. */
  498. static CustomRequestHeaders: {
  499. [key: string]: string;
  500. };
  501. /**
  502. * Add callback functions in this array to update all the requests before they get sent to the network
  503. */
  504. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  505. private _injectCustomRequestHeaders;
  506. /**
  507. * Gets or sets a function to be called when loading progress changes
  508. */
  509. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  510. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  511. /**
  512. * Returns client's state
  513. */
  514. get readyState(): number;
  515. /**
  516. * Returns client's status
  517. */
  518. get status(): number;
  519. /**
  520. * Returns client's status as a text
  521. */
  522. get statusText(): string;
  523. /**
  524. * Returns client's response
  525. */
  526. get response(): any;
  527. /**
  528. * Returns client's response url
  529. */
  530. get responseURL(): string;
  531. /**
  532. * Returns client's response as text
  533. */
  534. get responseText(): string;
  535. /**
  536. * Gets or sets the expected response type
  537. */
  538. get responseType(): XMLHttpRequestResponseType;
  539. set responseType(value: XMLHttpRequestResponseType);
  540. /** @hidden */
  541. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  542. /** @hidden */
  543. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  544. /**
  545. * Cancels any network activity
  546. */
  547. abort(): void;
  548. /**
  549. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  550. * @param body defines an optional request body
  551. */
  552. send(body?: Document | BodyInit | null): void;
  553. /**
  554. * Sets the request method, request URL
  555. * @param method defines the method to use (GET, POST, etc..)
  556. * @param url defines the url to connect with
  557. */
  558. open(method: string, url: string): void;
  559. /**
  560. * Sets the value of a request header.
  561. * @param name The name of the header whose value is to be set
  562. * @param value The value to set as the body of the header
  563. */
  564. setRequestHeader(name: string, value: string): void;
  565. /**
  566. * Get the string containing the text of a particular header's value.
  567. * @param name The name of the header
  568. * @returns The string containing the text of the given header name
  569. */
  570. getResponseHeader(name: string): Nullable<string>;
  571. }
  572. }
  573. declare module "babylonjs/Misc/fileRequest" {
  574. import { Observable } from "babylonjs/Misc/observable";
  575. /**
  576. * File request interface
  577. */
  578. export interface IFileRequest {
  579. /**
  580. * Raised when the request is complete (success or error).
  581. */
  582. onCompleteObservable: Observable<IFileRequest>;
  583. /**
  584. * Aborts the request for a file.
  585. */
  586. abort: () => void;
  587. }
  588. }
  589. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  590. /**
  591. * Define options used to create a render target texture
  592. */
  593. export class RenderTargetCreationOptions {
  594. /**
  595. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  596. */
  597. createMipMaps?: boolean;
  598. /**
  599. * Specifies if mipmaps must be generated
  600. */
  601. generateMipMaps?: boolean;
  602. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  603. generateDepthBuffer?: boolean;
  604. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  605. generateStencilBuffer?: boolean;
  606. /** Defines texture type (int by default) */
  607. type?: number;
  608. /** Defines sampling mode (trilinear by default) */
  609. samplingMode?: number;
  610. /** Defines format (RGBA by default) */
  611. format?: number;
  612. /** Defines sample count (1 by default) */
  613. samples?: number;
  614. }
  615. }
  616. declare module "babylonjs/Engines/constants" {
  617. /** Defines the cross module used constants to avoid circular dependncies */
  618. export class Constants {
  619. /** Defines that alpha blending is disabled */
  620. static readonly ALPHA_DISABLE: number;
  621. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  622. static readonly ALPHA_ADD: number;
  623. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  624. static readonly ALPHA_COMBINE: number;
  625. /** Defines that alpha blending is DEST - SRC * DEST */
  626. static readonly ALPHA_SUBTRACT: number;
  627. /** Defines that alpha blending is SRC * DEST */
  628. static readonly ALPHA_MULTIPLY: number;
  629. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  630. static readonly ALPHA_MAXIMIZED: number;
  631. /** Defines that alpha blending is SRC + DEST */
  632. static readonly ALPHA_ONEONE: number;
  633. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  634. static readonly ALPHA_PREMULTIPLIED: number;
  635. /**
  636. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  637. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  638. */
  639. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  640. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  641. static readonly ALPHA_INTERPOLATE: number;
  642. /**
  643. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  644. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  645. */
  646. static readonly ALPHA_SCREENMODE: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA + DST ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEONE: number;
  652. /**
  653. * Defines that alpha blending is SRC * DST ALPHA + DST
  654. * Alpha will be set to 0
  655. */
  656. static readonly ALPHA_ALPHATOCOLOR: number;
  657. /**
  658. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  659. */
  660. static readonly ALPHA_REVERSEONEMINUS: number;
  661. /**
  662. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  663. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  664. */
  665. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  666. /**
  667. * Defines that alpha blending is SRC + DST
  668. * Alpha will be set to SRC ALPHA
  669. */
  670. static readonly ALPHA_ONEONE_ONEZERO: number;
  671. /**
  672. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  673. * Alpha will be set to DST ALPHA
  674. */
  675. static readonly ALPHA_EXCLUSION: number;
  676. /** Defines that alpha blending equation a SUM */
  677. static readonly ALPHA_EQUATION_ADD: number;
  678. /** Defines that alpha blending equation a SUBSTRACTION */
  679. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  680. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  681. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  682. /** Defines that alpha blending equation a MAX operation */
  683. static readonly ALPHA_EQUATION_MAX: number;
  684. /** Defines that alpha blending equation a MIN operation */
  685. static readonly ALPHA_EQUATION_MIN: number;
  686. /**
  687. * Defines that alpha blending equation a DARKEN operation:
  688. * It takes the min of the src and sums the alpha channels.
  689. */
  690. static readonly ALPHA_EQUATION_DARKEN: number;
  691. /** Defines that the ressource is not delayed*/
  692. static readonly DELAYLOADSTATE_NONE: number;
  693. /** Defines that the ressource was successfully delay loaded */
  694. static readonly DELAYLOADSTATE_LOADED: number;
  695. /** Defines that the ressource is currently delay loading */
  696. static readonly DELAYLOADSTATE_LOADING: number;
  697. /** Defines that the ressource is delayed and has not started loading */
  698. static readonly DELAYLOADSTATE_NOTLOADED: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  700. static readonly NEVER: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  702. static readonly ALWAYS: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  704. static readonly LESS: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  706. static readonly EQUAL: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  708. static readonly LEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  710. static readonly GREATER: number;
  711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  712. static readonly GEQUAL: number;
  713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  714. static readonly NOTEQUAL: number;
  715. /** Passed to stencilOperation to specify that stencil value must be kept */
  716. static readonly KEEP: number;
  717. /** Passed to stencilOperation to specify that stencil value must be zero */
  718. static readonly ZERO: number;
  719. /** Passed to stencilOperation to specify that stencil value must be replaced */
  720. static readonly REPLACE: number;
  721. /** Passed to stencilOperation to specify that stencil value must be incremented */
  722. static readonly INCR: number;
  723. /** Passed to stencilOperation to specify that stencil value must be decremented */
  724. static readonly DECR: number;
  725. /** Passed to stencilOperation to specify that stencil value must be inverted */
  726. static readonly INVERT: number;
  727. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  728. static readonly INCR_WRAP: number;
  729. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  730. static readonly DECR_WRAP: number;
  731. /** Texture is not repeating outside of 0..1 UVs */
  732. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  733. /** Texture is repeating outside of 0..1 UVs */
  734. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  735. /** Texture is repeating and mirrored */
  736. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  737. /** ALPHA */
  738. static readonly TEXTUREFORMAT_ALPHA: number;
  739. /** LUMINANCE */
  740. static readonly TEXTUREFORMAT_LUMINANCE: number;
  741. /** LUMINANCE_ALPHA */
  742. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  743. /** RGB */
  744. static readonly TEXTUREFORMAT_RGB: number;
  745. /** RGBA */
  746. static readonly TEXTUREFORMAT_RGBA: number;
  747. /** RED */
  748. static readonly TEXTUREFORMAT_RED: number;
  749. /** RED (2nd reference) */
  750. static readonly TEXTUREFORMAT_R: number;
  751. /** RG */
  752. static readonly TEXTUREFORMAT_RG: number;
  753. /** RED_INTEGER */
  754. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  755. /** RED_INTEGER (2nd reference) */
  756. static readonly TEXTUREFORMAT_R_INTEGER: number;
  757. /** RG_INTEGER */
  758. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  759. /** RGB_INTEGER */
  760. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  761. /** RGBA_INTEGER */
  762. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  763. /** BGRA */
  764. static readonly TEXTUREFORMAT_BGRA: number;
  765. /** Depth 24 bits + Stencil 8 bits */
  766. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  767. /** Depth 32 bits float */
  768. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  769. /** Compressed BC7 */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  771. /** Compressed BC6 unsigned float */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  773. /** Compressed BC6 signed float */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  775. /** Compressed BC3 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  777. /** Compressed BC2 */
  778. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  779. /** Compressed BC1 */
  780. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  781. /** UNSIGNED_BYTE */
  782. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  783. /** UNSIGNED_BYTE (2nd reference) */
  784. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  785. /** FLOAT */
  786. static readonly TEXTURETYPE_FLOAT: number;
  787. /** HALF_FLOAT */
  788. static readonly TEXTURETYPE_HALF_FLOAT: number;
  789. /** BYTE */
  790. static readonly TEXTURETYPE_BYTE: number;
  791. /** SHORT */
  792. static readonly TEXTURETYPE_SHORT: number;
  793. /** UNSIGNED_SHORT */
  794. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  795. /** INT */
  796. static readonly TEXTURETYPE_INT: number;
  797. /** UNSIGNED_INT */
  798. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  799. /** UNSIGNED_SHORT_4_4_4_4 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  801. /** UNSIGNED_SHORT_5_5_5_1 */
  802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  803. /** UNSIGNED_SHORT_5_6_5 */
  804. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  805. /** UNSIGNED_INT_2_10_10_10_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  807. /** UNSIGNED_INT_24_8 */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  809. /** UNSIGNED_INT_10F_11F_11F_REV */
  810. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  811. /** UNSIGNED_INT_5_9_9_9_REV */
  812. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  813. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  814. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  815. /** nearest is mag = nearest and min = nearest and no mip */
  816. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  817. /** mag = nearest and min = nearest and mip = none */
  818. static readonly TEXTURE_NEAREST_NEAREST: number;
  819. /** Bilinear is mag = linear and min = linear and no mip */
  820. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  821. /** mag = linear and min = linear and mip = none */
  822. static readonly TEXTURE_LINEAR_LINEAR: number;
  823. /** Trilinear is mag = linear and min = linear and mip = linear */
  824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  825. /** Trilinear is mag = linear and min = linear and mip = linear */
  826. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  827. /** mag = nearest and min = nearest and mip = nearest */
  828. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  829. /** mag = nearest and min = linear and mip = nearest */
  830. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  831. /** mag = nearest and min = linear and mip = linear */
  832. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  833. /** mag = nearest and min = linear and mip = none */
  834. static readonly TEXTURE_NEAREST_LINEAR: number;
  835. /** nearest is mag = nearest and min = nearest and mip = linear */
  836. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  837. /** mag = linear and min = nearest and mip = nearest */
  838. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = linear */
  840. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  841. /** Bilinear is mag = linear and min = linear and mip = nearest */
  842. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  843. /** mag = linear and min = nearest and mip = none */
  844. static readonly TEXTURE_LINEAR_NEAREST: number;
  845. /** Explicit coordinates mode */
  846. static readonly TEXTURE_EXPLICIT_MODE: number;
  847. /** Spherical coordinates mode */
  848. static readonly TEXTURE_SPHERICAL_MODE: number;
  849. /** Planar coordinates mode */
  850. static readonly TEXTURE_PLANAR_MODE: number;
  851. /** Cubic coordinates mode */
  852. static readonly TEXTURE_CUBIC_MODE: number;
  853. /** Projection coordinates mode */
  854. static readonly TEXTURE_PROJECTION_MODE: number;
  855. /** Skybox coordinates mode */
  856. static readonly TEXTURE_SKYBOX_MODE: number;
  857. /** Inverse Cubic coordinates mode */
  858. static readonly TEXTURE_INVCUBIC_MODE: number;
  859. /** Equirectangular coordinates mode */
  860. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  861. /** Equirectangular Fixed coordinates mode */
  862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  863. /** Equirectangular Fixed Mirrored coordinates mode */
  864. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  865. /** Offline (baking) quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  867. /** High quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  869. /** Medium quality for texture filtering */
  870. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  871. /** Low quality for texture filtering */
  872. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  873. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  874. static readonly SCALEMODE_FLOOR: number;
  875. /** Defines that texture rescaling will look for the nearest power of 2 size */
  876. static readonly SCALEMODE_NEAREST: number;
  877. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  878. static readonly SCALEMODE_CEILING: number;
  879. /**
  880. * The dirty texture flag value
  881. */
  882. static readonly MATERIAL_TextureDirtyFlag: number;
  883. /**
  884. * The dirty light flag value
  885. */
  886. static readonly MATERIAL_LightDirtyFlag: number;
  887. /**
  888. * The dirty fresnel flag value
  889. */
  890. static readonly MATERIAL_FresnelDirtyFlag: number;
  891. /**
  892. * The dirty attribute flag value
  893. */
  894. static readonly MATERIAL_AttributesDirtyFlag: number;
  895. /**
  896. * The dirty misc flag value
  897. */
  898. static readonly MATERIAL_MiscDirtyFlag: number;
  899. /**
  900. * The dirty prepass flag value
  901. */
  902. static readonly MATERIAL_PrePassDirtyFlag: number;
  903. /**
  904. * The all dirty flag value
  905. */
  906. static readonly MATERIAL_AllDirtyFlag: number;
  907. /**
  908. * Returns the triangle fill mode
  909. */
  910. static readonly MATERIAL_TriangleFillMode: number;
  911. /**
  912. * Returns the wireframe mode
  913. */
  914. static readonly MATERIAL_WireFrameFillMode: number;
  915. /**
  916. * Returns the point fill mode
  917. */
  918. static readonly MATERIAL_PointFillMode: number;
  919. /**
  920. * Returns the point list draw mode
  921. */
  922. static readonly MATERIAL_PointListDrawMode: number;
  923. /**
  924. * Returns the line list draw mode
  925. */
  926. static readonly MATERIAL_LineListDrawMode: number;
  927. /**
  928. * Returns the line loop draw mode
  929. */
  930. static readonly MATERIAL_LineLoopDrawMode: number;
  931. /**
  932. * Returns the line strip draw mode
  933. */
  934. static readonly MATERIAL_LineStripDrawMode: number;
  935. /**
  936. * Returns the triangle strip draw mode
  937. */
  938. static readonly MATERIAL_TriangleStripDrawMode: number;
  939. /**
  940. * Returns the triangle fan draw mode
  941. */
  942. static readonly MATERIAL_TriangleFanDrawMode: number;
  943. /**
  944. * Stores the clock-wise side orientation
  945. */
  946. static readonly MATERIAL_ClockWiseSideOrientation: number;
  947. /**
  948. * Stores the counter clock-wise side orientation
  949. */
  950. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  951. /**
  952. * Nothing
  953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_NothingTrigger: number;
  956. /**
  957. * On pick
  958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPickTrigger: number;
  961. /**
  962. * On left pick
  963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnLeftPickTrigger: number;
  966. /**
  967. * On right pick
  968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnRightPickTrigger: number;
  971. /**
  972. * On center pick
  973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnCenterPickTrigger: number;
  976. /**
  977. * On pick down
  978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnPickDownTrigger: number;
  981. /**
  982. * On double pick
  983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnDoublePickTrigger: number;
  986. /**
  987. * On pick up
  988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  989. */
  990. static readonly ACTION_OnPickUpTrigger: number;
  991. /**
  992. * On pick out.
  993. * This trigger will only be raised if you also declared a OnPickDown
  994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  995. */
  996. static readonly ACTION_OnPickOutTrigger: number;
  997. /**
  998. * On long press
  999. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1000. */
  1001. static readonly ACTION_OnLongPressTrigger: number;
  1002. /**
  1003. * On pointer over
  1004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1005. */
  1006. static readonly ACTION_OnPointerOverTrigger: number;
  1007. /**
  1008. * On pointer out
  1009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1010. */
  1011. static readonly ACTION_OnPointerOutTrigger: number;
  1012. /**
  1013. * On every frame
  1014. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1015. */
  1016. static readonly ACTION_OnEveryFrameTrigger: number;
  1017. /**
  1018. * On intersection enter
  1019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1020. */
  1021. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1022. /**
  1023. * On intersection exit
  1024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1025. */
  1026. static readonly ACTION_OnIntersectionExitTrigger: number;
  1027. /**
  1028. * On key down
  1029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1030. */
  1031. static readonly ACTION_OnKeyDownTrigger: number;
  1032. /**
  1033. * On key up
  1034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1035. */
  1036. static readonly ACTION_OnKeyUpTrigger: number;
  1037. /**
  1038. * Billboard mode will only apply to Y axis
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1041. /**
  1042. * Billboard mode will apply to all axes
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1045. /**
  1046. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1047. */
  1048. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1049. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1050. * Test order :
  1051. * Is the bounding sphere outside the frustum ?
  1052. * If not, are the bounding box vertices outside the frustum ?
  1053. * It not, then the cullable object is in the frustum.
  1054. */
  1055. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1056. /** Culling strategy : Bounding Sphere Only.
  1057. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1058. * It's also less accurate than the standard because some not visible objects can still be selected.
  1059. * Test : is the bounding sphere outside the frustum ?
  1060. * If not, then the cullable object is in the frustum.
  1061. */
  1062. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1063. /** Culling strategy : Optimistic Inclusion.
  1064. * This in an inclusion test first, then the standard exclusion test.
  1065. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1066. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1067. * Anyway, it's as accurate as the standard strategy.
  1068. * Test :
  1069. * Is the cullable object bounding sphere center in the frustum ?
  1070. * If not, apply the default culling strategy.
  1071. */
  1072. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1073. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1074. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1075. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1076. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1077. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1078. * Test :
  1079. * Is the cullable object bounding sphere center in the frustum ?
  1080. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1081. */
  1082. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1083. /**
  1084. * No logging while loading
  1085. */
  1086. static readonly SCENELOADER_NO_LOGGING: number;
  1087. /**
  1088. * Minimal logging while loading
  1089. */
  1090. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1091. /**
  1092. * Summary logging while loading
  1093. */
  1094. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1095. /**
  1096. * Detailled logging while loading
  1097. */
  1098. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1099. /**
  1100. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1101. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1102. */
  1103. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1104. /**
  1105. * Constant used to retrieve the position texture index in the textures array in the prepass
  1106. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1107. */
  1108. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1109. /**
  1110. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1111. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1112. */
  1113. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1114. /**
  1115. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1116. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1117. */
  1118. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1119. /**
  1120. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1121. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1122. */
  1123. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1124. /**
  1125. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1126. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1127. */
  1128. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1129. /**
  1130. * Constant used to retrieve albedo index in the textures array in the prepass
  1131. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1132. */
  1133. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1134. /**
  1135. * Prefixes used by the engine for custom effects
  1136. */
  1137. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Materials/Textures/hardwareTextureWrapper" {
  1141. /** @hidden */
  1142. export interface HardwareTextureWrapper {
  1143. underlyingResource: any;
  1144. set(hardwareTexture: any): void;
  1145. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1146. reset(): void;
  1147. release(): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1151. import { Nullable } from "babylonjs/types";
  1152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1153. /**
  1154. * This represents the required contract to create a new type of texture loader.
  1155. */
  1156. export interface IInternalTextureLoader {
  1157. /**
  1158. * Defines wether the loader supports cascade loading the different faces.
  1159. */
  1160. supportCascades: boolean;
  1161. /**
  1162. * This returns if the loader support the current file information.
  1163. * @param extension defines the file extension of the file being loaded
  1164. * @param mimeType defines the optional mime type of the file being loaded
  1165. * @returns true if the loader can load the specified file
  1166. */
  1167. canLoad(extension: string, mimeType?: string): boolean;
  1168. /**
  1169. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1170. * @param data contains the texture data
  1171. * @param texture defines the BabylonJS internal texture
  1172. * @param createPolynomials will be true if polynomials have been requested
  1173. * @param onLoad defines the callback to trigger once the texture is ready
  1174. * @param onError defines the callback to trigger in case of error
  1175. * @param options options to be passed to the loader
  1176. */
  1177. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1178. /**
  1179. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1180. * @param data contains the texture data
  1181. * @param texture defines the BabylonJS internal texture
  1182. * @param callback defines the method to call once ready to upload
  1183. * @param options options to be passed to the loader
  1184. */
  1185. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1186. }
  1187. }
  1188. declare module "babylonjs/Maths/math.like" {
  1189. import { float, int, DeepImmutable } from "babylonjs/types";
  1190. /**
  1191. * @hidden
  1192. */
  1193. export interface IColor4Like {
  1194. r: float;
  1195. g: float;
  1196. b: float;
  1197. a: float;
  1198. }
  1199. /**
  1200. * @hidden
  1201. */
  1202. export interface IColor3Like {
  1203. r: float;
  1204. g: float;
  1205. b: float;
  1206. }
  1207. /**
  1208. * @hidden
  1209. */
  1210. export interface IVector4Like {
  1211. x: float;
  1212. y: float;
  1213. z: float;
  1214. w: float;
  1215. }
  1216. /**
  1217. * @hidden
  1218. */
  1219. export interface IVector3Like {
  1220. x: float;
  1221. y: float;
  1222. z: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IVector2Like {
  1228. x: float;
  1229. y: float;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IMatrixLike {
  1235. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1236. updateFlag: int;
  1237. }
  1238. /**
  1239. * @hidden
  1240. */
  1241. export interface IViewportLike {
  1242. x: float;
  1243. y: float;
  1244. width: float;
  1245. height: float;
  1246. }
  1247. /**
  1248. * @hidden
  1249. */
  1250. export interface IPlaneLike {
  1251. normal: IVector3Like;
  1252. d: float;
  1253. normalize(): void;
  1254. }
  1255. }
  1256. declare module "babylonjs/Engines/IPipelineContext" {
  1257. import { Nullable } from "babylonjs/types";
  1258. import { Effect } from "babylonjs/Materials/effect";
  1259. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  1260. /**
  1261. * Class used to store and describe the pipeline context associated with an effect
  1262. */
  1263. export interface IPipelineContext {
  1264. /**
  1265. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1266. */
  1267. isAsync: boolean;
  1268. /**
  1269. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1270. */
  1271. isReady: boolean;
  1272. /** @hidden */
  1273. _name?: string;
  1274. /** @hidden */
  1275. _getVertexShaderCode(): string | null;
  1276. /** @hidden */
  1277. _getFragmentShaderCode(): string | null;
  1278. /** @hidden */
  1279. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1280. /** @hidden */
  1281. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1282. [key: string]: number;
  1283. }, uniformsNames: string[], uniforms: {
  1284. [key: string]: Nullable<WebGLUniformLocation>;
  1285. }, samplerList: string[], samplers: {
  1286. [key: string]: number;
  1287. }, attributesNames: string[], attributes: number[]): void;
  1288. /** Releases the resources associated with the pipeline. */
  1289. dispose(): void;
  1290. /**
  1291. * Sets an integer value on a uniform variable.
  1292. * @param uniformName Name of the variable.
  1293. * @param value Value to be set.
  1294. */
  1295. setInt(uniformName: string, value: number): void;
  1296. /**
  1297. * Sets an int2 value on a uniform variable.
  1298. * @param uniformName Name of the variable.
  1299. * @param x First int in int2.
  1300. * @param y Second int in int2.
  1301. */
  1302. setInt2(uniformName: string, x: number, y: number): void;
  1303. /**
  1304. * Sets an int3 value on a uniform variable.
  1305. * @param uniformName Name of the variable.
  1306. * @param x First int in int3.
  1307. * @param y Second int in int3.
  1308. * @param z Third int in int3.
  1309. */
  1310. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1311. /**
  1312. * Sets an int4 value on a uniform variable.
  1313. * @param uniformName Name of the variable.
  1314. * @param x First int in int4.
  1315. * @param y Second int in int4.
  1316. * @param z Third int in int4.
  1317. * @param w Fourth int in int4.
  1318. */
  1319. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1320. /**
  1321. * Sets an int array on a uniform variable.
  1322. * @param uniformName Name of the variable.
  1323. * @param array array to be set.
  1324. */
  1325. setIntArray(uniformName: string, array: Int32Array): void;
  1326. /**
  1327. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1328. * @param uniformName Name of the variable.
  1329. * @param array array to be set.
  1330. */
  1331. setIntArray2(uniformName: string, array: Int32Array): void;
  1332. /**
  1333. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1334. * @param uniformName Name of the variable.
  1335. * @param array array to be set.
  1336. */
  1337. setIntArray3(uniformName: string, array: Int32Array): void;
  1338. /**
  1339. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1340. * @param uniformName Name of the variable.
  1341. * @param array array to be set.
  1342. */
  1343. setIntArray4(uniformName: string, array: Int32Array): void;
  1344. /**
  1345. * Sets an array on a uniform variable.
  1346. * @param uniformName Name of the variable.
  1347. * @param array array to be set.
  1348. */
  1349. setArray(uniformName: string, array: number[] | Float32Array): void;
  1350. /**
  1351. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1352. * @param uniformName Name of the variable.
  1353. * @param array array to be set.
  1354. */
  1355. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1356. /**
  1357. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1358. * @param uniformName Name of the variable.
  1359. * @param array array to be set.
  1360. */
  1361. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1362. /**
  1363. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1364. * @param uniformName Name of the variable.
  1365. * @param array array to be set.
  1366. */
  1367. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1368. /**
  1369. * Sets matrices on a uniform variable.
  1370. * @param uniformName Name of the variable.
  1371. * @param matrices matrices to be set.
  1372. */
  1373. setMatrices(uniformName: string, matrices: Float32Array): void;
  1374. /**
  1375. * Sets matrix on a uniform variable.
  1376. * @param uniformName Name of the variable.
  1377. * @param matrix matrix to be set.
  1378. */
  1379. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1380. /**
  1381. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1382. * @param uniformName Name of the variable.
  1383. * @param matrix matrix to be set.
  1384. */
  1385. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1386. /**
  1387. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1388. * @param uniformName Name of the variable.
  1389. * @param matrix matrix to be set.
  1390. */
  1391. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1392. /**
  1393. * Sets a float on a uniform variable.
  1394. * @param uniformName Name of the variable.
  1395. * @param value value to be set.
  1396. */
  1397. setFloat(uniformName: string, value: number): void;
  1398. /**
  1399. * Sets a Vector2 on a uniform variable.
  1400. * @param uniformName Name of the variable.
  1401. * @param vector2 vector2 to be set.
  1402. */
  1403. setVector2(uniformName: string, vector2: IVector2Like): void;
  1404. /**
  1405. * Sets a float2 on a uniform variable.
  1406. * @param uniformName Name of the variable.
  1407. * @param x First float in float2.
  1408. * @param y Second float in float2.
  1409. */
  1410. setFloat2(uniformName: string, x: number, y: number): void;
  1411. /**
  1412. * Sets a Vector3 on a uniform variable.
  1413. * @param uniformName Name of the variable.
  1414. * @param vector3 Value to be set.
  1415. */
  1416. setVector3(uniformName: string, vector3: IVector3Like): void;
  1417. /**
  1418. * Sets a float3 on a uniform variable.
  1419. * @param uniformName Name of the variable.
  1420. * @param x First float in float3.
  1421. * @param y Second float in float3.
  1422. * @param z Third float in float3.
  1423. */
  1424. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1425. /**
  1426. * Sets a Vector4 on a uniform variable.
  1427. * @param uniformName Name of the variable.
  1428. * @param vector4 Value to be set.
  1429. */
  1430. setVector4(uniformName: string, vector4: IVector4Like): void;
  1431. /**
  1432. * Sets a float4 on a uniform variable.
  1433. * @param uniformName Name of the variable.
  1434. * @param x First float in float4.
  1435. * @param y Second float in float4.
  1436. * @param z Third float in float4.
  1437. * @param w Fourth float in float4.
  1438. */
  1439. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1440. /**
  1441. * Sets a Color3 on a uniform variable.
  1442. * @param uniformName Name of the variable.
  1443. * @param color3 Value to be set.
  1444. */
  1445. setColor3(uniformName: string, color3: IColor3Like): void;
  1446. /**
  1447. * Sets a Color4 on a uniform variable.
  1448. * @param uniformName Name of the variable.
  1449. * @param color3 Value to be set.
  1450. * @param alpha Alpha value to be set.
  1451. */
  1452. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1453. /**
  1454. * Sets a Color4 on a uniform variable
  1455. * @param uniformName defines the name of the variable
  1456. * @param color4 defines the value to be set
  1457. */
  1458. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1459. }
  1460. }
  1461. declare module "babylonjs/Meshes/dataBuffer" {
  1462. /**
  1463. * Class used to store gfx data (like WebGLBuffer)
  1464. */
  1465. export class DataBuffer {
  1466. private static _Counter;
  1467. /**
  1468. * Gets or sets the number of objects referencing this buffer
  1469. */
  1470. references: number;
  1471. /** Gets or sets the size of the underlying buffer */
  1472. capacity: number;
  1473. /**
  1474. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1475. */
  1476. is32Bits: boolean;
  1477. /**
  1478. * Gets the underlying buffer
  1479. */
  1480. get underlyingResource(): any;
  1481. /**
  1482. * Gets the unique id of this buffer
  1483. */
  1484. readonly uniqueId: number;
  1485. /**
  1486. * Constructs the buffer
  1487. */
  1488. constructor();
  1489. }
  1490. }
  1491. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1492. import { Nullable } from "babylonjs/types";
  1493. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1494. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1495. /** @hidden */
  1496. export interface IShaderProcessor {
  1497. attributeProcessor?: (attribute: string, preProcessors: {
  1498. [key: string]: string;
  1499. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1501. [key: string]: string;
  1502. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1503. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1504. [key: string]: string;
  1505. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1506. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1507. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1508. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1509. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1510. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1511. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1512. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1513. vertexCode: string;
  1514. fragmentCode: string;
  1515. };
  1516. }
  1517. }
  1518. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1519. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1520. import { Nullable } from "babylonjs/types";
  1521. /** @hidden */
  1522. export interface ShaderProcessingContext {
  1523. }
  1524. /** @hidden */
  1525. export interface ProcessingOptions {
  1526. defines: string[];
  1527. indexParameters: any;
  1528. isFragment: boolean;
  1529. shouldUseHighPrecisionShader: boolean;
  1530. supportsUniformBuffers: boolean;
  1531. shadersRepository: string;
  1532. includesShadersStore: {
  1533. [key: string]: string;
  1534. };
  1535. processor: Nullable<IShaderProcessor>;
  1536. version: string;
  1537. platformName: string;
  1538. lookForClosingBracketForUniformBuffer?: boolean;
  1539. processingContext: Nullable<ShaderProcessingContext>;
  1540. }
  1541. }
  1542. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1543. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1544. /** @hidden */
  1545. export class ShaderCodeNode {
  1546. line: string;
  1547. children: ShaderCodeNode[];
  1548. additionalDefineKey?: string;
  1549. additionalDefineValue?: string;
  1550. isValid(preprocessors: {
  1551. [key: string]: string;
  1552. }): boolean;
  1553. process(preprocessors: {
  1554. [key: string]: string;
  1555. }, options: ProcessingOptions): string;
  1556. }
  1557. }
  1558. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1559. /** @hidden */
  1560. export class ShaderCodeCursor {
  1561. private _lines;
  1562. lineIndex: number;
  1563. get currentLine(): string;
  1564. get canRead(): boolean;
  1565. set lines(value: string[]);
  1566. }
  1567. }
  1568. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1569. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1570. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1571. /** @hidden */
  1572. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1573. process(preprocessors: {
  1574. [key: string]: string;
  1575. }, options: ProcessingOptions): string;
  1576. }
  1577. }
  1578. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1579. /** @hidden */
  1580. export class ShaderDefineExpression {
  1581. isTrue(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. private static _OperatorPriority;
  1585. private static _Stack;
  1586. static postfixToInfix(postfix: string[]): string;
  1587. static infixToPostfix(infix: string): string[];
  1588. }
  1589. }
  1590. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1591. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1593. /** @hidden */
  1594. export class ShaderCodeTestNode extends ShaderCodeNode {
  1595. testExpression: ShaderDefineExpression;
  1596. isValid(preprocessors: {
  1597. [key: string]: string;
  1598. }): boolean;
  1599. }
  1600. }
  1601. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1602. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1603. /** @hidden */
  1604. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1605. define: string;
  1606. not: boolean;
  1607. constructor(define: string, not?: boolean);
  1608. isTrue(preprocessors: {
  1609. [key: string]: string;
  1610. }): boolean;
  1611. }
  1612. }
  1613. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1614. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1615. /** @hidden */
  1616. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1617. leftOperand: ShaderDefineExpression;
  1618. rightOperand: ShaderDefineExpression;
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1625. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1626. /** @hidden */
  1627. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1628. leftOperand: ShaderDefineExpression;
  1629. rightOperand: ShaderDefineExpression;
  1630. isTrue(preprocessors: {
  1631. [key: string]: string;
  1632. }): boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1636. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1637. /** @hidden */
  1638. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1639. define: string;
  1640. operand: string;
  1641. testValue: string;
  1642. constructor(define: string, operand: string, testValue: string);
  1643. isTrue(preprocessors: {
  1644. [key: string]: string;
  1645. }): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Offline/IOfflineProvider" {
  1649. /**
  1650. * Class used to enable access to offline support
  1651. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1652. */
  1653. export interface IOfflineProvider {
  1654. /**
  1655. * Gets a boolean indicating if scene must be saved in the database
  1656. */
  1657. enableSceneOffline: boolean;
  1658. /**
  1659. * Gets a boolean indicating if textures must be saved in the database
  1660. */
  1661. enableTexturesOffline: boolean;
  1662. /**
  1663. * Open the offline support and make it available
  1664. * @param successCallback defines the callback to call on success
  1665. * @param errorCallback defines the callback to call on error
  1666. */
  1667. open(successCallback: () => void, errorCallback: () => void): void;
  1668. /**
  1669. * Loads an image from the offline support
  1670. * @param url defines the url to load from
  1671. * @param image defines the target DOM image
  1672. */
  1673. loadImage(url: string, image: HTMLImageElement): void;
  1674. /**
  1675. * Loads a file from offline support
  1676. * @param url defines the URL to load from
  1677. * @param sceneLoaded defines a callback to call on success
  1678. * @param progressCallBack defines a callback to call when progress changed
  1679. * @param errorCallback defines a callback to call on error
  1680. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1681. */
  1682. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1683. }
  1684. }
  1685. declare module "babylonjs/Misc/filesInputStore" {
  1686. /**
  1687. * Class used to help managing file picking and drag'n'drop
  1688. * File Storage
  1689. */
  1690. export class FilesInputStore {
  1691. /**
  1692. * List of files ready to be loaded
  1693. */
  1694. static FilesToLoad: {
  1695. [key: string]: File;
  1696. };
  1697. }
  1698. }
  1699. declare module "babylonjs/Misc/retryStrategy" {
  1700. import { WebRequest } from "babylonjs/Misc/webRequest";
  1701. /**
  1702. * Class used to define a retry strategy when error happens while loading assets
  1703. */
  1704. export class RetryStrategy {
  1705. /**
  1706. * Function used to defines an exponential back off strategy
  1707. * @param maxRetries defines the maximum number of retries (3 by default)
  1708. * @param baseInterval defines the interval between retries
  1709. * @returns the strategy function to use
  1710. */
  1711. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1712. }
  1713. }
  1714. declare module "babylonjs/Misc/baseError" {
  1715. /**
  1716. * @ignore
  1717. * Application error to support additional information when loading a file
  1718. */
  1719. export abstract class BaseError extends Error {
  1720. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1721. }
  1722. }
  1723. declare module "babylonjs/Misc/fileTools" {
  1724. import { WebRequest } from "babylonjs/Misc/webRequest";
  1725. import { Nullable } from "babylonjs/types";
  1726. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1727. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1728. import { BaseError } from "babylonjs/Misc/baseError";
  1729. /** @ignore */
  1730. export class LoadFileError extends BaseError {
  1731. request?: WebRequest;
  1732. file?: File;
  1733. /**
  1734. * Creates a new LoadFileError
  1735. * @param message defines the message of the error
  1736. * @param request defines the optional web request
  1737. * @param file defines the optional file
  1738. */
  1739. constructor(message: string, object?: WebRequest | File);
  1740. }
  1741. /** @ignore */
  1742. export class RequestFileError extends BaseError {
  1743. request: WebRequest;
  1744. /**
  1745. * Creates a new LoadFileError
  1746. * @param message defines the message of the error
  1747. * @param request defines the optional web request
  1748. */
  1749. constructor(message: string, request: WebRequest);
  1750. }
  1751. /** @ignore */
  1752. export class ReadFileError extends BaseError {
  1753. file: File;
  1754. /**
  1755. * Creates a new ReadFileError
  1756. * @param message defines the message of the error
  1757. * @param file defines the optional file
  1758. */
  1759. constructor(message: string, file: File);
  1760. }
  1761. /**
  1762. * @hidden
  1763. */
  1764. export class FileTools {
  1765. /**
  1766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1767. */
  1768. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1769. /**
  1770. * Gets or sets the base URL to use to load assets
  1771. */
  1772. static BaseUrl: string;
  1773. /**
  1774. * Default behaviour for cors in the application.
  1775. * It can be a string if the expected behavior is identical in the entire app.
  1776. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1777. */
  1778. static CorsBehavior: string | ((url: string | string[]) => string);
  1779. /**
  1780. * Gets or sets a function used to pre-process url before using them to load assets
  1781. */
  1782. static PreprocessUrl: (url: string) => string;
  1783. /**
  1784. * Removes unwanted characters from an url
  1785. * @param url defines the url to clean
  1786. * @returns the cleaned url
  1787. */
  1788. private static _CleanUrl;
  1789. /**
  1790. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1791. * @param url define the url we are trying
  1792. * @param element define the dom element where to configure the cors policy
  1793. */
  1794. static SetCorsBehavior(url: string | string[], element: {
  1795. crossOrigin: string | null;
  1796. }): void;
  1797. /**
  1798. * Loads an image as an HTMLImageElement.
  1799. * @param input url string, ArrayBuffer, or Blob to load
  1800. * @param onLoad callback called when the image successfully loads
  1801. * @param onError callback called when the image fails to load
  1802. * @param offlineProvider offline provider for caching
  1803. * @param mimeType optional mime type
  1804. * @returns the HTMLImageElement of the loaded image
  1805. */
  1806. 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>;
  1807. /**
  1808. * Reads a file from a File object
  1809. * @param file defines the file to load
  1810. * @param onSuccess defines the callback to call when data is loaded
  1811. * @param onProgress defines the callback to call during loading process
  1812. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1813. * @param onError defines the callback to call when an error occurs
  1814. * @returns a file request object
  1815. */
  1816. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1817. /**
  1818. * Loads a file from a url
  1819. * @param url url to load
  1820. * @param onSuccess callback called when the file successfully loads
  1821. * @param onProgress callback called while file is loading (if the server supports this mode)
  1822. * @param offlineProvider defines the offline provider for caching
  1823. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1824. * @param onError callback called when the file fails to load
  1825. * @returns a file request object
  1826. */
  1827. 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;
  1828. /**
  1829. * Loads a file
  1830. * @param url url to load
  1831. * @param onSuccess callback called when the file successfully loads
  1832. * @param onProgress callback called while file is loading (if the server supports this mode)
  1833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1834. * @param onError callback called when the file fails to load
  1835. * @param onOpened callback called when the web request is opened
  1836. * @returns a file request object
  1837. */
  1838. 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;
  1839. /**
  1840. * Checks if the loaded document was accessed via `file:`-Protocol.
  1841. * @returns boolean
  1842. */
  1843. static IsFileURL(): boolean;
  1844. }
  1845. }
  1846. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1847. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1848. import { WebRequest } from "babylonjs/Misc/webRequest";
  1849. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1851. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1852. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1853. /** @hidden */
  1854. export class ShaderProcessor {
  1855. static Initialize(options: ProcessingOptions): void;
  1856. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1857. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1858. vertexCode: string;
  1859. fragmentCode: string;
  1860. };
  1861. private static _ProcessPrecision;
  1862. private static _ExtractOperation;
  1863. private static _BuildSubExpression;
  1864. private static _BuildExpression;
  1865. private static _MoveCursorWithinIf;
  1866. private static _MoveCursor;
  1867. private static _EvaluatePreProcessors;
  1868. private static _PreparePreProcessors;
  1869. private static _ProcessShaderConversion;
  1870. private static _ProcessIncludes;
  1871. /**
  1872. * Loads a file from a url
  1873. * @param url url to load
  1874. * @param onSuccess callback called when the file successfully loads
  1875. * @param onProgress callback called while file is loading (if the server supports this mode)
  1876. * @param offlineProvider defines the offline provider for caching
  1877. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1878. * @param onError callback called when the file fails to load
  1879. * @returns a file request object
  1880. * @hidden
  1881. */
  1882. 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;
  1883. }
  1884. }
  1885. declare module "babylonjs/Materials/iEffectFallbacks" {
  1886. import { Effect } from "babylonjs/Materials/effect";
  1887. /**
  1888. * Interface used to define common properties for effect fallbacks
  1889. */
  1890. export interface IEffectFallbacks {
  1891. /**
  1892. * Removes the defines that should be removed when falling back.
  1893. * @param currentDefines defines the current define statements for the shader.
  1894. * @param effect defines the current effect we try to compile
  1895. * @returns The resulting defines with defines of the current rank removed.
  1896. */
  1897. reduce(currentDefines: string, effect: Effect): string;
  1898. /**
  1899. * Removes the fallback from the bound mesh.
  1900. */
  1901. unBindMesh(): void;
  1902. /**
  1903. * Checks to see if more fallbacks are still availible.
  1904. */
  1905. hasMoreFallbacks: boolean;
  1906. }
  1907. }
  1908. declare module "babylonjs/Maths/math.size" {
  1909. /**
  1910. * Interface for the size containing width and height
  1911. */
  1912. export interface ISize {
  1913. /**
  1914. * Width
  1915. */
  1916. width: number;
  1917. /**
  1918. * Heighht
  1919. */
  1920. height: number;
  1921. }
  1922. /**
  1923. * Size containing widht and height
  1924. */
  1925. export class Size implements ISize {
  1926. /**
  1927. * Width
  1928. */
  1929. width: number;
  1930. /**
  1931. * Height
  1932. */
  1933. height: number;
  1934. /**
  1935. * Creates a Size object from the given width and height (floats).
  1936. * @param width width of the new size
  1937. * @param height height of the new size
  1938. */
  1939. constructor(width: number, height: number);
  1940. /**
  1941. * Returns a string with the Size width and height
  1942. * @returns a string with the Size width and height
  1943. */
  1944. toString(): string;
  1945. /**
  1946. * "Size"
  1947. * @returns the string "Size"
  1948. */
  1949. getClassName(): string;
  1950. /**
  1951. * Returns the Size hash code.
  1952. * @returns a hash code for a unique width and height
  1953. */
  1954. getHashCode(): number;
  1955. /**
  1956. * Updates the current size from the given one.
  1957. * @param src the given size
  1958. */
  1959. copyFrom(src: Size): void;
  1960. /**
  1961. * Updates in place the current Size from the given floats.
  1962. * @param width width of the new size
  1963. * @param height height of the new size
  1964. * @returns the updated Size.
  1965. */
  1966. copyFromFloats(width: number, height: number): Size;
  1967. /**
  1968. * Updates in place the current Size from the given floats.
  1969. * @param width width to set
  1970. * @param height height to set
  1971. * @returns the updated Size.
  1972. */
  1973. set(width: number, height: number): Size;
  1974. /**
  1975. * Multiplies the width and height by numbers
  1976. * @param w factor to multiple the width by
  1977. * @param h factor to multiple the height by
  1978. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1979. */
  1980. multiplyByFloats(w: number, h: number): Size;
  1981. /**
  1982. * Clones the size
  1983. * @returns a new Size copied from the given one.
  1984. */
  1985. clone(): Size;
  1986. /**
  1987. * True if the current Size and the given one width and height are strictly equal.
  1988. * @param other the other size to compare against
  1989. * @returns True if the current Size and the given one width and height are strictly equal.
  1990. */
  1991. equals(other: Size): boolean;
  1992. /**
  1993. * The surface of the Size : width * height (float).
  1994. */
  1995. get surface(): number;
  1996. /**
  1997. * Create a new size of zero
  1998. * @returns a new Size set to (0.0, 0.0)
  1999. */
  2000. static Zero(): Size;
  2001. /**
  2002. * Sums the width and height of two sizes
  2003. * @param otherSize size to add to this size
  2004. * @returns a new Size set as the addition result of the current Size and the given one.
  2005. */
  2006. add(otherSize: Size): Size;
  2007. /**
  2008. * Subtracts the width and height of two
  2009. * @param otherSize size to subtract to this size
  2010. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2011. */
  2012. subtract(otherSize: Size): Size;
  2013. /**
  2014. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2015. * @param start starting size to lerp between
  2016. * @param end end size to lerp between
  2017. * @param amount amount to lerp between the start and end values
  2018. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2019. */
  2020. static Lerp(start: Size, end: Size, amount: number): Size;
  2021. }
  2022. }
  2023. declare module "babylonjs/Materials/Textures/thinTexture" {
  2024. import { Nullable } from "babylonjs/types";
  2025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  2026. import { ISize } from "babylonjs/Maths/math.size";
  2027. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  2028. /**
  2029. * Base class of all the textures in babylon.
  2030. * It groups all the common properties required to work with Thin Engine.
  2031. */
  2032. export class ThinTexture {
  2033. protected _wrapU: number;
  2034. /**
  2035. * | Value | Type | Description |
  2036. * | ----- | ------------------ | ----------- |
  2037. * | 0 | CLAMP_ADDRESSMODE | |
  2038. * | 1 | WRAP_ADDRESSMODE | |
  2039. * | 2 | MIRROR_ADDRESSMODE | |
  2040. */
  2041. get wrapU(): number;
  2042. set wrapU(value: number);
  2043. protected _wrapV: number;
  2044. /**
  2045. * | Value | Type | Description |
  2046. * | ----- | ------------------ | ----------- |
  2047. * | 0 | CLAMP_ADDRESSMODE | |
  2048. * | 1 | WRAP_ADDRESSMODE | |
  2049. * | 2 | MIRROR_ADDRESSMODE | |
  2050. */
  2051. get wrapV(): number;
  2052. set wrapV(value: number);
  2053. /**
  2054. * | Value | Type | Description |
  2055. * | ----- | ------------------ | ----------- |
  2056. * | 0 | CLAMP_ADDRESSMODE | |
  2057. * | 1 | WRAP_ADDRESSMODE | |
  2058. * | 2 | MIRROR_ADDRESSMODE | |
  2059. */
  2060. wrapR: number;
  2061. /**
  2062. * With compliant hardware and browser (supporting anisotropic filtering)
  2063. * this defines the level of anisotropic filtering in the texture.
  2064. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2065. */
  2066. anisotropicFilteringLevel: number;
  2067. /**
  2068. * Define the current state of the loading sequence when in delayed load mode.
  2069. */
  2070. delayLoadState: number;
  2071. /**
  2072. * How a texture is mapped.
  2073. * Unused in thin texture mode.
  2074. */
  2075. get coordinatesMode(): number;
  2076. /**
  2077. * Define if the texture is a cube texture or if false a 2d texture.
  2078. */
  2079. get isCube(): boolean;
  2080. set isCube(value: boolean);
  2081. /**
  2082. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2083. */
  2084. get is3D(): boolean;
  2085. set is3D(value: boolean);
  2086. /**
  2087. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2088. */
  2089. get is2DArray(): boolean;
  2090. set is2DArray(value: boolean);
  2091. /**
  2092. * Get the class name of the texture.
  2093. * @returns "ThinTexture"
  2094. */
  2095. getClassName(): string;
  2096. /** @hidden */
  2097. _texture: Nullable<InternalTexture>;
  2098. protected _engine: Nullable<ThinEngine>;
  2099. private _cachedSize;
  2100. private _cachedBaseSize;
  2101. /**
  2102. * Instantiates a new ThinTexture.
  2103. * Base class of all the textures in babylon.
  2104. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2105. * @param internalTexture Define the internalTexture to wrap
  2106. */
  2107. constructor(internalTexture: Nullable<InternalTexture>);
  2108. /**
  2109. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2110. * @returns true if fully ready
  2111. */
  2112. isReady(): boolean;
  2113. /**
  2114. * Triggers the load sequence in delayed load mode.
  2115. */
  2116. delayLoad(): void;
  2117. /**
  2118. * Get the underlying lower level texture from Babylon.
  2119. * @returns the insternal texture
  2120. */
  2121. getInternalTexture(): Nullable<InternalTexture>;
  2122. /**
  2123. * Get the size of the texture.
  2124. * @returns the texture size.
  2125. */
  2126. getSize(): ISize;
  2127. /**
  2128. * Get the base size of the texture.
  2129. * It can be different from the size if the texture has been resized for POT for instance
  2130. * @returns the base size
  2131. */
  2132. getBaseSize(): ISize;
  2133. /**
  2134. * Update the sampling mode of the texture.
  2135. * Default is Trilinear mode.
  2136. *
  2137. * | Value | Type | Description |
  2138. * | ----- | ------------------ | ----------- |
  2139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2145. * | 7 | NEAREST_LINEAR | |
  2146. * | 8 | NEAREST_NEAREST | |
  2147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2149. * | 11 | LINEAR_LINEAR | |
  2150. * | 12 | LINEAR_NEAREST | |
  2151. *
  2152. * > _mag_: magnification filter (close to the viewer)
  2153. * > _min_: minification filter (far from the viewer)
  2154. * > _mip_: filter used between mip map levels
  2155. *@param samplingMode Define the new sampling mode of the texture
  2156. */
  2157. updateSamplingMode(samplingMode: number): void;
  2158. /**
  2159. * Release and destroy the underlying lower level texture aka internalTexture.
  2160. */
  2161. releaseInternalTexture(): void;
  2162. /**
  2163. * Dispose the texture and release its associated resources.
  2164. */
  2165. dispose(): void;
  2166. }
  2167. }
  2168. declare module "babylonjs/Misc/smartArray" {
  2169. /**
  2170. * Defines an array and its length.
  2171. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2172. */
  2173. export interface ISmartArrayLike<T> {
  2174. /**
  2175. * The data of the array.
  2176. */
  2177. data: Array<T>;
  2178. /**
  2179. * The active length of the array.
  2180. */
  2181. length: number;
  2182. }
  2183. /**
  2184. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2185. */
  2186. export class SmartArray<T> implements ISmartArrayLike<T> {
  2187. /**
  2188. * The full set of data from the array.
  2189. */
  2190. data: Array<T>;
  2191. /**
  2192. * The active length of the array.
  2193. */
  2194. length: number;
  2195. protected _id: number;
  2196. /**
  2197. * Instantiates a Smart Array.
  2198. * @param capacity defines the default capacity of the array.
  2199. */
  2200. constructor(capacity: number);
  2201. /**
  2202. * Pushes a value at the end of the active data.
  2203. * @param value defines the object to push in the array.
  2204. */
  2205. push(value: T): void;
  2206. /**
  2207. * Iterates over the active data and apply the lambda to them.
  2208. * @param func defines the action to apply on each value.
  2209. */
  2210. forEach(func: (content: T) => void): void;
  2211. /**
  2212. * Sorts the full sets of data.
  2213. * @param compareFn defines the comparison function to apply.
  2214. */
  2215. sort(compareFn: (a: T, b: T) => number): void;
  2216. /**
  2217. * Resets the active data to an empty array.
  2218. */
  2219. reset(): void;
  2220. /**
  2221. * Releases all the data from the array as well as the array.
  2222. */
  2223. dispose(): void;
  2224. /**
  2225. * Concats the active data with a given array.
  2226. * @param array defines the data to concatenate with.
  2227. */
  2228. concat(array: any): void;
  2229. /**
  2230. * Returns the position of a value in the active data.
  2231. * @param value defines the value to find the index for
  2232. * @returns the index if found in the active data otherwise -1
  2233. */
  2234. indexOf(value: T): number;
  2235. /**
  2236. * Returns whether an element is part of the active data.
  2237. * @param value defines the value to look for
  2238. * @returns true if found in the active data otherwise false
  2239. */
  2240. contains(value: T): boolean;
  2241. private static _GlobalId;
  2242. }
  2243. /**
  2244. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2245. * The data in this array can only be present once
  2246. */
  2247. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2248. private _duplicateId;
  2249. /**
  2250. * Pushes a value at the end of the active data.
  2251. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2252. * @param value defines the object to push in the array.
  2253. */
  2254. push(value: T): void;
  2255. /**
  2256. * Pushes a value at the end of the active data.
  2257. * If the data is already present, it won t be added again
  2258. * @param value defines the object to push in the array.
  2259. * @returns true if added false if it was already present
  2260. */
  2261. pushNoDuplicate(value: T): boolean;
  2262. /**
  2263. * Resets the active data to an empty array.
  2264. */
  2265. reset(): void;
  2266. /**
  2267. * Concats the active data with a given array.
  2268. * This ensures no dupplicate will be present in the result.
  2269. * @param array defines the data to concatenate with.
  2270. */
  2271. concatWithNoDuplicate(array: any): void;
  2272. }
  2273. }
  2274. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2275. /**
  2276. * Class used to evalaute queries containing `and` and `or` operators
  2277. */
  2278. export class AndOrNotEvaluator {
  2279. /**
  2280. * Evaluate a query
  2281. * @param query defines the query to evaluate
  2282. * @param evaluateCallback defines the callback used to filter result
  2283. * @returns true if the query matches
  2284. */
  2285. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2286. private static _HandleParenthesisContent;
  2287. private static _SimplifyNegation;
  2288. }
  2289. }
  2290. declare module "babylonjs/Misc/tags" {
  2291. /**
  2292. * Class used to store custom tags
  2293. */
  2294. export class Tags {
  2295. /**
  2296. * Adds support for tags on the given object
  2297. * @param obj defines the object to use
  2298. */
  2299. static EnableFor(obj: any): void;
  2300. /**
  2301. * Removes tags support
  2302. * @param obj defines the object to use
  2303. */
  2304. static DisableFor(obj: any): void;
  2305. /**
  2306. * Gets a boolean indicating if the given object has tags
  2307. * @param obj defines the object to use
  2308. * @returns a boolean
  2309. */
  2310. static HasTags(obj: any): boolean;
  2311. /**
  2312. * Gets the tags available on a given object
  2313. * @param obj defines the object to use
  2314. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2315. * @returns the tags
  2316. */
  2317. static GetTags(obj: any, asString?: boolean): any;
  2318. /**
  2319. * Adds tags to an object
  2320. * @param obj defines the object to use
  2321. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2322. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2323. */
  2324. static AddTagsTo(obj: any, tagsString: string): void;
  2325. /**
  2326. * @hidden
  2327. */
  2328. static _AddTagTo(obj: any, tag: string): void;
  2329. /**
  2330. * Removes specific tags from a specific object
  2331. * @param obj defines the object to use
  2332. * @param tagsString defines the tags to remove
  2333. */
  2334. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2335. /**
  2336. * @hidden
  2337. */
  2338. static _RemoveTagFrom(obj: any, tag: string): void;
  2339. /**
  2340. * Defines if tags hosted on an object match a given query
  2341. * @param obj defines the object to use
  2342. * @param tagsQuery defines the tag query
  2343. * @returns a boolean
  2344. */
  2345. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2346. }
  2347. }
  2348. declare module "babylonjs/Maths/math.scalar" {
  2349. /**
  2350. * Scalar computation library
  2351. */
  2352. export class Scalar {
  2353. /**
  2354. * Two pi constants convenient for computation.
  2355. */
  2356. static TwoPi: number;
  2357. /**
  2358. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2359. * @param a number
  2360. * @param b number
  2361. * @param epsilon (default = 1.401298E-45)
  2362. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2363. */
  2364. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2365. /**
  2366. * Returns a string : the upper case translation of the number i to hexadecimal.
  2367. * @param i number
  2368. * @returns the upper case translation of the number i to hexadecimal.
  2369. */
  2370. static ToHex(i: number): string;
  2371. /**
  2372. * Returns -1 if value is negative and +1 is value is positive.
  2373. * @param value the value
  2374. * @returns the value itself if it's equal to zero.
  2375. */
  2376. static Sign(value: number): number;
  2377. /**
  2378. * Returns the value itself if it's between min and max.
  2379. * Returns min if the value is lower than min.
  2380. * Returns max if the value is greater than max.
  2381. * @param value the value to clmap
  2382. * @param min the min value to clamp to (default: 0)
  2383. * @param max the max value to clamp to (default: 1)
  2384. * @returns the clamped value
  2385. */
  2386. static Clamp(value: number, min?: number, max?: number): number;
  2387. /**
  2388. * the log2 of value.
  2389. * @param value the value to compute log2 of
  2390. * @returns the log2 of value.
  2391. */
  2392. static Log2(value: number): number;
  2393. /**
  2394. * the floor part of a log2 value.
  2395. * @param value the value to compute log2 of
  2396. * @returns the log2 of value.
  2397. */
  2398. static ILog2(value: number): number;
  2399. /**
  2400. * Loops the value, so that it is never larger than length and never smaller than 0.
  2401. *
  2402. * This is similar to the modulo operator but it works with floating point numbers.
  2403. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2404. * With t = 5 and length = 2.5, the result would be 0.0.
  2405. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2406. * @param value the value
  2407. * @param length the length
  2408. * @returns the looped value
  2409. */
  2410. static Repeat(value: number, length: number): number;
  2411. /**
  2412. * Normalize the value between 0.0 and 1.0 using min and max values
  2413. * @param value value to normalize
  2414. * @param min max to normalize between
  2415. * @param max min to normalize between
  2416. * @returns the normalized value
  2417. */
  2418. static Normalize(value: number, min: number, max: number): number;
  2419. /**
  2420. * Denormalize the value from 0.0 and 1.0 using min and max values
  2421. * @param normalized value to denormalize
  2422. * @param min max to denormalize between
  2423. * @param max min to denormalize between
  2424. * @returns the denormalized value
  2425. */
  2426. static Denormalize(normalized: number, min: number, max: number): number;
  2427. /**
  2428. * Calculates the shortest difference between two given angles given in degrees.
  2429. * @param current current angle in degrees
  2430. * @param target target angle in degrees
  2431. * @returns the delta
  2432. */
  2433. static DeltaAngle(current: number, target: number): number;
  2434. /**
  2435. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2436. * @param tx value
  2437. * @param length length
  2438. * @returns The returned value will move back and forth between 0 and length
  2439. */
  2440. static PingPong(tx: number, length: number): number;
  2441. /**
  2442. * Interpolates between min and max with smoothing at the limits.
  2443. *
  2444. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2445. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2446. * @param from from
  2447. * @param to to
  2448. * @param tx value
  2449. * @returns the smooth stepped value
  2450. */
  2451. static SmoothStep(from: number, to: number, tx: number): number;
  2452. /**
  2453. * Moves a value current towards target.
  2454. *
  2455. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2456. * Negative values of maxDelta pushes the value away from target.
  2457. * @param current current value
  2458. * @param target target value
  2459. * @param maxDelta max distance to move
  2460. * @returns resulting value
  2461. */
  2462. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2463. /**
  2464. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2465. *
  2466. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2467. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2468. * @param current current value
  2469. * @param target target value
  2470. * @param maxDelta max distance to move
  2471. * @returns resulting angle
  2472. */
  2473. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2474. /**
  2475. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2476. * @param start start value
  2477. * @param end target value
  2478. * @param amount amount to lerp between
  2479. * @returns the lerped value
  2480. */
  2481. static Lerp(start: number, end: number, amount: number): number;
  2482. /**
  2483. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2484. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2485. * @param start start value
  2486. * @param end target value
  2487. * @param amount amount to lerp between
  2488. * @returns the lerped value
  2489. */
  2490. static LerpAngle(start: number, end: number, amount: number): number;
  2491. /**
  2492. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2493. * @param a start value
  2494. * @param b target value
  2495. * @param value value between a and b
  2496. * @returns the inverseLerp value
  2497. */
  2498. static InverseLerp(a: number, b: number, value: number): number;
  2499. /**
  2500. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2501. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2502. * @param value1 spline value
  2503. * @param tangent1 spline value
  2504. * @param value2 spline value
  2505. * @param tangent2 spline value
  2506. * @param amount input value
  2507. * @returns hermite result
  2508. */
  2509. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2510. /**
  2511. * Returns a random float number between and min and max values
  2512. * @param min min value of random
  2513. * @param max max value of random
  2514. * @returns random value
  2515. */
  2516. static RandomRange(min: number, max: number): number;
  2517. /**
  2518. * This function returns percentage of a number in a given range.
  2519. *
  2520. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2521. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2522. * @param number to convert to percentage
  2523. * @param min min range
  2524. * @param max max range
  2525. * @returns the percentage
  2526. */
  2527. static RangeToPercent(number: number, min: number, max: number): number;
  2528. /**
  2529. * This function returns number that corresponds to the percentage in a given range.
  2530. *
  2531. * PercentToRange(0.34,0,100) will return 34.
  2532. * @param percent to convert to number
  2533. * @param min min range
  2534. * @param max max range
  2535. * @returns the number
  2536. */
  2537. static PercentToRange(percent: number, min: number, max: number): number;
  2538. /**
  2539. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2540. * @param angle The angle to normalize in radian.
  2541. * @return The converted angle.
  2542. */
  2543. static NormalizeRadians(angle: number): number;
  2544. }
  2545. }
  2546. declare module "babylonjs/Maths/math.constants" {
  2547. /**
  2548. * Constant used to convert a value to gamma space
  2549. * @ignorenaming
  2550. */
  2551. export const ToGammaSpace: number;
  2552. /**
  2553. * Constant used to convert a value to linear space
  2554. * @ignorenaming
  2555. */
  2556. export const ToLinearSpace = 2.2;
  2557. /**
  2558. * Constant used to define the minimal number value in Babylon.js
  2559. * @ignorenaming
  2560. */
  2561. let Epsilon: number;
  2562. export { Epsilon };
  2563. }
  2564. declare module "babylonjs/Maths/math.viewport" {
  2565. /**
  2566. * Class used to represent a viewport on screen
  2567. */
  2568. export class Viewport {
  2569. /** viewport left coordinate */
  2570. x: number;
  2571. /** viewport top coordinate */
  2572. y: number;
  2573. /**viewport width */
  2574. width: number;
  2575. /** viewport height */
  2576. height: number;
  2577. /**
  2578. * Creates a Viewport object located at (x, y) and sized (width, height)
  2579. * @param x defines viewport left coordinate
  2580. * @param y defines viewport top coordinate
  2581. * @param width defines the viewport width
  2582. * @param height defines the viewport height
  2583. */
  2584. constructor(
  2585. /** viewport left coordinate */
  2586. x: number,
  2587. /** viewport top coordinate */
  2588. y: number,
  2589. /**viewport width */
  2590. width: number,
  2591. /** viewport height */
  2592. height: number);
  2593. /**
  2594. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2595. * @param renderWidth defines the rendering width
  2596. * @param renderHeight defines the rendering height
  2597. * @returns a new Viewport
  2598. */
  2599. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2600. /**
  2601. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2602. * @param renderWidth defines the rendering width
  2603. * @param renderHeight defines the rendering height
  2604. * @param ref defines the target viewport
  2605. * @returns the current viewport
  2606. */
  2607. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2608. /**
  2609. * Returns a new Viewport copied from the current one
  2610. * @returns a new Viewport
  2611. */
  2612. clone(): Viewport;
  2613. }
  2614. }
  2615. declare module "babylonjs/Misc/arrayTools" {
  2616. /**
  2617. * Class containing a set of static utilities functions for arrays.
  2618. */
  2619. export class ArrayTools {
  2620. /**
  2621. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2622. * @param size the number of element to construct and put in the array
  2623. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2624. * @returns a new array filled with new objects
  2625. */
  2626. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2627. }
  2628. }
  2629. declare module "babylonjs/Maths/math.plane" {
  2630. import { DeepImmutable } from "babylonjs/types";
  2631. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2632. /**
  2633. * Represents a plane by the equation ax + by + cz + d = 0
  2634. */
  2635. export class Plane {
  2636. private static _TmpMatrix;
  2637. /**
  2638. * Normal of the plane (a,b,c)
  2639. */
  2640. normal: Vector3;
  2641. /**
  2642. * d component of the plane
  2643. */
  2644. d: number;
  2645. /**
  2646. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2647. * @param a a component of the plane
  2648. * @param b b component of the plane
  2649. * @param c c component of the plane
  2650. * @param d d component of the plane
  2651. */
  2652. constructor(a: number, b: number, c: number, d: number);
  2653. /**
  2654. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2655. */
  2656. asArray(): number[];
  2657. /**
  2658. * @returns a new plane copied from the current Plane.
  2659. */
  2660. clone(): Plane;
  2661. /**
  2662. * @returns the string "Plane".
  2663. */
  2664. getClassName(): string;
  2665. /**
  2666. * @returns the Plane hash code.
  2667. */
  2668. getHashCode(): number;
  2669. /**
  2670. * Normalize the current Plane in place.
  2671. * @returns the updated Plane.
  2672. */
  2673. normalize(): Plane;
  2674. /**
  2675. * Applies a transformation the plane and returns the result
  2676. * @param transformation the transformation matrix to be applied to the plane
  2677. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2678. */
  2679. transform(transformation: DeepImmutable<Matrix>): Plane;
  2680. /**
  2681. * Compute the dot product between the point and the plane normal
  2682. * @param point point to calculate the dot product with
  2683. * @returns the dot product (float) of the point coordinates and the plane normal.
  2684. */
  2685. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2686. /**
  2687. * Updates the current Plane from the plane defined by the three given points.
  2688. * @param point1 one of the points used to contruct the plane
  2689. * @param point2 one of the points used to contruct the plane
  2690. * @param point3 one of the points used to contruct the plane
  2691. * @returns the updated Plane.
  2692. */
  2693. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2694. /**
  2695. * 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).
  2696. * Note that for this function to work as expected you should make sure that:
  2697. * - direction and the plane normal are normalized
  2698. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2699. * @param direction the direction to check if the plane is facing
  2700. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2701. * @returns True if the plane is facing the given direction
  2702. */
  2703. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2704. /**
  2705. * Calculates the distance to a point
  2706. * @param point point to calculate distance to
  2707. * @returns the signed distance (float) from the given point to the Plane.
  2708. */
  2709. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2710. /**
  2711. * Creates a plane from an array
  2712. * @param array the array to create a plane from
  2713. * @returns a new Plane from the given array.
  2714. */
  2715. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2716. /**
  2717. * Creates a plane from three points
  2718. * @param point1 point used to create the plane
  2719. * @param point2 point used to create the plane
  2720. * @param point3 point used to create the plane
  2721. * @returns a new Plane defined by the three given points.
  2722. */
  2723. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2724. /**
  2725. * Creates a plane from an origin point and a normal
  2726. * @param origin origin of the plane to be constructed
  2727. * @param normal normal of the plane to be constructed
  2728. * @returns a new Plane the normal vector to this plane at the given origin point.
  2729. * Note : the vector "normal" is updated because normalized.
  2730. */
  2731. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2732. /**
  2733. * Calculates the distance from a plane and a point
  2734. * @param origin origin of the plane to be constructed
  2735. * @param normal normal of the plane to be constructed
  2736. * @param point point to calculate distance to
  2737. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2738. */
  2739. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2740. }
  2741. }
  2742. declare module "babylonjs/Engines/performanceConfigurator" {
  2743. /** @hidden */
  2744. export class PerformanceConfigurator {
  2745. /** @hidden */
  2746. static MatrixUse64Bits: boolean;
  2747. /** @hidden */
  2748. static MatrixTrackPrecisionChange: boolean;
  2749. /** @hidden */
  2750. static MatrixCurrentType: any;
  2751. /** @hidden */
  2752. static MatrixTrackedMatrices: Array<any> | null;
  2753. /** @hidden */
  2754. static SetMatrixPrecision(use64bits: boolean): void;
  2755. }
  2756. }
  2757. declare module "babylonjs/Maths/math.vector" {
  2758. import { Viewport } from "babylonjs/Maths/math.viewport";
  2759. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2760. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2761. import { Plane } from "babylonjs/Maths/math.plane";
  2762. /**
  2763. * Class representing a vector containing 2 coordinates
  2764. */
  2765. export class Vector2 {
  2766. /** defines the first coordinate */
  2767. x: number;
  2768. /** defines the second coordinate */
  2769. y: number;
  2770. /**
  2771. * Creates a new Vector2 from the given x and y coordinates
  2772. * @param x defines the first coordinate
  2773. * @param y defines the second coordinate
  2774. */
  2775. constructor(
  2776. /** defines the first coordinate */
  2777. x?: number,
  2778. /** defines the second coordinate */
  2779. y?: number);
  2780. /**
  2781. * Gets a string with the Vector2 coordinates
  2782. * @returns a string with the Vector2 coordinates
  2783. */
  2784. toString(): string;
  2785. /**
  2786. * Gets class name
  2787. * @returns the string "Vector2"
  2788. */
  2789. getClassName(): string;
  2790. /**
  2791. * Gets current vector hash code
  2792. * @returns the Vector2 hash code as a number
  2793. */
  2794. getHashCode(): number;
  2795. /**
  2796. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2797. * @param array defines the source array
  2798. * @param index defines the offset in source array
  2799. * @returns the current Vector2
  2800. */
  2801. toArray(array: FloatArray, index?: number): Vector2;
  2802. /**
  2803. * Update the current vector from an array
  2804. * @param array defines the destination array
  2805. * @param index defines the offset in the destination array
  2806. * @returns the current Vector3
  2807. */
  2808. fromArray(array: FloatArray, index?: number): Vector2;
  2809. /**
  2810. * Copy the current vector to an array
  2811. * @returns a new array with 2 elements: the Vector2 coordinates.
  2812. */
  2813. asArray(): number[];
  2814. /**
  2815. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2816. * @param source defines the source Vector2
  2817. * @returns the current updated Vector2
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2820. /**
  2821. * Sets the Vector2 coordinates with the given floats
  2822. * @param x defines the first coordinate
  2823. * @param y defines the second coordinate
  2824. * @returns the current updated Vector2
  2825. */
  2826. copyFromFloats(x: number, y: number): Vector2;
  2827. /**
  2828. * Sets the Vector2 coordinates with the given floats
  2829. * @param x defines the first coordinate
  2830. * @param y defines the second coordinate
  2831. * @returns the current updated Vector2
  2832. */
  2833. set(x: number, y: number): Vector2;
  2834. /**
  2835. * Add another vector with the current one
  2836. * @param otherVector defines the other vector
  2837. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2838. */
  2839. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2840. /**
  2841. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2842. * @param otherVector defines the other vector
  2843. * @param result defines the target vector
  2844. * @returns the unmodified current Vector2
  2845. */
  2846. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2847. /**
  2848. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2849. * @param otherVector defines the other vector
  2850. * @returns the current updated Vector2
  2851. */
  2852. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2853. /**
  2854. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2855. * @param otherVector defines the other vector
  2856. * @returns a new Vector2
  2857. */
  2858. addVector3(otherVector: Vector3): Vector2;
  2859. /**
  2860. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2861. * @param otherVector defines the other vector
  2862. * @returns a new Vector2
  2863. */
  2864. subtract(otherVector: Vector2): Vector2;
  2865. /**
  2866. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2867. * @param otherVector defines the other vector
  2868. * @param result defines the target vector
  2869. * @returns the unmodified current Vector2
  2870. */
  2871. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2872. /**
  2873. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2874. * @param otherVector defines the other vector
  2875. * @returns the current updated Vector2
  2876. */
  2877. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2878. /**
  2879. * Multiplies in place the current Vector2 coordinates by the given ones
  2880. * @param otherVector defines the other vector
  2881. * @returns the current updated Vector2
  2882. */
  2883. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2884. /**
  2885. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2886. * @param otherVector defines the other vector
  2887. * @returns a new Vector2
  2888. */
  2889. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2890. /**
  2891. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2892. * @param otherVector defines the other vector
  2893. * @param result defines the target vector
  2894. * @returns the unmodified current Vector2
  2895. */
  2896. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2897. /**
  2898. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2899. * @param x defines the first coordinate
  2900. * @param y defines the second coordinate
  2901. * @returns a new Vector2
  2902. */
  2903. multiplyByFloats(x: number, y: number): Vector2;
  2904. /**
  2905. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2906. * @param otherVector defines the other vector
  2907. * @returns a new Vector2
  2908. */
  2909. divide(otherVector: Vector2): Vector2;
  2910. /**
  2911. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2912. * @param otherVector defines the other vector
  2913. * @param result defines the target vector
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2917. /**
  2918. * Divides the current Vector2 coordinates by the given ones
  2919. * @param otherVector defines the other vector
  2920. * @returns the current updated Vector2
  2921. */
  2922. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2923. /**
  2924. * Gets a new Vector2 with current Vector2 negated coordinates
  2925. * @returns a new Vector2
  2926. */
  2927. negate(): Vector2;
  2928. /**
  2929. * Negate this vector in place
  2930. * @returns this
  2931. */
  2932. negateInPlace(): Vector2;
  2933. /**
  2934. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2935. * @param result defines the Vector3 object where to store the result
  2936. * @returns the current Vector2
  2937. */
  2938. negateToRef(result: Vector2): Vector2;
  2939. /**
  2940. * Multiply the Vector2 coordinates by scale
  2941. * @param scale defines the scaling factor
  2942. * @returns the current updated Vector2
  2943. */
  2944. scaleInPlace(scale: number): Vector2;
  2945. /**
  2946. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2947. * @param scale defines the scaling factor
  2948. * @returns a new Vector2
  2949. */
  2950. scale(scale: number): Vector2;
  2951. /**
  2952. * Scale the current Vector2 values by a factor to a given Vector2
  2953. * @param scale defines the scale factor
  2954. * @param result defines the Vector2 object where to store the result
  2955. * @returns the unmodified current Vector2
  2956. */
  2957. scaleToRef(scale: number, result: Vector2): Vector2;
  2958. /**
  2959. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2960. * @param scale defines the scale factor
  2961. * @param result defines the Vector2 object where to store the result
  2962. * @returns the unmodified current Vector2
  2963. */
  2964. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2965. /**
  2966. * Gets a boolean if two vectors are equals
  2967. * @param otherVector defines the other vector
  2968. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2969. */
  2970. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2971. /**
  2972. * Gets a boolean if two vectors are equals (using an epsilon value)
  2973. * @param otherVector defines the other vector
  2974. * @param epsilon defines the minimal distance to consider equality
  2975. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2976. */
  2977. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2978. /**
  2979. * Gets a new Vector2 from current Vector2 floored values
  2980. * @returns a new Vector2
  2981. */
  2982. floor(): Vector2;
  2983. /**
  2984. * Gets a new Vector2 from current Vector2 floored values
  2985. * @returns a new Vector2
  2986. */
  2987. fract(): Vector2;
  2988. /**
  2989. * Gets the length of the vector
  2990. * @returns the vector length (float)
  2991. */
  2992. length(): number;
  2993. /**
  2994. * Gets the vector squared length
  2995. * @returns the vector squared length (float)
  2996. */
  2997. lengthSquared(): number;
  2998. /**
  2999. * Normalize the vector
  3000. * @returns the current updated Vector2
  3001. */
  3002. normalize(): Vector2;
  3003. /**
  3004. * Gets a new Vector2 copied from the Vector2
  3005. * @returns a new Vector2
  3006. */
  3007. clone(): Vector2;
  3008. /**
  3009. * Gets a new Vector2(0, 0)
  3010. * @returns a new Vector2
  3011. */
  3012. static Zero(): Vector2;
  3013. /**
  3014. * Gets a new Vector2(1, 1)
  3015. * @returns a new Vector2
  3016. */
  3017. static One(): Vector2;
  3018. /**
  3019. * Gets a new Vector2 set from the given index element of the given array
  3020. * @param array defines the data source
  3021. * @param offset defines the offset in the data source
  3022. * @returns a new Vector2
  3023. */
  3024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  3025. /**
  3026. * Sets "result" from the given index element of the given array
  3027. * @param array defines the data source
  3028. * @param offset defines the offset in the data source
  3029. * @param result defines the target vector
  3030. */
  3031. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  3032. /**
  3033. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  3034. * @param value1 defines 1st point of control
  3035. * @param value2 defines 2nd point of control
  3036. * @param value3 defines 3rd point of control
  3037. * @param value4 defines 4th point of control
  3038. * @param amount defines the interpolation factor
  3039. * @returns a new Vector2
  3040. */
  3041. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  3042. /**
  3043. * 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".
  3044. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3045. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3046. * @param value defines the value to clamp
  3047. * @param min defines the lower limit
  3048. * @param max defines the upper limit
  3049. * @returns a new Vector2
  3050. */
  3051. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3052. /**
  3053. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3054. * @param value1 defines the 1st control point
  3055. * @param tangent1 defines the outgoing tangent
  3056. * @param value2 defines the 2nd control point
  3057. * @param tangent2 defines the incoming tangent
  3058. * @param amount defines the interpolation factor
  3059. * @returns a new Vector2
  3060. */
  3061. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3062. /**
  3063. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3064. * @param start defines the start vector
  3065. * @param end defines the end vector
  3066. * @param amount defines the interpolation factor
  3067. * @returns a new Vector2
  3068. */
  3069. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3070. /**
  3071. * Gets the dot product of the vector "left" and the vector "right"
  3072. * @param left defines first vector
  3073. * @param right defines second vector
  3074. * @returns the dot product (float)
  3075. */
  3076. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3077. /**
  3078. * Returns a new Vector2 equal to the normalized given vector
  3079. * @param vector defines the vector to normalize
  3080. * @returns a new Vector2
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3083. /**
  3084. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3085. * @param left defines 1st vector
  3086. * @param right defines 2nd vector
  3087. * @returns a new Vector2
  3088. */
  3089. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3090. /**
  3091. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3092. * @param left defines 1st vector
  3093. * @param right defines 2nd vector
  3094. * @returns a new Vector2
  3095. */
  3096. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3097. /**
  3098. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3099. * @param vector defines the vector to transform
  3100. * @param transformation defines the matrix to apply
  3101. * @returns a new Vector2
  3102. */
  3103. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3104. /**
  3105. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3106. * @param vector defines the vector to transform
  3107. * @param transformation defines the matrix to apply
  3108. * @param result defines the target vector
  3109. */
  3110. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3111. /**
  3112. * Determines if a given vector is included in a triangle
  3113. * @param p defines the vector to test
  3114. * @param p0 defines 1st triangle point
  3115. * @param p1 defines 2nd triangle point
  3116. * @param p2 defines 3rd triangle point
  3117. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3118. */
  3119. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3120. /**
  3121. * Gets the distance between the vectors "value1" and "value2"
  3122. * @param value1 defines first vector
  3123. * @param value2 defines second vector
  3124. * @returns the distance between vectors
  3125. */
  3126. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3127. /**
  3128. * Returns the squared distance between the vectors "value1" and "value2"
  3129. * @param value1 defines first vector
  3130. * @param value2 defines second vector
  3131. * @returns the squared distance between vectors
  3132. */
  3133. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3134. /**
  3135. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3136. * @param value1 defines first vector
  3137. * @param value2 defines second vector
  3138. * @returns a new Vector2
  3139. */
  3140. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3141. /**
  3142. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3143. * @param value1 defines first vector
  3144. * @param value2 defines second vector
  3145. * @param ref defines third vector
  3146. * @returns ref
  3147. */
  3148. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3149. /**
  3150. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3151. * @param p defines the middle point
  3152. * @param segA defines one point of the segment
  3153. * @param segB defines the other point of the segment
  3154. * @returns the shortest distance
  3155. */
  3156. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3157. }
  3158. /**
  3159. * Class used to store (x,y,z) vector representation
  3160. * A Vector3 is the main object used in 3D geometry
  3161. * It can represent etiher the coordinates of a point the space, either a direction
  3162. * Reminder: js uses a left handed forward facing system
  3163. */
  3164. export class Vector3 {
  3165. private static _UpReadOnly;
  3166. private static _ZeroReadOnly;
  3167. /** @hidden */
  3168. _x: number;
  3169. /** @hidden */
  3170. _y: number;
  3171. /** @hidden */
  3172. _z: number;
  3173. /** @hidden */
  3174. _isDirty: boolean;
  3175. /** Gets or sets the x coordinate */
  3176. get x(): number;
  3177. set x(value: number);
  3178. /** Gets or sets the y coordinate */
  3179. get y(): number;
  3180. set y(value: number);
  3181. /** Gets or sets the z coordinate */
  3182. get z(): number;
  3183. set z(value: number);
  3184. /**
  3185. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3186. * @param x defines the first coordinates (on X axis)
  3187. * @param y defines the second coordinates (on Y axis)
  3188. * @param z defines the third coordinates (on Z axis)
  3189. */
  3190. constructor(x?: number, y?: number, z?: number);
  3191. /**
  3192. * Creates a string representation of the Vector3
  3193. * @returns a string with the Vector3 coordinates.
  3194. */
  3195. toString(): string;
  3196. /**
  3197. * Gets the class name
  3198. * @returns the string "Vector3"
  3199. */
  3200. getClassName(): string;
  3201. /**
  3202. * Creates the Vector3 hash code
  3203. * @returns a number which tends to be unique between Vector3 instances
  3204. */
  3205. getHashCode(): number;
  3206. /**
  3207. * Creates an array containing three elements : the coordinates of the Vector3
  3208. * @returns a new array of numbers
  3209. */
  3210. asArray(): number[];
  3211. /**
  3212. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3213. * @param array defines the destination array
  3214. * @param index defines the offset in the destination array
  3215. * @returns the current Vector3
  3216. */
  3217. toArray(array: FloatArray, index?: number): Vector3;
  3218. /**
  3219. * Update the current vector from an array
  3220. * @param array defines the destination array
  3221. * @param index defines the offset in the destination array
  3222. * @returns the current Vector3
  3223. */
  3224. fromArray(array: FloatArray, index?: number): Vector3;
  3225. /**
  3226. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3227. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3228. */
  3229. toQuaternion(): Quaternion;
  3230. /**
  3231. * Adds the given vector to the current Vector3
  3232. * @param otherVector defines the second operand
  3233. * @returns the current updated Vector3
  3234. */
  3235. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3236. /**
  3237. * Adds the given coordinates to the current Vector3
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @returns the current updated Vector3
  3242. */
  3243. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3244. /**
  3245. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3246. * @param otherVector defines the second operand
  3247. * @returns the resulting Vector3
  3248. */
  3249. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3252. * @param otherVector defines the second operand
  3253. * @param result defines the Vector3 object where to store the result
  3254. * @returns the current Vector3
  3255. */
  3256. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3257. /**
  3258. * Subtract the given vector from the current Vector3
  3259. * @param otherVector defines the second operand
  3260. * @returns the current updated Vector3
  3261. */
  3262. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3263. /**
  3264. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3265. * @param otherVector defines the second operand
  3266. * @returns the resulting Vector3
  3267. */
  3268. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3269. /**
  3270. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3271. * @param otherVector defines the second operand
  3272. * @param result defines the Vector3 object where to store the result
  3273. * @returns the current Vector3
  3274. */
  3275. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3276. /**
  3277. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3278. * @param x defines the x coordinate of the operand
  3279. * @param y defines the y coordinate of the operand
  3280. * @param z defines the z coordinate of the operand
  3281. * @returns the resulting Vector3
  3282. */
  3283. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3284. /**
  3285. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3286. * @param x defines the x coordinate of the operand
  3287. * @param y defines the y coordinate of the operand
  3288. * @param z defines the z coordinate of the operand
  3289. * @param result defines the Vector3 object where to store the result
  3290. * @returns the current Vector3
  3291. */
  3292. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3293. /**
  3294. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3295. * @returns a new Vector3
  3296. */
  3297. negate(): Vector3;
  3298. /**
  3299. * Negate this vector in place
  3300. * @returns this
  3301. */
  3302. negateInPlace(): Vector3;
  3303. /**
  3304. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3305. * @param result defines the Vector3 object where to store the result
  3306. * @returns the current Vector3
  3307. */
  3308. negateToRef(result: Vector3): Vector3;
  3309. /**
  3310. * Multiplies the Vector3 coordinates by the float "scale"
  3311. * @param scale defines the multiplier factor
  3312. * @returns the current updated Vector3
  3313. */
  3314. scaleInPlace(scale: number): Vector3;
  3315. /**
  3316. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3317. * @param scale defines the multiplier factor
  3318. * @returns a new Vector3
  3319. */
  3320. scale(scale: number): Vector3;
  3321. /**
  3322. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3323. * @param scale defines the multiplier factor
  3324. * @param result defines the Vector3 object where to store the result
  3325. * @returns the current Vector3
  3326. */
  3327. scaleToRef(scale: number, result: Vector3): Vector3;
  3328. /**
  3329. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3330. * @param scale defines the scale factor
  3331. * @param result defines the Vector3 object where to store the result
  3332. * @returns the unmodified current Vector3
  3333. */
  3334. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3335. /**
  3336. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3337. * @param origin defines the origin of the projection ray
  3338. * @param plane defines the plane to project to
  3339. * @returns the projected vector3
  3340. */
  3341. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3342. /**
  3343. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3344. * @param origin defines the origin of the projection ray
  3345. * @param plane defines the plane to project to
  3346. * @param result defines the Vector3 where to store the result
  3347. */
  3348. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3349. /**
  3350. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3351. * @param otherVector defines the second operand
  3352. * @returns true if both vectors are equals
  3353. */
  3354. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3355. /**
  3356. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3357. * @param otherVector defines the second operand
  3358. * @param epsilon defines the minimal distance to define values as equals
  3359. * @returns true if both vectors are distant less than epsilon
  3360. */
  3361. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3362. /**
  3363. * Returns true if the current Vector3 coordinates equals the given floats
  3364. * @param x defines the x coordinate of the operand
  3365. * @param y defines the y coordinate of the operand
  3366. * @param z defines the z coordinate of the operand
  3367. * @returns true if both vectors are equals
  3368. */
  3369. equalsToFloats(x: number, y: number, z: number): boolean;
  3370. /**
  3371. * Multiplies the current Vector3 coordinates by the given ones
  3372. * @param otherVector defines the second operand
  3373. * @returns the current updated Vector3
  3374. */
  3375. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3376. /**
  3377. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3378. * @param otherVector defines the second operand
  3379. * @returns the new Vector3
  3380. */
  3381. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3382. /**
  3383. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3384. * @param otherVector defines the second operand
  3385. * @param result defines the Vector3 object where to store the result
  3386. * @returns the current Vector3
  3387. */
  3388. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3389. /**
  3390. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3391. * @param x defines the x coordinate of the operand
  3392. * @param y defines the y coordinate of the operand
  3393. * @param z defines the z coordinate of the operand
  3394. * @returns the new Vector3
  3395. */
  3396. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3397. /**
  3398. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3399. * @param otherVector defines the second operand
  3400. * @returns the new Vector3
  3401. */
  3402. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3403. /**
  3404. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3405. * @param otherVector defines the second operand
  3406. * @param result defines the Vector3 object where to store the result
  3407. * @returns the current Vector3
  3408. */
  3409. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3410. /**
  3411. * Divides the current Vector3 coordinates by the given ones.
  3412. * @param otherVector defines the second operand
  3413. * @returns the current updated Vector3
  3414. */
  3415. divideInPlace(otherVector: Vector3): Vector3;
  3416. /**
  3417. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3418. * @param other defines the second operand
  3419. * @returns the current updated Vector3
  3420. */
  3421. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3422. /**
  3423. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3424. * @param other defines the second operand
  3425. * @returns the current updated Vector3
  3426. */
  3427. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3428. /**
  3429. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3430. * @param x defines the x coordinate of the operand
  3431. * @param y defines the y coordinate of the operand
  3432. * @param z defines the z coordinate of the operand
  3433. * @returns the current updated Vector3
  3434. */
  3435. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3436. /**
  3437. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3438. * @param x defines the x coordinate of the operand
  3439. * @param y defines the y coordinate of the operand
  3440. * @param z defines the z coordinate of the operand
  3441. * @returns the current updated Vector3
  3442. */
  3443. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3444. /**
  3445. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3446. * Check if is non uniform within a certain amount of decimal places to account for this
  3447. * @param epsilon the amount the values can differ
  3448. * @returns if the the vector is non uniform to a certain number of decimal places
  3449. */
  3450. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3451. /**
  3452. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3453. */
  3454. get isNonUniform(): boolean;
  3455. /**
  3456. * Gets a new Vector3 from current Vector3 floored values
  3457. * @returns a new Vector3
  3458. */
  3459. floor(): Vector3;
  3460. /**
  3461. * Gets a new Vector3 from current Vector3 floored values
  3462. * @returns a new Vector3
  3463. */
  3464. fract(): Vector3;
  3465. /**
  3466. * Gets the length of the Vector3
  3467. * @returns the length of the Vector3
  3468. */
  3469. length(): number;
  3470. /**
  3471. * Gets the squared length of the Vector3
  3472. * @returns squared length of the Vector3
  3473. */
  3474. lengthSquared(): number;
  3475. /**
  3476. * Normalize the current Vector3.
  3477. * Please note that this is an in place operation.
  3478. * @returns the current updated Vector3
  3479. */
  3480. normalize(): Vector3;
  3481. /**
  3482. * Reorders the x y z properties of the vector in place
  3483. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3484. * @returns the current updated vector
  3485. */
  3486. reorderInPlace(order: string): this;
  3487. /**
  3488. * Rotates the vector around 0,0,0 by a quaternion
  3489. * @param quaternion the rotation quaternion
  3490. * @param result vector to store the result
  3491. * @returns the resulting vector
  3492. */
  3493. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3494. /**
  3495. * Rotates a vector around a given point
  3496. * @param quaternion the rotation quaternion
  3497. * @param point the point to rotate around
  3498. * @param result vector to store the result
  3499. * @returns the resulting vector
  3500. */
  3501. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3502. /**
  3503. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3504. * The cross product is then orthogonal to both current and "other"
  3505. * @param other defines the right operand
  3506. * @returns the cross product
  3507. */
  3508. cross(other: Vector3): Vector3;
  3509. /**
  3510. * Normalize the current Vector3 with the given input length.
  3511. * Please note that this is an in place operation.
  3512. * @param len the length of the vector
  3513. * @returns the current updated Vector3
  3514. */
  3515. normalizeFromLength(len: number): Vector3;
  3516. /**
  3517. * Normalize the current Vector3 to a new vector
  3518. * @returns the new Vector3
  3519. */
  3520. normalizeToNew(): Vector3;
  3521. /**
  3522. * Normalize the current Vector3 to the reference
  3523. * @param reference define the Vector3 to update
  3524. * @returns the updated Vector3
  3525. */
  3526. normalizeToRef(reference: Vector3): Vector3;
  3527. /**
  3528. * Creates a new Vector3 copied from the current Vector3
  3529. * @returns the new Vector3
  3530. */
  3531. clone(): Vector3;
  3532. /**
  3533. * Copies the given vector coordinates to the current Vector3 ones
  3534. * @param source defines the source Vector3
  3535. * @returns the current updated Vector3
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3538. /**
  3539. * Copies the given floats to the current Vector3 coordinates
  3540. * @param x defines the x coordinate of the operand
  3541. * @param y defines the y coordinate of the operand
  3542. * @param z defines the z coordinate of the operand
  3543. * @returns the current updated Vector3
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number): Vector3;
  3546. /**
  3547. * Copies the given floats to the current Vector3 coordinates
  3548. * @param x defines the x coordinate of the operand
  3549. * @param y defines the y coordinate of the operand
  3550. * @param z defines the z coordinate of the operand
  3551. * @returns the current updated Vector3
  3552. */
  3553. set(x: number, y: number, z: number): Vector3;
  3554. /**
  3555. * Copies the given float to the current Vector3 coordinates
  3556. * @param v defines the x, y and z coordinates of the operand
  3557. * @returns the current updated Vector3
  3558. */
  3559. setAll(v: number): Vector3;
  3560. /**
  3561. * Get the clip factor between two vectors
  3562. * @param vector0 defines the first operand
  3563. * @param vector1 defines the second operand
  3564. * @param axis defines the axis to use
  3565. * @param size defines the size along the axis
  3566. * @returns the clip factor
  3567. */
  3568. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3569. /**
  3570. * Get angle between two vectors
  3571. * @param vector0 angle between vector0 and vector1
  3572. * @param vector1 angle between vector0 and vector1
  3573. * @param normal direction of the normal
  3574. * @return the angle between vector0 and vector1
  3575. */
  3576. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3577. /**
  3578. * Returns a new Vector3 set from the index "offset" of the given array
  3579. * @param array defines the source array
  3580. * @param offset defines the offset in the source array
  3581. * @returns the new Vector3
  3582. */
  3583. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3584. /**
  3585. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3586. * @param array defines the source array
  3587. * @param offset defines the offset in the source array
  3588. * @returns the new Vector3
  3589. * @deprecated Please use FromArray instead.
  3590. */
  3591. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3592. /**
  3593. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3594. * @param array defines the source array
  3595. * @param offset defines the offset in the source array
  3596. * @param result defines the Vector3 where to store the result
  3597. */
  3598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3599. /**
  3600. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3601. * @param array defines the source array
  3602. * @param offset defines the offset in the source array
  3603. * @param result defines the Vector3 where to store the result
  3604. * @deprecated Please use FromArrayToRef instead.
  3605. */
  3606. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3607. /**
  3608. * Sets the given vector "result" with the given floats.
  3609. * @param x defines the x coordinate of the source
  3610. * @param y defines the y coordinate of the source
  3611. * @param z defines the z coordinate of the source
  3612. * @param result defines the Vector3 where to store the result
  3613. */
  3614. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3615. /**
  3616. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3617. * @returns a new empty Vector3
  3618. */
  3619. static Zero(): Vector3;
  3620. /**
  3621. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3622. * @returns a new unit Vector3
  3623. */
  3624. static One(): Vector3;
  3625. /**
  3626. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3627. * @returns a new up Vector3
  3628. */
  3629. static Up(): Vector3;
  3630. /**
  3631. * Gets a up Vector3 that must not be updated
  3632. */
  3633. static get UpReadOnly(): DeepImmutable<Vector3>;
  3634. /**
  3635. * Gets a zero Vector3 that must not be updated
  3636. */
  3637. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3638. /**
  3639. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3640. * @returns a new down Vector3
  3641. */
  3642. static Down(): Vector3;
  3643. /**
  3644. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3645. * @param rightHandedSystem is the scene right-handed (negative z)
  3646. * @returns a new forward Vector3
  3647. */
  3648. static Forward(rightHandedSystem?: boolean): Vector3;
  3649. /**
  3650. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3651. * @param rightHandedSystem is the scene right-handed (negative-z)
  3652. * @returns a new forward Vector3
  3653. */
  3654. static Backward(rightHandedSystem?: boolean): Vector3;
  3655. /**
  3656. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3657. * @returns a new right Vector3
  3658. */
  3659. static Right(): Vector3;
  3660. /**
  3661. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3662. * @returns a new left Vector3
  3663. */
  3664. static Left(): Vector3;
  3665. /**
  3666. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3667. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3668. * @param vector defines the Vector3 to transform
  3669. * @param transformation defines the transformation matrix
  3670. * @returns the transformed Vector3
  3671. */
  3672. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3673. /**
  3674. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3675. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3676. * @param vector defines the Vector3 to transform
  3677. * @param transformation defines the transformation matrix
  3678. * @param result defines the Vector3 where to store the result
  3679. */
  3680. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3681. /**
  3682. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3683. * This method computes tranformed coordinates only, not transformed direction vectors
  3684. * @param x define the x coordinate of the source vector
  3685. * @param y define the y coordinate of the source vector
  3686. * @param z define the z coordinate of the source vector
  3687. * @param transformation defines the transformation matrix
  3688. * @param result defines the Vector3 where to store the result
  3689. */
  3690. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3691. /**
  3692. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3693. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3694. * @param vector defines the Vector3 to transform
  3695. * @param transformation defines the transformation matrix
  3696. * @returns the new Vector3
  3697. */
  3698. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3699. /**
  3700. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3701. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3702. * @param vector defines the Vector3 to transform
  3703. * @param transformation defines the transformation matrix
  3704. * @param result defines the Vector3 where to store the result
  3705. */
  3706. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3707. /**
  3708. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3709. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3710. * @param x define the x coordinate of the source vector
  3711. * @param y define the y coordinate of the source vector
  3712. * @param z define the z coordinate of the source vector
  3713. * @param transformation defines the transformation matrix
  3714. * @param result defines the Vector3 where to store the result
  3715. */
  3716. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3717. /**
  3718. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3719. * @param value1 defines the first control point
  3720. * @param value2 defines the second control point
  3721. * @param value3 defines the third control point
  3722. * @param value4 defines the fourth control point
  3723. * @param amount defines the amount on the spline to use
  3724. * @returns the new Vector3
  3725. */
  3726. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3727. /**
  3728. * 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"
  3729. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3730. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3731. * @param value defines the current value
  3732. * @param min defines the lower range value
  3733. * @param max defines the upper range value
  3734. * @returns the new Vector3
  3735. */
  3736. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3737. /**
  3738. * 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"
  3739. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3740. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3741. * @param value defines the current value
  3742. * @param min defines the lower range value
  3743. * @param max defines the upper range value
  3744. * @param result defines the Vector3 where to store the result
  3745. */
  3746. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3747. /**
  3748. * Checks if a given vector is inside a specific range
  3749. * @param v defines the vector to test
  3750. * @param min defines the minimum range
  3751. * @param max defines the maximum range
  3752. */
  3753. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3754. /**
  3755. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3756. * @param value1 defines the first control point
  3757. * @param tangent1 defines the first tangent vector
  3758. * @param value2 defines the second control point
  3759. * @param tangent2 defines the second tangent vector
  3760. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3761. * @returns the new Vector3
  3762. */
  3763. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3764. /**
  3765. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3766. * @param start defines the start value
  3767. * @param end defines the end value
  3768. * @param amount max defines amount between both (between 0 and 1)
  3769. * @returns the new Vector3
  3770. */
  3771. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3772. /**
  3773. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3774. * @param start defines the start value
  3775. * @param end defines the end value
  3776. * @param amount max defines amount between both (between 0 and 1)
  3777. * @param result defines the Vector3 where to store the result
  3778. */
  3779. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3780. /**
  3781. * Returns the dot product (float) between the vectors "left" and "right"
  3782. * @param left defines the left operand
  3783. * @param right defines the right operand
  3784. * @returns the dot product
  3785. */
  3786. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3787. /**
  3788. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3789. * The cross product is then orthogonal to both "left" and "right"
  3790. * @param left defines the left operand
  3791. * @param right defines the right operand
  3792. * @returns the cross product
  3793. */
  3794. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3795. /**
  3796. * Sets the given vector "result" with the cross product of "left" and "right"
  3797. * The cross product is then orthogonal to both "left" and "right"
  3798. * @param left defines the left operand
  3799. * @param right defines the right operand
  3800. * @param result defines the Vector3 where to store the result
  3801. */
  3802. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3803. /**
  3804. * Returns a new Vector3 as the normalization of the given vector
  3805. * @param vector defines the Vector3 to normalize
  3806. * @returns the new Vector3
  3807. */
  3808. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3809. /**
  3810. * Sets the given vector "result" with the normalization of the given first vector
  3811. * @param vector defines the Vector3 to normalize
  3812. * @param result defines the Vector3 where to store the result
  3813. */
  3814. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3815. /**
  3816. * Project a Vector3 onto screen space
  3817. * @param vector defines the Vector3 to project
  3818. * @param world defines the world matrix to use
  3819. * @param transform defines the transform (view x projection) matrix to use
  3820. * @param viewport defines the screen viewport to use
  3821. * @returns the new Vector3
  3822. */
  3823. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3824. /**
  3825. * Project a Vector3 onto screen space to reference
  3826. * @param vector defines the Vector3 to project
  3827. * @param world defines the world matrix to use
  3828. * @param transform defines the transform (view x projection) matrix to use
  3829. * @param viewport defines the screen viewport to use
  3830. * @param result the vector in which the screen space will be stored
  3831. * @returns the new Vector3
  3832. */
  3833. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3834. /** @hidden */
  3835. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3836. /**
  3837. * Unproject from screen space to object space
  3838. * @param source defines the screen space Vector3 to use
  3839. * @param viewportWidth defines the current width of the viewport
  3840. * @param viewportHeight defines the current height of the viewport
  3841. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3842. * @param transform defines the transform (view x projection) matrix to use
  3843. * @returns the new Vector3
  3844. */
  3845. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3846. /**
  3847. * Unproject from screen space to object space
  3848. * @param source defines the screen space Vector3 to use
  3849. * @param viewportWidth defines the current width of the viewport
  3850. * @param viewportHeight defines the current height of the viewport
  3851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3852. * @param view defines the view matrix to use
  3853. * @param projection defines the projection matrix to use
  3854. * @returns the new Vector3
  3855. */
  3856. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3857. /**
  3858. * Unproject from screen space to object space
  3859. * @param source defines the screen space Vector3 to use
  3860. * @param viewportWidth defines the current width of the viewport
  3861. * @param viewportHeight defines the current height of the viewport
  3862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3863. * @param view defines the view matrix to use
  3864. * @param projection defines the projection matrix to use
  3865. * @param result defines the Vector3 where to store the result
  3866. */
  3867. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3868. /**
  3869. * Unproject from screen space to object space
  3870. * @param sourceX defines the screen space x coordinate to use
  3871. * @param sourceY defines the screen space y coordinate to use
  3872. * @param sourceZ defines the screen space z coordinate to use
  3873. * @param viewportWidth defines the current width of the viewport
  3874. * @param viewportHeight defines the current height of the viewport
  3875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3876. * @param view defines the view matrix to use
  3877. * @param projection defines the projection matrix to use
  3878. * @param result defines the Vector3 where to store the result
  3879. */
  3880. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3881. /**
  3882. * Gets the minimal coordinate values between two Vector3
  3883. * @param left defines the first operand
  3884. * @param right defines the second operand
  3885. * @returns the new Vector3
  3886. */
  3887. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3888. /**
  3889. * Gets the maximal coordinate values between two Vector3
  3890. * @param left defines the first operand
  3891. * @param right defines the second operand
  3892. * @returns the new Vector3
  3893. */
  3894. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3895. /**
  3896. * Returns the distance between the vectors "value1" and "value2"
  3897. * @param value1 defines the first operand
  3898. * @param value2 defines the second operand
  3899. * @returns the distance
  3900. */
  3901. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3902. /**
  3903. * Returns the squared distance between the vectors "value1" and "value2"
  3904. * @param value1 defines the first operand
  3905. * @param value2 defines the second operand
  3906. * @returns the squared distance
  3907. */
  3908. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3909. /**
  3910. * Returns a new Vector3 located at the center between "value1" and "value2"
  3911. * @param value1 defines the first operand
  3912. * @param value2 defines the second operand
  3913. * @returns the new Vector3
  3914. */
  3915. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3916. /**
  3917. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3918. * @param value1 defines first vector
  3919. * @param value2 defines second vector
  3920. * @param ref defines third vector
  3921. * @returns ref
  3922. */
  3923. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3924. /**
  3925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3927. * to something in order to rotate it from its local system to the given target system
  3928. * Note: axis1, axis2 and axis3 are normalized during this operation
  3929. * @param axis1 defines the first axis
  3930. * @param axis2 defines the second axis
  3931. * @param axis3 defines the third axis
  3932. * @returns a new Vector3
  3933. */
  3934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3935. /**
  3936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3937. * @param axis1 defines the first axis
  3938. * @param axis2 defines the second axis
  3939. * @param axis3 defines the third axis
  3940. * @param ref defines the Vector3 where to store the result
  3941. */
  3942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3943. }
  3944. /**
  3945. * Vector4 class created for EulerAngle class conversion to Quaternion
  3946. */
  3947. export class Vector4 {
  3948. /** x value of the vector */
  3949. x: number;
  3950. /** y value of the vector */
  3951. y: number;
  3952. /** z value of the vector */
  3953. z: number;
  3954. /** w value of the vector */
  3955. w: number;
  3956. /**
  3957. * Creates a Vector4 object from the given floats.
  3958. * @param x x value of the vector
  3959. * @param y y value of the vector
  3960. * @param z z value of the vector
  3961. * @param w w value of the vector
  3962. */
  3963. constructor(
  3964. /** x value of the vector */
  3965. x: number,
  3966. /** y value of the vector */
  3967. y: number,
  3968. /** z value of the vector */
  3969. z: number,
  3970. /** w value of the vector */
  3971. w: number);
  3972. /**
  3973. * Returns the string with the Vector4 coordinates.
  3974. * @returns a string containing all the vector values
  3975. */
  3976. toString(): string;
  3977. /**
  3978. * Returns the string "Vector4".
  3979. * @returns "Vector4"
  3980. */
  3981. getClassName(): string;
  3982. /**
  3983. * Returns the Vector4 hash code.
  3984. * @returns a unique hash code
  3985. */
  3986. getHashCode(): number;
  3987. /**
  3988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3989. * @returns the resulting array
  3990. */
  3991. asArray(): number[];
  3992. /**
  3993. * Populates the given array from the given index with the Vector4 coordinates.
  3994. * @param array array to populate
  3995. * @param index index of the array to start at (default: 0)
  3996. * @returns the Vector4.
  3997. */
  3998. toArray(array: FloatArray, index?: number): Vector4;
  3999. /**
  4000. * Update the current vector from an array
  4001. * @param array defines the destination array
  4002. * @param index defines the offset in the destination array
  4003. * @returns the current Vector3
  4004. */
  4005. fromArray(array: FloatArray, index?: number): Vector4;
  4006. /**
  4007. * Adds the given vector to the current Vector4.
  4008. * @param otherVector the vector to add
  4009. * @returns the updated Vector4.
  4010. */
  4011. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4012. /**
  4013. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  4014. * @param otherVector the vector to add
  4015. * @returns the resulting vector
  4016. */
  4017. add(otherVector: DeepImmutable<Vector4>): Vector4;
  4018. /**
  4019. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  4020. * @param otherVector the vector to add
  4021. * @param result the vector to store the result
  4022. * @returns the current Vector4.
  4023. */
  4024. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4025. /**
  4026. * Subtract in place the given vector from the current Vector4.
  4027. * @param otherVector the vector to subtract
  4028. * @returns the updated Vector4.
  4029. */
  4030. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4031. /**
  4032. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  4033. * @param otherVector the vector to add
  4034. * @returns the new vector with the result
  4035. */
  4036. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  4037. /**
  4038. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  4039. * @param otherVector the vector to subtract
  4040. * @param result the vector to store the result
  4041. * @returns the current Vector4.
  4042. */
  4043. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4044. /**
  4045. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4046. */
  4047. /**
  4048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4049. * @param x value to subtract
  4050. * @param y value to subtract
  4051. * @param z value to subtract
  4052. * @param w value to subtract
  4053. * @returns new vector containing the result
  4054. */
  4055. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4056. /**
  4057. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4058. * @param x value to subtract
  4059. * @param y value to subtract
  4060. * @param z value to subtract
  4061. * @param w value to subtract
  4062. * @param result the vector to store the result in
  4063. * @returns the current Vector4.
  4064. */
  4065. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4066. /**
  4067. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4068. * @returns a new vector with the negated values
  4069. */
  4070. negate(): Vector4;
  4071. /**
  4072. * Negate this vector in place
  4073. * @returns this
  4074. */
  4075. negateInPlace(): Vector4;
  4076. /**
  4077. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4078. * @param result defines the Vector3 object where to store the result
  4079. * @returns the current Vector4
  4080. */
  4081. negateToRef(result: Vector4): Vector4;
  4082. /**
  4083. * Multiplies the current Vector4 coordinates by scale (float).
  4084. * @param scale the number to scale with
  4085. * @returns the updated Vector4.
  4086. */
  4087. scaleInPlace(scale: number): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4090. * @param scale the number to scale with
  4091. * @returns a new vector with the result
  4092. */
  4093. scale(scale: number): Vector4;
  4094. /**
  4095. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4096. * @param scale the number to scale with
  4097. * @param result a vector to store the result in
  4098. * @returns the current Vector4.
  4099. */
  4100. scaleToRef(scale: number, result: Vector4): Vector4;
  4101. /**
  4102. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4103. * @param scale defines the scale factor
  4104. * @param result defines the Vector4 object where to store the result
  4105. * @returns the unmodified current Vector4
  4106. */
  4107. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4108. /**
  4109. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4110. * @param otherVector the vector to compare against
  4111. * @returns true if they are equal
  4112. */
  4113. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4114. /**
  4115. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4116. * @param otherVector vector to compare against
  4117. * @param epsilon (Default: very small number)
  4118. * @returns true if they are equal
  4119. */
  4120. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4121. /**
  4122. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4123. * @param x x value to compare against
  4124. * @param y y value to compare against
  4125. * @param z z value to compare against
  4126. * @param w w value to compare against
  4127. * @returns true if equal
  4128. */
  4129. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4130. /**
  4131. * Multiplies in place the current Vector4 by the given one.
  4132. * @param otherVector vector to multiple with
  4133. * @returns the updated Vector4.
  4134. */
  4135. multiplyInPlace(otherVector: Vector4): Vector4;
  4136. /**
  4137. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4138. * @param otherVector vector to multiple with
  4139. * @returns resulting new vector
  4140. */
  4141. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4142. /**
  4143. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4144. * @param otherVector vector to multiple with
  4145. * @param result vector to store the result
  4146. * @returns the current Vector4.
  4147. */
  4148. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4149. /**
  4150. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4151. * @param x x value multiply with
  4152. * @param y y value multiply with
  4153. * @param z z value multiply with
  4154. * @param w w value multiply with
  4155. * @returns resulting new vector
  4156. */
  4157. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4158. /**
  4159. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4160. * @param otherVector vector to devide with
  4161. * @returns resulting new vector
  4162. */
  4163. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4164. /**
  4165. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4166. * @param otherVector vector to devide with
  4167. * @param result vector to store the result
  4168. * @returns the current Vector4.
  4169. */
  4170. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4171. /**
  4172. * Divides the current Vector3 coordinates by the given ones.
  4173. * @param otherVector vector to devide with
  4174. * @returns the updated Vector3.
  4175. */
  4176. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4177. /**
  4178. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4179. * @param other defines the second operand
  4180. * @returns the current updated Vector4
  4181. */
  4182. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4183. /**
  4184. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4185. * @param other defines the second operand
  4186. * @returns the current updated Vector4
  4187. */
  4188. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4189. /**
  4190. * Gets a new Vector4 from current Vector4 floored values
  4191. * @returns a new Vector4
  4192. */
  4193. floor(): Vector4;
  4194. /**
  4195. * Gets a new Vector4 from current Vector3 floored values
  4196. * @returns a new Vector4
  4197. */
  4198. fract(): Vector4;
  4199. /**
  4200. * Returns the Vector4 length (float).
  4201. * @returns the length
  4202. */
  4203. length(): number;
  4204. /**
  4205. * Returns the Vector4 squared length (float).
  4206. * @returns the length squared
  4207. */
  4208. lengthSquared(): number;
  4209. /**
  4210. * Normalizes in place the Vector4.
  4211. * @returns the updated Vector4.
  4212. */
  4213. normalize(): Vector4;
  4214. /**
  4215. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4216. * @returns this converted to a new vector3
  4217. */
  4218. toVector3(): Vector3;
  4219. /**
  4220. * Returns a new Vector4 copied from the current one.
  4221. * @returns the new cloned vector
  4222. */
  4223. clone(): Vector4;
  4224. /**
  4225. * Updates the current Vector4 with the given one coordinates.
  4226. * @param source the source vector to copy from
  4227. * @returns the updated Vector4.
  4228. */
  4229. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4230. /**
  4231. * Updates the current Vector4 coordinates with the given floats.
  4232. * @param x float to copy from
  4233. * @param y float to copy from
  4234. * @param z float to copy from
  4235. * @param w float to copy from
  4236. * @returns the updated Vector4.
  4237. */
  4238. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4239. /**
  4240. * Updates the current Vector4 coordinates with the given floats.
  4241. * @param x float to set from
  4242. * @param y float to set from
  4243. * @param z float to set from
  4244. * @param w float to set from
  4245. * @returns the updated Vector4.
  4246. */
  4247. set(x: number, y: number, z: number, w: number): Vector4;
  4248. /**
  4249. * Copies the given float to the current Vector3 coordinates
  4250. * @param v defines the x, y, z and w coordinates of the operand
  4251. * @returns the current updated Vector3
  4252. */
  4253. setAll(v: number): Vector4;
  4254. /**
  4255. * Returns a new Vector4 set from the starting index of the given array.
  4256. * @param array the array to pull values from
  4257. * @param offset the offset into the array to start at
  4258. * @returns the new vector
  4259. */
  4260. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4261. /**
  4262. * Updates the given vector "result" from the starting index of the given array.
  4263. * @param array the array to pull values from
  4264. * @param offset the offset into the array to start at
  4265. * @param result the vector to store the result in
  4266. */
  4267. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4268. /**
  4269. * Updates the given vector "result" from the starting index of the given Float32Array.
  4270. * @param array the array to pull values from
  4271. * @param offset the offset into the array to start at
  4272. * @param result the vector to store the result in
  4273. */
  4274. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4275. /**
  4276. * Updates the given vector "result" coordinates from the given floats.
  4277. * @param x float to set from
  4278. * @param y float to set from
  4279. * @param z float to set from
  4280. * @param w float to set from
  4281. * @param result the vector to the floats in
  4282. */
  4283. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4284. /**
  4285. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4286. * @returns the new vector
  4287. */
  4288. static Zero(): Vector4;
  4289. /**
  4290. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4291. * @returns the new vector
  4292. */
  4293. static One(): Vector4;
  4294. /**
  4295. * Returns a new normalized Vector4 from the given one.
  4296. * @param vector the vector to normalize
  4297. * @returns the vector
  4298. */
  4299. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4300. /**
  4301. * Updates the given vector "result" from the normalization of the given one.
  4302. * @param vector the vector to normalize
  4303. * @param result the vector to store the result in
  4304. */
  4305. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4306. /**
  4307. * Returns a vector with the minimum values from the left and right vectors
  4308. * @param left left vector to minimize
  4309. * @param right right vector to minimize
  4310. * @returns a new vector with the minimum of the left and right vector values
  4311. */
  4312. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4313. /**
  4314. * Returns a vector with the maximum values from the left and right vectors
  4315. * @param left left vector to maximize
  4316. * @param right right vector to maximize
  4317. * @returns a new vector with the maximum of the left and right vector values
  4318. */
  4319. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4320. /**
  4321. * Returns the distance (float) between the vectors "value1" and "value2".
  4322. * @param value1 value to calulate the distance between
  4323. * @param value2 value to calulate the distance between
  4324. * @return the distance between the two vectors
  4325. */
  4326. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4327. /**
  4328. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4329. * @param value1 value to calulate the distance between
  4330. * @param value2 value to calulate the distance between
  4331. * @return the distance between the two vectors squared
  4332. */
  4333. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4334. /**
  4335. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4336. * @param value1 value to calulate the center between
  4337. * @param value2 value to calulate the center between
  4338. * @return the center between the two vectors
  4339. */
  4340. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4341. /**
  4342. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4343. * @param value1 defines first vector
  4344. * @param value2 defines second vector
  4345. * @param ref defines third vector
  4346. * @returns ref
  4347. */
  4348. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4349. /**
  4350. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4351. * This methods computes transformed normalized direction vectors only.
  4352. * @param vector the vector to transform
  4353. * @param transformation the transformation matrix to apply
  4354. * @returns the new vector
  4355. */
  4356. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4357. /**
  4358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4359. * This methods computes transformed normalized direction vectors only.
  4360. * @param vector the vector to transform
  4361. * @param transformation the transformation matrix to apply
  4362. * @param result the vector to store the result in
  4363. */
  4364. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4365. /**
  4366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4367. * This methods computes transformed normalized direction vectors only.
  4368. * @param x value to transform
  4369. * @param y value to transform
  4370. * @param z value to transform
  4371. * @param w value to transform
  4372. * @param transformation the transformation matrix to apply
  4373. * @param result the vector to store the results in
  4374. */
  4375. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4376. /**
  4377. * Creates a new Vector4 from a Vector3
  4378. * @param source defines the source data
  4379. * @param w defines the 4th component (default is 0)
  4380. * @returns a new Vector4
  4381. */
  4382. static FromVector3(source: Vector3, w?: number): Vector4;
  4383. }
  4384. /**
  4385. * Class used to store quaternion data
  4386. * @see https://en.wikipedia.org/wiki/Quaternion
  4387. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4388. */
  4389. export class Quaternion {
  4390. /** @hidden */
  4391. _x: number;
  4392. /** @hidden */
  4393. _y: number;
  4394. /** @hidden */
  4395. _z: number;
  4396. /** @hidden */
  4397. _w: number;
  4398. /** @hidden */
  4399. _isDirty: boolean;
  4400. /** Gets or sets the x coordinate */
  4401. get x(): number;
  4402. set x(value: number);
  4403. /** Gets or sets the y coordinate */
  4404. get y(): number;
  4405. set y(value: number);
  4406. /** Gets or sets the z coordinate */
  4407. get z(): number;
  4408. set z(value: number);
  4409. /** Gets or sets the w coordinate */
  4410. get w(): number;
  4411. set w(value: number);
  4412. /**
  4413. * Creates a new Quaternion from the given floats
  4414. * @param x defines the first component (0 by default)
  4415. * @param y defines the second component (0 by default)
  4416. * @param z defines the third component (0 by default)
  4417. * @param w defines the fourth component (1.0 by default)
  4418. */
  4419. constructor(x?: number, y?: number, z?: number, w?: number);
  4420. /**
  4421. * Gets a string representation for the current quaternion
  4422. * @returns a string with the Quaternion coordinates
  4423. */
  4424. toString(): string;
  4425. /**
  4426. * Gets the class name of the quaternion
  4427. * @returns the string "Quaternion"
  4428. */
  4429. getClassName(): string;
  4430. /**
  4431. * Gets a hash code for this quaternion
  4432. * @returns the quaternion hash code
  4433. */
  4434. getHashCode(): number;
  4435. /**
  4436. * Copy the quaternion to an array
  4437. * @returns a new array populated with 4 elements from the quaternion coordinates
  4438. */
  4439. asArray(): number[];
  4440. /**
  4441. * Check if two quaternions are equals
  4442. * @param otherQuaternion defines the second operand
  4443. * @return true if the current quaternion and the given one coordinates are strictly equals
  4444. */
  4445. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4446. /**
  4447. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4448. * @param otherQuaternion defines the other quaternion
  4449. * @param epsilon defines the minimal distance to consider equality
  4450. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4451. */
  4452. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4453. /**
  4454. * Clone the current quaternion
  4455. * @returns a new quaternion copied from the current one
  4456. */
  4457. clone(): Quaternion;
  4458. /**
  4459. * Copy a quaternion to the current one
  4460. * @param other defines the other quaternion
  4461. * @returns the updated current quaternion
  4462. */
  4463. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4464. /**
  4465. * Updates the current quaternion with the given float coordinates
  4466. * @param x defines the x coordinate
  4467. * @param y defines the y coordinate
  4468. * @param z defines the z coordinate
  4469. * @param w defines the w coordinate
  4470. * @returns the updated current quaternion
  4471. */
  4472. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4473. /**
  4474. * Updates the current quaternion from the given float coordinates
  4475. * @param x defines the x coordinate
  4476. * @param y defines the y coordinate
  4477. * @param z defines the z coordinate
  4478. * @param w defines the w coordinate
  4479. * @returns the updated current quaternion
  4480. */
  4481. set(x: number, y: number, z: number, w: number): Quaternion;
  4482. /**
  4483. * Adds two quaternions
  4484. * @param other defines the second operand
  4485. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4486. */
  4487. add(other: DeepImmutable<Quaternion>): Quaternion;
  4488. /**
  4489. * Add a quaternion to the current one
  4490. * @param other defines the quaternion to add
  4491. * @returns the current quaternion
  4492. */
  4493. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4494. /**
  4495. * Subtract two quaternions
  4496. * @param other defines the second operand
  4497. * @returns a new quaternion as the subtraction result of the given one from the current one
  4498. */
  4499. subtract(other: Quaternion): Quaternion;
  4500. /**
  4501. * Multiplies the current quaternion by a scale factor
  4502. * @param value defines the scale factor
  4503. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4504. */
  4505. scale(value: number): Quaternion;
  4506. /**
  4507. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4508. * @param scale defines the scale factor
  4509. * @param result defines the Quaternion object where to store the result
  4510. * @returns the unmodified current quaternion
  4511. */
  4512. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4513. /**
  4514. * Multiplies in place the current quaternion by a scale factor
  4515. * @param value defines the scale factor
  4516. * @returns the current modified quaternion
  4517. */
  4518. scaleInPlace(value: number): Quaternion;
  4519. /**
  4520. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4521. * @param scale defines the scale factor
  4522. * @param result defines the Quaternion object where to store the result
  4523. * @returns the unmodified current quaternion
  4524. */
  4525. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4526. /**
  4527. * Multiplies two quaternions
  4528. * @param q1 defines the second operand
  4529. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4530. */
  4531. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4532. /**
  4533. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4534. * @param q1 defines the second operand
  4535. * @param result defines the target quaternion
  4536. * @returns the current quaternion
  4537. */
  4538. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4539. /**
  4540. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4541. * @param q1 defines the second operand
  4542. * @returns the currentupdated quaternion
  4543. */
  4544. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4545. /**
  4546. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4547. * @param ref defines the target quaternion
  4548. * @returns the current quaternion
  4549. */
  4550. conjugateToRef(ref: Quaternion): Quaternion;
  4551. /**
  4552. * Conjugates in place (1-q) the current quaternion
  4553. * @returns the current updated quaternion
  4554. */
  4555. conjugateInPlace(): Quaternion;
  4556. /**
  4557. * Conjugates in place (1-q) the current quaternion
  4558. * @returns a new quaternion
  4559. */
  4560. conjugate(): Quaternion;
  4561. /**
  4562. * Gets length of current quaternion
  4563. * @returns the quaternion length (float)
  4564. */
  4565. length(): number;
  4566. /**
  4567. * Normalize in place the current quaternion
  4568. * @returns the current updated quaternion
  4569. */
  4570. normalize(): Quaternion;
  4571. /**
  4572. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4573. * @param order is a reserved parameter and is ignored for now
  4574. * @returns a new Vector3 containing the Euler angles
  4575. */
  4576. toEulerAngles(order?: string): Vector3;
  4577. /**
  4578. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4579. * @param result defines the vector which will be filled with the Euler angles
  4580. * @returns the current unchanged quaternion
  4581. */
  4582. toEulerAnglesToRef(result: Vector3): Quaternion;
  4583. /**
  4584. * Updates the given rotation matrix with the current quaternion values
  4585. * @param result defines the target matrix
  4586. * @returns the current unchanged quaternion
  4587. */
  4588. toRotationMatrix(result: Matrix): Quaternion;
  4589. /**
  4590. * Updates the current quaternion from the given rotation matrix values
  4591. * @param matrix defines the source matrix
  4592. * @returns the current updated quaternion
  4593. */
  4594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4595. /**
  4596. * Creates a new quaternion from a rotation matrix
  4597. * @param matrix defines the source matrix
  4598. * @returns a new quaternion created from the given rotation matrix values
  4599. */
  4600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4601. /**
  4602. * Updates the given quaternion with the given rotation matrix values
  4603. * @param matrix defines the source matrix
  4604. * @param result defines the target quaternion
  4605. */
  4606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4607. /**
  4608. * Returns the dot product (float) between the quaternions "left" and "right"
  4609. * @param left defines the left operand
  4610. * @param right defines the right operand
  4611. * @returns the dot product
  4612. */
  4613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4614. /**
  4615. * Checks if the two quaternions are close to each other
  4616. * @param quat0 defines the first quaternion to check
  4617. * @param quat1 defines the second quaternion to check
  4618. * @returns true if the two quaternions are close to each other
  4619. */
  4620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4621. /**
  4622. * Creates an empty quaternion
  4623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4624. */
  4625. static Zero(): Quaternion;
  4626. /**
  4627. * Inverse a given quaternion
  4628. * @param q defines the source quaternion
  4629. * @returns a new quaternion as the inverted current quaternion
  4630. */
  4631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4632. /**
  4633. * Inverse a given quaternion
  4634. * @param q defines the source quaternion
  4635. * @param result the quaternion the result will be stored in
  4636. * @returns the result quaternion
  4637. */
  4638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4639. /**
  4640. * Creates an identity quaternion
  4641. * @returns the identity quaternion
  4642. */
  4643. static Identity(): Quaternion;
  4644. /**
  4645. * Gets a boolean indicating if the given quaternion is identity
  4646. * @param quaternion defines the quaternion to check
  4647. * @returns true if the quaternion is identity
  4648. */
  4649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4650. /**
  4651. * Creates a quaternion from a rotation around an axis
  4652. * @param axis defines the axis to use
  4653. * @param angle defines the angle to use
  4654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4655. */
  4656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4657. /**
  4658. * Creates a rotation around an axis and stores it into the given quaternion
  4659. * @param axis defines the axis to use
  4660. * @param angle defines the angle to use
  4661. * @param result defines the target quaternion
  4662. * @returns the target quaternion
  4663. */
  4664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4665. /**
  4666. * Creates a new quaternion from data stored into an array
  4667. * @param array defines the data source
  4668. * @param offset defines the offset in the source array where the data starts
  4669. * @returns a new quaternion
  4670. */
  4671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4672. /**
  4673. * Updates the given quaternion "result" from the starting index of the given array.
  4674. * @param array the array to pull values from
  4675. * @param offset the offset into the array to start at
  4676. * @param result the quaternion to store the result in
  4677. */
  4678. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4679. /**
  4680. * Create a quaternion from Euler rotation angles
  4681. * @param x Pitch
  4682. * @param y Yaw
  4683. * @param z Roll
  4684. * @returns the new Quaternion
  4685. */
  4686. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4687. /**
  4688. * Updates a quaternion from Euler rotation angles
  4689. * @param x Pitch
  4690. * @param y Yaw
  4691. * @param z Roll
  4692. * @param result the quaternion to store the result
  4693. * @returns the updated quaternion
  4694. */
  4695. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4696. /**
  4697. * Create a quaternion from Euler rotation vector
  4698. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4699. * @returns the new Quaternion
  4700. */
  4701. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4702. /**
  4703. * Updates a quaternion from Euler rotation vector
  4704. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4705. * @param result the quaternion to store the result
  4706. * @returns the updated quaternion
  4707. */
  4708. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4709. /**
  4710. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4711. * @param yaw defines the rotation around Y axis
  4712. * @param pitch defines the rotation around X axis
  4713. * @param roll defines the rotation around Z axis
  4714. * @returns the new quaternion
  4715. */
  4716. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4717. /**
  4718. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4719. * @param yaw defines the rotation around Y axis
  4720. * @param pitch defines the rotation around X axis
  4721. * @param roll defines the rotation around Z axis
  4722. * @param result defines the target quaternion
  4723. */
  4724. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4725. /**
  4726. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4727. * @param alpha defines the rotation around first axis
  4728. * @param beta defines the rotation around second axis
  4729. * @param gamma defines the rotation around third axis
  4730. * @returns the new quaternion
  4731. */
  4732. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4733. /**
  4734. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4735. * @param alpha defines the rotation around first axis
  4736. * @param beta defines the rotation around second axis
  4737. * @param gamma defines the rotation around third axis
  4738. * @param result defines the target quaternion
  4739. */
  4740. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4741. /**
  4742. * 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)
  4743. * @param axis1 defines the first axis
  4744. * @param axis2 defines the second axis
  4745. * @param axis3 defines the third axis
  4746. * @returns the new quaternion
  4747. */
  4748. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4749. /**
  4750. * 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
  4751. * @param axis1 defines the first axis
  4752. * @param axis2 defines the second axis
  4753. * @param axis3 defines the third axis
  4754. * @param ref defines the target quaternion
  4755. */
  4756. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4757. /**
  4758. * Interpolates between two quaternions
  4759. * @param left defines first quaternion
  4760. * @param right defines second quaternion
  4761. * @param amount defines the gradient to use
  4762. * @returns the new interpolated quaternion
  4763. */
  4764. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4765. /**
  4766. * Interpolates between two quaternions and stores it into a target quaternion
  4767. * @param left defines first quaternion
  4768. * @param right defines second quaternion
  4769. * @param amount defines the gradient to use
  4770. * @param result defines the target quaternion
  4771. */
  4772. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4773. /**
  4774. * Interpolate between two quaternions using Hermite interpolation
  4775. * @param value1 defines first quaternion
  4776. * @param tangent1 defines the incoming tangent
  4777. * @param value2 defines second quaternion
  4778. * @param tangent2 defines the outgoing tangent
  4779. * @param amount defines the target quaternion
  4780. * @returns the new interpolated quaternion
  4781. */
  4782. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4783. }
  4784. /**
  4785. * Class used to store matrix data (4x4)
  4786. */
  4787. export class Matrix {
  4788. /**
  4789. * Gets the precision of matrix computations
  4790. */
  4791. static get Use64Bits(): boolean;
  4792. private static _updateFlagSeed;
  4793. private static _identityReadOnly;
  4794. private _isIdentity;
  4795. private _isIdentityDirty;
  4796. private _isIdentity3x2;
  4797. private _isIdentity3x2Dirty;
  4798. /**
  4799. * Gets the update flag of the matrix which is an unique number for the matrix.
  4800. * It will be incremented every time the matrix data change.
  4801. * You can use it to speed the comparison between two versions of the same matrix.
  4802. */
  4803. updateFlag: number;
  4804. private readonly _m;
  4805. /**
  4806. * Gets the internal data of the matrix
  4807. */
  4808. get m(): DeepImmutable<Float32Array | Array<number>>;
  4809. /** @hidden */
  4810. _markAsUpdated(): void;
  4811. /** @hidden */
  4812. private _updateIdentityStatus;
  4813. /**
  4814. * Creates an empty matrix (filled with zeros)
  4815. */
  4816. constructor();
  4817. /**
  4818. * Check if the current matrix is identity
  4819. * @returns true is the matrix is the identity matrix
  4820. */
  4821. isIdentity(): boolean;
  4822. /**
  4823. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4824. * @returns true is the matrix is the identity matrix
  4825. */
  4826. isIdentityAs3x2(): boolean;
  4827. /**
  4828. * Gets the determinant of the matrix
  4829. * @returns the matrix determinant
  4830. */
  4831. determinant(): number;
  4832. /**
  4833. * Returns the matrix as a Float32Array or Array<number>
  4834. * @returns the matrix underlying array
  4835. */
  4836. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4837. /**
  4838. * Returns the matrix as a Float32Array or Array<number>
  4839. * @returns the matrix underlying array.
  4840. */
  4841. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4842. /**
  4843. * Inverts the current matrix in place
  4844. * @returns the current inverted matrix
  4845. */
  4846. invert(): Matrix;
  4847. /**
  4848. * Sets all the matrix elements to zero
  4849. * @returns the current matrix
  4850. */
  4851. reset(): Matrix;
  4852. /**
  4853. * Adds the current matrix with a second one
  4854. * @param other defines the matrix to add
  4855. * @returns a new matrix as the addition of the current matrix and the given one
  4856. */
  4857. add(other: DeepImmutable<Matrix>): Matrix;
  4858. /**
  4859. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4860. * @param other defines the matrix to add
  4861. * @param result defines the target matrix
  4862. * @returns the current matrix
  4863. */
  4864. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4865. /**
  4866. * Adds in place the given matrix to the current matrix
  4867. * @param other defines the second operand
  4868. * @returns the current updated matrix
  4869. */
  4870. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4871. /**
  4872. * Sets the given matrix to the current inverted Matrix
  4873. * @param other defines the target matrix
  4874. * @returns the unmodified current matrix
  4875. */
  4876. invertToRef(other: Matrix): Matrix;
  4877. /**
  4878. * add a value at the specified position in the current Matrix
  4879. * @param index the index of the value within the matrix. between 0 and 15.
  4880. * @param value the value to be added
  4881. * @returns the current updated matrix
  4882. */
  4883. addAtIndex(index: number, value: number): Matrix;
  4884. /**
  4885. * mutiply the specified position in the current Matrix by a value
  4886. * @param index the index of the value within the matrix. between 0 and 15.
  4887. * @param value the value to be added
  4888. * @returns the current updated matrix
  4889. */
  4890. multiplyAtIndex(index: number, value: number): Matrix;
  4891. /**
  4892. * Inserts the translation vector (using 3 floats) in the current matrix
  4893. * @param x defines the 1st component of the translation
  4894. * @param y defines the 2nd component of the translation
  4895. * @param z defines the 3rd component of the translation
  4896. * @returns the current updated matrix
  4897. */
  4898. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4899. /**
  4900. * Adds the translation vector (using 3 floats) in the current matrix
  4901. * @param x defines the 1st component of the translation
  4902. * @param y defines the 2nd component of the translation
  4903. * @param z defines the 3rd component of the translation
  4904. * @returns the current updated matrix
  4905. */
  4906. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4907. /**
  4908. * Inserts the translation vector in the current matrix
  4909. * @param vector3 defines the translation to insert
  4910. * @returns the current updated matrix
  4911. */
  4912. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4913. /**
  4914. * Gets the translation value of the current matrix
  4915. * @returns a new Vector3 as the extracted translation from the matrix
  4916. */
  4917. getTranslation(): Vector3;
  4918. /**
  4919. * Fill a Vector3 with the extracted translation from the matrix
  4920. * @param result defines the Vector3 where to store the translation
  4921. * @returns the current matrix
  4922. */
  4923. getTranslationToRef(result: Vector3): Matrix;
  4924. /**
  4925. * Remove rotation and scaling part from the matrix
  4926. * @returns the updated matrix
  4927. */
  4928. removeRotationAndScaling(): Matrix;
  4929. /**
  4930. * Multiply two matrices
  4931. * @param other defines the second operand
  4932. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4933. */
  4934. multiply(other: DeepImmutable<Matrix>): Matrix;
  4935. /**
  4936. * Copy the current matrix from the given one
  4937. * @param other defines the source matrix
  4938. * @returns the current updated matrix
  4939. */
  4940. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4941. /**
  4942. * Populates the given array from the starting index with the current matrix values
  4943. * @param array defines the target array
  4944. * @param offset defines the offset in the target array where to start storing values
  4945. * @returns the current matrix
  4946. */
  4947. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4948. /**
  4949. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4950. * @param other defines the second operand
  4951. * @param result defines the matrix where to store the multiplication
  4952. * @returns the current matrix
  4953. */
  4954. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4955. /**
  4956. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4957. * @param other defines the second operand
  4958. * @param result defines the array where to store the multiplication
  4959. * @param offset defines the offset in the target array where to start storing values
  4960. * @returns the current matrix
  4961. */
  4962. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4963. /**
  4964. * Check equality between this matrix and a second one
  4965. * @param value defines the second matrix to compare
  4966. * @returns true is the current matrix and the given one values are strictly equal
  4967. */
  4968. equals(value: DeepImmutable<Matrix>): boolean;
  4969. /**
  4970. * Clone the current matrix
  4971. * @returns a new matrix from the current matrix
  4972. */
  4973. clone(): Matrix;
  4974. /**
  4975. * Returns the name of the current matrix class
  4976. * @returns the string "Matrix"
  4977. */
  4978. getClassName(): string;
  4979. /**
  4980. * Gets the hash code of the current matrix
  4981. * @returns the hash code
  4982. */
  4983. getHashCode(): number;
  4984. /**
  4985. * Decomposes the current Matrix into a translation, rotation and scaling components
  4986. * @param scale defines the scale vector3 given as a reference to update
  4987. * @param rotation defines the rotation quaternion given as a reference to update
  4988. * @param translation defines the translation vector3 given as a reference to update
  4989. * @returns true if operation was successful
  4990. */
  4991. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4992. /**
  4993. * Gets specific row of the matrix
  4994. * @param index defines the number of the row to get
  4995. * @returns the index-th row of the current matrix as a new Vector4
  4996. */
  4997. getRow(index: number): Nullable<Vector4>;
  4998. /**
  4999. * Sets the index-th row of the current matrix to the vector4 values
  5000. * @param index defines the number of the row to set
  5001. * @param row defines the target vector4
  5002. * @returns the updated current matrix
  5003. */
  5004. setRow(index: number, row: Vector4): Matrix;
  5005. /**
  5006. * Compute the transpose of the matrix
  5007. * @returns the new transposed matrix
  5008. */
  5009. transpose(): Matrix;
  5010. /**
  5011. * Compute the transpose of the matrix and store it in a given matrix
  5012. * @param result defines the target matrix
  5013. * @returns the current matrix
  5014. */
  5015. transposeToRef(result: Matrix): Matrix;
  5016. /**
  5017. * Sets the index-th row of the current matrix with the given 4 x float values
  5018. * @param index defines the row index
  5019. * @param x defines the x component to set
  5020. * @param y defines the y component to set
  5021. * @param z defines the z component to set
  5022. * @param w defines the w component to set
  5023. * @returns the updated current matrix
  5024. */
  5025. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  5026. /**
  5027. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  5028. * @param scale defines the scale factor
  5029. * @returns a new matrix
  5030. */
  5031. scale(scale: number): Matrix;
  5032. /**
  5033. * Scale the current matrix values by a factor to a given result matrix
  5034. * @param scale defines the scale factor
  5035. * @param result defines the matrix to store the result
  5036. * @returns the current matrix
  5037. */
  5038. scaleToRef(scale: number, result: Matrix): Matrix;
  5039. /**
  5040. * Scale the current matrix values by a factor and add the result to a given matrix
  5041. * @param scale defines the scale factor
  5042. * @param result defines the Matrix to store the result
  5043. * @returns the current matrix
  5044. */
  5045. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5046. /**
  5047. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5048. * @param ref matrix to store the result
  5049. */
  5050. toNormalMatrix(ref: Matrix): void;
  5051. /**
  5052. * Gets only rotation part of the current matrix
  5053. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5054. */
  5055. getRotationMatrix(): Matrix;
  5056. /**
  5057. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5058. * @param result defines the target matrix to store data to
  5059. * @returns the current matrix
  5060. */
  5061. getRotationMatrixToRef(result: Matrix): Matrix;
  5062. /**
  5063. * Toggles model matrix from being right handed to left handed in place and vice versa
  5064. */
  5065. toggleModelMatrixHandInPlace(): void;
  5066. /**
  5067. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5068. */
  5069. toggleProjectionMatrixHandInPlace(): void;
  5070. /**
  5071. * Creates a matrix from an array
  5072. * @param array defines the source array
  5073. * @param offset defines an offset in the source array
  5074. * @returns a new Matrix set from the starting index of the given array
  5075. */
  5076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5077. /**
  5078. * Copy the content of an array into a given matrix
  5079. * @param array defines the source array
  5080. * @param offset defines an offset in the source array
  5081. * @param result defines the target matrix
  5082. */
  5083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5084. /**
  5085. * Stores an array into a matrix after having multiplied each component by a given factor
  5086. * @param array defines the source array
  5087. * @param offset defines the offset in the source array
  5088. * @param scale defines the scaling factor
  5089. * @param result defines the target matrix
  5090. */
  5091. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5092. /**
  5093. * Gets an identity matrix that must not be updated
  5094. */
  5095. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5096. /**
  5097. * Stores a list of values (16) inside a given matrix
  5098. * @param initialM11 defines 1st value of 1st row
  5099. * @param initialM12 defines 2nd value of 1st row
  5100. * @param initialM13 defines 3rd value of 1st row
  5101. * @param initialM14 defines 4th value of 1st row
  5102. * @param initialM21 defines 1st value of 2nd row
  5103. * @param initialM22 defines 2nd value of 2nd row
  5104. * @param initialM23 defines 3rd value of 2nd row
  5105. * @param initialM24 defines 4th value of 2nd row
  5106. * @param initialM31 defines 1st value of 3rd row
  5107. * @param initialM32 defines 2nd value of 3rd row
  5108. * @param initialM33 defines 3rd value of 3rd row
  5109. * @param initialM34 defines 4th value of 3rd row
  5110. * @param initialM41 defines 1st value of 4th row
  5111. * @param initialM42 defines 2nd value of 4th row
  5112. * @param initialM43 defines 3rd value of 4th row
  5113. * @param initialM44 defines 4th value of 4th row
  5114. * @param result defines the target matrix
  5115. */
  5116. 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;
  5117. /**
  5118. * Creates new matrix from a list of values (16)
  5119. * @param initialM11 defines 1st value of 1st row
  5120. * @param initialM12 defines 2nd value of 1st row
  5121. * @param initialM13 defines 3rd value of 1st row
  5122. * @param initialM14 defines 4th value of 1st row
  5123. * @param initialM21 defines 1st value of 2nd row
  5124. * @param initialM22 defines 2nd value of 2nd row
  5125. * @param initialM23 defines 3rd value of 2nd row
  5126. * @param initialM24 defines 4th value of 2nd row
  5127. * @param initialM31 defines 1st value of 3rd row
  5128. * @param initialM32 defines 2nd value of 3rd row
  5129. * @param initialM33 defines 3rd value of 3rd row
  5130. * @param initialM34 defines 4th value of 3rd row
  5131. * @param initialM41 defines 1st value of 4th row
  5132. * @param initialM42 defines 2nd value of 4th row
  5133. * @param initialM43 defines 3rd value of 4th row
  5134. * @param initialM44 defines 4th value of 4th row
  5135. * @returns the new matrix
  5136. */
  5137. 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;
  5138. /**
  5139. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5140. * @param scale defines the scale vector3
  5141. * @param rotation defines the rotation quaternion
  5142. * @param translation defines the translation vector3
  5143. * @returns a new matrix
  5144. */
  5145. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5146. /**
  5147. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5148. * @param scale defines the scale vector3
  5149. * @param rotation defines the rotation quaternion
  5150. * @param translation defines the translation vector3
  5151. * @param result defines the target matrix
  5152. */
  5153. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5154. /**
  5155. * Creates a new identity matrix
  5156. * @returns a new identity matrix
  5157. */
  5158. static Identity(): Matrix;
  5159. /**
  5160. * Creates a new identity matrix and stores the result in a given matrix
  5161. * @param result defines the target matrix
  5162. */
  5163. static IdentityToRef(result: Matrix): void;
  5164. /**
  5165. * Creates a new zero matrix
  5166. * @returns a new zero matrix
  5167. */
  5168. static Zero(): Matrix;
  5169. /**
  5170. * Creates a new rotation matrix for "angle" radians around the X axis
  5171. * @param angle defines the angle (in radians) to use
  5172. * @return the new matrix
  5173. */
  5174. static RotationX(angle: number): Matrix;
  5175. /**
  5176. * Creates a new matrix as the invert of a given matrix
  5177. * @param source defines the source matrix
  5178. * @returns the new matrix
  5179. */
  5180. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5181. /**
  5182. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5183. * @param angle defines the angle (in radians) to use
  5184. * @param result defines the target matrix
  5185. */
  5186. static RotationXToRef(angle: number, result: Matrix): void;
  5187. /**
  5188. * Creates a new rotation matrix for "angle" radians around the Y axis
  5189. * @param angle defines the angle (in radians) to use
  5190. * @return the new matrix
  5191. */
  5192. static RotationY(angle: number): Matrix;
  5193. /**
  5194. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5195. * @param angle defines the angle (in radians) to use
  5196. * @param result defines the target matrix
  5197. */
  5198. static RotationYToRef(angle: number, result: Matrix): void;
  5199. /**
  5200. * Creates a new rotation matrix for "angle" radians around the Z axis
  5201. * @param angle defines the angle (in radians) to use
  5202. * @return the new matrix
  5203. */
  5204. static RotationZ(angle: number): Matrix;
  5205. /**
  5206. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5207. * @param angle defines the angle (in radians) to use
  5208. * @param result defines the target matrix
  5209. */
  5210. static RotationZToRef(angle: number, result: Matrix): void;
  5211. /**
  5212. * Creates a new rotation matrix for "angle" radians around the given axis
  5213. * @param axis defines the axis to use
  5214. * @param angle defines the angle (in radians) to use
  5215. * @return the new matrix
  5216. */
  5217. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5218. /**
  5219. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5220. * @param axis defines the axis to use
  5221. * @param angle defines the angle (in radians) to use
  5222. * @param result defines the target matrix
  5223. */
  5224. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5225. /**
  5226. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5227. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5228. * @param from defines the vector to align
  5229. * @param to defines the vector to align to
  5230. * @param result defines the target matrix
  5231. */
  5232. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5233. /**
  5234. * Creates a rotation matrix
  5235. * @param yaw defines the yaw angle in radians (Y axis)
  5236. * @param pitch defines the pitch angle in radians (X axis)
  5237. * @param roll defines the roll angle in radians (Z axis)
  5238. * @returns the new rotation matrix
  5239. */
  5240. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5241. /**
  5242. * Creates a rotation matrix and stores it in a given matrix
  5243. * @param yaw defines the yaw angle in radians (Y axis)
  5244. * @param pitch defines the pitch angle in radians (X axis)
  5245. * @param roll defines the roll angle in radians (Z axis)
  5246. * @param result defines the target matrix
  5247. */
  5248. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5249. /**
  5250. * Creates a scaling matrix
  5251. * @param x defines the scale factor on X axis
  5252. * @param y defines the scale factor on Y axis
  5253. * @param z defines the scale factor on Z axis
  5254. * @returns the new matrix
  5255. */
  5256. static Scaling(x: number, y: number, z: number): Matrix;
  5257. /**
  5258. * Creates a scaling matrix and stores it in a given matrix
  5259. * @param x defines the scale factor on X axis
  5260. * @param y defines the scale factor on Y axis
  5261. * @param z defines the scale factor on Z axis
  5262. * @param result defines the target matrix
  5263. */
  5264. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5265. /**
  5266. * Creates a translation matrix
  5267. * @param x defines the translation on X axis
  5268. * @param y defines the translation on Y axis
  5269. * @param z defines the translationon Z axis
  5270. * @returns the new matrix
  5271. */
  5272. static Translation(x: number, y: number, z: number): Matrix;
  5273. /**
  5274. * Creates a translation matrix and stores it in a given matrix
  5275. * @param x defines the translation on X axis
  5276. * @param y defines the translation on Y axis
  5277. * @param z defines the translationon Z axis
  5278. * @param result defines the target matrix
  5279. */
  5280. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5281. /**
  5282. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5283. * @param startValue defines the start value
  5284. * @param endValue defines the end value
  5285. * @param gradient defines the gradient factor
  5286. * @returns the new matrix
  5287. */
  5288. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5289. /**
  5290. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5291. * @param startValue defines the start value
  5292. * @param endValue defines the end value
  5293. * @param gradient defines the gradient factor
  5294. * @param result defines the Matrix object where to store data
  5295. */
  5296. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5297. /**
  5298. * Builds a new matrix whose values are computed by:
  5299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5302. * @param startValue defines the first matrix
  5303. * @param endValue defines the second matrix
  5304. * @param gradient defines the gradient between the two matrices
  5305. * @returns the new matrix
  5306. */
  5307. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5308. /**
  5309. * Update a matrix to values which are computed by:
  5310. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5311. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5312. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5313. * @param startValue defines the first matrix
  5314. * @param endValue defines the second matrix
  5315. * @param gradient defines the gradient between the two matrices
  5316. * @param result defines the target matrix
  5317. */
  5318. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5319. /**
  5320. * 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"
  5321. * This function works in left handed mode
  5322. * @param eye defines the final position of the entity
  5323. * @param target defines where the entity should look at
  5324. * @param up defines the up vector for the entity
  5325. * @returns the new matrix
  5326. */
  5327. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5328. /**
  5329. * 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".
  5330. * This function works in left handed mode
  5331. * @param eye defines the final position of the entity
  5332. * @param target defines where the entity should look at
  5333. * @param up defines the up vector for the entity
  5334. * @param result defines the target matrix
  5335. */
  5336. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5337. /**
  5338. * 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"
  5339. * This function works in right handed mode
  5340. * @param eye defines the final position of the entity
  5341. * @param target defines where the entity should look at
  5342. * @param up defines the up vector for the entity
  5343. * @returns the new matrix
  5344. */
  5345. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5346. /**
  5347. * 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".
  5348. * This function works in right handed mode
  5349. * @param eye defines the final position of the entity
  5350. * @param target defines where the entity should look at
  5351. * @param up defines the up vector for the entity
  5352. * @param result defines the target matrix
  5353. */
  5354. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5355. /**
  5356. * Create a left-handed orthographic projection matrix
  5357. * @param width defines the viewport width
  5358. * @param height defines the viewport height
  5359. * @param znear defines the near clip plane
  5360. * @param zfar defines the far clip plane
  5361. * @returns a new matrix as a left-handed orthographic projection matrix
  5362. */
  5363. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5364. /**
  5365. * Store a left-handed orthographic projection to a given matrix
  5366. * @param width defines the viewport width
  5367. * @param height defines the viewport height
  5368. * @param znear defines the near clip plane
  5369. * @param zfar defines the far clip plane
  5370. * @param result defines the target matrix
  5371. */
  5372. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5373. /**
  5374. * Create a left-handed orthographic projection matrix
  5375. * @param left defines the viewport left coordinate
  5376. * @param right defines the viewport right coordinate
  5377. * @param bottom defines the viewport bottom coordinate
  5378. * @param top defines the viewport top coordinate
  5379. * @param znear defines the near clip plane
  5380. * @param zfar defines the far clip plane
  5381. * @returns a new matrix as a left-handed orthographic projection matrix
  5382. */
  5383. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5384. /**
  5385. * Stores a left-handed orthographic projection into a given matrix
  5386. * @param left defines the viewport left coordinate
  5387. * @param right defines the viewport right coordinate
  5388. * @param bottom defines the viewport bottom coordinate
  5389. * @param top defines the viewport top coordinate
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @param result defines the target matrix
  5393. */
  5394. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5395. /**
  5396. * Creates a right-handed orthographic projection matrix
  5397. * @param left defines the viewport left coordinate
  5398. * @param right defines the viewport right coordinate
  5399. * @param bottom defines the viewport bottom coordinate
  5400. * @param top defines the viewport top coordinate
  5401. * @param znear defines the near clip plane
  5402. * @param zfar defines the far clip plane
  5403. * @returns a new matrix as a right-handed orthographic projection matrix
  5404. */
  5405. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5406. /**
  5407. * Stores a right-handed orthographic projection into a given matrix
  5408. * @param left defines the viewport left coordinate
  5409. * @param right defines the viewport right coordinate
  5410. * @param bottom defines the viewport bottom coordinate
  5411. * @param top defines the viewport top coordinate
  5412. * @param znear defines the near clip plane
  5413. * @param zfar defines the far clip plane
  5414. * @param result defines the target matrix
  5415. */
  5416. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5417. /**
  5418. * Creates a left-handed perspective projection matrix
  5419. * @param width defines the viewport width
  5420. * @param height defines the viewport height
  5421. * @param znear defines the near clip plane
  5422. * @param zfar defines the far clip plane
  5423. * @returns a new matrix as a left-handed perspective projection matrix
  5424. */
  5425. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5426. /**
  5427. * Creates a left-handed perspective projection matrix
  5428. * @param fov defines the horizontal field of view
  5429. * @param aspect defines the aspect ratio
  5430. * @param znear defines the near clip plane
  5431. * @param zfar defines the far clip plane
  5432. * @returns a new matrix as a left-handed perspective projection matrix
  5433. */
  5434. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5435. /**
  5436. * Stores a left-handed perspective projection into a given matrix
  5437. * @param fov defines the horizontal field of view
  5438. * @param aspect defines the aspect ratio
  5439. * @param znear defines the near clip plane
  5440. * @param zfar defines the far clip plane
  5441. * @param result defines the target matrix
  5442. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5443. */
  5444. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5445. /**
  5446. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5447. * @param fov defines the horizontal field of view
  5448. * @param aspect defines the aspect ratio
  5449. * @param znear defines the near clip plane
  5450. * @param zfar not used as infinity is used as far clip
  5451. * @param result defines the target matrix
  5452. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5453. */
  5454. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5455. /**
  5456. * Creates a right-handed perspective projection matrix
  5457. * @param fov defines the horizontal field of view
  5458. * @param aspect defines the aspect ratio
  5459. * @param znear defines the near clip plane
  5460. * @param zfar defines the far clip plane
  5461. * @returns a new matrix as a right-handed perspective projection matrix
  5462. */
  5463. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5464. /**
  5465. * Stores a right-handed perspective projection into a given matrix
  5466. * @param fov defines the horizontal field of view
  5467. * @param aspect defines the aspect ratio
  5468. * @param znear defines the near clip plane
  5469. * @param zfar defines the far clip plane
  5470. * @param result defines the target matrix
  5471. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5472. */
  5473. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5474. /**
  5475. * Stores a right-handed perspective projection into a given matrix
  5476. * @param fov defines the horizontal field of view
  5477. * @param aspect defines the aspect ratio
  5478. * @param znear defines the near clip plane
  5479. * @param zfar not used as infinity is used as far clip
  5480. * @param result defines the target matrix
  5481. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5482. */
  5483. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5484. /**
  5485. * Stores a perspective projection for WebVR info a given matrix
  5486. * @param fov defines the field of view
  5487. * @param znear defines the near clip plane
  5488. * @param zfar defines the far clip plane
  5489. * @param result defines the target matrix
  5490. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5491. */
  5492. static PerspectiveFovWebVRToRef(fov: {
  5493. upDegrees: number;
  5494. downDegrees: number;
  5495. leftDegrees: number;
  5496. rightDegrees: number;
  5497. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5498. /**
  5499. * Computes a complete transformation matrix
  5500. * @param viewport defines the viewport to use
  5501. * @param world defines the world matrix
  5502. * @param view defines the view matrix
  5503. * @param projection defines the projection matrix
  5504. * @param zmin defines the near clip plane
  5505. * @param zmax defines the far clip plane
  5506. * @returns the transformation matrix
  5507. */
  5508. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5509. /**
  5510. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5511. * @param matrix defines the matrix to use
  5512. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5513. */
  5514. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5515. /**
  5516. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5517. * @param matrix defines the matrix to use
  5518. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5519. */
  5520. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5521. /**
  5522. * Compute the transpose of a given matrix
  5523. * @param matrix defines the matrix to transpose
  5524. * @returns the new matrix
  5525. */
  5526. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5527. /**
  5528. * Compute the transpose of a matrix and store it in a target matrix
  5529. * @param matrix defines the matrix to transpose
  5530. * @param result defines the target matrix
  5531. */
  5532. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5533. /**
  5534. * Computes a reflection matrix from a plane
  5535. * @param plane defines the reflection plane
  5536. * @returns a new matrix
  5537. */
  5538. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5539. /**
  5540. * Computes a reflection matrix from a plane
  5541. * @param plane defines the reflection plane
  5542. * @param result defines the target matrix
  5543. */
  5544. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5545. /**
  5546. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5547. * @param xaxis defines the value of the 1st axis
  5548. * @param yaxis defines the value of the 2nd axis
  5549. * @param zaxis defines the value of the 3rd axis
  5550. * @param result defines the target matrix
  5551. */
  5552. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5553. /**
  5554. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5555. * @param quat defines the quaternion to use
  5556. * @param result defines the target matrix
  5557. */
  5558. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5559. }
  5560. /**
  5561. * @hidden
  5562. */
  5563. export class TmpVectors {
  5564. static Vector2: Vector2[];
  5565. static Vector3: Vector3[];
  5566. static Vector4: Vector4[];
  5567. static Quaternion: Quaternion[];
  5568. static Matrix: Matrix[];
  5569. }
  5570. }
  5571. declare module "babylonjs/Maths/math.path" {
  5572. import { DeepImmutable, Nullable } from "babylonjs/types";
  5573. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5574. /**
  5575. * Defines potential orientation for back face culling
  5576. */
  5577. export enum Orientation {
  5578. /**
  5579. * Clockwise
  5580. */
  5581. CW = 0,
  5582. /** Counter clockwise */
  5583. CCW = 1
  5584. }
  5585. /** Class used to represent a Bezier curve */
  5586. export class BezierCurve {
  5587. /**
  5588. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5589. * @param t defines the time
  5590. * @param x1 defines the left coordinate on X axis
  5591. * @param y1 defines the left coordinate on Y axis
  5592. * @param x2 defines the right coordinate on X axis
  5593. * @param y2 defines the right coordinate on Y axis
  5594. * @returns the interpolated value
  5595. */
  5596. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5597. }
  5598. /**
  5599. * Defines angle representation
  5600. */
  5601. export class Angle {
  5602. private _radians;
  5603. /**
  5604. * Creates an Angle object of "radians" radians (float).
  5605. * @param radians the angle in radians
  5606. */
  5607. constructor(radians: number);
  5608. /**
  5609. * Get value in degrees
  5610. * @returns the Angle value in degrees (float)
  5611. */
  5612. degrees(): number;
  5613. /**
  5614. * Get value in radians
  5615. * @returns the Angle value in radians (float)
  5616. */
  5617. radians(): number;
  5618. /**
  5619. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5620. * @param a defines first point as the origin
  5621. * @param b defines point
  5622. * @returns a new Angle
  5623. */
  5624. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5625. /**
  5626. * Gets a new Angle object from the given float in radians
  5627. * @param radians defines the angle value in radians
  5628. * @returns a new Angle
  5629. */
  5630. static FromRadians(radians: number): Angle;
  5631. /**
  5632. * Gets a new Angle object from the given float in degrees
  5633. * @param degrees defines the angle value in degrees
  5634. * @returns a new Angle
  5635. */
  5636. static FromDegrees(degrees: number): Angle;
  5637. }
  5638. /**
  5639. * This represents an arc in a 2d space.
  5640. */
  5641. export class Arc2 {
  5642. /** Defines the start point of the arc */
  5643. startPoint: Vector2;
  5644. /** Defines the mid point of the arc */
  5645. midPoint: Vector2;
  5646. /** Defines the end point of the arc */
  5647. endPoint: Vector2;
  5648. /**
  5649. * Defines the center point of the arc.
  5650. */
  5651. centerPoint: Vector2;
  5652. /**
  5653. * Defines the radius of the arc.
  5654. */
  5655. radius: number;
  5656. /**
  5657. * Defines the angle of the arc (from mid point to end point).
  5658. */
  5659. angle: Angle;
  5660. /**
  5661. * Defines the start angle of the arc (from start point to middle point).
  5662. */
  5663. startAngle: Angle;
  5664. /**
  5665. * Defines the orientation of the arc (clock wise/counter clock wise).
  5666. */
  5667. orientation: Orientation;
  5668. /**
  5669. * Creates an Arc object from the three given points : start, middle and end.
  5670. * @param startPoint Defines the start point of the arc
  5671. * @param midPoint Defines the midlle point of the arc
  5672. * @param endPoint Defines the end point of the arc
  5673. */
  5674. constructor(
  5675. /** Defines the start point of the arc */
  5676. startPoint: Vector2,
  5677. /** Defines the mid point of the arc */
  5678. midPoint: Vector2,
  5679. /** Defines the end point of the arc */
  5680. endPoint: Vector2);
  5681. }
  5682. /**
  5683. * Represents a 2D path made up of multiple 2D points
  5684. */
  5685. export class Path2 {
  5686. private _points;
  5687. private _length;
  5688. /**
  5689. * If the path start and end point are the same
  5690. */
  5691. closed: boolean;
  5692. /**
  5693. * Creates a Path2 object from the starting 2D coordinates x and y.
  5694. * @param x the starting points x value
  5695. * @param y the starting points y value
  5696. */
  5697. constructor(x: number, y: number);
  5698. /**
  5699. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5700. * @param x the added points x value
  5701. * @param y the added points y value
  5702. * @returns the updated Path2.
  5703. */
  5704. addLineTo(x: number, y: number): Path2;
  5705. /**
  5706. * 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.
  5707. * @param midX middle point x value
  5708. * @param midY middle point y value
  5709. * @param endX end point x value
  5710. * @param endY end point y value
  5711. * @param numberOfSegments (default: 36)
  5712. * @returns the updated Path2.
  5713. */
  5714. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5715. /**
  5716. * Closes the Path2.
  5717. * @returns the Path2.
  5718. */
  5719. close(): Path2;
  5720. /**
  5721. * Gets the sum of the distance between each sequential point in the path
  5722. * @returns the Path2 total length (float).
  5723. */
  5724. length(): number;
  5725. /**
  5726. * Gets the points which construct the path
  5727. * @returns the Path2 internal array of points.
  5728. */
  5729. getPoints(): Vector2[];
  5730. /**
  5731. * Retreives the point at the distance aways from the starting point
  5732. * @param normalizedLengthPosition the length along the path to retreive the point from
  5733. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5734. */
  5735. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5736. /**
  5737. * Creates a new path starting from an x and y position
  5738. * @param x starting x value
  5739. * @param y starting y value
  5740. * @returns a new Path2 starting at the coordinates (x, y).
  5741. */
  5742. static StartingAt(x: number, y: number): Path2;
  5743. }
  5744. /**
  5745. * Represents a 3D path made up of multiple 3D points
  5746. */
  5747. export class Path3D {
  5748. /**
  5749. * an array of Vector3, the curve axis of the Path3D
  5750. */
  5751. path: Vector3[];
  5752. private _curve;
  5753. private _distances;
  5754. private _tangents;
  5755. private _normals;
  5756. private _binormals;
  5757. private _raw;
  5758. private _alignTangentsWithPath;
  5759. private readonly _pointAtData;
  5760. /**
  5761. * new Path3D(path, normal, raw)
  5762. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5763. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5764. * @param path an array of Vector3, the curve axis of the Path3D
  5765. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5766. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5767. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5768. */
  5769. constructor(
  5770. /**
  5771. * an array of Vector3, the curve axis of the Path3D
  5772. */
  5773. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5774. /**
  5775. * Returns the Path3D array of successive Vector3 designing its curve.
  5776. * @returns the Path3D array of successive Vector3 designing its curve.
  5777. */
  5778. getCurve(): Vector3[];
  5779. /**
  5780. * Returns the Path3D array of successive Vector3 designing its curve.
  5781. * @returns the Path3D array of successive Vector3 designing its curve.
  5782. */
  5783. getPoints(): Vector3[];
  5784. /**
  5785. * @returns the computed length (float) of the path.
  5786. */
  5787. length(): number;
  5788. /**
  5789. * Returns an array populated with tangent vectors on each Path3D curve point.
  5790. * @returns an array populated with tangent vectors on each Path3D curve point.
  5791. */
  5792. getTangents(): Vector3[];
  5793. /**
  5794. * Returns an array populated with normal vectors on each Path3D curve point.
  5795. * @returns an array populated with normal vectors on each Path3D curve point.
  5796. */
  5797. getNormals(): Vector3[];
  5798. /**
  5799. * Returns an array populated with binormal vectors on each Path3D curve point.
  5800. * @returns an array populated with binormal vectors on each Path3D curve point.
  5801. */
  5802. getBinormals(): Vector3[];
  5803. /**
  5804. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5805. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5806. */
  5807. getDistances(): number[];
  5808. /**
  5809. * Returns an interpolated point along this path
  5810. * @param position the position of the point along this path, from 0.0 to 1.0
  5811. * @returns a new Vector3 as the point
  5812. */
  5813. getPointAt(position: number): Vector3;
  5814. /**
  5815. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5816. * @param position the position of the point along this path, from 0.0 to 1.0
  5817. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5818. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5819. */
  5820. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5821. /**
  5822. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5823. * @param position the position of the point along this path, from 0.0 to 1.0
  5824. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5825. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5826. */
  5827. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5828. /**
  5829. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5830. * @param position the position of the point along this path, from 0.0 to 1.0
  5831. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5832. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5833. */
  5834. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5835. /**
  5836. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5837. * @param position the position of the point along this path, from 0.0 to 1.0
  5838. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5839. */
  5840. getDistanceAt(position: number): number;
  5841. /**
  5842. * Returns the array index of the previous point of an interpolated point along this path
  5843. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5844. * @returns the array index
  5845. */
  5846. getPreviousPointIndexAt(position: number): number;
  5847. /**
  5848. * 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)
  5849. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5850. * @returns the sub position
  5851. */
  5852. getSubPositionAt(position: number): number;
  5853. /**
  5854. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5855. * @param target the vector of which to get the closest position to
  5856. * @returns the position of the closest virtual point on this path to the target vector
  5857. */
  5858. getClosestPositionTo(target: Vector3): number;
  5859. /**
  5860. * Returns a sub path (slice) of this path
  5861. * @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
  5862. * @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
  5863. * @returns a sub path (slice) of this path
  5864. */
  5865. slice(start?: number, end?: number): Path3D;
  5866. /**
  5867. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5868. * @param path path which all values are copied into the curves points
  5869. * @param firstNormal which should be projected onto the curve
  5870. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5871. * @returns the same object updated.
  5872. */
  5873. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5874. private _compute;
  5875. private _getFirstNonNullVector;
  5876. private _getLastNonNullVector;
  5877. private _normalVector;
  5878. /**
  5879. * Updates the point at data for an interpolated point along this curve
  5880. * @param position the position of the point along this curve, from 0.0 to 1.0
  5881. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5882. * @returns the (updated) point at data
  5883. */
  5884. private _updatePointAtData;
  5885. /**
  5886. * Updates the point at data from the specified parameters
  5887. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5888. * @param point the interpolated point
  5889. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5890. */
  5891. private _setPointAtData;
  5892. /**
  5893. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5894. */
  5895. private _updateInterpolationMatrix;
  5896. }
  5897. /**
  5898. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5899. * A Curve3 is designed from a series of successive Vector3.
  5900. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5901. */
  5902. export class Curve3 {
  5903. private _points;
  5904. private _length;
  5905. /**
  5906. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5907. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5908. * @param v1 (Vector3) the control point
  5909. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5910. * @param nbPoints (integer) the wanted number of points in the curve
  5911. * @returns the created Curve3
  5912. */
  5913. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5914. /**
  5915. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5916. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5917. * @param v1 (Vector3) the first control point
  5918. * @param v2 (Vector3) the second control point
  5919. * @param v3 (Vector3) the end point of the Cubic Bezier
  5920. * @param nbPoints (integer) the wanted number of points in the curve
  5921. * @returns the created Curve3
  5922. */
  5923. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5924. /**
  5925. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5926. * @param p1 (Vector3) the origin point of the Hermite Spline
  5927. * @param t1 (Vector3) the tangent vector at the origin point
  5928. * @param p2 (Vector3) the end point of the Hermite Spline
  5929. * @param t2 (Vector3) the tangent vector at the end point
  5930. * @param nbPoints (integer) the wanted number of points in the curve
  5931. * @returns the created Curve3
  5932. */
  5933. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5934. /**
  5935. * Returns a Curve3 object along a CatmullRom Spline curve :
  5936. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5937. * @param nbPoints (integer) the wanted number of points between each curve control points
  5938. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5939. * @returns the created Curve3
  5940. */
  5941. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5942. /**
  5943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5944. * A Curve3 is designed from a series of successive Vector3.
  5945. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5946. * @param points points which make up the curve
  5947. */
  5948. constructor(points: Vector3[]);
  5949. /**
  5950. * @returns the Curve3 stored array of successive Vector3
  5951. */
  5952. getPoints(): Vector3[];
  5953. /**
  5954. * @returns the computed length (float) of the curve.
  5955. */
  5956. length(): number;
  5957. /**
  5958. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5959. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5960. * curveA and curveB keep unchanged.
  5961. * @param curve the curve to continue from this curve
  5962. * @returns the newly constructed curve
  5963. */
  5964. continue(curve: DeepImmutable<Curve3>): Curve3;
  5965. private _computeLength;
  5966. }
  5967. }
  5968. declare module "babylonjs/Animations/easing" {
  5969. /**
  5970. * This represents the main contract an easing function should follow.
  5971. * Easing functions are used throughout the animation system.
  5972. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5973. */
  5974. export interface IEasingFunction {
  5975. /**
  5976. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5977. * of the easing function.
  5978. * The link below provides some of the most common examples of easing functions.
  5979. * @see https://easings.net/
  5980. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5981. * @returns the corresponding value on the curve defined by the easing function
  5982. */
  5983. ease(gradient: number): number;
  5984. }
  5985. /**
  5986. * Base class used for every default easing function.
  5987. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5988. */
  5989. export class EasingFunction implements IEasingFunction {
  5990. /**
  5991. * Interpolation follows the mathematical formula associated with the easing function.
  5992. */
  5993. static readonly EASINGMODE_EASEIN: number;
  5994. /**
  5995. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5996. */
  5997. static readonly EASINGMODE_EASEOUT: number;
  5998. /**
  5999. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6000. */
  6001. static readonly EASINGMODE_EASEINOUT: number;
  6002. private _easingMode;
  6003. /**
  6004. * Sets the easing mode of the current function.
  6005. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6006. */
  6007. setEasingMode(easingMode: number): void;
  6008. /**
  6009. * Gets the current easing mode.
  6010. * @returns the easing mode
  6011. */
  6012. getEasingMode(): number;
  6013. /**
  6014. * @hidden
  6015. */
  6016. easeInCore(gradient: number): number;
  6017. /**
  6018. * Given an input gradient between 0 and 1, this returns the corresponding value
  6019. * of the easing function.
  6020. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6021. * @returns the corresponding value on the curve defined by the easing function
  6022. */
  6023. ease(gradient: number): number;
  6024. }
  6025. /**
  6026. * Easing function with a circle shape (see link below).
  6027. * @see https://easings.net/#easeInCirc
  6028. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6029. */
  6030. export class CircleEase extends EasingFunction implements IEasingFunction {
  6031. /** @hidden */
  6032. easeInCore(gradient: number): number;
  6033. }
  6034. /**
  6035. * Easing function with a ease back shape (see link below).
  6036. * @see https://easings.net/#easeInBack
  6037. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6038. */
  6039. export class BackEase extends EasingFunction implements IEasingFunction {
  6040. /** Defines the amplitude of the function */
  6041. amplitude: number;
  6042. /**
  6043. * Instantiates a back ease easing
  6044. * @see https://easings.net/#easeInBack
  6045. * @param amplitude Defines the amplitude of the function
  6046. */
  6047. constructor(
  6048. /** Defines the amplitude of the function */
  6049. amplitude?: number);
  6050. /** @hidden */
  6051. easeInCore(gradient: number): number;
  6052. }
  6053. /**
  6054. * Easing function with a bouncing shape (see link below).
  6055. * @see https://easings.net/#easeInBounce
  6056. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6057. */
  6058. export class BounceEase extends EasingFunction implements IEasingFunction {
  6059. /** Defines the number of bounces */
  6060. bounces: number;
  6061. /** Defines the amplitude of the bounce */
  6062. bounciness: number;
  6063. /**
  6064. * Instantiates a bounce easing
  6065. * @see https://easings.net/#easeInBounce
  6066. * @param bounces Defines the number of bounces
  6067. * @param bounciness Defines the amplitude of the bounce
  6068. */
  6069. constructor(
  6070. /** Defines the number of bounces */
  6071. bounces?: number,
  6072. /** Defines the amplitude of the bounce */
  6073. bounciness?: number);
  6074. /** @hidden */
  6075. easeInCore(gradient: number): number;
  6076. }
  6077. /**
  6078. * Easing function with a power of 3 shape (see link below).
  6079. * @see https://easings.net/#easeInCubic
  6080. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6081. */
  6082. export class CubicEase extends EasingFunction implements IEasingFunction {
  6083. /** @hidden */
  6084. easeInCore(gradient: number): number;
  6085. }
  6086. /**
  6087. * Easing function with an elastic shape (see link below).
  6088. * @see https://easings.net/#easeInElastic
  6089. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6090. */
  6091. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6092. /** Defines the number of oscillations*/
  6093. oscillations: number;
  6094. /** Defines the amplitude of the oscillations*/
  6095. springiness: number;
  6096. /**
  6097. * Instantiates an elastic easing function
  6098. * @see https://easings.net/#easeInElastic
  6099. * @param oscillations Defines the number of oscillations
  6100. * @param springiness Defines the amplitude of the oscillations
  6101. */
  6102. constructor(
  6103. /** Defines the number of oscillations*/
  6104. oscillations?: number,
  6105. /** Defines the amplitude of the oscillations*/
  6106. springiness?: number);
  6107. /** @hidden */
  6108. easeInCore(gradient: number): number;
  6109. }
  6110. /**
  6111. * Easing function with an exponential shape (see link below).
  6112. * @see https://easings.net/#easeInExpo
  6113. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6114. */
  6115. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6116. /** Defines the exponent of the function */
  6117. exponent: number;
  6118. /**
  6119. * Instantiates an exponential easing function
  6120. * @see https://easings.net/#easeInExpo
  6121. * @param exponent Defines the exponent of the function
  6122. */
  6123. constructor(
  6124. /** Defines the exponent of the function */
  6125. exponent?: number);
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power shape (see link below).
  6131. * @see https://easings.net/#easeInQuad
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class PowerEase extends EasingFunction implements IEasingFunction {
  6135. /** Defines the power of the function */
  6136. power: number;
  6137. /**
  6138. * Instantiates an power base easing function
  6139. * @see https://easings.net/#easeInQuad
  6140. * @param power Defines the power of the function
  6141. */
  6142. constructor(
  6143. /** Defines the power of the function */
  6144. power?: number);
  6145. /** @hidden */
  6146. easeInCore(gradient: number): number;
  6147. }
  6148. /**
  6149. * Easing function with a power of 2 shape (see link below).
  6150. * @see https://easings.net/#easeInQuad
  6151. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6152. */
  6153. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6154. /** @hidden */
  6155. easeInCore(gradient: number): number;
  6156. }
  6157. /**
  6158. * Easing function with a power of 4 shape (see link below).
  6159. * @see https://easings.net/#easeInQuart
  6160. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6161. */
  6162. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6163. /** @hidden */
  6164. easeInCore(gradient: number): number;
  6165. }
  6166. /**
  6167. * Easing function with a power of 5 shape (see link below).
  6168. * @see https://easings.net/#easeInQuint
  6169. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6170. */
  6171. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a sin shape (see link below).
  6177. * @see https://easings.net/#easeInSine
  6178. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class SineEase extends EasingFunction implements IEasingFunction {
  6181. /** @hidden */
  6182. easeInCore(gradient: number): number;
  6183. }
  6184. /**
  6185. * Easing function with a bezier shape (see link below).
  6186. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6187. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6188. */
  6189. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6190. /** Defines the x component of the start tangent in the bezier curve */
  6191. x1: number;
  6192. /** Defines the y component of the start tangent in the bezier curve */
  6193. y1: number;
  6194. /** Defines the x component of the end tangent in the bezier curve */
  6195. x2: number;
  6196. /** Defines the y component of the end tangent in the bezier curve */
  6197. y2: number;
  6198. /**
  6199. * Instantiates a bezier function
  6200. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6201. * @param x1 Defines the x component of the start tangent in the bezier curve
  6202. * @param y1 Defines the y component of the start tangent in the bezier curve
  6203. * @param x2 Defines the x component of the end tangent in the bezier curve
  6204. * @param y2 Defines the y component of the end tangent in the bezier curve
  6205. */
  6206. constructor(
  6207. /** Defines the x component of the start tangent in the bezier curve */
  6208. x1?: number,
  6209. /** Defines the y component of the start tangent in the bezier curve */
  6210. y1?: number,
  6211. /** Defines the x component of the end tangent in the bezier curve */
  6212. x2?: number,
  6213. /** Defines the y component of the end tangent in the bezier curve */
  6214. y2?: number);
  6215. /** @hidden */
  6216. easeInCore(gradient: number): number;
  6217. }
  6218. }
  6219. declare module "babylonjs/Maths/math.color" {
  6220. import { DeepImmutable, FloatArray } from "babylonjs/types";
  6221. /**
  6222. * Class used to hold a RGB color
  6223. */
  6224. export class Color3 {
  6225. /**
  6226. * Defines the red component (between 0 and 1, default is 0)
  6227. */
  6228. r: number;
  6229. /**
  6230. * Defines the green component (between 0 and 1, default is 0)
  6231. */
  6232. g: number;
  6233. /**
  6234. * Defines the blue component (between 0 and 1, default is 0)
  6235. */
  6236. b: number;
  6237. /**
  6238. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6239. * @param r defines the red component (between 0 and 1, default is 0)
  6240. * @param g defines the green component (between 0 and 1, default is 0)
  6241. * @param b defines the blue component (between 0 and 1, default is 0)
  6242. */
  6243. constructor(
  6244. /**
  6245. * Defines the red component (between 0 and 1, default is 0)
  6246. */
  6247. r?: number,
  6248. /**
  6249. * Defines the green component (between 0 and 1, default is 0)
  6250. */
  6251. g?: number,
  6252. /**
  6253. * Defines the blue component (between 0 and 1, default is 0)
  6254. */
  6255. b?: number);
  6256. /**
  6257. * Creates a string with the Color3 current values
  6258. * @returns the string representation of the Color3 object
  6259. */
  6260. toString(): string;
  6261. /**
  6262. * Returns the string "Color3"
  6263. * @returns "Color3"
  6264. */
  6265. getClassName(): string;
  6266. /**
  6267. * Compute the Color3 hash code
  6268. * @returns an unique number that can be used to hash Color3 objects
  6269. */
  6270. getHashCode(): number;
  6271. /**
  6272. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6273. * @param array defines the array where to store the r,g,b components
  6274. * @param index defines an optional index in the target array to define where to start storing values
  6275. * @returns the current Color3 object
  6276. */
  6277. toArray(array: FloatArray, index?: number): Color3;
  6278. /**
  6279. * Update the current color with values stored in an array from the starting index of the given array
  6280. * @param array defines the source array
  6281. * @param offset defines an offset in the source array
  6282. * @returns the current Color3 object
  6283. */
  6284. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6285. /**
  6286. * Returns a new Color4 object from the current Color3 and the given alpha
  6287. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6288. * @returns a new Color4 object
  6289. */
  6290. toColor4(alpha?: number): Color4;
  6291. /**
  6292. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6293. * @returns the new array
  6294. */
  6295. asArray(): number[];
  6296. /**
  6297. * Returns the luminance value
  6298. * @returns a float value
  6299. */
  6300. toLuminance(): number;
  6301. /**
  6302. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6303. * @param otherColor defines the second operand
  6304. * @returns the new Color3 object
  6305. */
  6306. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6307. /**
  6308. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6309. * @param otherColor defines the second operand
  6310. * @param result defines the Color3 object where to store the result
  6311. * @returns the current Color3
  6312. */
  6313. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6314. /**
  6315. * Determines equality between Color3 objects
  6316. * @param otherColor defines the second operand
  6317. * @returns true if the rgb values are equal to the given ones
  6318. */
  6319. equals(otherColor: DeepImmutable<Color3>): boolean;
  6320. /**
  6321. * Determines equality between the current Color3 object and a set of r,b,g values
  6322. * @param r defines the red component to check
  6323. * @param g defines the green component to check
  6324. * @param b defines the blue component to check
  6325. * @returns true if the rgb values are equal to the given ones
  6326. */
  6327. equalsFloats(r: number, g: number, b: number): boolean;
  6328. /**
  6329. * Multiplies in place each rgb value by scale
  6330. * @param scale defines the scaling factor
  6331. * @returns the updated Color3
  6332. */
  6333. scale(scale: number): Color3;
  6334. /**
  6335. * Multiplies the rgb values by scale and stores the result into "result"
  6336. * @param scale defines the scaling factor
  6337. * @param result defines the Color3 object where to store the result
  6338. * @returns the unmodified current Color3
  6339. */
  6340. scaleToRef(scale: number, result: Color3): Color3;
  6341. /**
  6342. * Scale the current Color3 values by a factor and add the result to a given Color3
  6343. * @param scale defines the scale factor
  6344. * @param result defines color to store the result into
  6345. * @returns the unmodified current Color3
  6346. */
  6347. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6348. /**
  6349. * Clamps the rgb values by the min and max values and stores the result into "result"
  6350. * @param min defines minimum clamping value (default is 0)
  6351. * @param max defines maximum clamping value (default is 1)
  6352. * @param result defines color to store the result into
  6353. * @returns the original Color3
  6354. */
  6355. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6356. /**
  6357. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6358. * @param otherColor defines the second operand
  6359. * @returns the new Color3
  6360. */
  6361. add(otherColor: DeepImmutable<Color3>): Color3;
  6362. /**
  6363. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6364. * @param otherColor defines the second operand
  6365. * @param result defines Color3 object to store the result into
  6366. * @returns the unmodified current Color3
  6367. */
  6368. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6369. /**
  6370. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6371. * @param otherColor defines the second operand
  6372. * @returns the new Color3
  6373. */
  6374. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6375. /**
  6376. * Stores the result of the subtraction of given one from the current Color3 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. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6382. /**
  6383. * Copy the current object
  6384. * @returns a new Color3 copied the current one
  6385. */
  6386. clone(): Color3;
  6387. /**
  6388. * Copies the rgb values from the source in the current Color3
  6389. * @param source defines the source Color3 object
  6390. * @returns the updated Color3 object
  6391. */
  6392. copyFrom(source: DeepImmutable<Color3>): Color3;
  6393. /**
  6394. * Updates the Color3 rgb values from the given floats
  6395. * @param r defines the red component to read from
  6396. * @param g defines the green component to read from
  6397. * @param b defines the blue component to read from
  6398. * @returns the current Color3 object
  6399. */
  6400. copyFromFloats(r: number, g: number, b: number): Color3;
  6401. /**
  6402. * Updates the Color3 rgb values from the given floats
  6403. * @param r defines the red component to read from
  6404. * @param g defines the green component to read from
  6405. * @param b defines the blue component to read from
  6406. * @returns the current Color3 object
  6407. */
  6408. set(r: number, g: number, b: number): Color3;
  6409. /**
  6410. * Compute the Color3 hexadecimal code as a string
  6411. * @returns a string containing the hexadecimal representation of the Color3 object
  6412. */
  6413. toHexString(): string;
  6414. /**
  6415. * Computes a new Color3 converted from the current one to linear space
  6416. * @returns a new Color3 object
  6417. */
  6418. toLinearSpace(): Color3;
  6419. /**
  6420. * Converts current color in rgb space to HSV values
  6421. * @returns a new color3 representing the HSV values
  6422. */
  6423. toHSV(): Color3;
  6424. /**
  6425. * Converts current color in rgb space to HSV values
  6426. * @param result defines the Color3 where to store the HSV values
  6427. */
  6428. toHSVToRef(result: Color3): void;
  6429. /**
  6430. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6431. * @param convertedColor defines the Color3 object where to store the linear space version
  6432. * @returns the unmodified Color3
  6433. */
  6434. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6435. /**
  6436. * Computes a new Color3 converted from the current one to gamma space
  6437. * @returns a new Color3 object
  6438. */
  6439. toGammaSpace(): Color3;
  6440. /**
  6441. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6442. * @param convertedColor defines the Color3 object where to store the gamma space version
  6443. * @returns the unmodified Color3
  6444. */
  6445. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6446. private static _BlackReadOnly;
  6447. /**
  6448. * Convert Hue, saturation and value to a Color3 (RGB)
  6449. * @param hue defines the hue
  6450. * @param saturation defines the saturation
  6451. * @param value defines the value
  6452. * @param result defines the Color3 where to store the RGB values
  6453. */
  6454. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6455. /**
  6456. * Creates a new Color3 from the string containing valid hexadecimal values
  6457. * @param hex defines a string containing valid hexadecimal values
  6458. * @returns a new Color3 object
  6459. */
  6460. static FromHexString(hex: string): Color3;
  6461. /**
  6462. * Creates a new Color3 from the starting index of the given array
  6463. * @param array defines the source array
  6464. * @param offset defines an offset in the source array
  6465. * @returns a new Color3 object
  6466. */
  6467. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6468. /**
  6469. * Creates a new Color3 from the starting index element of the given array
  6470. * @param array defines the source array to read from
  6471. * @param offset defines the offset in the source array
  6472. * @param result defines the target Color3 object
  6473. */
  6474. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6475. /**
  6476. * Creates a new Color3 from integer values (< 256)
  6477. * @param r defines the red component to read from (value between 0 and 255)
  6478. * @param g defines the green component to read from (value between 0 and 255)
  6479. * @param b defines the blue component to read from (value between 0 and 255)
  6480. * @returns a new Color3 object
  6481. */
  6482. static FromInts(r: number, g: number, b: number): Color3;
  6483. /**
  6484. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6485. * @param start defines the start Color3 value
  6486. * @param end defines the end Color3 value
  6487. * @param amount defines the gradient value between start and end
  6488. * @returns a new Color3 object
  6489. */
  6490. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6491. /**
  6492. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6493. * @param left defines the start value
  6494. * @param right defines the end value
  6495. * @param amount defines the gradient factor
  6496. * @param result defines the Color3 object where to store the result
  6497. */
  6498. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6499. /**
  6500. * Returns a Color3 value containing a red color
  6501. * @returns a new Color3 object
  6502. */
  6503. static Red(): Color3;
  6504. /**
  6505. * Returns a Color3 value containing a green color
  6506. * @returns a new Color3 object
  6507. */
  6508. static Green(): Color3;
  6509. /**
  6510. * Returns a Color3 value containing a blue color
  6511. * @returns a new Color3 object
  6512. */
  6513. static Blue(): Color3;
  6514. /**
  6515. * Returns a Color3 value containing a black color
  6516. * @returns a new Color3 object
  6517. */
  6518. static Black(): Color3;
  6519. /**
  6520. * Gets a Color3 value containing a black color that must not be updated
  6521. */
  6522. static get BlackReadOnly(): DeepImmutable<Color3>;
  6523. /**
  6524. * Returns a Color3 value containing a white color
  6525. * @returns a new Color3 object
  6526. */
  6527. static White(): Color3;
  6528. /**
  6529. * Returns a Color3 value containing a purple color
  6530. * @returns a new Color3 object
  6531. */
  6532. static Purple(): Color3;
  6533. /**
  6534. * Returns a Color3 value containing a magenta color
  6535. * @returns a new Color3 object
  6536. */
  6537. static Magenta(): Color3;
  6538. /**
  6539. * Returns a Color3 value containing a yellow color
  6540. * @returns a new Color3 object
  6541. */
  6542. static Yellow(): Color3;
  6543. /**
  6544. * Returns a Color3 value containing a gray color
  6545. * @returns a new Color3 object
  6546. */
  6547. static Gray(): Color3;
  6548. /**
  6549. * Returns a Color3 value containing a teal color
  6550. * @returns a new Color3 object
  6551. */
  6552. static Teal(): Color3;
  6553. /**
  6554. * Returns a Color3 value containing a random color
  6555. * @returns a new Color3 object
  6556. */
  6557. static Random(): Color3;
  6558. }
  6559. /**
  6560. * Class used to hold a RBGA color
  6561. */
  6562. export class Color4 {
  6563. /**
  6564. * Defines the red component (between 0 and 1, default is 0)
  6565. */
  6566. r: number;
  6567. /**
  6568. * Defines the green component (between 0 and 1, default is 0)
  6569. */
  6570. g: number;
  6571. /**
  6572. * Defines the blue component (between 0 and 1, default is 0)
  6573. */
  6574. b: number;
  6575. /**
  6576. * Defines the alpha component (between 0 and 1, default is 1)
  6577. */
  6578. a: number;
  6579. /**
  6580. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6581. * @param r defines the red component (between 0 and 1, default is 0)
  6582. * @param g defines the green component (between 0 and 1, default is 0)
  6583. * @param b defines the blue component (between 0 and 1, default is 0)
  6584. * @param a defines the alpha component (between 0 and 1, default is 1)
  6585. */
  6586. constructor(
  6587. /**
  6588. * Defines the red component (between 0 and 1, default is 0)
  6589. */
  6590. r?: number,
  6591. /**
  6592. * Defines the green component (between 0 and 1, default is 0)
  6593. */
  6594. g?: number,
  6595. /**
  6596. * Defines the blue component (between 0 and 1, default is 0)
  6597. */
  6598. b?: number,
  6599. /**
  6600. * Defines the alpha component (between 0 and 1, default is 1)
  6601. */
  6602. a?: number);
  6603. /**
  6604. * Adds in place the given Color4 values to the current Color4 object
  6605. * @param right defines the second operand
  6606. * @returns the current updated Color4 object
  6607. */
  6608. addInPlace(right: DeepImmutable<Color4>): Color4;
  6609. /**
  6610. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6611. * @returns the new array
  6612. */
  6613. asArray(): number[];
  6614. /**
  6615. * Stores from the starting index in the given array the Color4 successive values
  6616. * @param array defines the array where to store the r,g,b components
  6617. * @param index defines an optional index in the target array to define where to start storing values
  6618. * @returns the current Color4 object
  6619. */
  6620. toArray(array: number[], index?: number): Color4;
  6621. /**
  6622. * Update the current color with values stored in an array from the starting index of the given array
  6623. * @param array defines the source array
  6624. * @param offset defines an offset in the source array
  6625. * @returns the current Color4 object
  6626. */
  6627. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6628. /**
  6629. * Determines equality between Color4 objects
  6630. * @param otherColor defines the second operand
  6631. * @returns true if the rgba values are equal to the given ones
  6632. */
  6633. equals(otherColor: DeepImmutable<Color4>): boolean;
  6634. /**
  6635. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6636. * @param right defines the second operand
  6637. * @returns a new Color4 object
  6638. */
  6639. add(right: DeepImmutable<Color4>): Color4;
  6640. /**
  6641. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6642. * @param right defines the second operand
  6643. * @returns a new Color4 object
  6644. */
  6645. subtract(right: DeepImmutable<Color4>): Color4;
  6646. /**
  6647. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6648. * @param right defines the second operand
  6649. * @param result defines the Color4 object where to store the result
  6650. * @returns the current Color4 object
  6651. */
  6652. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6653. /**
  6654. * Creates a new Color4 with the current Color4 values multiplied by scale
  6655. * @param scale defines the scaling factor to apply
  6656. * @returns a new Color4 object
  6657. */
  6658. scale(scale: number): Color4;
  6659. /**
  6660. * Multiplies the current Color4 values by scale and stores the result in "result"
  6661. * @param scale defines the scaling factor to apply
  6662. * @param result defines the Color4 object where to store the result
  6663. * @returns the current unmodified Color4
  6664. */
  6665. scaleToRef(scale: number, result: Color4): Color4;
  6666. /**
  6667. * Scale the current Color4 values by a factor and add the result to a given Color4
  6668. * @param scale defines the scale factor
  6669. * @param result defines the Color4 object where to store the result
  6670. * @returns the unmodified current Color4
  6671. */
  6672. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6673. /**
  6674. * Clamps the rgb values by the min and max values and stores the result into "result"
  6675. * @param min defines minimum clamping value (default is 0)
  6676. * @param max defines maximum clamping value (default is 1)
  6677. * @param result defines color to store the result into.
  6678. * @returns the cuurent Color4
  6679. */
  6680. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6681. /**
  6682. * Multipy an Color4 value by another and return a new Color4 object
  6683. * @param color defines the Color4 value to multiply by
  6684. * @returns a new Color4 object
  6685. */
  6686. multiply(color: Color4): Color4;
  6687. /**
  6688. * Multipy a Color4 value by another and push the result in a reference value
  6689. * @param color defines the Color4 value to multiply by
  6690. * @param result defines the Color4 to fill the result in
  6691. * @returns the result Color4
  6692. */
  6693. multiplyToRef(color: Color4, result: Color4): Color4;
  6694. /**
  6695. * Creates a string with the Color4 current values
  6696. * @returns the string representation of the Color4 object
  6697. */
  6698. toString(): string;
  6699. /**
  6700. * Returns the string "Color4"
  6701. * @returns "Color4"
  6702. */
  6703. getClassName(): string;
  6704. /**
  6705. * Compute the Color4 hash code
  6706. * @returns an unique number that can be used to hash Color4 objects
  6707. */
  6708. getHashCode(): number;
  6709. /**
  6710. * Creates a new Color4 copied from the current one
  6711. * @returns a new Color4 object
  6712. */
  6713. clone(): Color4;
  6714. /**
  6715. * Copies the given Color4 values into the current one
  6716. * @param source defines the source Color4 object
  6717. * @returns the current updated Color4 object
  6718. */
  6719. copyFrom(source: Color4): Color4;
  6720. /**
  6721. * Copies the given float values into the current one
  6722. * @param r defines the red component to read from
  6723. * @param g defines the green component to read from
  6724. * @param b defines the blue component to read from
  6725. * @param a defines the alpha component to read from
  6726. * @returns the current updated Color4 object
  6727. */
  6728. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6729. /**
  6730. * Copies the given float values into the current one
  6731. * @param r defines the red component to read from
  6732. * @param g defines the green component to read from
  6733. * @param b defines the blue component to read from
  6734. * @param a defines the alpha component to read from
  6735. * @returns the current updated Color4 object
  6736. */
  6737. set(r: number, g: number, b: number, a: number): Color4;
  6738. /**
  6739. * Compute the Color4 hexadecimal code as a string
  6740. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6741. * @returns a string containing the hexadecimal representation of the Color4 object
  6742. */
  6743. toHexString(returnAsColor3?: boolean): string;
  6744. /**
  6745. * Computes a new Color4 converted from the current one to linear space
  6746. * @returns a new Color4 object
  6747. */
  6748. toLinearSpace(): Color4;
  6749. /**
  6750. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6751. * @param convertedColor defines the Color4 object where to store the linear space version
  6752. * @returns the unmodified Color4
  6753. */
  6754. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6755. /**
  6756. * Computes a new Color4 converted from the current one to gamma space
  6757. * @returns a new Color4 object
  6758. */
  6759. toGammaSpace(): Color4;
  6760. /**
  6761. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6762. * @param convertedColor defines the Color4 object where to store the gamma space version
  6763. * @returns the unmodified Color4
  6764. */
  6765. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6766. /**
  6767. * Creates a new Color4 from the string containing valid hexadecimal values
  6768. * @param hex defines a string containing valid hexadecimal values
  6769. * @returns a new Color4 object
  6770. */
  6771. static FromHexString(hex: string): Color4;
  6772. /**
  6773. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6774. * @param left defines the start value
  6775. * @param right defines the end value
  6776. * @param amount defines the gradient factor
  6777. * @returns a new Color4 object
  6778. */
  6779. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6780. /**
  6781. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6782. * @param left defines the start value
  6783. * @param right defines the end value
  6784. * @param amount defines the gradient factor
  6785. * @param result defines the Color4 object where to store data
  6786. */
  6787. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6788. /**
  6789. * Creates a new Color4 from a Color3 and an alpha value
  6790. * @param color3 defines the source Color3 to read from
  6791. * @param alpha defines the alpha component (1.0 by default)
  6792. * @returns a new Color4 object
  6793. */
  6794. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6795. /**
  6796. * Creates a new Color4 from the starting index element of the given array
  6797. * @param array defines the source array to read from
  6798. * @param offset defines the offset in the source array
  6799. * @returns a new Color4 object
  6800. */
  6801. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6802. /**
  6803. * Creates a new Color4 from the starting index element of the given array
  6804. * @param array defines the source array to read from
  6805. * @param offset defines the offset in the source array
  6806. * @param result defines the target Color4 object
  6807. */
  6808. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6809. /**
  6810. * Creates a new Color3 from integer values (< 256)
  6811. * @param r defines the red component to read from (value between 0 and 255)
  6812. * @param g defines the green component to read from (value between 0 and 255)
  6813. * @param b defines the blue component to read from (value between 0 and 255)
  6814. * @param a defines the alpha component to read from (value between 0 and 255)
  6815. * @returns a new Color3 object
  6816. */
  6817. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6818. /**
  6819. * Check the content of a given array and convert it to an array containing RGBA data
  6820. * If the original array was already containing count * 4 values then it is returned directly
  6821. * @param colors defines the array to check
  6822. * @param count defines the number of RGBA data to expect
  6823. * @returns an array containing count * 4 values (RGBA)
  6824. */
  6825. static CheckColors4(colors: number[], count: number): number[];
  6826. }
  6827. /**
  6828. * @hidden
  6829. */
  6830. export class TmpColors {
  6831. static Color3: Color3[];
  6832. static Color4: Color4[];
  6833. }
  6834. }
  6835. declare module "babylonjs/Animations/animationKey" {
  6836. /**
  6837. * Defines an interface which represents an animation key frame
  6838. */
  6839. export interface IAnimationKey {
  6840. /**
  6841. * Frame of the key frame
  6842. */
  6843. frame: number;
  6844. /**
  6845. * Value at the specifies key frame
  6846. */
  6847. value: any;
  6848. /**
  6849. * The input tangent for the cubic hermite spline
  6850. */
  6851. inTangent?: any;
  6852. /**
  6853. * The output tangent for the cubic hermite spline
  6854. */
  6855. outTangent?: any;
  6856. /**
  6857. * The animation interpolation type
  6858. */
  6859. interpolation?: AnimationKeyInterpolation;
  6860. }
  6861. /**
  6862. * Enum for the animation key frame interpolation type
  6863. */
  6864. export enum AnimationKeyInterpolation {
  6865. /**
  6866. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6867. */
  6868. STEP = 1
  6869. }
  6870. }
  6871. declare module "babylonjs/Animations/animationRange" {
  6872. /**
  6873. * Represents the range of an animation
  6874. */
  6875. export class AnimationRange {
  6876. /**The name of the animation range**/
  6877. name: string;
  6878. /**The starting frame of the animation */
  6879. from: number;
  6880. /**The ending frame of the animation*/
  6881. to: number;
  6882. /**
  6883. * Initializes the range of an animation
  6884. * @param name The name of the animation range
  6885. * @param from The starting frame of the animation
  6886. * @param to The ending frame of the animation
  6887. */
  6888. constructor(
  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. * Makes a copy of the animation range
  6897. * @returns A copy of the animation range
  6898. */
  6899. clone(): AnimationRange;
  6900. }
  6901. }
  6902. declare module "babylonjs/Animations/animationEvent" {
  6903. /**
  6904. * Composed of a frame, and an action function
  6905. */
  6906. export class AnimationEvent {
  6907. /** The frame for which the event is triggered **/
  6908. frame: number;
  6909. /** The event to perform when triggered **/
  6910. action: (currentFrame: number) => void;
  6911. /** Specifies if the event should be triggered only once**/
  6912. onlyOnce?: boolean | undefined;
  6913. /**
  6914. * Specifies if the animation event is done
  6915. */
  6916. isDone: boolean;
  6917. /**
  6918. * Initializes the animation event
  6919. * @param frame The frame for which the event is triggered
  6920. * @param action The event to perform when triggered
  6921. * @param onlyOnce Specifies if the event should be triggered only once
  6922. */
  6923. constructor(
  6924. /** The frame for which the event is triggered **/
  6925. frame: number,
  6926. /** The event to perform when triggered **/
  6927. action: (currentFrame: number) => void,
  6928. /** Specifies if the event should be triggered only once**/
  6929. onlyOnce?: boolean | undefined);
  6930. /** @hidden */
  6931. _clone(): AnimationEvent;
  6932. }
  6933. }
  6934. declare module "babylonjs/Behaviors/behavior" {
  6935. import { Nullable } from "babylonjs/types";
  6936. /**
  6937. * Interface used to define a behavior
  6938. */
  6939. export interface Behavior<T> {
  6940. /** gets or sets behavior's name */
  6941. name: string;
  6942. /**
  6943. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6944. */
  6945. init(): void;
  6946. /**
  6947. * Called when the behavior is attached to a target
  6948. * @param target defines the target where the behavior is attached to
  6949. */
  6950. attach(target: T): void;
  6951. /**
  6952. * Called when the behavior is detached from its target
  6953. */
  6954. detach(): void;
  6955. }
  6956. /**
  6957. * Interface implemented by classes supporting behaviors
  6958. */
  6959. export interface IBehaviorAware<T> {
  6960. /**
  6961. * Attach a behavior
  6962. * @param behavior defines the behavior to attach
  6963. * @returns the current host
  6964. */
  6965. addBehavior(behavior: Behavior<T>): T;
  6966. /**
  6967. * Remove a behavior from the current object
  6968. * @param behavior defines the behavior to detach
  6969. * @returns the current host
  6970. */
  6971. removeBehavior(behavior: Behavior<T>): T;
  6972. /**
  6973. * Gets a behavior using its name to search
  6974. * @param name defines the name to search
  6975. * @returns the behavior or null if not found
  6976. */
  6977. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6978. }
  6979. }
  6980. declare module "babylonjs/Meshes/buffer" {
  6981. import { Nullable, DataArray } from "babylonjs/types";
  6982. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6983. /**
  6984. * Class used to store data that will be store in GPU memory
  6985. */
  6986. export class Buffer {
  6987. private _engine;
  6988. private _buffer;
  6989. /** @hidden */
  6990. _data: Nullable<DataArray>;
  6991. private _updatable;
  6992. private _instanced;
  6993. private _divisor;
  6994. private _isAlreadyOwned;
  6995. /**
  6996. * Gets the byte stride.
  6997. */
  6998. readonly byteStride: number;
  6999. /**
  7000. * Constructor
  7001. * @param engine the engine
  7002. * @param data the data to use for this buffer
  7003. * @param updatable whether the data is updatable
  7004. * @param stride the stride (optional)
  7005. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7006. * @param instanced whether the buffer is instanced (optional)
  7007. * @param useBytes set to true if the stride in in bytes (optional)
  7008. * @param divisor sets an optional divisor for instances (1 by default)
  7009. */
  7010. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  7011. /**
  7012. * Create a new VertexBuffer based on the current buffer
  7013. * @param kind defines the vertex buffer kind (position, normal, etc.)
  7014. * @param offset defines offset in the buffer (0 by default)
  7015. * @param size defines the size in floats of attributes (position is 3 for instance)
  7016. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7017. * @param instanced defines if the vertex buffer contains indexed data
  7018. * @param useBytes defines if the offset and stride are in bytes *
  7019. * @param divisor sets an optional divisor for instances (1 by default)
  7020. * @returns the new vertex buffer
  7021. */
  7022. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7023. /**
  7024. * Gets a boolean indicating if the Buffer is updatable?
  7025. * @returns true if the buffer is updatable
  7026. */
  7027. isUpdatable(): boolean;
  7028. /**
  7029. * Gets current buffer's data
  7030. * @returns a DataArray or null
  7031. */
  7032. getData(): Nullable<DataArray>;
  7033. /**
  7034. * Gets underlying native buffer
  7035. * @returns underlying native buffer
  7036. */
  7037. getBuffer(): Nullable<DataBuffer>;
  7038. /**
  7039. * Gets the stride in float32 units (i.e. byte stride / 4).
  7040. * May not be an integer if the byte stride is not divisible by 4.
  7041. * @returns the stride in float32 units
  7042. * @deprecated Please use byteStride instead.
  7043. */
  7044. getStrideSize(): number;
  7045. /**
  7046. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7047. * @param data defines the data to store
  7048. */
  7049. create(data?: Nullable<DataArray>): void;
  7050. /** @hidden */
  7051. _rebuild(): void;
  7052. /**
  7053. * Update current buffer data
  7054. * @param data defines the data to store
  7055. */
  7056. update(data: DataArray): void;
  7057. /**
  7058. * Updates the data directly.
  7059. * @param data the new data
  7060. * @param offset the new offset
  7061. * @param vertexCount the vertex count (optional)
  7062. * @param useBytes set to true if the offset is in bytes
  7063. */
  7064. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7065. /** @hidden */
  7066. _increaseReferences(): void;
  7067. /**
  7068. * Release all resources
  7069. */
  7070. dispose(): void;
  7071. }
  7072. /**
  7073. * Specialized buffer used to store vertex data
  7074. */
  7075. export class VertexBuffer {
  7076. private static _Counter;
  7077. /** @hidden */
  7078. _buffer: Buffer;
  7079. private _kind;
  7080. private _size;
  7081. private _ownsBuffer;
  7082. private _instanced;
  7083. private _instanceDivisor;
  7084. /**
  7085. * The byte type.
  7086. */
  7087. static readonly BYTE: number;
  7088. /**
  7089. * The unsigned byte type.
  7090. */
  7091. static readonly UNSIGNED_BYTE: number;
  7092. /**
  7093. * The short type.
  7094. */
  7095. static readonly SHORT: number;
  7096. /**
  7097. * The unsigned short type.
  7098. */
  7099. static readonly UNSIGNED_SHORT: number;
  7100. /**
  7101. * The integer type.
  7102. */
  7103. static readonly INT: number;
  7104. /**
  7105. * The unsigned integer type.
  7106. */
  7107. static readonly UNSIGNED_INT: number;
  7108. /**
  7109. * The float type.
  7110. */
  7111. static readonly FLOAT: number;
  7112. /**
  7113. * Gets or sets the instance divisor when in instanced mode
  7114. */
  7115. get instanceDivisor(): number;
  7116. set instanceDivisor(value: number);
  7117. /**
  7118. * Gets the byte stride.
  7119. */
  7120. readonly byteStride: number;
  7121. /**
  7122. * Gets the byte offset.
  7123. */
  7124. readonly byteOffset: number;
  7125. /**
  7126. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7127. */
  7128. readonly normalized: boolean;
  7129. /**
  7130. * Gets the data type of each component in the array.
  7131. */
  7132. readonly type: number;
  7133. /**
  7134. * Gets the unique id of this vertex buffer
  7135. */
  7136. readonly uniqueId: number;
  7137. /**
  7138. * Constructor
  7139. * @param engine the engine
  7140. * @param data the data to use for this vertex buffer
  7141. * @param kind the vertex buffer kind
  7142. * @param updatable whether the data is updatable
  7143. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7144. * @param stride the stride (optional)
  7145. * @param instanced whether the buffer is instanced (optional)
  7146. * @param offset the offset of the data (optional)
  7147. * @param size the number of components (optional)
  7148. * @param type the type of the component (optional)
  7149. * @param normalized whether the data contains normalized data (optional)
  7150. * @param useBytes set to true if stride and offset are in bytes (optional)
  7151. * @param divisor defines the instance divisor to use (1 by default)
  7152. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7153. */
  7154. 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);
  7155. /** @hidden */
  7156. _rebuild(): void;
  7157. /**
  7158. * Returns the kind of the VertexBuffer (string)
  7159. * @returns a string
  7160. */
  7161. getKind(): string;
  7162. /**
  7163. * Gets a boolean indicating if the VertexBuffer is updatable?
  7164. * @returns true if the buffer is updatable
  7165. */
  7166. isUpdatable(): boolean;
  7167. /**
  7168. * Gets current buffer's data
  7169. * @returns a DataArray or null
  7170. */
  7171. getData(): Nullable<DataArray>;
  7172. /**
  7173. * Gets underlying native buffer
  7174. * @returns underlying native buffer
  7175. */
  7176. getBuffer(): Nullable<DataBuffer>;
  7177. /**
  7178. * Gets the stride in float32 units (i.e. byte stride / 4).
  7179. * May not be an integer if the byte stride is not divisible by 4.
  7180. * @returns the stride in float32 units
  7181. * @deprecated Please use byteStride instead.
  7182. */
  7183. getStrideSize(): number;
  7184. /**
  7185. * Returns the offset as a multiple of the type byte length.
  7186. * @returns the offset in bytes
  7187. * @deprecated Please use byteOffset instead.
  7188. */
  7189. getOffset(): number;
  7190. /**
  7191. * Returns the number of components per vertex attribute (integer)
  7192. * @returns the size in float
  7193. */
  7194. getSize(): number;
  7195. /**
  7196. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7197. * @returns true if this buffer is instanced
  7198. */
  7199. getIsInstanced(): boolean;
  7200. /**
  7201. * Returns the instancing divisor, zero for non-instanced (integer).
  7202. * @returns a number
  7203. */
  7204. getInstanceDivisor(): number;
  7205. /**
  7206. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7207. * @param data defines the data to store
  7208. */
  7209. create(data?: DataArray): void;
  7210. /**
  7211. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7212. * This function will create a new buffer if the current one is not updatable
  7213. * @param data defines the data to store
  7214. */
  7215. update(data: DataArray): void;
  7216. /**
  7217. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7218. * Returns the directly updated WebGLBuffer.
  7219. * @param data the new data
  7220. * @param offset the new offset
  7221. * @param useBytes set to true if the offset is in bytes
  7222. */
  7223. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7224. /**
  7225. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7226. */
  7227. dispose(): void;
  7228. /**
  7229. * Enumerates each value of this vertex buffer as numbers.
  7230. * @param count the number of values to enumerate
  7231. * @param callback the callback function called for each value
  7232. */
  7233. forEach(count: number, callback: (value: number, index: number) => void): void;
  7234. /**
  7235. * Positions
  7236. */
  7237. static readonly PositionKind: string;
  7238. /**
  7239. * Normals
  7240. */
  7241. static readonly NormalKind: string;
  7242. /**
  7243. * Tangents
  7244. */
  7245. static readonly TangentKind: string;
  7246. /**
  7247. * Texture coordinates
  7248. */
  7249. static readonly UVKind: string;
  7250. /**
  7251. * Texture coordinates 2
  7252. */
  7253. static readonly UV2Kind: string;
  7254. /**
  7255. * Texture coordinates 3
  7256. */
  7257. static readonly UV3Kind: string;
  7258. /**
  7259. * Texture coordinates 4
  7260. */
  7261. static readonly UV4Kind: string;
  7262. /**
  7263. * Texture coordinates 5
  7264. */
  7265. static readonly UV5Kind: string;
  7266. /**
  7267. * Texture coordinates 6
  7268. */
  7269. static readonly UV6Kind: string;
  7270. /**
  7271. * Colors
  7272. */
  7273. static readonly ColorKind: string;
  7274. /**
  7275. * Matrix indices (for bones)
  7276. */
  7277. static readonly MatricesIndicesKind: string;
  7278. /**
  7279. * Matrix weights (for bones)
  7280. */
  7281. static readonly MatricesWeightsKind: string;
  7282. /**
  7283. * Additional matrix indices (for bones)
  7284. */
  7285. static readonly MatricesIndicesExtraKind: string;
  7286. /**
  7287. * Additional matrix weights (for bones)
  7288. */
  7289. static readonly MatricesWeightsExtraKind: string;
  7290. /**
  7291. * Deduces the stride given a kind.
  7292. * @param kind The kind string to deduce
  7293. * @returns The deduced stride
  7294. */
  7295. static DeduceStride(kind: string): number;
  7296. /**
  7297. * Gets the byte length of the given type.
  7298. * @param type the type
  7299. * @returns the number of bytes
  7300. */
  7301. static GetTypeByteLength(type: number): number;
  7302. /**
  7303. * Enumerates each value of the given parameters as numbers.
  7304. * @param data the data to enumerate
  7305. * @param byteOffset the byte offset of the data
  7306. * @param byteStride the byte stride of the data
  7307. * @param componentCount the number of components per element
  7308. * @param componentType the type of the component
  7309. * @param count the number of values to enumerate
  7310. * @param normalized whether the data is normalized
  7311. * @param callback the callback function called for each value
  7312. */
  7313. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7314. private static _GetFloatValue;
  7315. }
  7316. }
  7317. declare module "babylonjs/Collisions/intersectionInfo" {
  7318. import { Nullable } from "babylonjs/types";
  7319. /**
  7320. * @hidden
  7321. */
  7322. export class IntersectionInfo {
  7323. bu: Nullable<number>;
  7324. bv: Nullable<number>;
  7325. distance: number;
  7326. faceId: number;
  7327. subMeshId: number;
  7328. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7329. }
  7330. }
  7331. declare module "babylonjs/Culling/boundingSphere" {
  7332. import { DeepImmutable } from "babylonjs/types";
  7333. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7334. import { Plane } from "babylonjs/Maths/math.plane";
  7335. /**
  7336. * Class used to store bounding sphere information
  7337. */
  7338. export class BoundingSphere {
  7339. /**
  7340. * Gets the center of the bounding sphere in local space
  7341. */
  7342. readonly center: Vector3;
  7343. /**
  7344. * Radius of the bounding sphere in local space
  7345. */
  7346. radius: number;
  7347. /**
  7348. * Gets the center of the bounding sphere in world space
  7349. */
  7350. readonly centerWorld: Vector3;
  7351. /**
  7352. * Radius of the bounding sphere in world space
  7353. */
  7354. radiusWorld: number;
  7355. /**
  7356. * Gets the minimum vector in local space
  7357. */
  7358. readonly minimum: Vector3;
  7359. /**
  7360. * Gets the maximum vector in local space
  7361. */
  7362. readonly maximum: Vector3;
  7363. private _worldMatrix;
  7364. private static readonly TmpVector3;
  7365. /**
  7366. * Creates a new bounding sphere
  7367. * @param min defines the minimum vector (in local space)
  7368. * @param max defines the maximum vector (in local space)
  7369. * @param worldMatrix defines the new world matrix
  7370. */
  7371. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7372. /**
  7373. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7374. * @param min defines the new minimum vector (in local space)
  7375. * @param max defines the new maximum vector (in local space)
  7376. * @param worldMatrix defines the new world matrix
  7377. */
  7378. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7379. /**
  7380. * Scale the current bounding sphere by applying a scale factor
  7381. * @param factor defines the scale factor to apply
  7382. * @returns the current bounding box
  7383. */
  7384. scale(factor: number): BoundingSphere;
  7385. /**
  7386. * Gets the world matrix of the bounding box
  7387. * @returns a matrix
  7388. */
  7389. getWorldMatrix(): DeepImmutable<Matrix>;
  7390. /** @hidden */
  7391. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7392. /**
  7393. * Tests if the bounding sphere is intersecting the frustum planes
  7394. * @param frustumPlanes defines the frustum planes to test
  7395. * @returns true if there is an intersection
  7396. */
  7397. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7398. /**
  7399. * Tests if the bounding sphere center is in between the frustum planes.
  7400. * Used for optimistic fast inclusion.
  7401. * @param frustumPlanes defines the frustum planes to test
  7402. * @returns true if the sphere center is in between the frustum planes
  7403. */
  7404. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7405. /**
  7406. * Tests if a point is inside the bounding sphere
  7407. * @param point defines the point to test
  7408. * @returns true if the point is inside the bounding sphere
  7409. */
  7410. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7411. /**
  7412. * Checks if two sphere intersct
  7413. * @param sphere0 sphere 0
  7414. * @param sphere1 sphere 1
  7415. * @returns true if the speres intersect
  7416. */
  7417. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7418. }
  7419. }
  7420. declare module "babylonjs/Culling/boundingBox" {
  7421. import { DeepImmutable } from "babylonjs/types";
  7422. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7423. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7424. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7425. import { Plane } from "babylonjs/Maths/math.plane";
  7426. /**
  7427. * Class used to store bounding box information
  7428. */
  7429. export class BoundingBox implements ICullable {
  7430. /**
  7431. * Gets the 8 vectors representing the bounding box in local space
  7432. */
  7433. readonly vectors: Vector3[];
  7434. /**
  7435. * Gets the center of the bounding box in local space
  7436. */
  7437. readonly center: Vector3;
  7438. /**
  7439. * Gets the center of the bounding box in world space
  7440. */
  7441. readonly centerWorld: Vector3;
  7442. /**
  7443. * Gets the extend size in local space
  7444. */
  7445. readonly extendSize: Vector3;
  7446. /**
  7447. * Gets the extend size in world space
  7448. */
  7449. readonly extendSizeWorld: Vector3;
  7450. /**
  7451. * Gets the OBB (object bounding box) directions
  7452. */
  7453. readonly directions: Vector3[];
  7454. /**
  7455. * Gets the 8 vectors representing the bounding box in world space
  7456. */
  7457. readonly vectorsWorld: Vector3[];
  7458. /**
  7459. * Gets the minimum vector in world space
  7460. */
  7461. readonly minimumWorld: Vector3;
  7462. /**
  7463. * Gets the maximum vector in world space
  7464. */
  7465. readonly maximumWorld: Vector3;
  7466. /**
  7467. * Gets the minimum vector in local space
  7468. */
  7469. readonly minimum: Vector3;
  7470. /**
  7471. * Gets the maximum vector in local space
  7472. */
  7473. readonly maximum: Vector3;
  7474. private _worldMatrix;
  7475. private static readonly TmpVector3;
  7476. /**
  7477. * @hidden
  7478. */
  7479. _tag: number;
  7480. /**
  7481. * Creates a new bounding box
  7482. * @param min defines the minimum vector (in local space)
  7483. * @param max defines the maximum vector (in local space)
  7484. * @param worldMatrix defines the new world matrix
  7485. */
  7486. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7487. /**
  7488. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7489. * @param min defines the new minimum vector (in local space)
  7490. * @param max defines the new maximum vector (in local space)
  7491. * @param worldMatrix defines the new world matrix
  7492. */
  7493. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7494. /**
  7495. * Scale the current bounding box by applying a scale factor
  7496. * @param factor defines the scale factor to apply
  7497. * @returns the current bounding box
  7498. */
  7499. scale(factor: number): BoundingBox;
  7500. /**
  7501. * Gets the world matrix of the bounding box
  7502. * @returns a matrix
  7503. */
  7504. getWorldMatrix(): DeepImmutable<Matrix>;
  7505. /** @hidden */
  7506. _update(world: DeepImmutable<Matrix>): void;
  7507. /**
  7508. * Tests if the bounding box is intersecting the frustum planes
  7509. * @param frustumPlanes defines the frustum planes to test
  7510. * @returns true if there is an intersection
  7511. */
  7512. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7513. /**
  7514. * Tests if the bounding box is entirely inside the frustum planes
  7515. * @param frustumPlanes defines the frustum planes to test
  7516. * @returns true if there is an inclusion
  7517. */
  7518. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7519. /**
  7520. * Tests if a point is inside the bounding box
  7521. * @param point defines the point to test
  7522. * @returns true if the point is inside the bounding box
  7523. */
  7524. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7525. /**
  7526. * Tests if the bounding box intersects with a bounding sphere
  7527. * @param sphere defines the sphere to test
  7528. * @returns true if there is an intersection
  7529. */
  7530. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7531. /**
  7532. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7533. * @param min defines the min vector to use
  7534. * @param max defines the max vector to use
  7535. * @returns true if there is an intersection
  7536. */
  7537. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7538. /**
  7539. * Tests if two bounding boxes are intersections
  7540. * @param box0 defines the first box to test
  7541. * @param box1 defines the second box to test
  7542. * @returns true if there is an intersection
  7543. */
  7544. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7545. /**
  7546. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7547. * @param minPoint defines the minimum vector of the bounding box
  7548. * @param maxPoint defines the maximum vector of the bounding box
  7549. * @param sphereCenter defines the sphere center
  7550. * @param sphereRadius defines the sphere radius
  7551. * @returns true if there is an intersection
  7552. */
  7553. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7554. /**
  7555. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7556. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7557. * @param frustumPlanes defines the frustum planes to test
  7558. * @return true if there is an inclusion
  7559. */
  7560. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7561. /**
  7562. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7563. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7564. * @param frustumPlanes defines the frustum planes to test
  7565. * @return true if there is an intersection
  7566. */
  7567. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7568. }
  7569. }
  7570. declare module "babylonjs/Collisions/collider" {
  7571. import { Nullable, IndicesArray } from "babylonjs/types";
  7572. import { Vector3 } from "babylonjs/Maths/math.vector";
  7573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7574. import { Plane } from "babylonjs/Maths/math.plane";
  7575. /** @hidden */
  7576. export class Collider {
  7577. /** Define if a collision was found */
  7578. collisionFound: boolean;
  7579. /**
  7580. * Define last intersection point in local space
  7581. */
  7582. intersectionPoint: Vector3;
  7583. /**
  7584. * Define last collided mesh
  7585. */
  7586. collidedMesh: Nullable<AbstractMesh>;
  7587. private _collisionPoint;
  7588. private _planeIntersectionPoint;
  7589. private _tempVector;
  7590. private _tempVector2;
  7591. private _tempVector3;
  7592. private _tempVector4;
  7593. private _edge;
  7594. private _baseToVertex;
  7595. private _destinationPoint;
  7596. private _slidePlaneNormal;
  7597. private _displacementVector;
  7598. /** @hidden */
  7599. _radius: Vector3;
  7600. /** @hidden */
  7601. _retry: number;
  7602. private _velocity;
  7603. private _basePoint;
  7604. private _epsilon;
  7605. /** @hidden */
  7606. _velocityWorldLength: number;
  7607. /** @hidden */
  7608. _basePointWorld: Vector3;
  7609. private _velocityWorld;
  7610. private _normalizedVelocity;
  7611. /** @hidden */
  7612. _initialVelocity: Vector3;
  7613. /** @hidden */
  7614. _initialPosition: Vector3;
  7615. private _nearestDistance;
  7616. private _collisionMask;
  7617. get collisionMask(): number;
  7618. set collisionMask(mask: number);
  7619. /**
  7620. * Gets the plane normal used to compute the sliding response (in local space)
  7621. */
  7622. get slidePlaneNormal(): Vector3;
  7623. /** @hidden */
  7624. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7625. /** @hidden */
  7626. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7627. /** @hidden */
  7628. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7629. /** @hidden */
  7630. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7631. /** @hidden */
  7632. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7633. /** @hidden */
  7634. _getResponse(pos: Vector3, vel: Vector3): void;
  7635. }
  7636. }
  7637. declare module "babylonjs/Culling/boundingInfo" {
  7638. import { DeepImmutable } from "babylonjs/types";
  7639. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7640. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7641. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7642. import { Plane } from "babylonjs/Maths/math.plane";
  7643. import { Collider } from "babylonjs/Collisions/collider";
  7644. /**
  7645. * Interface for cullable objects
  7646. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7647. */
  7648. export interface ICullable {
  7649. /**
  7650. * Checks if the object or part of the object is in the frustum
  7651. * @param frustumPlanes Camera near/planes
  7652. * @returns true if the object is in frustum otherwise false
  7653. */
  7654. isInFrustum(frustumPlanes: Plane[]): boolean;
  7655. /**
  7656. * Checks if a cullable object (mesh...) is in the camera frustum
  7657. * Unlike isInFrustum this cheks the full bounding box
  7658. * @param frustumPlanes Camera near/planes
  7659. * @returns true if the object is in frustum otherwise false
  7660. */
  7661. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7662. }
  7663. /**
  7664. * Info for a bounding data of a mesh
  7665. */
  7666. export class BoundingInfo implements ICullable {
  7667. /**
  7668. * Bounding box for the mesh
  7669. */
  7670. readonly boundingBox: BoundingBox;
  7671. /**
  7672. * Bounding sphere for the mesh
  7673. */
  7674. readonly boundingSphere: BoundingSphere;
  7675. private _isLocked;
  7676. private static readonly TmpVector3;
  7677. /**
  7678. * Constructs bounding info
  7679. * @param minimum min vector of the bounding box/sphere
  7680. * @param maximum max vector of the bounding box/sphere
  7681. * @param worldMatrix defines the new world matrix
  7682. */
  7683. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7684. /**
  7685. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7686. * @param min defines the new minimum vector (in local space)
  7687. * @param max defines the new maximum vector (in local space)
  7688. * @param worldMatrix defines the new world matrix
  7689. */
  7690. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7691. /**
  7692. * min vector of the bounding box/sphere
  7693. */
  7694. get minimum(): Vector3;
  7695. /**
  7696. * max vector of the bounding box/sphere
  7697. */
  7698. get maximum(): Vector3;
  7699. /**
  7700. * If the info is locked and won't be updated to avoid perf overhead
  7701. */
  7702. get isLocked(): boolean;
  7703. set isLocked(value: boolean);
  7704. /**
  7705. * Updates the bounding sphere and box
  7706. * @param world world matrix to be used to update
  7707. */
  7708. update(world: DeepImmutable<Matrix>): void;
  7709. /**
  7710. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7711. * @param center New center of the bounding info
  7712. * @param extend New extend of the bounding info
  7713. * @returns the current bounding info
  7714. */
  7715. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7716. /**
  7717. * Scale the current bounding info by applying a scale factor
  7718. * @param factor defines the scale factor to apply
  7719. * @returns the current bounding info
  7720. */
  7721. scale(factor: number): BoundingInfo;
  7722. /**
  7723. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7724. * @param frustumPlanes defines the frustum to test
  7725. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7726. * @returns true if the bounding info is in the frustum planes
  7727. */
  7728. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7729. /**
  7730. * Gets the world distance between the min and max points of the bounding box
  7731. */
  7732. get diagonalLength(): number;
  7733. /**
  7734. * Checks if a cullable object (mesh...) is in the camera frustum
  7735. * Unlike isInFrustum this cheks the full bounding box
  7736. * @param frustumPlanes Camera near/planes
  7737. * @returns true if the object is in frustum otherwise false
  7738. */
  7739. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7740. /** @hidden */
  7741. _checkCollision(collider: Collider): boolean;
  7742. /**
  7743. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7744. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7745. * @param point the point to check intersection with
  7746. * @returns if the point intersects
  7747. */
  7748. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7749. /**
  7750. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7751. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7752. * @param boundingInfo the bounding info to check intersection with
  7753. * @param precise if the intersection should be done using OBB
  7754. * @returns if the bounding info intersects
  7755. */
  7756. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7757. }
  7758. }
  7759. declare module "babylonjs/Maths/math.functions" {
  7760. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7761. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7762. /**
  7763. * Extracts minimum and maximum values from a list of indexed positions
  7764. * @param positions defines the positions to use
  7765. * @param indices defines the indices to the positions
  7766. * @param indexStart defines the start index
  7767. * @param indexCount defines the end index
  7768. * @param bias defines bias value to add to the result
  7769. * @return minimum and maximum values
  7770. */
  7771. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7772. minimum: Vector3;
  7773. maximum: Vector3;
  7774. };
  7775. /**
  7776. * Extracts minimum and maximum values from a list of positions
  7777. * @param positions defines the positions to use
  7778. * @param start defines the start index in the positions array
  7779. * @param count defines the number of positions to handle
  7780. * @param bias defines bias value to add to the result
  7781. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7782. * @return minimum and maximum values
  7783. */
  7784. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7785. minimum: Vector3;
  7786. maximum: Vector3;
  7787. };
  7788. }
  7789. declare module "babylonjs/Misc/guid" {
  7790. /**
  7791. * Class used to manipulate GUIDs
  7792. */
  7793. export class GUID {
  7794. /**
  7795. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7796. * Be aware Math.random() could cause collisions, but:
  7797. * "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"
  7798. * @returns a pseudo random id
  7799. */
  7800. static RandomId(): string;
  7801. }
  7802. }
  7803. declare module "babylonjs/Materials/Textures/baseTexture" {
  7804. import { Observable } from "babylonjs/Misc/observable";
  7805. import { Nullable } from "babylonjs/types";
  7806. import { Scene } from "babylonjs/scene";
  7807. import { Matrix } from "babylonjs/Maths/math.vector";
  7808. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7809. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7810. import "babylonjs/Misc/fileTools";
  7811. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7812. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7813. /**
  7814. * Base class of all the textures in babylon.
  7815. * It groups all the common properties the materials, post process, lights... might need
  7816. * in order to make a correct use of the texture.
  7817. */
  7818. export class BaseTexture extends ThinTexture implements IAnimatable {
  7819. /**
  7820. * Default anisotropic filtering level for the application.
  7821. * It is set to 4 as a good tradeoff between perf and quality.
  7822. */
  7823. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7824. /**
  7825. * Gets or sets the unique id of the texture
  7826. */
  7827. uniqueId: number;
  7828. /**
  7829. * Define the name of the texture.
  7830. */
  7831. name: string;
  7832. /**
  7833. * Gets or sets an object used to store user defined information.
  7834. */
  7835. metadata: any;
  7836. /**
  7837. * For internal use only. Please do not use.
  7838. */
  7839. reservedDataStore: any;
  7840. private _hasAlpha;
  7841. /**
  7842. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7843. */
  7844. set hasAlpha(value: boolean);
  7845. get hasAlpha(): boolean;
  7846. /**
  7847. * Defines if the alpha value should be determined via the rgb values.
  7848. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7849. */
  7850. getAlphaFromRGB: boolean;
  7851. /**
  7852. * Intensity or strength of the texture.
  7853. * It is commonly used by materials to fine tune the intensity of the texture
  7854. */
  7855. level: number;
  7856. /**
  7857. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7858. * This is part of the texture as textures usually maps to one uv set.
  7859. */
  7860. coordinatesIndex: number;
  7861. protected _coordinatesMode: number;
  7862. /**
  7863. * How a texture is mapped.
  7864. *
  7865. * | Value | Type | Description |
  7866. * | ----- | ----------------------------------- | ----------- |
  7867. * | 0 | EXPLICIT_MODE | |
  7868. * | 1 | SPHERICAL_MODE | |
  7869. * | 2 | PLANAR_MODE | |
  7870. * | 3 | CUBIC_MODE | |
  7871. * | 4 | PROJECTION_MODE | |
  7872. * | 5 | SKYBOX_MODE | |
  7873. * | 6 | INVCUBIC_MODE | |
  7874. * | 7 | EQUIRECTANGULAR_MODE | |
  7875. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7876. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7877. */
  7878. set coordinatesMode(value: number);
  7879. get coordinatesMode(): number;
  7880. /**
  7881. * | Value | Type | Description |
  7882. * | ----- | ------------------ | ----------- |
  7883. * | 0 | CLAMP_ADDRESSMODE | |
  7884. * | 1 | WRAP_ADDRESSMODE | |
  7885. * | 2 | MIRROR_ADDRESSMODE | |
  7886. */
  7887. get wrapU(): number;
  7888. set wrapU(value: number);
  7889. /**
  7890. * | Value | Type | Description |
  7891. * | ----- | ------------------ | ----------- |
  7892. * | 0 | CLAMP_ADDRESSMODE | |
  7893. * | 1 | WRAP_ADDRESSMODE | |
  7894. * | 2 | MIRROR_ADDRESSMODE | |
  7895. */
  7896. get wrapV(): number;
  7897. set wrapV(value: number);
  7898. /**
  7899. * | Value | Type | Description |
  7900. * | ----- | ------------------ | ----------- |
  7901. * | 0 | CLAMP_ADDRESSMODE | |
  7902. * | 1 | WRAP_ADDRESSMODE | |
  7903. * | 2 | MIRROR_ADDRESSMODE | |
  7904. */
  7905. wrapR: number;
  7906. /**
  7907. * With compliant hardware and browser (supporting anisotropic filtering)
  7908. * this defines the level of anisotropic filtering in the texture.
  7909. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7910. */
  7911. anisotropicFilteringLevel: number;
  7912. private _isCube;
  7913. /**
  7914. * Define if the texture is a cube texture or if false a 2d texture.
  7915. */
  7916. get isCube(): boolean;
  7917. set isCube(value: boolean);
  7918. /**
  7919. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7920. */
  7921. get is3D(): boolean;
  7922. set is3D(value: boolean);
  7923. /**
  7924. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7925. */
  7926. get is2DArray(): boolean;
  7927. set is2DArray(value: boolean);
  7928. private _gammaSpace;
  7929. /**
  7930. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7931. * HDR texture are usually stored in linear space.
  7932. * This only impacts the PBR and Background materials
  7933. */
  7934. get gammaSpace(): boolean;
  7935. set gammaSpace(gamma: boolean);
  7936. /**
  7937. * Gets or sets whether or not the texture contains RGBD data.
  7938. */
  7939. get isRGBD(): boolean;
  7940. set isRGBD(value: boolean);
  7941. /**
  7942. * Is Z inverted in the texture (useful in a cube texture).
  7943. */
  7944. invertZ: boolean;
  7945. /**
  7946. * Are mip maps generated for this texture or not.
  7947. */
  7948. get noMipmap(): boolean;
  7949. /**
  7950. * @hidden
  7951. */
  7952. lodLevelInAlpha: boolean;
  7953. /**
  7954. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7955. */
  7956. get lodGenerationOffset(): number;
  7957. set lodGenerationOffset(value: number);
  7958. /**
  7959. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7960. */
  7961. get lodGenerationScale(): number;
  7962. set lodGenerationScale(value: number);
  7963. /**
  7964. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7965. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7966. * average roughness values.
  7967. */
  7968. get linearSpecularLOD(): boolean;
  7969. set linearSpecularLOD(value: boolean);
  7970. /**
  7971. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7972. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7973. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7974. */
  7975. get irradianceTexture(): Nullable<BaseTexture>;
  7976. set irradianceTexture(value: Nullable<BaseTexture>);
  7977. /**
  7978. * Define if the texture is a render target.
  7979. */
  7980. isRenderTarget: boolean;
  7981. /**
  7982. * Define the unique id of the texture in the scene.
  7983. */
  7984. get uid(): string;
  7985. /** @hidden */
  7986. _prefiltered: boolean;
  7987. /**
  7988. * Return a string representation of the texture.
  7989. * @returns the texture as a string
  7990. */
  7991. toString(): string;
  7992. /**
  7993. * Get the class name of the texture.
  7994. * @returns "BaseTexture"
  7995. */
  7996. getClassName(): string;
  7997. /**
  7998. * Define the list of animation attached to the texture.
  7999. */
  8000. animations: import("babylonjs/Animations/animation").Animation[];
  8001. /**
  8002. * An event triggered when the texture is disposed.
  8003. */
  8004. onDisposeObservable: Observable<BaseTexture>;
  8005. private _onDisposeObserver;
  8006. /**
  8007. * Callback triggered when the texture has been disposed.
  8008. * Kept for back compatibility, you can use the onDisposeObservable instead.
  8009. */
  8010. set onDispose(callback: () => void);
  8011. protected _scene: Nullable<Scene>;
  8012. /** @hidden */
  8013. _texture: Nullable<InternalTexture>;
  8014. private _uid;
  8015. /**
  8016. * Define if the texture is preventinga material to render or not.
  8017. * If not and the texture is not ready, the engine will use a default black texture instead.
  8018. */
  8019. get isBlocking(): boolean;
  8020. /**
  8021. * Instantiates a new BaseTexture.
  8022. * Base class of all the textures in babylon.
  8023. * It groups all the common properties the materials, post process, lights... might need
  8024. * in order to make a correct use of the texture.
  8025. * @param sceneOrEngine Define the scene or engine the texture blongs to
  8026. */
  8027. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8028. /**
  8029. * Get the scene the texture belongs to.
  8030. * @returns the scene or null if undefined
  8031. */
  8032. getScene(): Nullable<Scene>;
  8033. /** @hidden */
  8034. protected _getEngine(): Nullable<ThinEngine>;
  8035. /**
  8036. * Checks if the texture has the same transform matrix than another texture
  8037. * @param texture texture to check against
  8038. * @returns true if the transforms are the same, else false
  8039. */
  8040. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8041. /**
  8042. * Get the texture transform matrix used to offset tile the texture for istance.
  8043. * @returns the transformation matrix
  8044. */
  8045. getTextureMatrix(): Matrix;
  8046. /**
  8047. * Get the texture reflection matrix used to rotate/transform the reflection.
  8048. * @returns the reflection matrix
  8049. */
  8050. getReflectionTextureMatrix(): Matrix;
  8051. /**
  8052. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8053. * @returns true if ready or not blocking
  8054. */
  8055. isReadyOrNotBlocking(): boolean;
  8056. /**
  8057. * Scales the texture if is `canRescale()`
  8058. * @param ratio the resize factor we want to use to rescale
  8059. */
  8060. scale(ratio: number): void;
  8061. /**
  8062. * Get if the texture can rescale.
  8063. */
  8064. get canRescale(): boolean;
  8065. /** @hidden */
  8066. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8067. /** @hidden */
  8068. _rebuild(): void;
  8069. /**
  8070. * Clones the texture.
  8071. * @returns the cloned texture
  8072. */
  8073. clone(): Nullable<BaseTexture>;
  8074. /**
  8075. * Get the texture underlying type (INT, FLOAT...)
  8076. */
  8077. get textureType(): number;
  8078. /**
  8079. * Get the texture underlying format (RGB, RGBA...)
  8080. */
  8081. get textureFormat(): number;
  8082. /**
  8083. * Indicates that textures need to be re-calculated for all materials
  8084. */
  8085. protected _markAllSubMeshesAsTexturesDirty(): void;
  8086. /**
  8087. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8088. * This will returns an RGBA array buffer containing either in values (0-255) or
  8089. * float values (0-1) depending of the underlying buffer type.
  8090. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8091. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8092. * @param buffer defines a user defined buffer to fill with data (can be null)
  8093. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8094. * @returns The Array buffer promise containing the pixels data.
  8095. */
  8096. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8097. /** @hidden */
  8098. get _lodTextureHigh(): Nullable<BaseTexture>;
  8099. /** @hidden */
  8100. get _lodTextureMid(): Nullable<BaseTexture>;
  8101. /** @hidden */
  8102. get _lodTextureLow(): Nullable<BaseTexture>;
  8103. /**
  8104. * Dispose the texture and release its associated resources.
  8105. */
  8106. dispose(): void;
  8107. /**
  8108. * Serialize the texture into a JSON representation that can be parsed later on.
  8109. * @returns the JSON representation of the texture
  8110. */
  8111. serialize(): any;
  8112. /**
  8113. * Helper function to be called back once a list of texture contains only ready textures.
  8114. * @param textures Define the list of textures to wait for
  8115. * @param callback Define the callback triggered once the entire list will be ready
  8116. */
  8117. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8118. private static _isScene;
  8119. }
  8120. }
  8121. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  8122. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8123. /** @hidden */
  8124. export class WebGLDataBuffer extends DataBuffer {
  8125. private _buffer;
  8126. constructor(resource: WebGLBuffer);
  8127. get underlyingResource(): any;
  8128. }
  8129. }
  8130. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  8131. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8132. import { Nullable } from "babylonjs/types";
  8133. import { Effect } from "babylonjs/Materials/effect";
  8134. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  8135. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  8136. /** @hidden */
  8137. export class WebGLPipelineContext implements IPipelineContext {
  8138. private _valueCache;
  8139. private _uniforms;
  8140. engine: ThinEngine;
  8141. program: Nullable<WebGLProgram>;
  8142. context?: WebGLRenderingContext;
  8143. vertexShader?: WebGLShader;
  8144. fragmentShader?: WebGLShader;
  8145. isParallelCompiled: boolean;
  8146. onCompiled?: () => void;
  8147. transformFeedback?: WebGLTransformFeedback | null;
  8148. vertexCompilationError: Nullable<string>;
  8149. fragmentCompilationError: Nullable<string>;
  8150. programLinkError: Nullable<string>;
  8151. programValidationError: Nullable<string>;
  8152. get isAsync(): boolean;
  8153. get isReady(): boolean;
  8154. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8155. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8156. [key: string]: number;
  8157. }, uniformsNames: string[], uniforms: {
  8158. [key: string]: Nullable<WebGLUniformLocation>;
  8159. }, samplerList: string[], samplers: {
  8160. [key: string]: number;
  8161. }, attributesNames: string[], attributes: number[]): void;
  8162. /**
  8163. * Release all associated resources.
  8164. **/
  8165. dispose(): void;
  8166. /** @hidden */
  8167. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8168. /** @hidden */
  8169. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8170. /** @hidden */
  8171. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8172. /** @hidden */
  8173. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8174. /**
  8175. * Sets an interger value on a uniform variable.
  8176. * @param uniformName Name of the variable.
  8177. * @param value Value to be set.
  8178. */
  8179. setInt(uniformName: string, value: number): void;
  8180. /**
  8181. * Sets a int2 on a uniform variable.
  8182. * @param uniformName Name of the variable.
  8183. * @param x First int in int2.
  8184. * @param y Second int in int2.
  8185. */
  8186. setInt2(uniformName: string, x: number, y: number): void;
  8187. /**
  8188. * Sets a int3 on a uniform variable.
  8189. * @param uniformName Name of the variable.
  8190. * @param x First int in int3.
  8191. * @param y Second int in int3.
  8192. * @param y Third int in int3.
  8193. */
  8194. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8195. /**
  8196. * Sets a int4 on a uniform variable.
  8197. * @param uniformName Name of the variable.
  8198. * @param x First int in int4.
  8199. * @param y Second int in int4.
  8200. * @param y Third int in int4.
  8201. * @param w Fourth int in int4.
  8202. */
  8203. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8204. /**
  8205. * Sets an int array on a uniform variable.
  8206. * @param uniformName Name of the variable.
  8207. * @param array array to be set.
  8208. */
  8209. setIntArray(uniformName: string, array: Int32Array): void;
  8210. /**
  8211. * 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)
  8212. * @param uniformName Name of the variable.
  8213. * @param array array to be set.
  8214. */
  8215. setIntArray2(uniformName: string, array: Int32Array): void;
  8216. /**
  8217. * 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)
  8218. * @param uniformName Name of the variable.
  8219. * @param array array to be set.
  8220. */
  8221. setIntArray3(uniformName: string, array: Int32Array): void;
  8222. /**
  8223. * 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)
  8224. * @param uniformName Name of the variable.
  8225. * @param array array to be set.
  8226. */
  8227. setIntArray4(uniformName: string, array: Int32Array): void;
  8228. /**
  8229. * Sets an array on a uniform variable.
  8230. * @param uniformName Name of the variable.
  8231. * @param array array to be set.
  8232. */
  8233. setArray(uniformName: string, array: number[]): void;
  8234. /**
  8235. * 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)
  8236. * @param uniformName Name of the variable.
  8237. * @param array array to be set.
  8238. */
  8239. setArray2(uniformName: string, array: number[]): void;
  8240. /**
  8241. * 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)
  8242. * @param uniformName Name of the variable.
  8243. * @param array array to be set.
  8244. * @returns this effect.
  8245. */
  8246. setArray3(uniformName: string, array: number[]): void;
  8247. /**
  8248. * 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)
  8249. * @param uniformName Name of the variable.
  8250. * @param array array to be set.
  8251. */
  8252. setArray4(uniformName: string, array: number[]): void;
  8253. /**
  8254. * Sets matrices on a uniform variable.
  8255. * @param uniformName Name of the variable.
  8256. * @param matrices matrices to be set.
  8257. */
  8258. setMatrices(uniformName: string, matrices: Float32Array): void;
  8259. /**
  8260. * Sets matrix on a uniform variable.
  8261. * @param uniformName Name of the variable.
  8262. * @param matrix matrix to be set.
  8263. */
  8264. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8265. /**
  8266. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8267. * @param uniformName Name of the variable.
  8268. * @param matrix matrix to be set.
  8269. */
  8270. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8271. /**
  8272. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8273. * @param uniformName Name of the variable.
  8274. * @param matrix matrix to be set.
  8275. */
  8276. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8277. /**
  8278. * Sets a float on a uniform variable.
  8279. * @param uniformName Name of the variable.
  8280. * @param value value to be set.
  8281. * @returns this effect.
  8282. */
  8283. setFloat(uniformName: string, value: number): void;
  8284. /**
  8285. * Sets a Vector2 on a uniform variable.
  8286. * @param uniformName Name of the variable.
  8287. * @param vector2 vector2 to be set.
  8288. */
  8289. setVector2(uniformName: string, vector2: IVector2Like): void;
  8290. /**
  8291. * Sets a float2 on a uniform variable.
  8292. * @param uniformName Name of the variable.
  8293. * @param x First float in float2.
  8294. * @param y Second float in float2.
  8295. */
  8296. setFloat2(uniformName: string, x: number, y: number): void;
  8297. /**
  8298. * Sets a Vector3 on a uniform variable.
  8299. * @param uniformName Name of the variable.
  8300. * @param vector3 Value to be set.
  8301. */
  8302. setVector3(uniformName: string, vector3: IVector3Like): void;
  8303. /**
  8304. * Sets a float3 on a uniform variable.
  8305. * @param uniformName Name of the variable.
  8306. * @param x First float in float3.
  8307. * @param y Second float in float3.
  8308. * @param z Third float in float3.
  8309. */
  8310. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8311. /**
  8312. * Sets a Vector4 on a uniform variable.
  8313. * @param uniformName Name of the variable.
  8314. * @param vector4 Value to be set.
  8315. */
  8316. setVector4(uniformName: string, vector4: IVector4Like): void;
  8317. /**
  8318. * Sets a float4 on a uniform variable.
  8319. * @param uniformName Name of the variable.
  8320. * @param x First float in float4.
  8321. * @param y Second float in float4.
  8322. * @param z Third float in float4.
  8323. * @param w Fourth float in float4.
  8324. * @returns this effect.
  8325. */
  8326. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8327. /**
  8328. * Sets a Color3 on a uniform variable.
  8329. * @param uniformName Name of the variable.
  8330. * @param color3 Value to be set.
  8331. */
  8332. setColor3(uniformName: string, color3: IColor3Like): void;
  8333. /**
  8334. * Sets a Color4 on a uniform variable.
  8335. * @param uniformName Name of the variable.
  8336. * @param color3 Value to be set.
  8337. * @param alpha Alpha value to be set.
  8338. */
  8339. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8340. /**
  8341. * Sets a Color4 on a uniform variable
  8342. * @param uniformName defines the name of the variable
  8343. * @param color4 defines the value to be set
  8344. */
  8345. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8346. _getVertexShaderCode(): string | null;
  8347. _getFragmentShaderCode(): string | null;
  8348. }
  8349. }
  8350. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  8351. import { FloatArray, Nullable } from "babylonjs/types";
  8352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8353. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8354. module "babylonjs/Engines/thinEngine" {
  8355. interface ThinEngine {
  8356. /**
  8357. * Create an uniform buffer
  8358. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8359. * @param elements defines the content of the uniform buffer
  8360. * @returns the webGL uniform buffer
  8361. */
  8362. createUniformBuffer(elements: FloatArray): DataBuffer;
  8363. /**
  8364. * Create a dynamic uniform buffer
  8365. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8366. * @param elements defines the content of the uniform buffer
  8367. * @returns the webGL uniform buffer
  8368. */
  8369. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8370. /**
  8371. * Update an existing uniform buffer
  8372. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8373. * @param uniformBuffer defines the target uniform buffer
  8374. * @param elements defines the content to update
  8375. * @param offset defines the offset in the uniform buffer where update should start
  8376. * @param count defines the size of the data to update
  8377. */
  8378. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8379. /**
  8380. * Bind an uniform buffer to the current webGL context
  8381. * @param buffer defines the buffer to bind
  8382. */
  8383. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8384. /**
  8385. * Bind a buffer to the current webGL context at a given location
  8386. * @param buffer defines the buffer to bind
  8387. * @param location defines the index where to bind the buffer
  8388. * @param name Name of the uniform variable to bind
  8389. */
  8390. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8391. /**
  8392. * Bind a specific block at a given index in a specific shader program
  8393. * @param pipelineContext defines the pipeline context to use
  8394. * @param blockName defines the block name
  8395. * @param index defines the index where to bind the block
  8396. */
  8397. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8398. }
  8399. }
  8400. }
  8401. declare module "babylonjs/Materials/uniformBuffer" {
  8402. import { Nullable, FloatArray } from "babylonjs/types";
  8403. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  8404. import { Engine } from "babylonjs/Engines/engine";
  8405. import { Effect } from "babylonjs/Materials/effect";
  8406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8407. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8408. import { Color3 } from "babylonjs/Maths/math.color";
  8409. import { IMatrixLike } from "babylonjs/Maths/math.like";
  8410. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  8411. /**
  8412. * Uniform buffer objects.
  8413. *
  8414. * Handles blocks of uniform on the GPU.
  8415. *
  8416. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8417. *
  8418. * For more information, please refer to :
  8419. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8420. */
  8421. export class UniformBuffer {
  8422. /** @hidden */
  8423. static _updatedUbosInFrame: {
  8424. [name: string]: number;
  8425. };
  8426. private _engine;
  8427. private _buffer;
  8428. private _buffers;
  8429. private _bufferIndex;
  8430. private _createBufferOnWrite;
  8431. private _data;
  8432. private _bufferData;
  8433. private _dynamic?;
  8434. private _uniformLocations;
  8435. private _uniformSizes;
  8436. private _uniformArraySizes;
  8437. private _uniformLocationPointer;
  8438. private _needSync;
  8439. private _noUBO;
  8440. private _currentEffect;
  8441. private _currentEffectName;
  8442. private _name;
  8443. private _currentFrameId;
  8444. /** @hidden */
  8445. _alreadyBound: boolean;
  8446. private static _MAX_UNIFORM_SIZE;
  8447. private static _tempBuffer;
  8448. private static _tempBufferInt32View;
  8449. /**
  8450. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8451. * This is dynamic to allow compat with webgl 1 and 2.
  8452. * You will need to pass the name of the uniform as well as the value.
  8453. */
  8454. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8455. /**
  8456. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8457. * This is dynamic to allow compat with webgl 1 and 2.
  8458. * You will need to pass the name of the uniform as well as the value.
  8459. */
  8460. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8461. /**
  8462. * Lambda to Update a single float in a uniform buffer.
  8463. * This is dynamic to allow compat with webgl 1 and 2.
  8464. * You will need to pass the name of the uniform as well as the value.
  8465. */
  8466. updateFloat: (name: string, x: number) => void;
  8467. /**
  8468. * Lambda to Update a vec2 of float in a uniform buffer.
  8469. * This is dynamic to allow compat with webgl 1 and 2.
  8470. * You will need to pass the name of the uniform as well as the value.
  8471. */
  8472. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8473. /**
  8474. * Lambda to Update a vec3 of float in a uniform buffer.
  8475. * This is dynamic to allow compat with webgl 1 and 2.
  8476. * You will need to pass the name of the uniform as well as the value.
  8477. */
  8478. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8479. /**
  8480. * Lambda to Update a vec4 of float in a uniform buffer.
  8481. * This is dynamic to allow compat with webgl 1 and 2.
  8482. * You will need to pass the name of the uniform as well as the value.
  8483. */
  8484. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8485. /**
  8486. * Lambda to Update an array of float in a uniform buffer.
  8487. * This is dynamic to allow compat with webgl 1 and 2.
  8488. * You will need to pass the name of the uniform as well as the value.
  8489. */
  8490. updateFloatArray: (name: string, array: Float32Array) => void;
  8491. /**
  8492. * Lambda to Update an array of number in a uniform buffer.
  8493. * This is dynamic to allow compat with webgl 1 and 2.
  8494. * You will need to pass the name of the uniform as well as the value.
  8495. */
  8496. updateArray: (name: string, array: number[]) => void;
  8497. /**
  8498. * Lambda to Update an array of number in a uniform buffer.
  8499. * This is dynamic to allow compat with webgl 1 and 2.
  8500. * You will need to pass the name of the uniform as well as the value.
  8501. */
  8502. updateIntArray: (name: string, array: Int32Array) => void;
  8503. /**
  8504. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8505. * This is dynamic to allow compat with webgl 1 and 2.
  8506. * You will need to pass the name of the uniform as well as the value.
  8507. */
  8508. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8509. /**
  8510. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8511. * This is dynamic to allow compat with webgl 1 and 2.
  8512. * You will need to pass the name of the uniform as well as the value.
  8513. */
  8514. updateMatrices: (name: string, mat: Float32Array) => void;
  8515. /**
  8516. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8517. * This is dynamic to allow compat with webgl 1 and 2.
  8518. * You will need to pass the name of the uniform as well as the value.
  8519. */
  8520. updateVector3: (name: string, vector: Vector3) => void;
  8521. /**
  8522. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8523. * This is dynamic to allow compat with webgl 1 and 2.
  8524. * You will need to pass the name of the uniform as well as the value.
  8525. */
  8526. updateVector4: (name: string, vector: Vector4) => void;
  8527. /**
  8528. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8529. * This is dynamic to allow compat with webgl 1 and 2.
  8530. * You will need to pass the name of the uniform as well as the value.
  8531. */
  8532. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8533. /**
  8534. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8535. * This is dynamic to allow compat with webgl 1 and 2.
  8536. * You will need to pass the name of the uniform as well as the value.
  8537. */
  8538. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8539. /**
  8540. * Lambda to Update a int a uniform buffer.
  8541. * This is dynamic to allow compat with webgl 1 and 2.
  8542. * You will need to pass the name of the uniform as well as the value.
  8543. */
  8544. updateInt: (name: string, x: number, suffix?: string) => void;
  8545. /**
  8546. * Lambda to Update a vec2 of int in a uniform buffer.
  8547. * This is dynamic to allow compat with webgl 1 and 2.
  8548. * You will need to pass the name of the uniform as well as the value.
  8549. */
  8550. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8551. /**
  8552. * Lambda to Update a vec3 of int in a uniform buffer.
  8553. * This is dynamic to allow compat with webgl 1 and 2.
  8554. * You will need to pass the name of the uniform as well as the value.
  8555. */
  8556. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8557. /**
  8558. * Lambda to Update a vec4 of int in a uniform buffer.
  8559. * This is dynamic to allow compat with webgl 1 and 2.
  8560. * You will need to pass the name of the uniform as well as the value.
  8561. */
  8562. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8563. /**
  8564. * Instantiates a new Uniform buffer objects.
  8565. *
  8566. * Handles blocks of uniform on the GPU.
  8567. *
  8568. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8569. *
  8570. * For more information, please refer to :
  8571. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8572. * @param engine Define the engine the buffer is associated with
  8573. * @param data Define the data contained in the buffer
  8574. * @param dynamic Define if the buffer is updatable
  8575. * @param name to assign to the buffer (debugging purpose)
  8576. */
  8577. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8578. /**
  8579. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8580. * or just falling back on setUniformXXX calls.
  8581. */
  8582. get useUbo(): boolean;
  8583. /**
  8584. * Indicates if the WebGL underlying uniform buffer is in sync
  8585. * with the javascript cache data.
  8586. */
  8587. get isSync(): boolean;
  8588. /**
  8589. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8590. * Also, a dynamic UniformBuffer will disable cache verification and always
  8591. * update the underlying WebGL uniform buffer to the GPU.
  8592. * @returns if Dynamic, otherwise false
  8593. */
  8594. isDynamic(): boolean;
  8595. /**
  8596. * The data cache on JS side.
  8597. * @returns the underlying data as a float array
  8598. */
  8599. getData(): Float32Array;
  8600. /**
  8601. * The underlying WebGL Uniform buffer.
  8602. * @returns the webgl buffer
  8603. */
  8604. getBuffer(): Nullable<DataBuffer>;
  8605. /**
  8606. * std140 layout specifies how to align data within an UBO structure.
  8607. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8608. * for specs.
  8609. */
  8610. private _fillAlignment;
  8611. /**
  8612. * Adds an uniform in the buffer.
  8613. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8614. * for the layout to be correct !
  8615. * @param name Name of the uniform, as used in the uniform block in the shader.
  8616. * @param size Data size, or data directly.
  8617. * @param arraySize The number of elements in the array, 0 if not an array.
  8618. */
  8619. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8620. /**
  8621. * Adds a Matrix 4x4 to the uniform buffer.
  8622. * @param name Name of the uniform, as used in the uniform block in the shader.
  8623. * @param mat A 4x4 matrix.
  8624. */
  8625. addMatrix(name: string, mat: Matrix): void;
  8626. /**
  8627. * Adds a vec2 to the uniform buffer.
  8628. * @param name Name of the uniform, as used in the uniform block in the shader.
  8629. * @param x Define the x component value of the vec2
  8630. * @param y Define the y component value of the vec2
  8631. */
  8632. addFloat2(name: string, x: number, y: number): void;
  8633. /**
  8634. * Adds a vec3 to the uniform buffer.
  8635. * @param name Name of the uniform, as used in the uniform block in the shader.
  8636. * @param x Define the x component value of the vec3
  8637. * @param y Define the y component value of the vec3
  8638. * @param z Define the z component value of the vec3
  8639. */
  8640. addFloat3(name: string, x: number, y: number, z: number): void;
  8641. /**
  8642. * Adds a vec3 to the uniform buffer.
  8643. * @param name Name of the uniform, as used in the uniform block in the shader.
  8644. * @param color Define the vec3 from a Color
  8645. */
  8646. addColor3(name: string, color: Color3): void;
  8647. /**
  8648. * Adds a vec4 to the uniform buffer.
  8649. * @param name Name of the uniform, as used in the uniform block in the shader.
  8650. * @param color Define the rgb components from a Color
  8651. * @param alpha Define the a component of the vec4
  8652. */
  8653. addColor4(name: string, color: Color3, alpha: number): void;
  8654. /**
  8655. * Adds a vec3 to the uniform buffer.
  8656. * @param name Name of the uniform, as used in the uniform block in the shader.
  8657. * @param vector Define the vec3 components from a Vector
  8658. */
  8659. addVector3(name: string, vector: Vector3): void;
  8660. /**
  8661. * Adds a Matrix 3x3 to the uniform buffer.
  8662. * @param name Name of the uniform, as used in the uniform block in the shader.
  8663. */
  8664. addMatrix3x3(name: string): void;
  8665. /**
  8666. * Adds a Matrix 2x2 to the uniform buffer.
  8667. * @param name Name of the uniform, as used in the uniform block in the shader.
  8668. */
  8669. addMatrix2x2(name: string): void;
  8670. /**
  8671. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8672. */
  8673. create(): void;
  8674. /** @hidden */
  8675. _rebuild(): void;
  8676. /** @hidden */
  8677. get _numBuffers(): number;
  8678. /** @hidden */
  8679. get _indexBuffer(): number;
  8680. /** Gets the name of this buffer */
  8681. get name(): string;
  8682. /**
  8683. * Updates the WebGL Uniform Buffer on the GPU.
  8684. * If the `dynamic` flag is set to true, no cache comparison is done.
  8685. * Otherwise, the buffer will be updated only if the cache differs.
  8686. */
  8687. update(): void;
  8688. private _createNewBuffer;
  8689. private _checkNewFrame;
  8690. /**
  8691. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8692. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8693. * @param data Define the flattened data
  8694. * @param size Define the size of the data.
  8695. */
  8696. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8697. /**
  8698. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8699. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8700. * @param data Define the flattened data
  8701. * @param size Define the size of the data.
  8702. */
  8703. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8704. private _valueCache;
  8705. private _cacheMatrix;
  8706. private _updateMatrix3x3ForUniform;
  8707. private _updateMatrix3x3ForEffect;
  8708. private _updateMatrix2x2ForEffect;
  8709. private _updateMatrix2x2ForUniform;
  8710. private _updateFloatForEffect;
  8711. private _updateFloatForUniform;
  8712. private _updateFloat2ForEffect;
  8713. private _updateFloat2ForUniform;
  8714. private _updateFloat3ForEffect;
  8715. private _updateFloat3ForUniform;
  8716. private _updateFloat4ForEffect;
  8717. private _updateFloat4ForUniform;
  8718. private _updateFloatArrayForEffect;
  8719. private _updateFloatArrayForUniform;
  8720. private _updateArrayForEffect;
  8721. private _updateArrayForUniform;
  8722. private _updateIntArrayForEffect;
  8723. private _updateIntArrayForUniform;
  8724. private _updateMatrixForEffect;
  8725. private _updateMatrixForUniform;
  8726. private _updateMatricesForEffect;
  8727. private _updateMatricesForUniform;
  8728. private _updateVector3ForEffect;
  8729. private _updateVector3ForUniform;
  8730. private _updateVector4ForEffect;
  8731. private _updateVector4ForUniform;
  8732. private _updateColor3ForEffect;
  8733. private _updateColor3ForUniform;
  8734. private _updateColor4ForEffect;
  8735. private _updateColor4ForUniform;
  8736. private _updateIntForEffect;
  8737. private _updateIntForUniform;
  8738. private _updateInt2ForEffect;
  8739. private _updateInt2ForUniform;
  8740. private _updateInt3ForEffect;
  8741. private _updateInt3ForUniform;
  8742. private _updateInt4ForEffect;
  8743. private _updateInt4ForUniform;
  8744. /**
  8745. * Sets a sampler uniform on the effect.
  8746. * @param name Define the name of the sampler.
  8747. * @param texture Define the texture to set in the sampler
  8748. */
  8749. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8750. /**
  8751. * Directly updates the value of the uniform in the cache AND on the GPU.
  8752. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8753. * @param data Define the flattened data
  8754. */
  8755. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8756. /**
  8757. * Binds this uniform buffer to an effect.
  8758. * @param effect Define the effect to bind the buffer to
  8759. * @param name Name of the uniform block in the shader.
  8760. */
  8761. bindToEffect(effect: Effect, name: string): void;
  8762. /**
  8763. * Disposes the uniform buffer.
  8764. */
  8765. dispose(): void;
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/materialDefines" {
  8769. /**
  8770. * Manages the defines for the Material
  8771. */
  8772. export class MaterialDefines {
  8773. /** @hidden */
  8774. protected _keys: string[];
  8775. private _isDirty;
  8776. /** @hidden */
  8777. _renderId: number;
  8778. /** @hidden */
  8779. _areLightsDirty: boolean;
  8780. /** @hidden */
  8781. _areLightsDisposed: boolean;
  8782. /** @hidden */
  8783. _areAttributesDirty: boolean;
  8784. /** @hidden */
  8785. _areTexturesDirty: boolean;
  8786. /** @hidden */
  8787. _areFresnelDirty: boolean;
  8788. /** @hidden */
  8789. _areMiscDirty: boolean;
  8790. /** @hidden */
  8791. _arePrePassDirty: boolean;
  8792. /** @hidden */
  8793. _areImageProcessingDirty: boolean;
  8794. /** @hidden */
  8795. _normals: boolean;
  8796. /** @hidden */
  8797. _uvs: boolean;
  8798. /** @hidden */
  8799. _needNormals: boolean;
  8800. /** @hidden */
  8801. _needUVs: boolean;
  8802. [id: string]: any;
  8803. /**
  8804. * Specifies if the material needs to be re-calculated
  8805. */
  8806. get isDirty(): boolean;
  8807. /**
  8808. * Marks the material to indicate that it has been re-calculated
  8809. */
  8810. markAsProcessed(): void;
  8811. /**
  8812. * Marks the material to indicate that it needs to be re-calculated
  8813. */
  8814. markAsUnprocessed(): void;
  8815. /**
  8816. * Marks the material to indicate all of its defines need to be re-calculated
  8817. */
  8818. markAllAsDirty(): void;
  8819. /**
  8820. * Marks the material to indicate that image processing needs to be re-calculated
  8821. */
  8822. markAsImageProcessingDirty(): void;
  8823. /**
  8824. * Marks the material to indicate the lights need to be re-calculated
  8825. * @param disposed Defines whether the light is dirty due to dispose or not
  8826. */
  8827. markAsLightDirty(disposed?: boolean): void;
  8828. /**
  8829. * Marks the attribute state as changed
  8830. */
  8831. markAsAttributesDirty(): void;
  8832. /**
  8833. * Marks the texture state as changed
  8834. */
  8835. markAsTexturesDirty(): void;
  8836. /**
  8837. * Marks the fresnel state as changed
  8838. */
  8839. markAsFresnelDirty(): void;
  8840. /**
  8841. * Marks the misc state as changed
  8842. */
  8843. markAsMiscDirty(): void;
  8844. /**
  8845. * Marks the prepass state as changed
  8846. */
  8847. markAsPrePassDirty(): void;
  8848. /**
  8849. * Rebuilds the material defines
  8850. */
  8851. rebuild(): void;
  8852. /**
  8853. * Specifies if two material defines are equal
  8854. * @param other - A material define instance to compare to
  8855. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8856. */
  8857. isEqual(other: MaterialDefines): boolean;
  8858. /**
  8859. * Clones this instance's defines to another instance
  8860. * @param other - material defines to clone values to
  8861. */
  8862. cloneTo(other: MaterialDefines): void;
  8863. /**
  8864. * Resets the material define values
  8865. */
  8866. reset(): void;
  8867. /**
  8868. * Converts the material define values to a string
  8869. * @returns - String of material define information
  8870. */
  8871. toString(): string;
  8872. }
  8873. }
  8874. declare module "babylonjs/Misc/iInspectable" {
  8875. /**
  8876. * Enum that determines the text-wrapping mode to use.
  8877. */
  8878. export enum InspectableType {
  8879. /**
  8880. * Checkbox for booleans
  8881. */
  8882. Checkbox = 0,
  8883. /**
  8884. * Sliders for numbers
  8885. */
  8886. Slider = 1,
  8887. /**
  8888. * Vector3
  8889. */
  8890. Vector3 = 2,
  8891. /**
  8892. * Quaternions
  8893. */
  8894. Quaternion = 3,
  8895. /**
  8896. * Color3
  8897. */
  8898. Color3 = 4,
  8899. /**
  8900. * String
  8901. */
  8902. String = 5
  8903. }
  8904. /**
  8905. * Interface used to define custom inspectable properties.
  8906. * This interface is used by the inspector to display custom property grids
  8907. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8908. */
  8909. export interface IInspectable {
  8910. /**
  8911. * Gets the label to display
  8912. */
  8913. label: string;
  8914. /**
  8915. * Gets the name of the property to edit
  8916. */
  8917. propertyName: string;
  8918. /**
  8919. * Gets the type of the editor to use
  8920. */
  8921. type: InspectableType;
  8922. /**
  8923. * Gets the minimum value of the property when using in "slider" mode
  8924. */
  8925. min?: number;
  8926. /**
  8927. * Gets the maximum value of the property when using in "slider" mode
  8928. */
  8929. max?: number;
  8930. /**
  8931. * Gets the setp to use when using in "slider" mode
  8932. */
  8933. step?: number;
  8934. }
  8935. }
  8936. declare module "babylonjs/Lights/light" {
  8937. import { Nullable } from "babylonjs/types";
  8938. import { Scene } from "babylonjs/scene";
  8939. import { Vector3 } from "babylonjs/Maths/math.vector";
  8940. import { Color3 } from "babylonjs/Maths/math.color";
  8941. import { Node } from "babylonjs/node";
  8942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8943. import { Effect } from "babylonjs/Materials/effect";
  8944. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8945. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8946. /**
  8947. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8948. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8949. * 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.
  8950. */
  8951. export abstract class Light extends Node {
  8952. /**
  8953. * Falloff Default: light is falling off following the material specification:
  8954. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8955. */
  8956. static readonly FALLOFF_DEFAULT: number;
  8957. /**
  8958. * Falloff Physical: light is falling off following the inverse squared distance law.
  8959. */
  8960. static readonly FALLOFF_PHYSICAL: number;
  8961. /**
  8962. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8963. * to enhance interoperability with other engines.
  8964. */
  8965. static readonly FALLOFF_GLTF: number;
  8966. /**
  8967. * Falloff Standard: light is falling off like in the standard material
  8968. * to enhance interoperability with other materials.
  8969. */
  8970. static readonly FALLOFF_STANDARD: number;
  8971. /**
  8972. * If every light affecting the material is in this lightmapMode,
  8973. * material.lightmapTexture adds or multiplies
  8974. * (depends on material.useLightmapAsShadowmap)
  8975. * after every other light calculations.
  8976. */
  8977. static readonly LIGHTMAP_DEFAULT: number;
  8978. /**
  8979. * material.lightmapTexture as only diffuse lighting from this light
  8980. * adds only specular lighting from this light
  8981. * adds dynamic shadows
  8982. */
  8983. static readonly LIGHTMAP_SPECULAR: number;
  8984. /**
  8985. * material.lightmapTexture as only lighting
  8986. * no light calculation from this light
  8987. * only adds dynamic shadows from this light
  8988. */
  8989. static readonly LIGHTMAP_SHADOWSONLY: number;
  8990. /**
  8991. * Each light type uses the default quantity according to its type:
  8992. * point/spot lights use luminous intensity
  8993. * directional lights use illuminance
  8994. */
  8995. static readonly INTENSITYMODE_AUTOMATIC: number;
  8996. /**
  8997. * lumen (lm)
  8998. */
  8999. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9000. /**
  9001. * candela (lm/sr)
  9002. */
  9003. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9004. /**
  9005. * lux (lm/m^2)
  9006. */
  9007. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9008. /**
  9009. * nit (cd/m^2)
  9010. */
  9011. static readonly INTENSITYMODE_LUMINANCE: number;
  9012. /**
  9013. * Light type const id of the point light.
  9014. */
  9015. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9016. /**
  9017. * Light type const id of the directional light.
  9018. */
  9019. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9020. /**
  9021. * Light type const id of the spot light.
  9022. */
  9023. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9024. /**
  9025. * Light type const id of the hemispheric light.
  9026. */
  9027. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9028. /**
  9029. * Diffuse gives the basic color to an object.
  9030. */
  9031. diffuse: Color3;
  9032. /**
  9033. * Specular produces a highlight color on an object.
  9034. * Note: This is note affecting PBR materials.
  9035. */
  9036. specular: Color3;
  9037. /**
  9038. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9039. * falling off base on range or angle.
  9040. * This can be set to any values in Light.FALLOFF_x.
  9041. *
  9042. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9043. * other types of materials.
  9044. */
  9045. falloffType: number;
  9046. /**
  9047. * Strength of the light.
  9048. * Note: By default it is define in the framework own unit.
  9049. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9050. */
  9051. intensity: number;
  9052. private _range;
  9053. protected _inverseSquaredRange: number;
  9054. /**
  9055. * Defines how far from the source the light is impacting in scene units.
  9056. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9057. */
  9058. get range(): number;
  9059. /**
  9060. * Defines how far from the source the light is impacting in scene units.
  9061. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9062. */
  9063. set range(value: number);
  9064. /**
  9065. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9066. * of light.
  9067. */
  9068. private _photometricScale;
  9069. private _intensityMode;
  9070. /**
  9071. * Gets the photometric scale used to interpret the intensity.
  9072. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9073. */
  9074. get intensityMode(): number;
  9075. /**
  9076. * Sets the photometric scale used to interpret the intensity.
  9077. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9078. */
  9079. set intensityMode(value: number);
  9080. private _radius;
  9081. /**
  9082. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9083. */
  9084. get radius(): number;
  9085. /**
  9086. * sets the light radius used by PBR Materials to simulate soft area lights.
  9087. */
  9088. set radius(value: number);
  9089. private _renderPriority;
  9090. /**
  9091. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9092. * exceeding the number allowed of the materials.
  9093. */
  9094. renderPriority: number;
  9095. private _shadowEnabled;
  9096. /**
  9097. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9098. * the current shadow generator.
  9099. */
  9100. get shadowEnabled(): boolean;
  9101. /**
  9102. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9103. * the current shadow generator.
  9104. */
  9105. set shadowEnabled(value: boolean);
  9106. private _includedOnlyMeshes;
  9107. /**
  9108. * Gets the only meshes impacted by this light.
  9109. */
  9110. get includedOnlyMeshes(): AbstractMesh[];
  9111. /**
  9112. * Sets the only meshes impacted by this light.
  9113. */
  9114. set includedOnlyMeshes(value: AbstractMesh[]);
  9115. private _excludedMeshes;
  9116. /**
  9117. * Gets the meshes not impacted by this light.
  9118. */
  9119. get excludedMeshes(): AbstractMesh[];
  9120. /**
  9121. * Sets the meshes not impacted by this light.
  9122. */
  9123. set excludedMeshes(value: AbstractMesh[]);
  9124. private _excludeWithLayerMask;
  9125. /**
  9126. * Gets the layer id use to find what meshes are not impacted by the light.
  9127. * Inactive if 0
  9128. */
  9129. get excludeWithLayerMask(): number;
  9130. /**
  9131. * Sets the layer id use to find what meshes are not impacted by the light.
  9132. * Inactive if 0
  9133. */
  9134. set excludeWithLayerMask(value: number);
  9135. private _includeOnlyWithLayerMask;
  9136. /**
  9137. * Gets the layer id use to find what meshes are impacted by the light.
  9138. * Inactive if 0
  9139. */
  9140. get includeOnlyWithLayerMask(): number;
  9141. /**
  9142. * Sets the layer id use to find what meshes are impacted by the light.
  9143. * Inactive if 0
  9144. */
  9145. set includeOnlyWithLayerMask(value: number);
  9146. private _lightmapMode;
  9147. /**
  9148. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9149. */
  9150. get lightmapMode(): number;
  9151. /**
  9152. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9153. */
  9154. set lightmapMode(value: number);
  9155. /**
  9156. * Shadow generator associted to the light.
  9157. * @hidden Internal use only.
  9158. */
  9159. _shadowGenerator: Nullable<IShadowGenerator>;
  9160. /**
  9161. * @hidden Internal use only.
  9162. */
  9163. _excludedMeshesIds: string[];
  9164. /**
  9165. * @hidden Internal use only.
  9166. */
  9167. _includedOnlyMeshesIds: string[];
  9168. /**
  9169. * The current light unifom buffer.
  9170. * @hidden Internal use only.
  9171. */
  9172. _uniformBuffer: UniformBuffer;
  9173. /** @hidden */
  9174. _renderId: number;
  9175. /**
  9176. * Creates a Light object in the scene.
  9177. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9178. * @param name The firendly name of the light
  9179. * @param scene The scene the light belongs too
  9180. */
  9181. constructor(name: string, scene: Scene);
  9182. protected abstract _buildUniformLayout(): void;
  9183. /**
  9184. * Sets the passed Effect "effect" with the Light information.
  9185. * @param effect The effect to update
  9186. * @param lightIndex The index of the light in the effect to update
  9187. * @returns The light
  9188. */
  9189. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9190. /**
  9191. * Sets the passed Effect "effect" with the Light textures.
  9192. * @param effect The effect to update
  9193. * @param lightIndex The index of the light in the effect to update
  9194. * @returns The light
  9195. */
  9196. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9197. /**
  9198. * Binds the lights information from the scene to the effect for the given mesh.
  9199. * @param lightIndex Light index
  9200. * @param scene The scene where the light belongs to
  9201. * @param effect The effect we are binding the data to
  9202. * @param useSpecular Defines if specular is supported
  9203. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9204. */
  9205. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9206. /**
  9207. * Sets the passed Effect "effect" with the Light information.
  9208. * @param effect The effect to update
  9209. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9210. * @returns The light
  9211. */
  9212. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9213. /**
  9214. * Returns the string "Light".
  9215. * @returns the class name
  9216. */
  9217. getClassName(): string;
  9218. /** @hidden */
  9219. readonly _isLight: boolean;
  9220. /**
  9221. * Converts the light information to a readable string for debug purpose.
  9222. * @param fullDetails Supports for multiple levels of logging within scene loading
  9223. * @returns the human readable light info
  9224. */
  9225. toString(fullDetails?: boolean): string;
  9226. /** @hidden */
  9227. protected _syncParentEnabledState(): void;
  9228. /**
  9229. * Set the enabled state of this node.
  9230. * @param value - the new enabled state
  9231. */
  9232. setEnabled(value: boolean): void;
  9233. /**
  9234. * Returns the Light associated shadow generator if any.
  9235. * @return the associated shadow generator.
  9236. */
  9237. getShadowGenerator(): Nullable<IShadowGenerator>;
  9238. /**
  9239. * Returns a Vector3, the absolute light position in the World.
  9240. * @returns the world space position of the light
  9241. */
  9242. getAbsolutePosition(): Vector3;
  9243. /**
  9244. * Specifies if the light will affect the passed mesh.
  9245. * @param mesh The mesh to test against the light
  9246. * @return true the mesh is affected otherwise, false.
  9247. */
  9248. canAffectMesh(mesh: AbstractMesh): boolean;
  9249. /**
  9250. * Sort function to order lights for rendering.
  9251. * @param a First Light object to compare to second.
  9252. * @param b Second Light object to compare first.
  9253. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9254. */
  9255. static CompareLightsPriority(a: Light, b: Light): number;
  9256. /**
  9257. * Releases resources associated with this node.
  9258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9260. */
  9261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9262. /**
  9263. * Returns the light type ID (integer).
  9264. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9265. */
  9266. getTypeID(): number;
  9267. /**
  9268. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9269. * @returns the scaled intensity in intensity mode unit
  9270. */
  9271. getScaledIntensity(): number;
  9272. /**
  9273. * Returns a new Light object, named "name", from the current one.
  9274. * @param name The name of the cloned light
  9275. * @param newParent The parent of this light, if it has one
  9276. * @returns the new created light
  9277. */
  9278. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9279. /**
  9280. * Serializes the current light into a Serialization object.
  9281. * @returns the serialized object.
  9282. */
  9283. serialize(): any;
  9284. /**
  9285. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9286. * This new light is named "name" and added to the passed scene.
  9287. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9288. * @param name The friendly name of the light
  9289. * @param scene The scene the new light will belong to
  9290. * @returns the constructor function
  9291. */
  9292. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9293. /**
  9294. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9295. * @param parsedLight The JSON representation of the light
  9296. * @param scene The scene to create the parsed light in
  9297. * @returns the created light after parsing
  9298. */
  9299. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9300. private _hookArrayForExcluded;
  9301. private _hookArrayForIncludedOnly;
  9302. private _resyncMeshes;
  9303. /**
  9304. * Forces the meshes to update their light related information in their rendering used effects
  9305. * @hidden Internal Use Only
  9306. */
  9307. _markMeshesAsLightDirty(): void;
  9308. /**
  9309. * Recomputes the cached photometric scale if needed.
  9310. */
  9311. private _computePhotometricScale;
  9312. /**
  9313. * Returns the Photometric Scale according to the light type and intensity mode.
  9314. */
  9315. private _getPhotometricScale;
  9316. /**
  9317. * Reorder the light in the scene according to their defined priority.
  9318. * @hidden Internal Use Only
  9319. */
  9320. _reorderLightsInScene(): void;
  9321. /**
  9322. * Prepares the list of defines specific to the light type.
  9323. * @param defines the list of defines
  9324. * @param lightIndex defines the index of the light for the effect
  9325. */
  9326. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9327. }
  9328. }
  9329. declare module "babylonjs/Maths/math.axis" {
  9330. import { Vector3 } from "babylonjs/Maths/math.vector";
  9331. /** Defines supported spaces */
  9332. export enum Space {
  9333. /** Local (object) space */
  9334. LOCAL = 0,
  9335. /** World space */
  9336. WORLD = 1,
  9337. /** Bone space */
  9338. BONE = 2
  9339. }
  9340. /** Defines the 3 main axes */
  9341. export class Axis {
  9342. /** X axis */
  9343. static X: Vector3;
  9344. /** Y axis */
  9345. static Y: Vector3;
  9346. /** Z axis */
  9347. static Z: Vector3;
  9348. }
  9349. /**
  9350. * Defines cartesian components.
  9351. */
  9352. export enum Coordinate {
  9353. /** X axis */
  9354. X = 0,
  9355. /** Y axis */
  9356. Y = 1,
  9357. /** Z axis */
  9358. Z = 2
  9359. }
  9360. }
  9361. declare module "babylonjs/Lights/shadowLight" {
  9362. import { Camera } from "babylonjs/Cameras/camera";
  9363. import { Scene } from "babylonjs/scene";
  9364. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9366. import { Light } from "babylonjs/Lights/light";
  9367. /**
  9368. * Interface describing all the common properties and methods a shadow light needs to implement.
  9369. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9370. * as well as binding the different shadow properties to the effects.
  9371. */
  9372. export interface IShadowLight extends Light {
  9373. /**
  9374. * The light id in the scene (used in scene.findLighById for instance)
  9375. */
  9376. id: string;
  9377. /**
  9378. * The position the shdow will be casted from.
  9379. */
  9380. position: Vector3;
  9381. /**
  9382. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9383. */
  9384. direction: Vector3;
  9385. /**
  9386. * The transformed position. Position of the light in world space taking parenting in account.
  9387. */
  9388. transformedPosition: Vector3;
  9389. /**
  9390. * The transformed direction. Direction of the light in world space taking parenting in account.
  9391. */
  9392. transformedDirection: Vector3;
  9393. /**
  9394. * The friendly name of the light in the scene.
  9395. */
  9396. name: string;
  9397. /**
  9398. * Defines the shadow projection clipping minimum z value.
  9399. */
  9400. shadowMinZ: number;
  9401. /**
  9402. * Defines the shadow projection clipping maximum z value.
  9403. */
  9404. shadowMaxZ: number;
  9405. /**
  9406. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9407. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9408. */
  9409. computeTransformedInformation(): boolean;
  9410. /**
  9411. * Gets the scene the light belongs to.
  9412. * @returns The scene
  9413. */
  9414. getScene(): Scene;
  9415. /**
  9416. * Callback defining a custom Projection Matrix Builder.
  9417. * This can be used to override the default projection matrix computation.
  9418. */
  9419. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9420. /**
  9421. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9422. * @param matrix The materix to updated with the projection information
  9423. * @param viewMatrix The transform matrix of the light
  9424. * @param renderList The list of mesh to render in the map
  9425. * @returns The current light
  9426. */
  9427. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9428. /**
  9429. * Gets the current depth scale used in ESM.
  9430. * @returns The scale
  9431. */
  9432. getDepthScale(): number;
  9433. /**
  9434. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9435. * @returns true if a cube texture needs to be use
  9436. */
  9437. needCube(): boolean;
  9438. /**
  9439. * Detects if the projection matrix requires to be recomputed this frame.
  9440. * @returns true if it requires to be recomputed otherwise, false.
  9441. */
  9442. needProjectionMatrixCompute(): boolean;
  9443. /**
  9444. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9445. */
  9446. forceProjectionMatrixCompute(): void;
  9447. /**
  9448. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9449. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9450. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9451. */
  9452. getShadowDirection(faceIndex?: number): Vector3;
  9453. /**
  9454. * Gets the minZ used for shadow according to both the scene and the light.
  9455. * @param activeCamera The camera we are returning the min for
  9456. * @returns the depth min z
  9457. */
  9458. getDepthMinZ(activeCamera: Camera): number;
  9459. /**
  9460. * Gets the maxZ used for shadow according to both the scene and the light.
  9461. * @param activeCamera The camera we are returning the max for
  9462. * @returns the depth max z
  9463. */
  9464. getDepthMaxZ(activeCamera: Camera): number;
  9465. }
  9466. /**
  9467. * Base implementation IShadowLight
  9468. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9469. */
  9470. export abstract class ShadowLight extends Light implements IShadowLight {
  9471. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9472. protected _position: Vector3;
  9473. protected _setPosition(value: Vector3): void;
  9474. /**
  9475. * Sets the position the shadow will be casted from. Also use as the light position for both
  9476. * point and spot lights.
  9477. */
  9478. get position(): Vector3;
  9479. /**
  9480. * Sets the position the shadow will be casted from. Also use as the light position for both
  9481. * point and spot lights.
  9482. */
  9483. set position(value: Vector3);
  9484. protected _direction: Vector3;
  9485. protected _setDirection(value: Vector3): void;
  9486. /**
  9487. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9488. * Also use as the light direction on spot and directional lights.
  9489. */
  9490. get direction(): Vector3;
  9491. /**
  9492. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9493. * Also use as the light direction on spot and directional lights.
  9494. */
  9495. set direction(value: Vector3);
  9496. protected _shadowMinZ: number;
  9497. /**
  9498. * Gets the shadow projection clipping minimum z value.
  9499. */
  9500. get shadowMinZ(): number;
  9501. /**
  9502. * Sets the shadow projection clipping minimum z value.
  9503. */
  9504. set shadowMinZ(value: number);
  9505. protected _shadowMaxZ: number;
  9506. /**
  9507. * Sets the shadow projection clipping maximum z value.
  9508. */
  9509. get shadowMaxZ(): number;
  9510. /**
  9511. * Gets the shadow projection clipping maximum z value.
  9512. */
  9513. set shadowMaxZ(value: number);
  9514. /**
  9515. * Callback defining a custom Projection Matrix Builder.
  9516. * This can be used to override the default projection matrix computation.
  9517. */
  9518. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9519. /**
  9520. * The transformed position. Position of the light in world space taking parenting in account.
  9521. */
  9522. transformedPosition: Vector3;
  9523. /**
  9524. * The transformed direction. Direction of the light in world space taking parenting in account.
  9525. */
  9526. transformedDirection: Vector3;
  9527. private _needProjectionMatrixCompute;
  9528. /**
  9529. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9530. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9531. */
  9532. computeTransformedInformation(): boolean;
  9533. /**
  9534. * Return the depth scale used for the shadow map.
  9535. * @returns the depth scale.
  9536. */
  9537. getDepthScale(): number;
  9538. /**
  9539. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9540. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9541. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9542. */
  9543. getShadowDirection(faceIndex?: number): Vector3;
  9544. /**
  9545. * Returns the ShadowLight absolute position in the World.
  9546. * @returns the position vector in world space
  9547. */
  9548. getAbsolutePosition(): Vector3;
  9549. /**
  9550. * Sets the ShadowLight direction toward the passed target.
  9551. * @param target The point to target in local space
  9552. * @returns the updated ShadowLight direction
  9553. */
  9554. setDirectionToTarget(target: Vector3): Vector3;
  9555. /**
  9556. * Returns the light rotation in euler definition.
  9557. * @returns the x y z rotation in local space.
  9558. */
  9559. getRotation(): Vector3;
  9560. /**
  9561. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9562. * @returns true if a cube texture needs to be use
  9563. */
  9564. needCube(): boolean;
  9565. /**
  9566. * Detects if the projection matrix requires to be recomputed this frame.
  9567. * @returns true if it requires to be recomputed otherwise, false.
  9568. */
  9569. needProjectionMatrixCompute(): boolean;
  9570. /**
  9571. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9572. */
  9573. forceProjectionMatrixCompute(): void;
  9574. /** @hidden */
  9575. _initCache(): void;
  9576. /** @hidden */
  9577. _isSynchronized(): boolean;
  9578. /**
  9579. * Computes the world matrix of the node
  9580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9581. * @returns the world matrix
  9582. */
  9583. computeWorldMatrix(force?: boolean): Matrix;
  9584. /**
  9585. * Gets the minZ used for shadow according to both the scene and the light.
  9586. * @param activeCamera The camera we are returning the min for
  9587. * @returns the depth min z
  9588. */
  9589. getDepthMinZ(activeCamera: Camera): number;
  9590. /**
  9591. * Gets the maxZ used for shadow according to both the scene and the light.
  9592. * @param activeCamera The camera we are returning the max for
  9593. * @returns the depth max z
  9594. */
  9595. getDepthMaxZ(activeCamera: Camera): number;
  9596. /**
  9597. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9598. * @param matrix The materix to updated with the projection information
  9599. * @param viewMatrix The transform matrix of the light
  9600. * @param renderList The list of mesh to render in the map
  9601. * @returns The current light
  9602. */
  9603. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9604. }
  9605. }
  9606. declare module "babylonjs/Materials/prePassConfiguration" {
  9607. import { Matrix } from "babylonjs/Maths/math.vector";
  9608. import { Mesh } from "babylonjs/Meshes/mesh";
  9609. import { Scene } from "babylonjs/scene";
  9610. import { Effect } from "babylonjs/Materials/effect";
  9611. /**
  9612. * Configuration needed for prepass-capable materials
  9613. */
  9614. export class PrePassConfiguration {
  9615. /**
  9616. * Previous world matrices of meshes carrying this material
  9617. * Used for computing velocity
  9618. */
  9619. previousWorldMatrices: {
  9620. [index: number]: Matrix;
  9621. };
  9622. /**
  9623. * Previous view project matrix
  9624. * Used for computing velocity
  9625. */
  9626. previousViewProjection: Matrix;
  9627. /**
  9628. * Previous bones of meshes carrying this material
  9629. * Used for computing velocity
  9630. */
  9631. previousBones: {
  9632. [index: number]: Float32Array;
  9633. };
  9634. /**
  9635. * Add the required uniforms to the current list.
  9636. * @param uniforms defines the current uniform list.
  9637. */
  9638. static AddUniforms(uniforms: string[]): void;
  9639. /**
  9640. * Add the required samplers to the current list.
  9641. * @param samplers defines the current sampler list.
  9642. */
  9643. static AddSamplers(samplers: string[]): void;
  9644. /**
  9645. * Binds the material data.
  9646. * @param effect defines the effect to update
  9647. * @param scene defines the scene the material belongs to.
  9648. * @param mesh The mesh
  9649. * @param world World matrix of this mesh
  9650. * @param isFrozen Is the material frozen
  9651. */
  9652. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9653. }
  9654. }
  9655. declare module "babylonjs/Cameras/targetCamera" {
  9656. import { Nullable } from "babylonjs/types";
  9657. import { Camera } from "babylonjs/Cameras/camera";
  9658. import { Scene } from "babylonjs/scene";
  9659. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9660. /**
  9661. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9662. * This is the base of the follow, arc rotate cameras and Free camera
  9663. * @see https://doc.babylonjs.com/features/cameras
  9664. */
  9665. export class TargetCamera extends Camera {
  9666. private static _RigCamTransformMatrix;
  9667. private static _TargetTransformMatrix;
  9668. private static _TargetFocalPoint;
  9669. private _tmpUpVector;
  9670. private _tmpTargetVector;
  9671. /**
  9672. * Define the current direction the camera is moving to
  9673. */
  9674. cameraDirection: Vector3;
  9675. /**
  9676. * Define the current rotation the camera is rotating to
  9677. */
  9678. cameraRotation: Vector2;
  9679. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9680. ignoreParentScaling: boolean;
  9681. /**
  9682. * When set, the up vector of the camera will be updated by the rotation of the camera
  9683. */
  9684. updateUpVectorFromRotation: boolean;
  9685. private _tmpQuaternion;
  9686. /**
  9687. * Define the current rotation of the camera
  9688. */
  9689. rotation: Vector3;
  9690. /**
  9691. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9692. */
  9693. rotationQuaternion: Quaternion;
  9694. /**
  9695. * Define the current speed of the camera
  9696. */
  9697. speed: number;
  9698. /**
  9699. * Add constraint to the camera to prevent it to move freely in all directions and
  9700. * around all axis.
  9701. */
  9702. noRotationConstraint: boolean;
  9703. /**
  9704. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9705. * panning
  9706. */
  9707. invertRotation: boolean;
  9708. /**
  9709. * Speed multiplier for inverse camera panning
  9710. */
  9711. inverseRotationSpeed: number;
  9712. /**
  9713. * Define the current target of the camera as an object or a position.
  9714. */
  9715. lockedTarget: any;
  9716. /** @hidden */
  9717. _currentTarget: Vector3;
  9718. /** @hidden */
  9719. _initialFocalDistance: number;
  9720. /** @hidden */
  9721. _viewMatrix: Matrix;
  9722. /** @hidden */
  9723. _camMatrix: Matrix;
  9724. /** @hidden */
  9725. _cameraTransformMatrix: Matrix;
  9726. /** @hidden */
  9727. _cameraRotationMatrix: Matrix;
  9728. /** @hidden */
  9729. _referencePoint: Vector3;
  9730. /** @hidden */
  9731. _transformedReferencePoint: Vector3;
  9732. /** @hidden */
  9733. _reset: () => void;
  9734. private _defaultUp;
  9735. /**
  9736. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9737. * This is the base of the follow, arc rotate cameras and Free camera
  9738. * @see https://doc.babylonjs.com/features/cameras
  9739. * @param name Defines the name of the camera in the scene
  9740. * @param position Defines the start position of the camera in the scene
  9741. * @param scene Defines the scene the camera belongs to
  9742. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9743. */
  9744. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9745. /**
  9746. * Gets the position in front of the camera at a given distance.
  9747. * @param distance The distance from the camera we want the position to be
  9748. * @returns the position
  9749. */
  9750. getFrontPosition(distance: number): Vector3;
  9751. /** @hidden */
  9752. _getLockedTargetPosition(): Nullable<Vector3>;
  9753. private _storedPosition;
  9754. private _storedRotation;
  9755. private _storedRotationQuaternion;
  9756. /**
  9757. * Store current camera state of the camera (fov, position, rotation, etc..)
  9758. * @returns the camera
  9759. */
  9760. storeState(): Camera;
  9761. /**
  9762. * Restored camera state. You must call storeState() first
  9763. * @returns whether it was successful or not
  9764. * @hidden
  9765. */
  9766. _restoreStateValues(): boolean;
  9767. /** @hidden */
  9768. _initCache(): void;
  9769. /** @hidden */
  9770. _updateCache(ignoreParentClass?: boolean): void;
  9771. /** @hidden */
  9772. _isSynchronizedViewMatrix(): boolean;
  9773. /** @hidden */
  9774. _computeLocalCameraSpeed(): number;
  9775. /**
  9776. * Defines the target the camera should look at.
  9777. * @param target Defines the new target as a Vector or a mesh
  9778. */
  9779. setTarget(target: Vector3): void;
  9780. /**
  9781. * Defines the target point of the camera.
  9782. * The camera looks towards it form the radius distance.
  9783. */
  9784. get target(): Vector3;
  9785. set target(value: Vector3);
  9786. /**
  9787. * Return the current target position of the camera. This value is expressed in local space.
  9788. * @returns the target position
  9789. */
  9790. getTarget(): Vector3;
  9791. /** @hidden */
  9792. _decideIfNeedsToMove(): boolean;
  9793. /** @hidden */
  9794. _updatePosition(): void;
  9795. /** @hidden */
  9796. _checkInputs(): void;
  9797. protected _updateCameraRotationMatrix(): void;
  9798. /**
  9799. * 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)
  9800. * @returns the current camera
  9801. */
  9802. private _rotateUpVectorWithCameraRotationMatrix;
  9803. private _cachedRotationZ;
  9804. private _cachedQuaternionRotationZ;
  9805. /** @hidden */
  9806. _getViewMatrix(): Matrix;
  9807. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9808. /**
  9809. * @hidden
  9810. */
  9811. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9812. /**
  9813. * @hidden
  9814. */
  9815. _updateRigCameras(): void;
  9816. private _getRigCamPositionAndTarget;
  9817. /**
  9818. * Gets the current object class name.
  9819. * @return the class name
  9820. */
  9821. getClassName(): string;
  9822. }
  9823. }
  9824. declare module "babylonjs/Cameras/cameraInputsManager" {
  9825. import { Nullable } from "babylonjs/types";
  9826. import { Camera } from "babylonjs/Cameras/camera";
  9827. /**
  9828. * @ignore
  9829. * This is a list of all the different input types that are available in the application.
  9830. * Fo instance: ArcRotateCameraGamepadInput...
  9831. */
  9832. export var CameraInputTypes: {};
  9833. /**
  9834. * This is the contract to implement in order to create a new input class.
  9835. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9836. */
  9837. export interface ICameraInput<TCamera extends Camera> {
  9838. /**
  9839. * Defines the camera the input is attached to.
  9840. */
  9841. camera: Nullable<TCamera>;
  9842. /**
  9843. * Gets the class name of the current intput.
  9844. * @returns the class name
  9845. */
  9846. getClassName(): string;
  9847. /**
  9848. * Get the friendly name associated with the input class.
  9849. * @returns the input friendly name
  9850. */
  9851. getSimpleName(): string;
  9852. /**
  9853. * Attach the input controls to a specific dom element to get the input from.
  9854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9855. */
  9856. attachControl(noPreventDefault?: boolean): void;
  9857. /**
  9858. * Detach the current controls from the specified dom element.
  9859. */
  9860. detachControl(): void;
  9861. /**
  9862. * Update the current camera state depending on the inputs that have been used this frame.
  9863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9864. */
  9865. checkInputs?: () => void;
  9866. }
  9867. /**
  9868. * Represents a map of input types to input instance or input index to input instance.
  9869. */
  9870. export interface CameraInputsMap<TCamera extends Camera> {
  9871. /**
  9872. * Accessor to the input by input type.
  9873. */
  9874. [name: string]: ICameraInput<TCamera>;
  9875. /**
  9876. * Accessor to the input by input index.
  9877. */
  9878. [idx: number]: ICameraInput<TCamera>;
  9879. }
  9880. /**
  9881. * This represents the input manager used within a camera.
  9882. * It helps dealing with all the different kind of input attached to a camera.
  9883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9884. */
  9885. export class CameraInputsManager<TCamera extends Camera> {
  9886. /**
  9887. * Defines the list of inputs attahed to the camera.
  9888. */
  9889. attached: CameraInputsMap<TCamera>;
  9890. /**
  9891. * Defines the dom element the camera is collecting inputs from.
  9892. * This is null if the controls have not been attached.
  9893. */
  9894. attachedToElement: boolean;
  9895. /**
  9896. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9897. */
  9898. noPreventDefault: boolean;
  9899. /**
  9900. * Defined the camera the input manager belongs to.
  9901. */
  9902. camera: TCamera;
  9903. /**
  9904. * Update the current camera state depending on the inputs that have been used this frame.
  9905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9906. */
  9907. checkInputs: () => void;
  9908. /**
  9909. * Instantiate a new Camera Input Manager.
  9910. * @param camera Defines the camera the input manager blongs to
  9911. */
  9912. constructor(camera: TCamera);
  9913. /**
  9914. * Add an input method to a camera
  9915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9916. * @param input camera input method
  9917. */
  9918. add(input: ICameraInput<TCamera>): void;
  9919. /**
  9920. * Remove a specific input method from a camera
  9921. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9922. * @param inputToRemove camera input method
  9923. */
  9924. remove(inputToRemove: ICameraInput<TCamera>): void;
  9925. /**
  9926. * Remove a specific input type from a camera
  9927. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9928. * @param inputType the type of the input to remove
  9929. */
  9930. removeByType(inputType: string): void;
  9931. private _addCheckInputs;
  9932. /**
  9933. * Attach the input controls to the currently attached dom element to listen the events from.
  9934. * @param input Defines the input to attach
  9935. */
  9936. attachInput(input: ICameraInput<TCamera>): void;
  9937. /**
  9938. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9939. * @param element Defines the dom element to collect the events from
  9940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9941. */
  9942. attachElement(noPreventDefault?: boolean): void;
  9943. /**
  9944. * Detach the current manager inputs controls from a specific dom element.
  9945. * @param element Defines the dom element to collect the events from
  9946. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9947. */
  9948. detachElement(disconnect?: boolean): void;
  9949. /**
  9950. * Rebuild the dynamic inputCheck function from the current list of
  9951. * defined inputs in the manager.
  9952. */
  9953. rebuildInputCheck(): void;
  9954. /**
  9955. * Remove all attached input methods from a camera
  9956. */
  9957. clear(): void;
  9958. /**
  9959. * Serialize the current input manager attached to a camera.
  9960. * This ensures than once parsed,
  9961. * the input associated to the camera will be identical to the current ones
  9962. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9963. */
  9964. serialize(serializedCamera: any): void;
  9965. /**
  9966. * Parses an input manager serialized JSON to restore the previous list of inputs
  9967. * and states associated to a camera.
  9968. * @param parsedCamera Defines the JSON to parse
  9969. */
  9970. parse(parsedCamera: any): void;
  9971. }
  9972. }
  9973. declare module "babylonjs/Events/keyboardEvents" {
  9974. /**
  9975. * Gather the list of keyboard event types as constants.
  9976. */
  9977. export class KeyboardEventTypes {
  9978. /**
  9979. * The keydown event is fired when a key becomes active (pressed).
  9980. */
  9981. static readonly KEYDOWN: number;
  9982. /**
  9983. * The keyup event is fired when a key has been released.
  9984. */
  9985. static readonly KEYUP: number;
  9986. }
  9987. /**
  9988. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9989. */
  9990. export class KeyboardInfo {
  9991. /**
  9992. * Defines the type of event (KeyboardEventTypes)
  9993. */
  9994. type: number;
  9995. /**
  9996. * Defines the related dom event
  9997. */
  9998. event: KeyboardEvent;
  9999. /**
  10000. * Instantiates a new keyboard info.
  10001. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10002. * @param type Defines the type of event (KeyboardEventTypes)
  10003. * @param event Defines the related dom event
  10004. */
  10005. constructor(
  10006. /**
  10007. * Defines the type of event (KeyboardEventTypes)
  10008. */
  10009. type: number,
  10010. /**
  10011. * Defines the related dom event
  10012. */
  10013. event: KeyboardEvent);
  10014. }
  10015. /**
  10016. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10017. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  10018. */
  10019. export class KeyboardInfoPre extends KeyboardInfo {
  10020. /**
  10021. * Defines the type of event (KeyboardEventTypes)
  10022. */
  10023. type: number;
  10024. /**
  10025. * Defines the related dom event
  10026. */
  10027. event: KeyboardEvent;
  10028. /**
  10029. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  10030. */
  10031. skipOnPointerObservable: boolean;
  10032. /**
  10033. * Instantiates a new keyboard pre info.
  10034. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10035. * @param type Defines the type of event (KeyboardEventTypes)
  10036. * @param event Defines the related dom event
  10037. */
  10038. constructor(
  10039. /**
  10040. * Defines the type of event (KeyboardEventTypes)
  10041. */
  10042. type: number,
  10043. /**
  10044. * Defines the related dom event
  10045. */
  10046. event: KeyboardEvent);
  10047. }
  10048. }
  10049. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  10050. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10051. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10052. /**
  10053. * Manage the keyboard inputs to control the movement of a free camera.
  10054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  10055. */
  10056. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  10057. /**
  10058. * Defines the camera the input is attached to.
  10059. */
  10060. camera: FreeCamera;
  10061. /**
  10062. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  10063. */
  10064. keysUp: number[];
  10065. /**
  10066. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10067. */
  10068. keysUpward: number[];
  10069. /**
  10070. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10071. */
  10072. keysDown: number[];
  10073. /**
  10074. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10075. */
  10076. keysDownward: number[];
  10077. /**
  10078. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10079. */
  10080. keysLeft: number[];
  10081. /**
  10082. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10083. */
  10084. keysRight: number[];
  10085. private _keys;
  10086. private _onCanvasBlurObserver;
  10087. private _onKeyboardObserver;
  10088. private _engine;
  10089. private _scene;
  10090. /**
  10091. * Attach the input controls to a specific dom element to get the input from.
  10092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10093. */
  10094. attachControl(noPreventDefault?: boolean): void;
  10095. /**
  10096. * Detach the current controls from the specified dom element.
  10097. */
  10098. detachControl(): void;
  10099. /**
  10100. * Update the current camera state depending on the inputs that have been used this frame.
  10101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10102. */
  10103. checkInputs(): void;
  10104. /**
  10105. * Gets the class name of the current intput.
  10106. * @returns the class name
  10107. */
  10108. getClassName(): string;
  10109. /** @hidden */
  10110. _onLostFocus(): void;
  10111. /**
  10112. * Get the friendly name associated with the input class.
  10113. * @returns the input friendly name
  10114. */
  10115. getSimpleName(): string;
  10116. }
  10117. }
  10118. declare module "babylonjs/Actions/action" {
  10119. import { Observable } from "babylonjs/Misc/observable";
  10120. import { Condition } from "babylonjs/Actions/condition";
  10121. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10122. import { Nullable } from "babylonjs/types";
  10123. import { Scene } from "babylonjs/scene";
  10124. import { ActionManager } from "babylonjs/Actions/actionManager";
  10125. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10126. import { Node } from "babylonjs/node";
  10127. /**
  10128. * Interface used to define Action
  10129. */
  10130. export interface IAction {
  10131. /**
  10132. * Trigger for the action
  10133. */
  10134. trigger: number;
  10135. /** Options of the trigger */
  10136. triggerOptions: any;
  10137. /**
  10138. * Gets the trigger parameters
  10139. * @returns the trigger parameters
  10140. */
  10141. getTriggerParameter(): any;
  10142. /**
  10143. * Internal only - executes current action event
  10144. * @hidden
  10145. */
  10146. _executeCurrent(evt?: ActionEvent): void;
  10147. /**
  10148. * Serialize placeholder for child classes
  10149. * @param parent of child
  10150. * @returns the serialized object
  10151. */
  10152. serialize(parent: any): any;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _prepare(): void;
  10158. /**
  10159. * Internal only - manager for action
  10160. * @hidden
  10161. */
  10162. _actionManager: Nullable<AbstractActionManager>;
  10163. /**
  10164. * Adds action to chain of actions, may be a DoNothingAction
  10165. * @param action defines the next action to execute
  10166. * @returns The action passed in
  10167. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10168. */
  10169. then(action: IAction): IAction;
  10170. }
  10171. /**
  10172. * The action to be carried out following a trigger
  10173. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10174. */
  10175. export class Action implements IAction {
  10176. /** the trigger, with or without parameters, for the action */
  10177. triggerOptions: any;
  10178. /**
  10179. * Trigger for the action
  10180. */
  10181. trigger: number;
  10182. /**
  10183. * Internal only - manager for action
  10184. * @hidden
  10185. */
  10186. _actionManager: ActionManager;
  10187. private _nextActiveAction;
  10188. private _child;
  10189. private _condition?;
  10190. private _triggerParameter;
  10191. /**
  10192. * An event triggered prior to action being executed.
  10193. */
  10194. onBeforeExecuteObservable: Observable<Action>;
  10195. /**
  10196. * Creates a new Action
  10197. * @param triggerOptions the trigger, with or without parameters, for the action
  10198. * @param condition an optional determinant of action
  10199. */
  10200. constructor(
  10201. /** the trigger, with or without parameters, for the action */
  10202. triggerOptions: any, condition?: Condition);
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _prepare(): void;
  10208. /**
  10209. * Gets the trigger parameter
  10210. * @returns the trigger parameter
  10211. */
  10212. getTriggerParameter(): any;
  10213. /**
  10214. * Sets the trigger parameter
  10215. * @param value defines the new trigger parameter
  10216. */
  10217. setTriggerParameter(value: any): void;
  10218. /**
  10219. * Internal only - executes current action event
  10220. * @hidden
  10221. */
  10222. _executeCurrent(evt?: ActionEvent): void;
  10223. /**
  10224. * Execute placeholder for child classes
  10225. * @param evt optional action event
  10226. */
  10227. execute(evt?: ActionEvent): void;
  10228. /**
  10229. * Skips to next active action
  10230. */
  10231. skipToNextActiveAction(): void;
  10232. /**
  10233. * Adds action to chain of actions, may be a DoNothingAction
  10234. * @param action defines the next action to execute
  10235. * @returns The action passed in
  10236. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10237. */
  10238. then(action: Action): Action;
  10239. /**
  10240. * Internal only
  10241. * @hidden
  10242. */
  10243. _getProperty(propertyPath: string): string;
  10244. /**
  10245. * Internal only
  10246. * @hidden
  10247. */
  10248. _getEffectiveTarget(target: any, propertyPath: string): any;
  10249. /**
  10250. * Serialize placeholder for child classes
  10251. * @param parent of child
  10252. * @returns the serialized object
  10253. */
  10254. serialize(parent: any): any;
  10255. /**
  10256. * Internal only called by serialize
  10257. * @hidden
  10258. */
  10259. protected _serialize(serializedAction: any, parent?: any): any;
  10260. /**
  10261. * Internal only
  10262. * @hidden
  10263. */
  10264. static _SerializeValueAsString: (value: any) => string;
  10265. /**
  10266. * Internal only
  10267. * @hidden
  10268. */
  10269. static _GetTargetProperty: (target: Scene | Node) => {
  10270. name: string;
  10271. targetType: string;
  10272. value: string;
  10273. };
  10274. }
  10275. }
  10276. declare module "babylonjs/Actions/condition" {
  10277. import { ActionManager } from "babylonjs/Actions/actionManager";
  10278. /**
  10279. * A Condition applied to an Action
  10280. */
  10281. export class Condition {
  10282. /**
  10283. * Internal only - manager for action
  10284. * @hidden
  10285. */
  10286. _actionManager: ActionManager;
  10287. /**
  10288. * Internal only
  10289. * @hidden
  10290. */
  10291. _evaluationId: number;
  10292. /**
  10293. * Internal only
  10294. * @hidden
  10295. */
  10296. _currentResult: boolean;
  10297. /**
  10298. * Creates a new Condition
  10299. * @param actionManager the manager of the action the condition is applied to
  10300. */
  10301. constructor(actionManager: ActionManager);
  10302. /**
  10303. * Check if the current condition is valid
  10304. * @returns a boolean
  10305. */
  10306. isValid(): boolean;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. _getProperty(propertyPath: string): string;
  10312. /**
  10313. * Internal only
  10314. * @hidden
  10315. */
  10316. _getEffectiveTarget(target: any, propertyPath: string): any;
  10317. /**
  10318. * Serialize placeholder for child classes
  10319. * @returns the serialized object
  10320. */
  10321. serialize(): any;
  10322. /**
  10323. * Internal only
  10324. * @hidden
  10325. */
  10326. protected _serialize(serializedCondition: any): any;
  10327. }
  10328. /**
  10329. * Defines specific conditional operators as extensions of Condition
  10330. */
  10331. export class ValueCondition extends Condition {
  10332. /** path to specify the property of the target the conditional operator uses */
  10333. propertyPath: string;
  10334. /** the value compared by the conditional operator against the current value of the property */
  10335. value: any;
  10336. /** the conditional operator, default ValueCondition.IsEqual */
  10337. operator: number;
  10338. /**
  10339. * Internal only
  10340. * @hidden
  10341. */
  10342. private static _IsEqual;
  10343. /**
  10344. * Internal only
  10345. * @hidden
  10346. */
  10347. private static _IsDifferent;
  10348. /**
  10349. * Internal only
  10350. * @hidden
  10351. */
  10352. private static _IsGreater;
  10353. /**
  10354. * Internal only
  10355. * @hidden
  10356. */
  10357. private static _IsLesser;
  10358. /**
  10359. * returns the number for IsEqual
  10360. */
  10361. static get IsEqual(): number;
  10362. /**
  10363. * Returns the number for IsDifferent
  10364. */
  10365. static get IsDifferent(): number;
  10366. /**
  10367. * Returns the number for IsGreater
  10368. */
  10369. static get IsGreater(): number;
  10370. /**
  10371. * Returns the number for IsLesser
  10372. */
  10373. static get IsLesser(): number;
  10374. /**
  10375. * Internal only The action manager for the condition
  10376. * @hidden
  10377. */
  10378. _actionManager: ActionManager;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. private _target;
  10384. /**
  10385. * Internal only
  10386. * @hidden
  10387. */
  10388. private _effectiveTarget;
  10389. /**
  10390. * Internal only
  10391. * @hidden
  10392. */
  10393. private _property;
  10394. /**
  10395. * Creates a new ValueCondition
  10396. * @param actionManager manager for the action the condition applies to
  10397. * @param target for the action
  10398. * @param propertyPath path to specify the property of the target the conditional operator uses
  10399. * @param value the value compared by the conditional operator against the current value of the property
  10400. * @param operator the conditional operator, default ValueCondition.IsEqual
  10401. */
  10402. constructor(actionManager: ActionManager, target: any,
  10403. /** path to specify the property of the target the conditional operator uses */
  10404. propertyPath: string,
  10405. /** the value compared by the conditional operator against the current value of the property */
  10406. value: any,
  10407. /** the conditional operator, default ValueCondition.IsEqual */
  10408. operator?: number);
  10409. /**
  10410. * Compares the given value with the property value for the specified conditional operator
  10411. * @returns the result of the comparison
  10412. */
  10413. isValid(): boolean;
  10414. /**
  10415. * Serialize the ValueCondition into a JSON compatible object
  10416. * @returns serialization object
  10417. */
  10418. serialize(): any;
  10419. /**
  10420. * Gets the name of the conditional operator for the ValueCondition
  10421. * @param operator the conditional operator
  10422. * @returns the name
  10423. */
  10424. static GetOperatorName(operator: number): string;
  10425. }
  10426. /**
  10427. * Defines a predicate condition as an extension of Condition
  10428. */
  10429. export class PredicateCondition extends Condition {
  10430. /** defines the predicate function used to validate the condition */
  10431. predicate: () => boolean;
  10432. /**
  10433. * Internal only - manager for action
  10434. * @hidden
  10435. */
  10436. _actionManager: ActionManager;
  10437. /**
  10438. * Creates a new PredicateCondition
  10439. * @param actionManager manager for the action the condition applies to
  10440. * @param predicate defines the predicate function used to validate the condition
  10441. */
  10442. constructor(actionManager: ActionManager,
  10443. /** defines the predicate function used to validate the condition */
  10444. predicate: () => boolean);
  10445. /**
  10446. * @returns the validity of the predicate condition
  10447. */
  10448. isValid(): boolean;
  10449. }
  10450. /**
  10451. * Defines a state condition as an extension of Condition
  10452. */
  10453. export class StateCondition extends Condition {
  10454. /** Value to compare with target state */
  10455. value: string;
  10456. /**
  10457. * Internal only - manager for action
  10458. * @hidden
  10459. */
  10460. _actionManager: ActionManager;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. private _target;
  10466. /**
  10467. * Creates a new StateCondition
  10468. * @param actionManager manager for the action the condition applies to
  10469. * @param target of the condition
  10470. * @param value to compare with target state
  10471. */
  10472. constructor(actionManager: ActionManager, target: any,
  10473. /** Value to compare with target state */
  10474. value: string);
  10475. /**
  10476. * Gets a boolean indicating if the current condition is met
  10477. * @returns the validity of the state
  10478. */
  10479. isValid(): boolean;
  10480. /**
  10481. * Serialize the StateCondition into a JSON compatible object
  10482. * @returns serialization object
  10483. */
  10484. serialize(): any;
  10485. }
  10486. }
  10487. declare module "babylonjs/Actions/directActions" {
  10488. import { Action } from "babylonjs/Actions/action";
  10489. import { Condition } from "babylonjs/Actions/condition";
  10490. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10491. /**
  10492. * This defines an action responsible to toggle a boolean once triggered.
  10493. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10494. */
  10495. export class SwitchBooleanAction extends Action {
  10496. /**
  10497. * The path to the boolean property in the target object
  10498. */
  10499. propertyPath: string;
  10500. private _target;
  10501. private _effectiveTarget;
  10502. private _property;
  10503. /**
  10504. * Instantiate the action
  10505. * @param triggerOptions defines the trigger options
  10506. * @param target defines the object containing the boolean
  10507. * @param propertyPath defines the path to the boolean property in the target object
  10508. * @param condition defines the trigger related conditions
  10509. */
  10510. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10511. /** @hidden */
  10512. _prepare(): void;
  10513. /**
  10514. * Execute the action toggle the boolean value.
  10515. */
  10516. execute(): void;
  10517. /**
  10518. * Serializes the actions and its related information.
  10519. * @param parent defines the object to serialize in
  10520. * @returns the serialized object
  10521. */
  10522. serialize(parent: any): any;
  10523. }
  10524. /**
  10525. * This defines an action responsible to set a the state field of the target
  10526. * to a desired value once triggered.
  10527. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10528. */
  10529. export class SetStateAction extends Action {
  10530. /**
  10531. * The value to store in the state field.
  10532. */
  10533. value: string;
  10534. private _target;
  10535. /**
  10536. * Instantiate the action
  10537. * @param triggerOptions defines the trigger options
  10538. * @param target defines the object containing the state property
  10539. * @param value defines the value to store in the state field
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10543. /**
  10544. * Execute the action and store the value on the target state property.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to set a property of the target
  10556. * to a desired value once triggered.
  10557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10558. */
  10559. export class SetValueAction extends Action {
  10560. /**
  10561. * The path of the property to set in the target.
  10562. */
  10563. propertyPath: string;
  10564. /**
  10565. * The value to set in the property
  10566. */
  10567. value: any;
  10568. private _target;
  10569. private _effectiveTarget;
  10570. private _property;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the object containing the property
  10575. * @param propertyPath defines the path of the property to set in the target
  10576. * @param value defines the value to set in the property
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10580. /** @hidden */
  10581. _prepare(): void;
  10582. /**
  10583. * Execute the action and set the targetted property to the desired value.
  10584. */
  10585. execute(): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to increment the target value
  10595. * to a desired value once triggered.
  10596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class IncrementValueAction extends Action {
  10599. /**
  10600. * The path of the property to increment in the target.
  10601. */
  10602. propertyPath: string;
  10603. /**
  10604. * The value we should increment the property by.
  10605. */
  10606. value: any;
  10607. private _target;
  10608. private _effectiveTarget;
  10609. private _property;
  10610. /**
  10611. * Instantiate the action
  10612. * @param triggerOptions defines the trigger options
  10613. * @param target defines the object containing the property
  10614. * @param propertyPath defines the path of the property to increment in the target
  10615. * @param value defines the value value we should increment the property by
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and increment the target of the value amount.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. /**
  10633. * This defines an action responsible to start an animation once triggered.
  10634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10635. */
  10636. export class PlayAnimationAction extends Action {
  10637. /**
  10638. * Where the animation should start (animation frame)
  10639. */
  10640. from: number;
  10641. /**
  10642. * Where the animation should stop (animation frame)
  10643. */
  10644. to: number;
  10645. /**
  10646. * Define if the animation should loop or stop after the first play.
  10647. */
  10648. loop?: boolean;
  10649. private _target;
  10650. /**
  10651. * Instantiate the action
  10652. * @param triggerOptions defines the trigger options
  10653. * @param target defines the target animation or animation name
  10654. * @param from defines from where the animation should start (animation frame)
  10655. * @param end defines where the animation should stop (animation frame)
  10656. * @param loop defines if the animation should loop or stop after the first play
  10657. * @param condition defines the trigger related conditions
  10658. */
  10659. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10660. /** @hidden */
  10661. _prepare(): void;
  10662. /**
  10663. * Execute the action and play the animation.
  10664. */
  10665. execute(): void;
  10666. /**
  10667. * Serializes the actions and its related information.
  10668. * @param parent defines the object to serialize in
  10669. * @returns the serialized object
  10670. */
  10671. serialize(parent: any): any;
  10672. }
  10673. /**
  10674. * This defines an action responsible to stop an animation once triggered.
  10675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10676. */
  10677. export class StopAnimationAction extends Action {
  10678. private _target;
  10679. /**
  10680. * Instantiate the action
  10681. * @param triggerOptions defines the trigger options
  10682. * @param target defines the target animation or animation name
  10683. * @param condition defines the trigger related conditions
  10684. */
  10685. constructor(triggerOptions: any, target: any, condition?: Condition);
  10686. /** @hidden */
  10687. _prepare(): void;
  10688. /**
  10689. * Execute the action and stop the animation.
  10690. */
  10691. execute(): void;
  10692. /**
  10693. * Serializes the actions and its related information.
  10694. * @param parent defines the object to serialize in
  10695. * @returns the serialized object
  10696. */
  10697. serialize(parent: any): any;
  10698. }
  10699. /**
  10700. * This defines an action responsible that does nothing once triggered.
  10701. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10702. */
  10703. export class DoNothingAction extends Action {
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param condition defines the trigger related conditions
  10708. */
  10709. constructor(triggerOptions?: any, condition?: Condition);
  10710. /**
  10711. * Execute the action and do nothing.
  10712. */
  10713. execute(): void;
  10714. /**
  10715. * Serializes the actions and its related information.
  10716. * @param parent defines the object to serialize in
  10717. * @returns the serialized object
  10718. */
  10719. serialize(parent: any): any;
  10720. }
  10721. /**
  10722. * This defines an action responsible to trigger several actions once triggered.
  10723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10724. */
  10725. export class CombineAction extends Action {
  10726. /**
  10727. * The list of aggregated animations to run.
  10728. */
  10729. children: Action[];
  10730. /**
  10731. * Instantiate the action
  10732. * @param triggerOptions defines the trigger options
  10733. * @param children defines the list of aggregated animations to run
  10734. * @param condition defines the trigger related conditions
  10735. */
  10736. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10737. /** @hidden */
  10738. _prepare(): void;
  10739. /**
  10740. * Execute the action and executes all the aggregated actions.
  10741. */
  10742. execute(evt: ActionEvent): void;
  10743. /**
  10744. * Serializes the actions and its related information.
  10745. * @param parent defines the object to serialize in
  10746. * @returns the serialized object
  10747. */
  10748. serialize(parent: any): any;
  10749. }
  10750. /**
  10751. * This defines an action responsible to run code (external event) once triggered.
  10752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10753. */
  10754. export class ExecuteCodeAction extends Action {
  10755. /**
  10756. * The callback function to run.
  10757. */
  10758. func: (evt: ActionEvent) => void;
  10759. /**
  10760. * Instantiate the action
  10761. * @param triggerOptions defines the trigger options
  10762. * @param func defines the callback function to run
  10763. * @param condition defines the trigger related conditions
  10764. */
  10765. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10766. /**
  10767. * Execute the action and run the attached code.
  10768. */
  10769. execute(evt: ActionEvent): void;
  10770. }
  10771. /**
  10772. * This defines an action responsible to set the parent property of the target once triggered.
  10773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10774. */
  10775. export class SetParentAction extends Action {
  10776. private _parent;
  10777. private _target;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the target containing the parent property
  10782. * @param parent defines from where the animation should start (animation frame)
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10786. /** @hidden */
  10787. _prepare(): void;
  10788. /**
  10789. * Execute the action and set the parent property.
  10790. */
  10791. execute(): void;
  10792. /**
  10793. * Serializes the actions and its related information.
  10794. * @param parent defines the object to serialize in
  10795. * @returns the serialized object
  10796. */
  10797. serialize(parent: any): any;
  10798. }
  10799. }
  10800. declare module "babylonjs/Actions/actionManager" {
  10801. import { Nullable } from "babylonjs/types";
  10802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10803. import { Scene } from "babylonjs/scene";
  10804. import { IAction } from "babylonjs/Actions/action";
  10805. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10806. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10807. /**
  10808. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10809. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10810. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class ActionManager extends AbstractActionManager {
  10813. /**
  10814. * Nothing
  10815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10816. */
  10817. static readonly NothingTrigger: number;
  10818. /**
  10819. * On pick
  10820. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10821. */
  10822. static readonly OnPickTrigger: number;
  10823. /**
  10824. * On left pick
  10825. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10826. */
  10827. static readonly OnLeftPickTrigger: number;
  10828. /**
  10829. * On right pick
  10830. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10831. */
  10832. static readonly OnRightPickTrigger: number;
  10833. /**
  10834. * On center pick
  10835. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10836. */
  10837. static readonly OnCenterPickTrigger: number;
  10838. /**
  10839. * On pick down
  10840. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10841. */
  10842. static readonly OnPickDownTrigger: number;
  10843. /**
  10844. * On double pick
  10845. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10846. */
  10847. static readonly OnDoublePickTrigger: number;
  10848. /**
  10849. * On pick up
  10850. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10851. */
  10852. static readonly OnPickUpTrigger: number;
  10853. /**
  10854. * On pick out.
  10855. * This trigger will only be raised if you also declared a OnPickDown
  10856. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickOutTrigger: number;
  10859. /**
  10860. * On long press
  10861. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10862. */
  10863. static readonly OnLongPressTrigger: number;
  10864. /**
  10865. * On pointer over
  10866. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10867. */
  10868. static readonly OnPointerOverTrigger: number;
  10869. /**
  10870. * On pointer out
  10871. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10872. */
  10873. static readonly OnPointerOutTrigger: number;
  10874. /**
  10875. * On every frame
  10876. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10877. */
  10878. static readonly OnEveryFrameTrigger: number;
  10879. /**
  10880. * On intersection enter
  10881. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10882. */
  10883. static readonly OnIntersectionEnterTrigger: number;
  10884. /**
  10885. * On intersection exit
  10886. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10887. */
  10888. static readonly OnIntersectionExitTrigger: number;
  10889. /**
  10890. * On key down
  10891. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10892. */
  10893. static readonly OnKeyDownTrigger: number;
  10894. /**
  10895. * On key up
  10896. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10897. */
  10898. static readonly OnKeyUpTrigger: number;
  10899. private _scene;
  10900. /**
  10901. * Creates a new action manager
  10902. * @param scene defines the hosting scene
  10903. */
  10904. constructor(scene: Scene);
  10905. /**
  10906. * Releases all associated resources
  10907. */
  10908. dispose(): void;
  10909. /**
  10910. * Gets hosting scene
  10911. * @returns the hosting scene
  10912. */
  10913. getScene(): Scene;
  10914. /**
  10915. * Does this action manager handles actions of any of the given triggers
  10916. * @param triggers defines the triggers to be tested
  10917. * @return a boolean indicating whether one (or more) of the triggers is handled
  10918. */
  10919. hasSpecificTriggers(triggers: number[]): boolean;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10922. * speed.
  10923. * @param triggerA defines the trigger to be tested
  10924. * @param triggerB defines the trigger to be tested
  10925. * @return a boolean indicating whether one (or more) of the triggers is handled
  10926. */
  10927. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10928. /**
  10929. * Does this action manager handles actions of a given trigger
  10930. * @param trigger defines the trigger to be tested
  10931. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10932. * @return whether the trigger is handled
  10933. */
  10934. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10935. /**
  10936. * Does this action manager has pointer triggers
  10937. */
  10938. get hasPointerTriggers(): boolean;
  10939. /**
  10940. * Does this action manager has pick triggers
  10941. */
  10942. get hasPickTriggers(): boolean;
  10943. /**
  10944. * Registers an action to this action manager
  10945. * @param action defines the action to be registered
  10946. * @return the action amended (prepared) after registration
  10947. */
  10948. registerAction(action: IAction): Nullable<IAction>;
  10949. /**
  10950. * Unregisters an action to this action manager
  10951. * @param action defines the action to be unregistered
  10952. * @return a boolean indicating whether the action has been unregistered
  10953. */
  10954. unregisterAction(action: IAction): Boolean;
  10955. /**
  10956. * Process a specific trigger
  10957. * @param trigger defines the trigger to process
  10958. * @param evt defines the event details to be processed
  10959. */
  10960. processTrigger(trigger: number, evt?: IActionEvent): void;
  10961. /** @hidden */
  10962. _getEffectiveTarget(target: any, propertyPath: string): any;
  10963. /** @hidden */
  10964. _getProperty(propertyPath: string): string;
  10965. /**
  10966. * Serialize this manager to a JSON object
  10967. * @param name defines the property name to store this manager
  10968. * @returns a JSON representation of this manager
  10969. */
  10970. serialize(name: string): any;
  10971. /**
  10972. * Creates a new ActionManager from a JSON data
  10973. * @param parsedActions defines the JSON data to read from
  10974. * @param object defines the hosting mesh
  10975. * @param scene defines the hosting scene
  10976. */
  10977. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10978. /**
  10979. * Get a trigger name by index
  10980. * @param trigger defines the trigger index
  10981. * @returns a trigger name
  10982. */
  10983. static GetTriggerName(trigger: number): string;
  10984. }
  10985. }
  10986. declare module "babylonjs/Culling/ray" {
  10987. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10991. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10992. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10993. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10994. import { Plane } from "babylonjs/Maths/math.plane";
  10995. /**
  10996. * Class representing a ray with position and direction
  10997. */
  10998. export class Ray {
  10999. /** origin point */
  11000. origin: Vector3;
  11001. /** direction */
  11002. direction: Vector3;
  11003. /** length of the ray */
  11004. length: number;
  11005. private static readonly _TmpVector3;
  11006. private _tmpRay;
  11007. /**
  11008. * Creates a new ray
  11009. * @param origin origin point
  11010. * @param direction direction
  11011. * @param length length of the ray
  11012. */
  11013. constructor(
  11014. /** origin point */
  11015. origin: Vector3,
  11016. /** direction */
  11017. direction: Vector3,
  11018. /** length of the ray */
  11019. length?: number);
  11020. /**
  11021. * Checks if the ray intersects a box
  11022. * This does not account for the ray lenght by design to improve perfs.
  11023. * @param minimum bound of the box
  11024. * @param maximum bound of the box
  11025. * @param intersectionTreshold extra extend to be added to the box in all direction
  11026. * @returns if the box was hit
  11027. */
  11028. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11029. /**
  11030. * Checks if the ray intersects a box
  11031. * This does not account for the ray lenght by design to improve perfs.
  11032. * @param box the bounding box to check
  11033. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11034. * @returns if the box was hit
  11035. */
  11036. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11037. /**
  11038. * If the ray hits a sphere
  11039. * @param sphere the bounding sphere to check
  11040. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11041. * @returns true if it hits the sphere
  11042. */
  11043. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11044. /**
  11045. * If the ray hits a triange
  11046. * @param vertex0 triangle vertex
  11047. * @param vertex1 triangle vertex
  11048. * @param vertex2 triangle vertex
  11049. * @returns intersection information if hit
  11050. */
  11051. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11052. /**
  11053. * Checks if ray intersects a plane
  11054. * @param plane the plane to check
  11055. * @returns the distance away it was hit
  11056. */
  11057. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11058. /**
  11059. * Calculate the intercept of a ray on a given axis
  11060. * @param axis to check 'x' | 'y' | 'z'
  11061. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11062. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11063. */
  11064. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11065. /**
  11066. * Checks if ray intersects a mesh
  11067. * @param mesh the mesh to check
  11068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11069. * @returns picking info of the intersecton
  11070. */
  11071. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11072. /**
  11073. * Checks if ray intersects a mesh
  11074. * @param meshes the meshes to check
  11075. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11076. * @param results array to store result in
  11077. * @returns Array of picking infos
  11078. */
  11079. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11080. private _comparePickingInfo;
  11081. private static smallnum;
  11082. private static rayl;
  11083. /**
  11084. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11085. * @param sega the first point of the segment to test the intersection against
  11086. * @param segb the second point of the segment to test the intersection against
  11087. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11088. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11089. */
  11090. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11091. /**
  11092. * Update the ray from viewport position
  11093. * @param x position
  11094. * @param y y position
  11095. * @param viewportWidth viewport width
  11096. * @param viewportHeight viewport height
  11097. * @param world world matrix
  11098. * @param view view matrix
  11099. * @param projection projection matrix
  11100. * @returns this ray updated
  11101. */
  11102. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11103. /**
  11104. * Creates a ray with origin and direction of 0,0,0
  11105. * @returns the new ray
  11106. */
  11107. static Zero(): Ray;
  11108. /**
  11109. * Creates a new ray from screen space and viewport
  11110. * @param x position
  11111. * @param y y position
  11112. * @param viewportWidth viewport width
  11113. * @param viewportHeight viewport height
  11114. * @param world world matrix
  11115. * @param view view matrix
  11116. * @param projection projection matrix
  11117. * @returns new ray
  11118. */
  11119. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11120. /**
  11121. * 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
  11122. * transformed to the given world matrix.
  11123. * @param origin The origin point
  11124. * @param end The end point
  11125. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11126. * @returns the new ray
  11127. */
  11128. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11129. /**
  11130. * Transforms a ray by a matrix
  11131. * @param ray ray to transform
  11132. * @param matrix matrix to apply
  11133. * @returns the resulting new ray
  11134. */
  11135. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11136. /**
  11137. * Transforms a ray by a matrix
  11138. * @param ray ray to transform
  11139. * @param matrix matrix to apply
  11140. * @param result ray to store result in
  11141. */
  11142. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11143. /**
  11144. * Unproject a ray from screen space to object space
  11145. * @param sourceX defines the screen space x coordinate to use
  11146. * @param sourceY defines the screen space y coordinate to use
  11147. * @param viewportWidth defines the current width of the viewport
  11148. * @param viewportHeight defines the current height of the viewport
  11149. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11150. * @param view defines the view matrix to use
  11151. * @param projection defines the projection matrix to use
  11152. */
  11153. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11154. }
  11155. /**
  11156. * Type used to define predicate used to select faces when a mesh intersection is detected
  11157. */
  11158. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11159. module "babylonjs/scene" {
  11160. interface Scene {
  11161. /** @hidden */
  11162. _tempPickingRay: Nullable<Ray>;
  11163. /** @hidden */
  11164. _cachedRayForTransform: Ray;
  11165. /** @hidden */
  11166. _pickWithRayInverseMatrix: Matrix;
  11167. /** @hidden */
  11168. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11169. /** @hidden */
  11170. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11171. /** @hidden */
  11172. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11173. }
  11174. }
  11175. }
  11176. declare module "babylonjs/sceneComponent" {
  11177. import { Scene } from "babylonjs/scene";
  11178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11179. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11180. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11181. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11182. import { Nullable } from "babylonjs/types";
  11183. import { Camera } from "babylonjs/Cameras/camera";
  11184. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11185. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11186. import { AbstractScene } from "babylonjs/abstractScene";
  11187. import { Mesh } from "babylonjs/Meshes/mesh";
  11188. import { Effect } from "babylonjs/Materials/effect";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_PREPASSRENDERER: string;
  11203. static readonly NAME_DEPTHRENDERER: string;
  11204. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11205. static readonly NAME_SPRITE: string;
  11206. static readonly NAME_SUBSURFACE: string;
  11207. static readonly NAME_OUTLINERENDERER: string;
  11208. static readonly NAME_PROCEDURALTEXTURE: string;
  11209. static readonly NAME_SHADOWGENERATOR: string;
  11210. static readonly NAME_OCTREE: string;
  11211. static readonly NAME_PHYSICSENGINE: string;
  11212. static readonly NAME_AUDIO: string;
  11213. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11214. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11217. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11218. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11219. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11220. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11221. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11222. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11223. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11224. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11225. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11226. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11227. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11228. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11229. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11230. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11231. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11232. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11233. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11234. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11235. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11236. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11237. static readonly STEP_AFTERRENDER_AUDIO: number;
  11238. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11239. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11240. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11241. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11242. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11243. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11244. static readonly STEP_POINTERMOVE_SPRITE: number;
  11245. static readonly STEP_POINTERDOWN_SPRITE: number;
  11246. static readonly STEP_POINTERUP_SPRITE: number;
  11247. }
  11248. /**
  11249. * This represents a scene component.
  11250. *
  11251. * This is used to decouple the dependency the scene is having on the different workloads like
  11252. * layers, post processes...
  11253. */
  11254. export interface ISceneComponent {
  11255. /**
  11256. * The name of the component. Each component must have a unique name.
  11257. */
  11258. name: string;
  11259. /**
  11260. * The scene the component belongs to.
  11261. */
  11262. scene: Scene;
  11263. /**
  11264. * Register the component to one instance of a scene.
  11265. */
  11266. register(): void;
  11267. /**
  11268. * Rebuilds the elements related to this component in case of
  11269. * context lost for instance.
  11270. */
  11271. rebuild(): void;
  11272. /**
  11273. * Disposes the component and the associated ressources.
  11274. */
  11275. dispose(): void;
  11276. }
  11277. /**
  11278. * This represents a SERIALIZABLE scene component.
  11279. *
  11280. * This extends Scene Component to add Serialization methods on top.
  11281. */
  11282. export interface ISceneSerializableComponent extends ISceneComponent {
  11283. /**
  11284. * Adds all the elements from the container to the scene
  11285. * @param container the container holding the elements
  11286. */
  11287. addFromContainer(container: AbstractScene): void;
  11288. /**
  11289. * Removes all the elements in the container from the scene
  11290. * @param container contains the elements to remove
  11291. * @param dispose if the removed element should be disposed (default: false)
  11292. */
  11293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11294. /**
  11295. * Serializes the component data to the specified json object
  11296. * @param serializationObject The object to serialize to
  11297. */
  11298. serialize(serializationObject: any): void;
  11299. }
  11300. /**
  11301. * Strong typing of a Mesh related stage step action
  11302. */
  11303. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11304. /**
  11305. * Strong typing of a Evaluate Sub Mesh related stage step action
  11306. */
  11307. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11308. /**
  11309. * Strong typing of a pre active Mesh related stage step action
  11310. */
  11311. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11312. /**
  11313. * Strong typing of a Camera related stage step action
  11314. */
  11315. export type CameraStageAction = (camera: Camera) => void;
  11316. /**
  11317. * Strong typing of a Camera Frame buffer related stage step action
  11318. */
  11319. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11320. /**
  11321. * Strong typing of a Render Target related stage step action
  11322. */
  11323. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11324. /**
  11325. * Strong typing of a RenderingGroup related stage step action
  11326. */
  11327. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11328. /**
  11329. * Strong typing of a Mesh Render related stage step action
  11330. */
  11331. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11332. /**
  11333. * Strong typing of a simple stage step action
  11334. */
  11335. export type SimpleStageAction = () => void;
  11336. /**
  11337. * Strong typing of a render target action.
  11338. */
  11339. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11340. /**
  11341. * Strong typing of a pointer move action.
  11342. */
  11343. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11344. /**
  11345. * Strong typing of a pointer up/down action.
  11346. */
  11347. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11348. /**
  11349. * Representation of a stage in the scene (Basically a list of ordered steps)
  11350. * @hidden
  11351. */
  11352. export class Stage<T extends Function> extends Array<{
  11353. index: number;
  11354. component: ISceneComponent;
  11355. action: T;
  11356. }> {
  11357. /**
  11358. * Hide ctor from the rest of the world.
  11359. * @param items The items to add.
  11360. */
  11361. private constructor();
  11362. /**
  11363. * Creates a new Stage.
  11364. * @returns A new instance of a Stage
  11365. */
  11366. static Create<T extends Function>(): Stage<T>;
  11367. /**
  11368. * Registers a step in an ordered way in the targeted stage.
  11369. * @param index Defines the position to register the step in
  11370. * @param component Defines the component attached to the step
  11371. * @param action Defines the action to launch during the step
  11372. */
  11373. registerStep(index: number, component: ISceneComponent, action: T): void;
  11374. /**
  11375. * Clears all the steps from the stage.
  11376. */
  11377. clear(): void;
  11378. }
  11379. }
  11380. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11381. import { Nullable } from "babylonjs/types";
  11382. import { Observable } from "babylonjs/Misc/observable";
  11383. import { Scene } from "babylonjs/scene";
  11384. import { Sprite } from "babylonjs/Sprites/sprite";
  11385. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11386. import { Ray } from "babylonjs/Culling/ray";
  11387. import { Camera } from "babylonjs/Cameras/camera";
  11388. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11389. import { ISceneComponent } from "babylonjs/sceneComponent";
  11390. module "babylonjs/scene" {
  11391. interface Scene {
  11392. /** @hidden */
  11393. _pointerOverSprite: Nullable<Sprite>;
  11394. /** @hidden */
  11395. _pickedDownSprite: Nullable<Sprite>;
  11396. /** @hidden */
  11397. _tempSpritePickingRay: Nullable<Ray>;
  11398. /**
  11399. * All of the sprite managers added to this scene
  11400. * @see https://doc.babylonjs.com/babylon101/sprites
  11401. */
  11402. spriteManagers: Array<ISpriteManager>;
  11403. /**
  11404. * An event triggered when sprites rendering is about to start
  11405. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11406. */
  11407. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11408. /**
  11409. * An event triggered when sprites rendering is done
  11410. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11411. */
  11412. onAfterSpritesRenderingObservable: Observable<Scene>;
  11413. /** @hidden */
  11414. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11415. /** Launch a ray to try to pick a sprite in the scene
  11416. * @param x position on screen
  11417. * @param y position on screen
  11418. * @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
  11419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11421. * @returns a PickingInfo
  11422. */
  11423. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11424. /** Use the given ray to pick a sprite in the scene
  11425. * @param ray The ray (in world space) to use to pick meshes
  11426. * @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
  11427. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11428. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11429. * @returns a PickingInfo
  11430. */
  11431. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11432. /** @hidden */
  11433. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11434. /** Launch a ray to try to pick sprites in the scene
  11435. * @param x position on screen
  11436. * @param y position on screen
  11437. * @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
  11438. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /** Use the given ray to pick sprites in the scene
  11443. * @param ray The ray (in world space) to use to pick meshes
  11444. * @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
  11445. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11446. * @returns a PickingInfo array
  11447. */
  11448. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11449. /**
  11450. * Force the sprite under the pointer
  11451. * @param sprite defines the sprite to use
  11452. */
  11453. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11454. /**
  11455. * Gets the sprite under the pointer
  11456. * @returns a Sprite or null if no sprite is under the pointer
  11457. */
  11458. getPointerOverSprite(): Nullable<Sprite>;
  11459. }
  11460. }
  11461. /**
  11462. * Defines the sprite scene component responsible to manage sprites
  11463. * in a given scene.
  11464. */
  11465. export class SpriteSceneComponent implements ISceneComponent {
  11466. /**
  11467. * The component name helpfull to identify the component in the list of scene components.
  11468. */
  11469. readonly name: string;
  11470. /**
  11471. * The scene the component belongs to.
  11472. */
  11473. scene: Scene;
  11474. /** @hidden */
  11475. private _spritePredicate;
  11476. /**
  11477. * Creates a new instance of the component for the given scene
  11478. * @param scene Defines the scene to register the component in
  11479. */
  11480. constructor(scene: Scene);
  11481. /**
  11482. * Registers the component in a given scene
  11483. */
  11484. register(): void;
  11485. /**
  11486. * Rebuilds the elements related to this component in case of
  11487. * context lost for instance.
  11488. */
  11489. rebuild(): void;
  11490. /**
  11491. * Disposes the component and the associated ressources.
  11492. */
  11493. dispose(): void;
  11494. private _pickSpriteButKeepRay;
  11495. private _pointerMove;
  11496. private _pointerDown;
  11497. private _pointerUp;
  11498. }
  11499. }
  11500. declare module "babylonjs/Misc/timingTools" {
  11501. /**
  11502. * Class used to provide helper for timing
  11503. */
  11504. export class TimingTools {
  11505. /**
  11506. * Polyfill for setImmediate
  11507. * @param action defines the action to execute after the current execution block
  11508. */
  11509. static SetImmediate(action: () => void): void;
  11510. }
  11511. }
  11512. declare module "babylonjs/Misc/instantiationTools" {
  11513. /**
  11514. * Class used to enable instatition of objects by class name
  11515. */
  11516. export class InstantiationTools {
  11517. /**
  11518. * Use this object to register external classes like custom textures or material
  11519. * to allow the laoders to instantiate them
  11520. */
  11521. static RegisteredExternalClasses: {
  11522. [key: string]: Object;
  11523. };
  11524. /**
  11525. * Tries to instantiate a new object from a given class name
  11526. * @param className defines the class name to instantiate
  11527. * @returns the new object or null if the system was not able to do the instantiation
  11528. */
  11529. static Instantiate(className: string): any;
  11530. }
  11531. }
  11532. declare module "babylonjs/Misc/copyTools" {
  11533. import { Nullable } from "babylonjs/types";
  11534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11535. /**
  11536. * Class used to host copy specific utilities
  11537. */
  11538. export class CopyTools {
  11539. /**
  11540. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11541. * @param texture defines the texture to read pixels from
  11542. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11543. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11544. * @returns The base64 encoded string or null
  11545. */
  11546. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11547. }
  11548. }
  11549. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  11550. /**
  11551. * Define options used to create a depth texture
  11552. */
  11553. export class DepthTextureCreationOptions {
  11554. /** Specifies whether or not a stencil should be allocated in the texture */
  11555. generateStencil?: boolean;
  11556. /** Specifies whether or not bilinear filtering is enable on the texture */
  11557. bilinearFiltering?: boolean;
  11558. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11559. comparisonFunction?: number;
  11560. /** Specifies if the created texture is a cube texture */
  11561. isCube?: boolean;
  11562. /** Specifies the sample count of the depth/stencil texture texture */
  11563. samples?: number;
  11564. }
  11565. }
  11566. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  11567. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11568. import { Nullable } from "babylonjs/types";
  11569. import { Scene } from "babylonjs/scene";
  11570. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11571. module "babylonjs/Engines/thinEngine" {
  11572. interface ThinEngine {
  11573. /**
  11574. * Creates a depth stencil cube texture.
  11575. * This is only available in WebGL 2.
  11576. * @param size The size of face edge in the cube texture.
  11577. * @param options The options defining the cube texture.
  11578. * @returns The cube texture
  11579. */
  11580. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11581. /**
  11582. * Creates a cube texture
  11583. * @param rootUrl defines the url where the files to load is located
  11584. * @param scene defines the current scene
  11585. * @param files defines the list of files to load (1 per face)
  11586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11587. * @param onLoad defines an optional callback raised when the texture is loaded
  11588. * @param onError defines an optional callback raised if there is an issue to load the texture
  11589. * @param format defines the format of the data
  11590. * @param forcedExtension defines the extension to use to pick the right loader
  11591. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11592. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11593. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11594. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11595. * @param loaderOptions options to be passed to the loader
  11596. * @returns the cube texture as an InternalTexture
  11597. */
  11598. 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;
  11599. /**
  11600. * Creates a cube texture
  11601. * @param rootUrl defines the url where the files to load is located
  11602. * @param scene defines the current scene
  11603. * @param files defines the list of files to load (1 per face)
  11604. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11605. * @param onLoad defines an optional callback raised when the texture is loaded
  11606. * @param onError defines an optional callback raised if there is an issue to load the texture
  11607. * @param format defines the format of the data
  11608. * @param forcedExtension defines the extension to use to pick the right loader
  11609. * @returns the cube texture as an InternalTexture
  11610. */
  11611. 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;
  11612. /**
  11613. * Creates a cube texture
  11614. * @param rootUrl defines the url where the files to load is located
  11615. * @param scene defines the current scene
  11616. * @param files defines the list of files to load (1 per face)
  11617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11618. * @param onLoad defines an optional callback raised when the texture is loaded
  11619. * @param onError defines an optional callback raised if there is an issue to load the texture
  11620. * @param format defines the format of the data
  11621. * @param forcedExtension defines the extension to use to pick the right loader
  11622. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11623. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11624. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11625. * @returns the cube texture as an InternalTexture
  11626. */
  11627. 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;
  11628. /** @hidden */
  11629. 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;
  11630. /** @hidden */
  11631. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11632. /** @hidden */
  11633. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11634. /** @hidden */
  11635. _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;
  11636. /** @hidden */
  11637. _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;
  11638. /**
  11639. * @hidden
  11640. */
  11641. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11642. }
  11643. }
  11644. }
  11645. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11646. import { Nullable } from "babylonjs/types";
  11647. import { Scene } from "babylonjs/scene";
  11648. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11650. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11651. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11652. import { Observable } from "babylonjs/Misc/observable";
  11653. /**
  11654. * Class for creating a cube texture
  11655. */
  11656. export class CubeTexture extends BaseTexture {
  11657. private _delayedOnLoad;
  11658. /**
  11659. * Observable triggered once the texture has been loaded.
  11660. */
  11661. onLoadObservable: Observable<CubeTexture>;
  11662. /**
  11663. * The url of the texture
  11664. */
  11665. url: string;
  11666. /**
  11667. * Gets or sets the center of the bounding box associated with the cube texture.
  11668. * It must define where the camera used to render the texture was set
  11669. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11670. */
  11671. boundingBoxPosition: Vector3;
  11672. private _boundingBoxSize;
  11673. /**
  11674. * Gets or sets the size of the bounding box associated with the cube texture
  11675. * When defined, the cubemap will switch to local mode
  11676. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11677. * @example https://www.babylonjs-playground.com/#RNASML
  11678. */
  11679. set boundingBoxSize(value: Vector3);
  11680. /**
  11681. * Returns the bounding box size
  11682. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11683. */
  11684. get boundingBoxSize(): Vector3;
  11685. protected _rotationY: number;
  11686. /**
  11687. * Sets texture matrix rotation angle around Y axis in radians.
  11688. */
  11689. set rotationY(value: number);
  11690. /**
  11691. * Gets texture matrix rotation angle around Y axis radians.
  11692. */
  11693. get rotationY(): number;
  11694. /**
  11695. * Are mip maps generated for this texture or not.
  11696. */
  11697. get noMipmap(): boolean;
  11698. private _noMipmap;
  11699. private _files;
  11700. protected _forcedExtension: Nullable<string>;
  11701. private _extensions;
  11702. private _textureMatrix;
  11703. private _format;
  11704. private _createPolynomials;
  11705. private _loaderOptions;
  11706. /**
  11707. * Creates a cube texture from an array of image urls
  11708. * @param files defines an array of image urls
  11709. * @param scene defines the hosting scene
  11710. * @param noMipmap specifies if mip maps are not used
  11711. * @returns a cube texture
  11712. */
  11713. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11714. /**
  11715. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11716. * @param url defines the url of the prefiltered texture
  11717. * @param scene defines the scene the texture is attached to
  11718. * @param forcedExtension defines the extension of the file if different from the url
  11719. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11720. * @return the prefiltered texture
  11721. */
  11722. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11723. /**
  11724. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11725. * as prefiltered data.
  11726. * @param rootUrl defines the url of the texture or the root name of the six images
  11727. * @param null defines the scene or engine the texture is attached to
  11728. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11729. * @param noMipmap defines if mipmaps should be created or not
  11730. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11731. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11732. * @param onError defines a callback triggered in case of error during load
  11733. * @param format defines the internal format to use for the texture once loaded
  11734. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11735. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11736. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11737. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11738. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11739. * @param loaderOptions options to be passed to the loader
  11740. * @return the cube texture
  11741. */
  11742. 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);
  11743. /**
  11744. * Get the current class name of the texture useful for serialization or dynamic coding.
  11745. * @returns "CubeTexture"
  11746. */
  11747. getClassName(): string;
  11748. /**
  11749. * Update the url (and optional buffer) of this texture if url was null during construction.
  11750. * @param url the url of the texture
  11751. * @param forcedExtension defines the extension to use
  11752. * @param onLoad callback called when the texture is loaded (defaults to null)
  11753. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11754. */
  11755. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11756. /**
  11757. * Delays loading of the cube texture
  11758. * @param forcedExtension defines the extension to use
  11759. */
  11760. delayLoad(forcedExtension?: string): void;
  11761. /**
  11762. * Returns the reflection texture matrix
  11763. * @returns the reflection texture matrix
  11764. */
  11765. getReflectionTextureMatrix(): Matrix;
  11766. /**
  11767. * Sets the reflection texture matrix
  11768. * @param value Reflection texture matrix
  11769. */
  11770. setReflectionTextureMatrix(value: Matrix): void;
  11771. /**
  11772. * Parses text to create a cube texture
  11773. * @param parsedTexture define the serialized text to read from
  11774. * @param scene defines the hosting scene
  11775. * @param rootUrl defines the root url of the cube texture
  11776. * @returns a cube texture
  11777. */
  11778. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11779. /**
  11780. * Makes a clone, or deep copy, of the cube texture
  11781. * @returns a new cube texture
  11782. */
  11783. clone(): CubeTexture;
  11784. }
  11785. }
  11786. declare module "babylonjs/Materials/colorCurves" {
  11787. import { Effect } from "babylonjs/Materials/effect";
  11788. /**
  11789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11791. * 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;
  11792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11793. */
  11794. export class ColorCurves {
  11795. private _dirty;
  11796. private _tempColor;
  11797. private _globalCurve;
  11798. private _highlightsCurve;
  11799. private _midtonesCurve;
  11800. private _shadowsCurve;
  11801. private _positiveCurve;
  11802. private _negativeCurve;
  11803. private _globalHue;
  11804. private _globalDensity;
  11805. private _globalSaturation;
  11806. private _globalExposure;
  11807. /**
  11808. * Gets the global Hue value.
  11809. * 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).
  11810. */
  11811. get globalHue(): number;
  11812. /**
  11813. * Sets the global Hue value.
  11814. * 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).
  11815. */
  11816. set globalHue(value: number);
  11817. /**
  11818. * Gets the global Density value.
  11819. * 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.
  11820. * Values less than zero provide a filter of opposite hue.
  11821. */
  11822. get globalDensity(): number;
  11823. /**
  11824. * Sets the global Density value.
  11825. * 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.
  11826. * Values less than zero provide a filter of opposite hue.
  11827. */
  11828. set globalDensity(value: number);
  11829. /**
  11830. * Gets the global Saturation value.
  11831. * 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.
  11832. */
  11833. get globalSaturation(): number;
  11834. /**
  11835. * Sets the global Saturation value.
  11836. * 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.
  11837. */
  11838. set globalSaturation(value: number);
  11839. /**
  11840. * Gets the global Exposure value.
  11841. * 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.
  11842. */
  11843. get globalExposure(): number;
  11844. /**
  11845. * Sets the global Exposure value.
  11846. * 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.
  11847. */
  11848. set globalExposure(value: number);
  11849. private _highlightsHue;
  11850. private _highlightsDensity;
  11851. private _highlightsSaturation;
  11852. private _highlightsExposure;
  11853. /**
  11854. * Gets the highlights Hue value.
  11855. * 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).
  11856. */
  11857. get highlightsHue(): number;
  11858. /**
  11859. * Sets the highlights Hue value.
  11860. * 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).
  11861. */
  11862. set highlightsHue(value: number);
  11863. /**
  11864. * Gets the highlights Density value.
  11865. * 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.
  11866. * Values less than zero provide a filter of opposite hue.
  11867. */
  11868. get highlightsDensity(): number;
  11869. /**
  11870. * Sets the highlights Density value.
  11871. * 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.
  11872. * Values less than zero provide a filter of opposite hue.
  11873. */
  11874. set highlightsDensity(value: number);
  11875. /**
  11876. * Gets the highlights Saturation value.
  11877. * 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.
  11878. */
  11879. get highlightsSaturation(): number;
  11880. /**
  11881. * Sets the highlights Saturation value.
  11882. * 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.
  11883. */
  11884. set highlightsSaturation(value: number);
  11885. /**
  11886. * Gets the highlights Exposure value.
  11887. * 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.
  11888. */
  11889. get highlightsExposure(): number;
  11890. /**
  11891. * Sets the highlights Exposure value.
  11892. * 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.
  11893. */
  11894. set highlightsExposure(value: number);
  11895. private _midtonesHue;
  11896. private _midtonesDensity;
  11897. private _midtonesSaturation;
  11898. private _midtonesExposure;
  11899. /**
  11900. * Gets the midtones Hue value.
  11901. * 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).
  11902. */
  11903. get midtonesHue(): number;
  11904. /**
  11905. * Sets the midtones Hue value.
  11906. * 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).
  11907. */
  11908. set midtonesHue(value: number);
  11909. /**
  11910. * Gets the midtones Density value.
  11911. * 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.
  11912. * Values less than zero provide a filter of opposite hue.
  11913. */
  11914. get midtonesDensity(): number;
  11915. /**
  11916. * Sets the midtones Density value.
  11917. * 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.
  11918. * Values less than zero provide a filter of opposite hue.
  11919. */
  11920. set midtonesDensity(value: number);
  11921. /**
  11922. * Gets the midtones Saturation value.
  11923. * 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.
  11924. */
  11925. get midtonesSaturation(): number;
  11926. /**
  11927. * Sets the midtones Saturation value.
  11928. * 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.
  11929. */
  11930. set midtonesSaturation(value: number);
  11931. /**
  11932. * Gets the midtones Exposure value.
  11933. * 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.
  11934. */
  11935. get midtonesExposure(): number;
  11936. /**
  11937. * Sets the midtones Exposure value.
  11938. * 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.
  11939. */
  11940. set midtonesExposure(value: number);
  11941. private _shadowsHue;
  11942. private _shadowsDensity;
  11943. private _shadowsSaturation;
  11944. private _shadowsExposure;
  11945. /**
  11946. * Gets the shadows Hue value.
  11947. * 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).
  11948. */
  11949. get shadowsHue(): number;
  11950. /**
  11951. * Sets the shadows Hue value.
  11952. * 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).
  11953. */
  11954. set shadowsHue(value: number);
  11955. /**
  11956. * Gets the shadows Density value.
  11957. * 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.
  11958. * Values less than zero provide a filter of opposite hue.
  11959. */
  11960. get shadowsDensity(): number;
  11961. /**
  11962. * Sets the shadows Density value.
  11963. * 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.
  11964. * Values less than zero provide a filter of opposite hue.
  11965. */
  11966. set shadowsDensity(value: number);
  11967. /**
  11968. * Gets the shadows Saturation value.
  11969. * 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.
  11970. */
  11971. get shadowsSaturation(): number;
  11972. /**
  11973. * Sets the shadows Saturation value.
  11974. * 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.
  11975. */
  11976. set shadowsSaturation(value: number);
  11977. /**
  11978. * Gets the shadows Exposure value.
  11979. * 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.
  11980. */
  11981. get shadowsExposure(): number;
  11982. /**
  11983. * Sets the shadows Exposure value.
  11984. * 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.
  11985. */
  11986. set shadowsExposure(value: number);
  11987. /**
  11988. * Returns the class name
  11989. * @returns The class name
  11990. */
  11991. getClassName(): string;
  11992. /**
  11993. * Binds the color curves to the shader.
  11994. * @param colorCurves The color curve to bind
  11995. * @param effect The effect to bind to
  11996. * @param positiveUniform The positive uniform shader parameter
  11997. * @param neutralUniform The neutral uniform shader parameter
  11998. * @param negativeUniform The negative uniform shader parameter
  11999. */
  12000. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12001. /**
  12002. * Prepare the list of uniforms associated with the ColorCurves effects.
  12003. * @param uniformsList The list of uniforms used in the effect
  12004. */
  12005. static PrepareUniforms(uniformsList: string[]): void;
  12006. /**
  12007. * Returns color grading data based on a hue, density, saturation and exposure value.
  12008. * @param filterHue The hue of the color filter.
  12009. * @param filterDensity The density of the color filter.
  12010. * @param saturation The saturation.
  12011. * @param exposure The exposure.
  12012. * @param result The result data container.
  12013. */
  12014. private getColorGradingDataToRef;
  12015. /**
  12016. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12017. * @param value The input slider value in range [-100,100].
  12018. * @returns Adjusted value.
  12019. */
  12020. private static applyColorGradingSliderNonlinear;
  12021. /**
  12022. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12023. * @param hue The hue (H) input.
  12024. * @param saturation The saturation (S) input.
  12025. * @param brightness The brightness (B) input.
  12026. * @result An RGBA color represented as Vector4.
  12027. */
  12028. private static fromHSBToRef;
  12029. /**
  12030. * Returns a value clamped between min and max
  12031. * @param value The value to clamp
  12032. * @param min The minimum of value
  12033. * @param max The maximum of value
  12034. * @returns The clamped value.
  12035. */
  12036. private static clamp;
  12037. /**
  12038. * Clones the current color curve instance.
  12039. * @return The cloned curves
  12040. */
  12041. clone(): ColorCurves;
  12042. /**
  12043. * Serializes the current color curve instance to a json representation.
  12044. * @return a JSON representation
  12045. */
  12046. serialize(): any;
  12047. /**
  12048. * Parses the color curve from a json representation.
  12049. * @param source the JSON source to parse
  12050. * @return The parsed curves
  12051. */
  12052. static Parse(source: any): ColorCurves;
  12053. }
  12054. }
  12055. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  12056. import { Observable } from "babylonjs/Misc/observable";
  12057. import { Nullable } from "babylonjs/types";
  12058. import { Color4 } from "babylonjs/Maths/math.color";
  12059. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  12060. import { Effect } from "babylonjs/Materials/effect";
  12061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12062. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  12063. /**
  12064. * Interface to follow in your material defines to integrate easily the
  12065. * Image proccessing functions.
  12066. * @hidden
  12067. */
  12068. export interface IImageProcessingConfigurationDefines {
  12069. IMAGEPROCESSING: boolean;
  12070. VIGNETTE: boolean;
  12071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12072. VIGNETTEBLENDMODEOPAQUE: boolean;
  12073. TONEMAPPING: boolean;
  12074. TONEMAPPING_ACES: boolean;
  12075. CONTRAST: boolean;
  12076. EXPOSURE: boolean;
  12077. COLORCURVES: boolean;
  12078. COLORGRADING: boolean;
  12079. COLORGRADING3D: boolean;
  12080. SAMPLER3DGREENDEPTH: boolean;
  12081. SAMPLER3DBGRMAP: boolean;
  12082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12083. }
  12084. /**
  12085. * @hidden
  12086. */
  12087. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12088. IMAGEPROCESSING: boolean;
  12089. VIGNETTE: boolean;
  12090. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12091. VIGNETTEBLENDMODEOPAQUE: boolean;
  12092. TONEMAPPING: boolean;
  12093. TONEMAPPING_ACES: boolean;
  12094. CONTRAST: boolean;
  12095. COLORCURVES: boolean;
  12096. COLORGRADING: boolean;
  12097. COLORGRADING3D: boolean;
  12098. SAMPLER3DGREENDEPTH: boolean;
  12099. SAMPLER3DBGRMAP: boolean;
  12100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12101. EXPOSURE: boolean;
  12102. constructor();
  12103. }
  12104. /**
  12105. * This groups together the common properties used for image processing either in direct forward pass
  12106. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12107. * or not.
  12108. */
  12109. export class ImageProcessingConfiguration {
  12110. /**
  12111. * Default tone mapping applied in BabylonJS.
  12112. */
  12113. static readonly TONEMAPPING_STANDARD: number;
  12114. /**
  12115. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12116. * to other engines rendering to increase portability.
  12117. */
  12118. static readonly TONEMAPPING_ACES: number;
  12119. /**
  12120. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12121. */
  12122. colorCurves: Nullable<ColorCurves>;
  12123. private _colorCurvesEnabled;
  12124. /**
  12125. * Gets wether the color curves effect is enabled.
  12126. */
  12127. get colorCurvesEnabled(): boolean;
  12128. /**
  12129. * Sets wether the color curves effect is enabled.
  12130. */
  12131. set colorCurvesEnabled(value: boolean);
  12132. private _colorGradingTexture;
  12133. /**
  12134. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12135. */
  12136. get colorGradingTexture(): Nullable<BaseTexture>;
  12137. /**
  12138. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12139. */
  12140. set colorGradingTexture(value: Nullable<BaseTexture>);
  12141. private _colorGradingEnabled;
  12142. /**
  12143. * Gets wether the color grading effect is enabled.
  12144. */
  12145. get colorGradingEnabled(): boolean;
  12146. /**
  12147. * Sets wether the color grading effect is enabled.
  12148. */
  12149. set colorGradingEnabled(value: boolean);
  12150. private _colorGradingWithGreenDepth;
  12151. /**
  12152. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12153. */
  12154. get colorGradingWithGreenDepth(): boolean;
  12155. /**
  12156. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12157. */
  12158. set colorGradingWithGreenDepth(value: boolean);
  12159. private _colorGradingBGR;
  12160. /**
  12161. * Gets wether the color grading texture contains BGR values.
  12162. */
  12163. get colorGradingBGR(): boolean;
  12164. /**
  12165. * Sets wether the color grading texture contains BGR values.
  12166. */
  12167. set colorGradingBGR(value: boolean);
  12168. /** @hidden */
  12169. _exposure: number;
  12170. /**
  12171. * Gets the Exposure used in the effect.
  12172. */
  12173. get exposure(): number;
  12174. /**
  12175. * Sets the Exposure used in the effect.
  12176. */
  12177. set exposure(value: number);
  12178. private _toneMappingEnabled;
  12179. /**
  12180. * Gets wether the tone mapping effect is enabled.
  12181. */
  12182. get toneMappingEnabled(): boolean;
  12183. /**
  12184. * Sets wether the tone mapping effect is enabled.
  12185. */
  12186. set toneMappingEnabled(value: boolean);
  12187. private _toneMappingType;
  12188. /**
  12189. * Gets the type of tone mapping effect.
  12190. */
  12191. get toneMappingType(): number;
  12192. /**
  12193. * Sets the type of tone mapping effect used in BabylonJS.
  12194. */
  12195. set toneMappingType(value: number);
  12196. protected _contrast: number;
  12197. /**
  12198. * Gets the contrast used in the effect.
  12199. */
  12200. get contrast(): number;
  12201. /**
  12202. * Sets the contrast used in the effect.
  12203. */
  12204. set contrast(value: number);
  12205. /**
  12206. * Vignette stretch size.
  12207. */
  12208. vignetteStretch: number;
  12209. /**
  12210. * Vignette centre X Offset.
  12211. */
  12212. vignetteCentreX: number;
  12213. /**
  12214. * Vignette centre Y Offset.
  12215. */
  12216. vignetteCentreY: number;
  12217. /**
  12218. * Vignette weight or intensity of the vignette effect.
  12219. */
  12220. vignetteWeight: number;
  12221. /**
  12222. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12223. * if vignetteEnabled is set to true.
  12224. */
  12225. vignetteColor: Color4;
  12226. /**
  12227. * Camera field of view used by the Vignette effect.
  12228. */
  12229. vignetteCameraFov: number;
  12230. private _vignetteBlendMode;
  12231. /**
  12232. * Gets the vignette blend mode allowing different kind of effect.
  12233. */
  12234. get vignetteBlendMode(): number;
  12235. /**
  12236. * Sets the vignette blend mode allowing different kind of effect.
  12237. */
  12238. set vignetteBlendMode(value: number);
  12239. private _vignetteEnabled;
  12240. /**
  12241. * Gets wether the vignette effect is enabled.
  12242. */
  12243. get vignetteEnabled(): boolean;
  12244. /**
  12245. * Sets wether the vignette effect is enabled.
  12246. */
  12247. set vignetteEnabled(value: boolean);
  12248. private _applyByPostProcess;
  12249. /**
  12250. * Gets wether the image processing is applied through a post process or not.
  12251. */
  12252. get applyByPostProcess(): boolean;
  12253. /**
  12254. * Sets wether the image processing is applied through a post process or not.
  12255. */
  12256. set applyByPostProcess(value: boolean);
  12257. private _isEnabled;
  12258. /**
  12259. * Gets wether the image processing is enabled or not.
  12260. */
  12261. get isEnabled(): boolean;
  12262. /**
  12263. * Sets wether the image processing is enabled or not.
  12264. */
  12265. set isEnabled(value: boolean);
  12266. /**
  12267. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12268. */
  12269. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12270. /**
  12271. * Method called each time the image processing information changes requires to recompile the effect.
  12272. */
  12273. protected _updateParameters(): void;
  12274. /**
  12275. * Gets the current class name.
  12276. * @return "ImageProcessingConfiguration"
  12277. */
  12278. getClassName(): string;
  12279. /**
  12280. * Prepare the list of uniforms associated with the Image Processing effects.
  12281. * @param uniforms The list of uniforms used in the effect
  12282. * @param defines the list of defines currently in use
  12283. */
  12284. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12285. /**
  12286. * Prepare the list of samplers associated with the Image Processing effects.
  12287. * @param samplersList The list of uniforms used in the effect
  12288. * @param defines the list of defines currently in use
  12289. */
  12290. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12291. /**
  12292. * Prepare the list of defines associated to the shader.
  12293. * @param defines the list of defines to complete
  12294. * @param forPostProcess Define if we are currently in post process mode or not
  12295. */
  12296. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12297. /**
  12298. * Returns true if all the image processing information are ready.
  12299. * @returns True if ready, otherwise, false
  12300. */
  12301. isReady(): boolean;
  12302. /**
  12303. * Binds the image processing to the shader.
  12304. * @param effect The effect to bind to
  12305. * @param overrideAspectRatio Override the aspect ratio of the effect
  12306. */
  12307. bind(effect: Effect, overrideAspectRatio?: number): void;
  12308. /**
  12309. * Clones the current image processing instance.
  12310. * @return The cloned image processing
  12311. */
  12312. clone(): ImageProcessingConfiguration;
  12313. /**
  12314. * Serializes the current image processing instance to a json representation.
  12315. * @return a JSON representation
  12316. */
  12317. serialize(): any;
  12318. /**
  12319. * Parses the image processing from a json representation.
  12320. * @param source the JSON source to parse
  12321. * @return The parsed image processing
  12322. */
  12323. static Parse(source: any): ImageProcessingConfiguration;
  12324. private static _VIGNETTEMODE_MULTIPLY;
  12325. private static _VIGNETTEMODE_OPAQUE;
  12326. /**
  12327. * Used to apply the vignette as a mix with the pixel color.
  12328. */
  12329. static get VIGNETTEMODE_MULTIPLY(): number;
  12330. /**
  12331. * Used to apply the vignette as a replacement of the pixel color.
  12332. */
  12333. static get VIGNETTEMODE_OPAQUE(): number;
  12334. }
  12335. }
  12336. declare module "babylonjs/Shaders/postprocess.vertex" {
  12337. /** @hidden */
  12338. export var postprocessVertexShader: {
  12339. name: string;
  12340. shader: string;
  12341. };
  12342. }
  12343. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  12344. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12345. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12346. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  12347. /**
  12348. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12349. */
  12350. export type RenderTargetTextureSize = number | {
  12351. width: number;
  12352. height: number;
  12353. layers?: number;
  12354. };
  12355. module "babylonjs/Engines/thinEngine" {
  12356. interface ThinEngine {
  12357. /**
  12358. * Creates a new render target texture
  12359. * @param size defines the size of the texture
  12360. * @param options defines the options used to create the texture
  12361. * @returns a new render target texture stored in an InternalTexture
  12362. */
  12363. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12364. /**
  12365. * Creates a depth stencil texture.
  12366. * This is only available in WebGL 2 or with the depth texture extension available.
  12367. * @param size The size of face edge in the texture.
  12368. * @param options The options defining the texture.
  12369. * @returns The texture
  12370. */
  12371. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12372. /** @hidden */
  12373. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12374. }
  12375. }
  12376. }
  12377. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  12378. /**
  12379. * Defines the kind of connection point for node based material
  12380. */
  12381. export enum NodeMaterialBlockConnectionPointTypes {
  12382. /** Float */
  12383. Float = 1,
  12384. /** Int */
  12385. Int = 2,
  12386. /** Vector2 */
  12387. Vector2 = 4,
  12388. /** Vector3 */
  12389. Vector3 = 8,
  12390. /** Vector4 */
  12391. Vector4 = 16,
  12392. /** Color3 */
  12393. Color3 = 32,
  12394. /** Color4 */
  12395. Color4 = 64,
  12396. /** Matrix */
  12397. Matrix = 128,
  12398. /** Custom object */
  12399. Object = 256,
  12400. /** Detect type based on connection */
  12401. AutoDetect = 1024,
  12402. /** Output type that will be defined by input type */
  12403. BasedOnInput = 2048
  12404. }
  12405. }
  12406. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  12407. /**
  12408. * Enum used to define the target of a block
  12409. */
  12410. export enum NodeMaterialBlockTargets {
  12411. /** Vertex shader */
  12412. Vertex = 1,
  12413. /** Fragment shader */
  12414. Fragment = 2,
  12415. /** Neutral */
  12416. Neutral = 4,
  12417. /** Vertex and Fragment */
  12418. VertexAndFragment = 3
  12419. }
  12420. }
  12421. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  12422. /**
  12423. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12424. */
  12425. export enum NodeMaterialBlockConnectionPointMode {
  12426. /** Value is an uniform */
  12427. Uniform = 0,
  12428. /** Value is a mesh attribute */
  12429. Attribute = 1,
  12430. /** Value is a varying between vertex and fragment shaders */
  12431. Varying = 2,
  12432. /** Mode is undefined */
  12433. Undefined = 3
  12434. }
  12435. }
  12436. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  12437. /**
  12438. * Enum used to define system values e.g. values automatically provided by the system
  12439. */
  12440. export enum NodeMaterialSystemValues {
  12441. /** World */
  12442. World = 1,
  12443. /** View */
  12444. View = 2,
  12445. /** Projection */
  12446. Projection = 3,
  12447. /** ViewProjection */
  12448. ViewProjection = 4,
  12449. /** WorldView */
  12450. WorldView = 5,
  12451. /** WorldViewProjection */
  12452. WorldViewProjection = 6,
  12453. /** CameraPosition */
  12454. CameraPosition = 7,
  12455. /** Fog Color */
  12456. FogColor = 8,
  12457. /** Delta time */
  12458. DeltaTime = 9
  12459. }
  12460. }
  12461. declare module "babylonjs/Maths/math.frustum" {
  12462. import { Matrix } from "babylonjs/Maths/math.vector";
  12463. import { DeepImmutable } from "babylonjs/types";
  12464. import { Plane } from "babylonjs/Maths/math.plane";
  12465. /**
  12466. * Represents a camera frustum
  12467. */
  12468. export class Frustum {
  12469. /**
  12470. * Gets the planes representing the frustum
  12471. * @param transform matrix to be applied to the returned planes
  12472. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12473. */
  12474. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12475. /**
  12476. * Gets the near frustum plane transformed by the transform matrix
  12477. * @param transform transformation matrix to be applied to the resulting frustum plane
  12478. * @param frustumPlane the resuling frustum plane
  12479. */
  12480. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12481. /**
  12482. * Gets the far frustum plane transformed by the transform matrix
  12483. * @param transform transformation matrix to be applied to the resulting frustum plane
  12484. * @param frustumPlane the resuling frustum plane
  12485. */
  12486. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12487. /**
  12488. * Gets the left frustum plane transformed by the transform matrix
  12489. * @param transform transformation matrix to be applied to the resulting frustum plane
  12490. * @param frustumPlane the resuling frustum plane
  12491. */
  12492. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12493. /**
  12494. * Gets the right frustum plane transformed by the transform matrix
  12495. * @param transform transformation matrix to be applied to the resulting frustum plane
  12496. * @param frustumPlane the resuling frustum plane
  12497. */
  12498. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12499. /**
  12500. * Gets the top frustum plane transformed by the transform matrix
  12501. * @param transform transformation matrix to be applied to the resulting frustum plane
  12502. * @param frustumPlane the resuling frustum plane
  12503. */
  12504. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12505. /**
  12506. * Gets the bottom frustum plane transformed by the transform matrix
  12507. * @param transform transformation matrix to be applied to the resulting frustum plane
  12508. * @param frustumPlane the resuling frustum plane
  12509. */
  12510. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12511. /**
  12512. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12513. * @param transform transformation matrix to be applied to the resulting frustum planes
  12514. * @param frustumPlanes the resuling frustum planes
  12515. */
  12516. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12517. }
  12518. }
  12519. declare module "babylonjs/Maths/math.vertexFormat" {
  12520. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12521. /**
  12522. * Contains position and normal vectors for a vertex
  12523. */
  12524. export class PositionNormalVertex {
  12525. /** the position of the vertex (defaut: 0,0,0) */
  12526. position: Vector3;
  12527. /** the normal of the vertex (defaut: 0,1,0) */
  12528. normal: Vector3;
  12529. /**
  12530. * Creates a PositionNormalVertex
  12531. * @param position the position of the vertex (defaut: 0,0,0)
  12532. * @param normal the normal of the vertex (defaut: 0,1,0)
  12533. */
  12534. constructor(
  12535. /** the position of the vertex (defaut: 0,0,0) */
  12536. position?: Vector3,
  12537. /** the normal of the vertex (defaut: 0,1,0) */
  12538. normal?: Vector3);
  12539. /**
  12540. * Clones the PositionNormalVertex
  12541. * @returns the cloned PositionNormalVertex
  12542. */
  12543. clone(): PositionNormalVertex;
  12544. }
  12545. /**
  12546. * Contains position, normal and uv vectors for a vertex
  12547. */
  12548. export class PositionNormalTextureVertex {
  12549. /** the position of the vertex (defaut: 0,0,0) */
  12550. position: Vector3;
  12551. /** the normal of the vertex (defaut: 0,1,0) */
  12552. normal: Vector3;
  12553. /** the uv of the vertex (default: 0,0) */
  12554. uv: Vector2;
  12555. /**
  12556. * Creates a PositionNormalTextureVertex
  12557. * @param position the position of the vertex (defaut: 0,0,0)
  12558. * @param normal the normal of the vertex (defaut: 0,1,0)
  12559. * @param uv the uv of the vertex (default: 0,0)
  12560. */
  12561. constructor(
  12562. /** the position of the vertex (defaut: 0,0,0) */
  12563. position?: Vector3,
  12564. /** the normal of the vertex (defaut: 0,1,0) */
  12565. normal?: Vector3,
  12566. /** the uv of the vertex (default: 0,0) */
  12567. uv?: Vector2);
  12568. /**
  12569. * Clones the PositionNormalTextureVertex
  12570. * @returns the cloned PositionNormalTextureVertex
  12571. */
  12572. clone(): PositionNormalTextureVertex;
  12573. }
  12574. }
  12575. declare module "babylonjs/Maths/math" {
  12576. export * from "babylonjs/Maths/math.axis";
  12577. export * from "babylonjs/Maths/math.color";
  12578. export * from "babylonjs/Maths/math.constants";
  12579. export * from "babylonjs/Maths/math.frustum";
  12580. export * from "babylonjs/Maths/math.path";
  12581. export * from "babylonjs/Maths/math.plane";
  12582. export * from "babylonjs/Maths/math.size";
  12583. export * from "babylonjs/Maths/math.vector";
  12584. export * from "babylonjs/Maths/math.vertexFormat";
  12585. export * from "babylonjs/Maths/math.viewport";
  12586. }
  12587. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  12588. /**
  12589. * Enum defining the type of animations supported by InputBlock
  12590. */
  12591. export enum AnimatedInputBlockTypes {
  12592. /** No animation */
  12593. None = 0,
  12594. /** Time based animation. Will only work for floats */
  12595. Time = 1
  12596. }
  12597. }
  12598. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12600. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12601. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12602. import { Nullable } from "babylonjs/types";
  12603. import { Effect } from "babylonjs/Materials/effect";
  12604. import { Matrix } from "babylonjs/Maths/math.vector";
  12605. import { Scene } from "babylonjs/scene";
  12606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12608. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12609. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. /**
  12612. * Block used to expose an input value
  12613. */
  12614. export class InputBlock extends NodeMaterialBlock {
  12615. private _mode;
  12616. private _associatedVariableName;
  12617. private _storedValue;
  12618. private _valueCallback;
  12619. private _type;
  12620. private _animationType;
  12621. /** Gets or set a value used to limit the range of float values */
  12622. min: number;
  12623. /** Gets or set a value used to limit the range of float values */
  12624. max: number;
  12625. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12626. isBoolean: boolean;
  12627. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12628. matrixMode: number;
  12629. /** @hidden */
  12630. _systemValue: Nullable<NodeMaterialSystemValues>;
  12631. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12632. isConstant: boolean;
  12633. /** Gets or sets the group to use to display this block in the Inspector */
  12634. groupInInspector: string;
  12635. /** Gets an observable raised when the value is changed */
  12636. onValueChangedObservable: Observable<InputBlock>;
  12637. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12638. convertToGammaSpace: boolean;
  12639. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12640. convertToLinearSpace: boolean;
  12641. /**
  12642. * Gets or sets the connection point type (default is float)
  12643. */
  12644. get type(): NodeMaterialBlockConnectionPointTypes;
  12645. /**
  12646. * Creates a new InputBlock
  12647. * @param name defines the block name
  12648. * @param target defines the target of that block (Vertex by default)
  12649. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12650. */
  12651. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12652. /**
  12653. * Validates if a name is a reserve word.
  12654. * @param newName the new name to be given to the node.
  12655. * @returns false if the name is a reserve word, else true.
  12656. */
  12657. validateBlockName(newName: string): boolean;
  12658. /**
  12659. * Gets the output component
  12660. */
  12661. get output(): NodeMaterialConnectionPoint;
  12662. /**
  12663. * Set the source of this connection point to a vertex attribute
  12664. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12665. * @returns the current connection point
  12666. */
  12667. setAsAttribute(attributeName?: string): InputBlock;
  12668. /**
  12669. * Set the source of this connection point to a system value
  12670. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12671. * @returns the current connection point
  12672. */
  12673. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12674. /**
  12675. * Gets or sets the value of that point.
  12676. * Please note that this value will be ignored if valueCallback is defined
  12677. */
  12678. get value(): any;
  12679. set value(value: any);
  12680. /**
  12681. * Gets or sets a callback used to get the value of that point.
  12682. * Please note that setting this value will force the connection point to ignore the value property
  12683. */
  12684. get valueCallback(): () => any;
  12685. set valueCallback(value: () => any);
  12686. /**
  12687. * Gets or sets the associated variable name in the shader
  12688. */
  12689. get associatedVariableName(): string;
  12690. set associatedVariableName(value: string);
  12691. /** Gets or sets the type of animation applied to the input */
  12692. get animationType(): AnimatedInputBlockTypes;
  12693. set animationType(value: AnimatedInputBlockTypes);
  12694. /**
  12695. * Gets a boolean indicating that this connection point not defined yet
  12696. */
  12697. get isUndefined(): boolean;
  12698. /**
  12699. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12700. * In this case the connection point name must be the name of the uniform to use.
  12701. * Can only be set on inputs
  12702. */
  12703. get isUniform(): boolean;
  12704. set isUniform(value: boolean);
  12705. /**
  12706. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12707. * In this case the connection point name must be the name of the attribute to use
  12708. * Can only be set on inputs
  12709. */
  12710. get isAttribute(): boolean;
  12711. set isAttribute(value: boolean);
  12712. /**
  12713. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12714. * Can only be set on exit points
  12715. */
  12716. get isVarying(): boolean;
  12717. set isVarying(value: boolean);
  12718. /**
  12719. * Gets a boolean indicating that the current connection point is a system value
  12720. */
  12721. get isSystemValue(): boolean;
  12722. /**
  12723. * Gets or sets the current well known value or null if not defined as a system value
  12724. */
  12725. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12726. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12727. /**
  12728. * Gets the current class name
  12729. * @returns the class name
  12730. */
  12731. getClassName(): string;
  12732. /**
  12733. * Animate the input if animationType !== None
  12734. * @param scene defines the rendering scene
  12735. */
  12736. animate(scene: Scene): void;
  12737. private _emitDefine;
  12738. initialize(state: NodeMaterialBuildState): void;
  12739. /**
  12740. * Set the input block to its default value (based on its type)
  12741. */
  12742. setDefaultValue(): void;
  12743. private _emitConstant;
  12744. /** @hidden */
  12745. get _noContextSwitch(): boolean;
  12746. private _emit;
  12747. /** @hidden */
  12748. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12749. /** @hidden */
  12750. _transmit(effect: Effect, scene: Scene): void;
  12751. protected _buildBlock(state: NodeMaterialBuildState): void;
  12752. protected _dumpPropertiesCode(): string;
  12753. dispose(): void;
  12754. serialize(): any;
  12755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12756. }
  12757. }
  12758. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12759. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12760. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12761. import { Nullable } from "babylonjs/types";
  12762. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12763. import { Observable } from "babylonjs/Misc/observable";
  12764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12765. /**
  12766. * Enum used to define the compatibility state between two connection points
  12767. */
  12768. export enum NodeMaterialConnectionPointCompatibilityStates {
  12769. /** Points are compatibles */
  12770. Compatible = 0,
  12771. /** Points are incompatible because of their types */
  12772. TypeIncompatible = 1,
  12773. /** Points are incompatible because of their targets (vertex vs fragment) */
  12774. TargetIncompatible = 2
  12775. }
  12776. /**
  12777. * Defines the direction of a connection point
  12778. */
  12779. export enum NodeMaterialConnectionPointDirection {
  12780. /** Input */
  12781. Input = 0,
  12782. /** Output */
  12783. Output = 1
  12784. }
  12785. /**
  12786. * Defines a connection point for a block
  12787. */
  12788. export class NodeMaterialConnectionPoint {
  12789. /**
  12790. * Checks if two types are equivalent
  12791. * @param type1 type 1 to check
  12792. * @param type2 type 2 to check
  12793. * @returns true if both types are equivalent, else false
  12794. */
  12795. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12796. /** @hidden */
  12797. _ownerBlock: NodeMaterialBlock;
  12798. /** @hidden */
  12799. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12800. private _endpoints;
  12801. private _associatedVariableName;
  12802. private _direction;
  12803. /** @hidden */
  12804. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12805. /** @hidden */
  12806. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12807. /** @hidden */
  12808. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12809. private _type;
  12810. /** @hidden */
  12811. _enforceAssociatedVariableName: boolean;
  12812. /** Gets the direction of the point */
  12813. get direction(): NodeMaterialConnectionPointDirection;
  12814. /** Indicates that this connection point needs dual validation before being connected to another point */
  12815. needDualDirectionValidation: boolean;
  12816. /**
  12817. * Gets or sets the additional types supported by this connection point
  12818. */
  12819. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12820. /**
  12821. * Gets or sets the additional types excluded by this connection point
  12822. */
  12823. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12824. /**
  12825. * Observable triggered when this point is connected
  12826. */
  12827. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12828. /**
  12829. * Gets or sets the associated variable name in the shader
  12830. */
  12831. get associatedVariableName(): string;
  12832. set associatedVariableName(value: string);
  12833. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12834. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12835. /**
  12836. * Gets or sets the connection point type (default is float)
  12837. */
  12838. get type(): NodeMaterialBlockConnectionPointTypes;
  12839. set type(value: NodeMaterialBlockConnectionPointTypes);
  12840. /**
  12841. * Gets or sets the connection point name
  12842. */
  12843. name: string;
  12844. /**
  12845. * Gets or sets the connection point name
  12846. */
  12847. displayName: string;
  12848. /**
  12849. * Gets or sets a boolean indicating that this connection point can be omitted
  12850. */
  12851. isOptional: boolean;
  12852. /**
  12853. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12854. */
  12855. isExposedOnFrame: boolean;
  12856. /**
  12857. * Gets or sets number indicating the position that the port is exposed to on a frame
  12858. */
  12859. exposedPortPosition: number;
  12860. /**
  12861. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12862. */
  12863. define: string;
  12864. /** @hidden */
  12865. _prioritizeVertex: boolean;
  12866. private _target;
  12867. /** Gets or sets the target of that connection point */
  12868. get target(): NodeMaterialBlockTargets;
  12869. set target(value: NodeMaterialBlockTargets);
  12870. /**
  12871. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12872. */
  12873. get isConnected(): boolean;
  12874. /**
  12875. * Gets a boolean indicating that the current point is connected to an input block
  12876. */
  12877. get isConnectedToInputBlock(): boolean;
  12878. /**
  12879. * Gets a the connected input block (if any)
  12880. */
  12881. get connectInputBlock(): Nullable<InputBlock>;
  12882. /** Get the other side of the connection (if any) */
  12883. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12884. /** Get the block that owns this connection point */
  12885. get ownerBlock(): NodeMaterialBlock;
  12886. /** Get the block connected on the other side of this connection (if any) */
  12887. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12888. /** Get the block connected on the endpoints of this connection (if any) */
  12889. get connectedBlocks(): Array<NodeMaterialBlock>;
  12890. /** Gets the list of connected endpoints */
  12891. get endpoints(): NodeMaterialConnectionPoint[];
  12892. /** Gets a boolean indicating if that output point is connected to at least one input */
  12893. get hasEndpoints(): boolean;
  12894. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12895. get isConnectedInVertexShader(): boolean;
  12896. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12897. get isConnectedInFragmentShader(): boolean;
  12898. /**
  12899. * Creates a block suitable to be used as an input for this input point.
  12900. * If null is returned, a block based on the point type will be created.
  12901. * @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
  12902. */
  12903. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12904. /**
  12905. * Creates a new connection point
  12906. * @param name defines the connection point name
  12907. * @param ownerBlock defines the block hosting this connection point
  12908. * @param direction defines the direction of the connection point
  12909. */
  12910. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12911. /**
  12912. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12913. * @returns the class name
  12914. */
  12915. getClassName(): string;
  12916. /**
  12917. * Gets a boolean indicating if the current point can be connected to another point
  12918. * @param connectionPoint defines the other connection point
  12919. * @returns a boolean
  12920. */
  12921. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12922. /**
  12923. * Gets a number indicating if the current point can be connected to another point
  12924. * @param connectionPoint defines the other connection point
  12925. * @returns a number defining the compatibility state
  12926. */
  12927. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12928. /**
  12929. * Connect this point to another connection point
  12930. * @param connectionPoint defines the other connection point
  12931. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12932. * @returns the current connection point
  12933. */
  12934. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12935. /**
  12936. * Disconnect this point from one of his endpoint
  12937. * @param endpoint defines the other connection point
  12938. * @returns the current connection point
  12939. */
  12940. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12941. /**
  12942. * Serializes this point in a JSON representation
  12943. * @param isInput defines if the connection point is an input (default is true)
  12944. * @returns the serialized point object
  12945. */
  12946. serialize(isInput?: boolean): any;
  12947. /**
  12948. * Release resources
  12949. */
  12950. dispose(): void;
  12951. }
  12952. }
  12953. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12954. /**
  12955. * Enum used to define the material modes
  12956. */
  12957. export enum NodeMaterialModes {
  12958. /** Regular material */
  12959. Material = 0,
  12960. /** For post process */
  12961. PostProcess = 1,
  12962. /** For particle system */
  12963. Particle = 2,
  12964. /** For procedural texture */
  12965. ProceduralTexture = 3
  12966. }
  12967. }
  12968. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12969. /** @hidden */
  12970. export var helperFunctions: {
  12971. name: string;
  12972. shader: string;
  12973. };
  12974. }
  12975. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12978. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12981. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12982. import { Effect } from "babylonjs/Materials/effect";
  12983. import { Mesh } from "babylonjs/Meshes/mesh";
  12984. import { Nullable } from "babylonjs/types";
  12985. import { Texture } from "babylonjs/Materials/Textures/texture";
  12986. import { Scene } from "babylonjs/scene";
  12987. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12988. /**
  12989. * Block used to read a texture from a sampler
  12990. */
  12991. export class TextureBlock extends NodeMaterialBlock {
  12992. private _defineName;
  12993. private _linearDefineName;
  12994. private _gammaDefineName;
  12995. private _tempTextureRead;
  12996. private _samplerName;
  12997. private _transformedUVName;
  12998. private _textureTransformName;
  12999. private _textureInfoName;
  13000. private _mainUVName;
  13001. private _mainUVDefineName;
  13002. private _fragmentOnly;
  13003. /**
  13004. * Gets or sets the texture associated with the node
  13005. */
  13006. texture: Nullable<Texture>;
  13007. /**
  13008. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13009. */
  13010. convertToGammaSpace: boolean;
  13011. /**
  13012. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13013. */
  13014. convertToLinearSpace: boolean;
  13015. /**
  13016. * Create a new TextureBlock
  13017. * @param name defines the block name
  13018. */
  13019. constructor(name: string, fragmentOnly?: boolean);
  13020. /**
  13021. * Gets the current class name
  13022. * @returns the class name
  13023. */
  13024. getClassName(): string;
  13025. /**
  13026. * Gets the uv input component
  13027. */
  13028. get uv(): NodeMaterialConnectionPoint;
  13029. /**
  13030. * Gets the rgba output component
  13031. */
  13032. get rgba(): NodeMaterialConnectionPoint;
  13033. /**
  13034. * Gets the rgb output component
  13035. */
  13036. get rgb(): NodeMaterialConnectionPoint;
  13037. /**
  13038. * Gets the r output component
  13039. */
  13040. get r(): NodeMaterialConnectionPoint;
  13041. /**
  13042. * Gets the g output component
  13043. */
  13044. get g(): NodeMaterialConnectionPoint;
  13045. /**
  13046. * Gets the b output component
  13047. */
  13048. get b(): NodeMaterialConnectionPoint;
  13049. /**
  13050. * Gets the a output component
  13051. */
  13052. get a(): NodeMaterialConnectionPoint;
  13053. get target(): NodeMaterialBlockTargets;
  13054. autoConfigure(material: NodeMaterial): void;
  13055. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13057. isReady(): boolean;
  13058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13059. private get _isMixed();
  13060. private _injectVertexCode;
  13061. private _writeTextureRead;
  13062. private _writeOutput;
  13063. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13064. protected _dumpPropertiesCode(): string;
  13065. serialize(): any;
  13066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13067. }
  13068. }
  13069. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  13070. /** @hidden */
  13071. export var reflectionFunction: {
  13072. name: string;
  13073. shader: string;
  13074. };
  13075. }
  13076. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  13077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13082. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13083. import { Effect } from "babylonjs/Materials/effect";
  13084. import { Mesh } from "babylonjs/Meshes/mesh";
  13085. import { Nullable } from "babylonjs/types";
  13086. import { Scene } from "babylonjs/scene";
  13087. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  13088. /**
  13089. * Base block used to read a reflection texture from a sampler
  13090. */
  13091. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13092. /** @hidden */
  13093. _define3DName: string;
  13094. /** @hidden */
  13095. _defineCubicName: string;
  13096. /** @hidden */
  13097. _defineExplicitName: string;
  13098. /** @hidden */
  13099. _defineProjectionName: string;
  13100. /** @hidden */
  13101. _defineLocalCubicName: string;
  13102. /** @hidden */
  13103. _defineSphericalName: string;
  13104. /** @hidden */
  13105. _definePlanarName: string;
  13106. /** @hidden */
  13107. _defineEquirectangularName: string;
  13108. /** @hidden */
  13109. _defineMirroredEquirectangularFixedName: string;
  13110. /** @hidden */
  13111. _defineEquirectangularFixedName: string;
  13112. /** @hidden */
  13113. _defineSkyboxName: string;
  13114. /** @hidden */
  13115. _defineOppositeZ: string;
  13116. /** @hidden */
  13117. _cubeSamplerName: string;
  13118. /** @hidden */
  13119. _2DSamplerName: string;
  13120. protected _positionUVWName: string;
  13121. protected _directionWName: string;
  13122. protected _reflectionVectorName: string;
  13123. /** @hidden */
  13124. _reflectionCoordsName: string;
  13125. /** @hidden */
  13126. _reflectionMatrixName: string;
  13127. protected _reflectionColorName: string;
  13128. /**
  13129. * Gets or sets the texture associated with the node
  13130. */
  13131. texture: Nullable<BaseTexture>;
  13132. /**
  13133. * Create a new ReflectionTextureBaseBlock
  13134. * @param name defines the block name
  13135. */
  13136. constructor(name: string);
  13137. /**
  13138. * Gets the current class name
  13139. * @returns the class name
  13140. */
  13141. getClassName(): string;
  13142. /**
  13143. * Gets the world position input component
  13144. */
  13145. abstract get position(): NodeMaterialConnectionPoint;
  13146. /**
  13147. * Gets the world position input component
  13148. */
  13149. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13150. /**
  13151. * Gets the world normal input component
  13152. */
  13153. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13154. /**
  13155. * Gets the world input component
  13156. */
  13157. abstract get world(): NodeMaterialConnectionPoint;
  13158. /**
  13159. * Gets the camera (or eye) position component
  13160. */
  13161. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13162. /**
  13163. * Gets the view input component
  13164. */
  13165. abstract get view(): NodeMaterialConnectionPoint;
  13166. protected _getTexture(): Nullable<BaseTexture>;
  13167. autoConfigure(material: NodeMaterial): void;
  13168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13169. isReady(): boolean;
  13170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13171. /**
  13172. * Gets the code to inject in the vertex shader
  13173. * @param state current state of the node material building
  13174. * @returns the shader code
  13175. */
  13176. handleVertexSide(state: NodeMaterialBuildState): string;
  13177. /**
  13178. * Handles the inits for the fragment code path
  13179. * @param state node material build state
  13180. */
  13181. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13182. /**
  13183. * Generates the reflection coords code for the fragment code path
  13184. * @param worldNormalVarName name of the world normal variable
  13185. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13186. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13187. * @returns the shader code
  13188. */
  13189. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13190. /**
  13191. * Generates the reflection color code for the fragment code path
  13192. * @param lodVarName name of the lod variable
  13193. * @param swizzleLookupTexture swizzle to use for the final color variable
  13194. * @returns the shader code
  13195. */
  13196. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13197. /**
  13198. * Generates the code corresponding to the connected output points
  13199. * @param state node material build state
  13200. * @param varName name of the variable to output
  13201. * @returns the shader code
  13202. */
  13203. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13204. protected _buildBlock(state: NodeMaterialBuildState): this;
  13205. protected _dumpPropertiesCode(): string;
  13206. serialize(): any;
  13207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13208. }
  13209. }
  13210. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  13211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13212. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13213. import { Nullable } from "babylonjs/types";
  13214. /**
  13215. * Defines a connection point to be used for points with a custom object type
  13216. */
  13217. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13218. private _blockType;
  13219. private _blockName;
  13220. private _nameForCheking?;
  13221. /**
  13222. * Creates a new connection point
  13223. * @param name defines the connection point name
  13224. * @param ownerBlock defines the block hosting this connection point
  13225. * @param direction defines the direction of the connection point
  13226. */
  13227. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13228. /**
  13229. * Gets a number indicating if the current point can be connected to another point
  13230. * @param connectionPoint defines the other connection point
  13231. * @returns a number defining the compatibility state
  13232. */
  13233. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13234. /**
  13235. * Creates a block suitable to be used as an input for this input point.
  13236. * If null is returned, a block based on the point type will be created.
  13237. * @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
  13238. */
  13239. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13240. }
  13241. }
  13242. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  13243. /**
  13244. * Enum defining the type of properties that can be edited in the property pages in the NME
  13245. */
  13246. export enum PropertyTypeForEdition {
  13247. /** property is a boolean */
  13248. Boolean = 0,
  13249. /** property is a float */
  13250. Float = 1,
  13251. /** property is a Vector2 */
  13252. Vector2 = 2,
  13253. /** property is a list of values */
  13254. List = 3
  13255. }
  13256. /**
  13257. * Interface that defines an option in a variable of type list
  13258. */
  13259. export interface IEditablePropertyListOption {
  13260. /** label of the option */
  13261. "label": string;
  13262. /** value of the option */
  13263. "value": number;
  13264. }
  13265. /**
  13266. * Interface that defines the options available for an editable property
  13267. */
  13268. export interface IEditablePropertyOption {
  13269. /** min value */
  13270. "min"?: number;
  13271. /** max value */
  13272. "max"?: number;
  13273. /** notifiers: indicates which actions to take when the property is changed */
  13274. "notifiers"?: {
  13275. /** the material should be rebuilt */
  13276. "rebuild"?: boolean;
  13277. /** the preview should be updated */
  13278. "update"?: boolean;
  13279. };
  13280. /** list of the options for a variable of type list */
  13281. "options"?: IEditablePropertyListOption[];
  13282. }
  13283. /**
  13284. * Interface that describes an editable property
  13285. */
  13286. export interface IPropertyDescriptionForEdition {
  13287. /** name of the property */
  13288. "propertyName": string;
  13289. /** display name of the property */
  13290. "displayName": string;
  13291. /** type of the property */
  13292. "type": PropertyTypeForEdition;
  13293. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13294. "groupName": string;
  13295. /** options for the property */
  13296. "options": IEditablePropertyOption;
  13297. }
  13298. /**
  13299. * Decorator that flags a property in a node material block as being editable
  13300. */
  13301. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13302. }
  13303. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  13304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13306. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13308. import { Nullable } from "babylonjs/types";
  13309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13310. import { Mesh } from "babylonjs/Meshes/mesh";
  13311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13312. import { Effect } from "babylonjs/Materials/effect";
  13313. import { Scene } from "babylonjs/scene";
  13314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13315. /**
  13316. * Block used to implement the refraction part of the sub surface module of the PBR material
  13317. */
  13318. export class RefractionBlock extends NodeMaterialBlock {
  13319. /** @hidden */
  13320. _define3DName: string;
  13321. /** @hidden */
  13322. _refractionMatrixName: string;
  13323. /** @hidden */
  13324. _defineLODRefractionAlpha: string;
  13325. /** @hidden */
  13326. _defineLinearSpecularRefraction: string;
  13327. /** @hidden */
  13328. _defineOppositeZ: string;
  13329. /** @hidden */
  13330. _cubeSamplerName: string;
  13331. /** @hidden */
  13332. _2DSamplerName: string;
  13333. /** @hidden */
  13334. _vRefractionMicrosurfaceInfosName: string;
  13335. /** @hidden */
  13336. _vRefractionInfosName: string;
  13337. /** @hidden */
  13338. _vRefractionFilteringInfoName: string;
  13339. private _scene;
  13340. /**
  13341. * The properties below are set by the main PBR block prior to calling methods of this class.
  13342. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13343. * It's less burden on the user side in the editor part.
  13344. */
  13345. /** @hidden */
  13346. viewConnectionPoint: NodeMaterialConnectionPoint;
  13347. /** @hidden */
  13348. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13349. /**
  13350. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13351. * Materials half opaque for instance using refraction could benefit from this control.
  13352. */
  13353. linkRefractionWithTransparency: boolean;
  13354. /**
  13355. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13356. */
  13357. invertRefractionY: boolean;
  13358. /**
  13359. * Gets or sets the texture associated with the node
  13360. */
  13361. texture: Nullable<BaseTexture>;
  13362. /**
  13363. * Create a new RefractionBlock
  13364. * @param name defines the block name
  13365. */
  13366. constructor(name: string);
  13367. /**
  13368. * Gets the current class name
  13369. * @returns the class name
  13370. */
  13371. getClassName(): string;
  13372. /**
  13373. * Gets the intensity input component
  13374. */
  13375. get intensity(): NodeMaterialConnectionPoint;
  13376. /**
  13377. * Gets the tint at distance input component
  13378. */
  13379. get tintAtDistance(): NodeMaterialConnectionPoint;
  13380. /**
  13381. * Gets the view input component
  13382. */
  13383. get view(): NodeMaterialConnectionPoint;
  13384. /**
  13385. * Gets the refraction object output component
  13386. */
  13387. get refraction(): NodeMaterialConnectionPoint;
  13388. /**
  13389. * Returns true if the block has a texture
  13390. */
  13391. get hasTexture(): boolean;
  13392. protected _getTexture(): Nullable<BaseTexture>;
  13393. autoConfigure(material: NodeMaterial): void;
  13394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13395. isReady(): boolean;
  13396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13397. /**
  13398. * Gets the main code of the block (fragment side)
  13399. * @param state current state of the node material building
  13400. * @returns the shader code
  13401. */
  13402. getCode(state: NodeMaterialBuildState): string;
  13403. protected _buildBlock(state: NodeMaterialBuildState): this;
  13404. protected _dumpPropertiesCode(): string;
  13405. serialize(): any;
  13406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13407. }
  13408. }
  13409. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  13410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13412. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13415. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13417. import { Nullable } from "babylonjs/types";
  13418. import { Scene } from "babylonjs/scene";
  13419. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13420. /**
  13421. * Base block used as input for post process
  13422. */
  13423. export class CurrentScreenBlock extends NodeMaterialBlock {
  13424. private _samplerName;
  13425. private _linearDefineName;
  13426. private _gammaDefineName;
  13427. private _mainUVName;
  13428. private _tempTextureRead;
  13429. /**
  13430. * Gets or sets the texture associated with the node
  13431. */
  13432. texture: Nullable<BaseTexture>;
  13433. /**
  13434. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13435. */
  13436. convertToGammaSpace: boolean;
  13437. /**
  13438. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13439. */
  13440. convertToLinearSpace: boolean;
  13441. /**
  13442. * Create a new CurrentScreenBlock
  13443. * @param name defines the block name
  13444. */
  13445. constructor(name: string);
  13446. /**
  13447. * Gets the current class name
  13448. * @returns the class name
  13449. */
  13450. getClassName(): string;
  13451. /**
  13452. * Gets the uv input component
  13453. */
  13454. get uv(): NodeMaterialConnectionPoint;
  13455. /**
  13456. * Gets the rgba output component
  13457. */
  13458. get rgba(): NodeMaterialConnectionPoint;
  13459. /**
  13460. * Gets the rgb output component
  13461. */
  13462. get rgb(): NodeMaterialConnectionPoint;
  13463. /**
  13464. * Gets the r output component
  13465. */
  13466. get r(): NodeMaterialConnectionPoint;
  13467. /**
  13468. * Gets the g output component
  13469. */
  13470. get g(): NodeMaterialConnectionPoint;
  13471. /**
  13472. * Gets the b output component
  13473. */
  13474. get b(): NodeMaterialConnectionPoint;
  13475. /**
  13476. * Gets the a output component
  13477. */
  13478. get a(): NodeMaterialConnectionPoint;
  13479. /**
  13480. * Initialize the block and prepare the context for build
  13481. * @param state defines the state that will be used for the build
  13482. */
  13483. initialize(state: NodeMaterialBuildState): void;
  13484. get target(): NodeMaterialBlockTargets;
  13485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13486. isReady(): boolean;
  13487. private _injectVertexCode;
  13488. private _writeTextureRead;
  13489. private _writeOutput;
  13490. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13491. serialize(): any;
  13492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13493. }
  13494. }
  13495. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  13496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  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 for the particle texture
  13507. */
  13508. export class ParticleTextureBlock extends NodeMaterialBlock {
  13509. private _samplerName;
  13510. private _linearDefineName;
  13511. private _gammaDefineName;
  13512. private _tempTextureRead;
  13513. /**
  13514. * Gets or sets the texture associated with the node
  13515. */
  13516. texture: Nullable<BaseTexture>;
  13517. /**
  13518. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13519. */
  13520. convertToGammaSpace: boolean;
  13521. /**
  13522. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13523. */
  13524. convertToLinearSpace: boolean;
  13525. /**
  13526. * Create a new ParticleTextureBlock
  13527. * @param name defines the block name
  13528. */
  13529. constructor(name: string);
  13530. /**
  13531. * Gets the current class name
  13532. * @returns the class name
  13533. */
  13534. getClassName(): string;
  13535. /**
  13536. * Gets the uv input component
  13537. */
  13538. get uv(): NodeMaterialConnectionPoint;
  13539. /**
  13540. * Gets the rgba output component
  13541. */
  13542. get rgba(): NodeMaterialConnectionPoint;
  13543. /**
  13544. * Gets the rgb output component
  13545. */
  13546. get rgb(): NodeMaterialConnectionPoint;
  13547. /**
  13548. * Gets the r output component
  13549. */
  13550. get r(): NodeMaterialConnectionPoint;
  13551. /**
  13552. * Gets the g output component
  13553. */
  13554. get g(): NodeMaterialConnectionPoint;
  13555. /**
  13556. * Gets the b output component
  13557. */
  13558. get b(): NodeMaterialConnectionPoint;
  13559. /**
  13560. * Gets the a output component
  13561. */
  13562. get a(): NodeMaterialConnectionPoint;
  13563. /**
  13564. * Initialize the block and prepare the context for build
  13565. * @param state defines the state that will be used for the build
  13566. */
  13567. initialize(state: NodeMaterialBuildState): void;
  13568. autoConfigure(material: NodeMaterial): void;
  13569. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13570. isReady(): boolean;
  13571. private _writeOutput;
  13572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13573. serialize(): any;
  13574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13575. }
  13576. }
  13577. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  13578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13580. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  13581. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  13582. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  13583. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  13584. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  13585. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  13586. import { Scene } from "babylonjs/scene";
  13587. /**
  13588. * Class used to store shared data between 2 NodeMaterialBuildState
  13589. */
  13590. export class NodeMaterialBuildStateSharedData {
  13591. /**
  13592. * Gets the list of emitted varyings
  13593. */
  13594. temps: string[];
  13595. /**
  13596. * Gets the list of emitted varyings
  13597. */
  13598. varyings: string[];
  13599. /**
  13600. * Gets the varying declaration string
  13601. */
  13602. varyingDeclaration: string;
  13603. /**
  13604. * Input blocks
  13605. */
  13606. inputBlocks: InputBlock[];
  13607. /**
  13608. * Input blocks
  13609. */
  13610. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13611. /**
  13612. * Bindable blocks (Blocks that need to set data to the effect)
  13613. */
  13614. bindableBlocks: NodeMaterialBlock[];
  13615. /**
  13616. * List of blocks that can provide a compilation fallback
  13617. */
  13618. blocksWithFallbacks: NodeMaterialBlock[];
  13619. /**
  13620. * List of blocks that can provide a define update
  13621. */
  13622. blocksWithDefines: NodeMaterialBlock[];
  13623. /**
  13624. * List of blocks that can provide a repeatable content
  13625. */
  13626. repeatableContentBlocks: NodeMaterialBlock[];
  13627. /**
  13628. * List of blocks that can provide a dynamic list of uniforms
  13629. */
  13630. dynamicUniformBlocks: NodeMaterialBlock[];
  13631. /**
  13632. * List of blocks that can block the isReady function for the material
  13633. */
  13634. blockingBlocks: NodeMaterialBlock[];
  13635. /**
  13636. * Gets the list of animated inputs
  13637. */
  13638. animatedInputs: InputBlock[];
  13639. /**
  13640. * Build Id used to avoid multiple recompilations
  13641. */
  13642. buildId: number;
  13643. /** List of emitted variables */
  13644. variableNames: {
  13645. [key: string]: number;
  13646. };
  13647. /** List of emitted defines */
  13648. defineNames: {
  13649. [key: string]: number;
  13650. };
  13651. /** Should emit comments? */
  13652. emitComments: boolean;
  13653. /** Emit build activity */
  13654. verbose: boolean;
  13655. /** Gets or sets the hosting scene */
  13656. scene: Scene;
  13657. /**
  13658. * Gets the compilation hints emitted at compilation time
  13659. */
  13660. hints: {
  13661. needWorldViewMatrix: boolean;
  13662. needWorldViewProjectionMatrix: boolean;
  13663. needAlphaBlending: boolean;
  13664. needAlphaTesting: boolean;
  13665. };
  13666. /**
  13667. * List of compilation checks
  13668. */
  13669. checks: {
  13670. emitVertex: boolean;
  13671. emitFragment: boolean;
  13672. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13673. };
  13674. /**
  13675. * Is vertex program allowed to be empty?
  13676. */
  13677. allowEmptyVertexProgram: boolean;
  13678. /** Creates a new shared data */
  13679. constructor();
  13680. /**
  13681. * Emits console errors and exceptions if there is a failing check
  13682. */
  13683. emitErrors(): void;
  13684. }
  13685. }
  13686. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13687. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13688. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13689. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13690. /**
  13691. * Class used to store node based material build state
  13692. */
  13693. export class NodeMaterialBuildState {
  13694. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13695. supportUniformBuffers: boolean;
  13696. /**
  13697. * Gets the list of emitted attributes
  13698. */
  13699. attributes: string[];
  13700. /**
  13701. * Gets the list of emitted uniforms
  13702. */
  13703. uniforms: string[];
  13704. /**
  13705. * Gets the list of emitted constants
  13706. */
  13707. constants: string[];
  13708. /**
  13709. * Gets the list of emitted samplers
  13710. */
  13711. samplers: string[];
  13712. /**
  13713. * Gets the list of emitted functions
  13714. */
  13715. functions: {
  13716. [key: string]: string;
  13717. };
  13718. /**
  13719. * Gets the list of emitted extensions
  13720. */
  13721. extensions: {
  13722. [key: string]: string;
  13723. };
  13724. /**
  13725. * Gets the target of the compilation state
  13726. */
  13727. target: NodeMaterialBlockTargets;
  13728. /**
  13729. * Gets the list of emitted counters
  13730. */
  13731. counters: {
  13732. [key: string]: number;
  13733. };
  13734. /**
  13735. * Shared data between multiple NodeMaterialBuildState instances
  13736. */
  13737. sharedData: NodeMaterialBuildStateSharedData;
  13738. /** @hidden */
  13739. _vertexState: NodeMaterialBuildState;
  13740. /** @hidden */
  13741. _attributeDeclaration: string;
  13742. /** @hidden */
  13743. _uniformDeclaration: string;
  13744. /** @hidden */
  13745. _constantDeclaration: string;
  13746. /** @hidden */
  13747. _samplerDeclaration: string;
  13748. /** @hidden */
  13749. _varyingTransfer: string;
  13750. /** @hidden */
  13751. _injectAtEnd: string;
  13752. private _repeatableContentAnchorIndex;
  13753. /** @hidden */
  13754. _builtCompilationString: string;
  13755. /**
  13756. * Gets the emitted compilation strings
  13757. */
  13758. compilationString: string;
  13759. /**
  13760. * Finalize the compilation strings
  13761. * @param state defines the current compilation state
  13762. */
  13763. finalize(state: NodeMaterialBuildState): void;
  13764. /** @hidden */
  13765. get _repeatableContentAnchor(): string;
  13766. /** @hidden */
  13767. _getFreeVariableName(prefix: string): string;
  13768. /** @hidden */
  13769. _getFreeDefineName(prefix: string): string;
  13770. /** @hidden */
  13771. _excludeVariableName(name: string): void;
  13772. /** @hidden */
  13773. _emit2DSampler(name: string): void;
  13774. /** @hidden */
  13775. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13776. /** @hidden */
  13777. _emitExtension(name: string, extension: string, define?: string): void;
  13778. /** @hidden */
  13779. _emitFunction(name: string, code: string, comments: string): void;
  13780. /** @hidden */
  13781. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13782. replaceStrings?: {
  13783. search: RegExp;
  13784. replace: string;
  13785. }[];
  13786. repeatKey?: string;
  13787. }): string;
  13788. /** @hidden */
  13789. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13790. repeatKey?: string;
  13791. removeAttributes?: boolean;
  13792. removeUniforms?: boolean;
  13793. removeVaryings?: boolean;
  13794. removeIfDef?: boolean;
  13795. replaceStrings?: {
  13796. search: RegExp;
  13797. replace: string;
  13798. }[];
  13799. }, storeKey?: string): void;
  13800. /** @hidden */
  13801. _registerTempVariable(name: string): boolean;
  13802. /** @hidden */
  13803. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13804. /** @hidden */
  13805. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13806. /** @hidden */
  13807. _emitFloat(value: number): string;
  13808. }
  13809. }
  13810. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13811. /**
  13812. * Helper class used to generate session unique ID
  13813. */
  13814. export class UniqueIdGenerator {
  13815. private static _UniqueIdCounter;
  13816. /**
  13817. * Gets an unique (relatively to the current scene) Id
  13818. */
  13819. static get UniqueId(): number;
  13820. }
  13821. }
  13822. declare module "babylonjs/Materials/effectFallbacks" {
  13823. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13824. import { Effect } from "babylonjs/Materials/effect";
  13825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13826. /**
  13827. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13828. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13829. */
  13830. export class EffectFallbacks implements IEffectFallbacks {
  13831. private _defines;
  13832. private _currentRank;
  13833. private _maxRank;
  13834. private _mesh;
  13835. /**
  13836. * Removes the fallback from the bound mesh.
  13837. */
  13838. unBindMesh(): void;
  13839. /**
  13840. * Adds a fallback on the specified property.
  13841. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13842. * @param define The name of the define in the shader
  13843. */
  13844. addFallback(rank: number, define: string): void;
  13845. /**
  13846. * Sets the mesh to use CPU skinning when needing to fallback.
  13847. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13848. * @param mesh The mesh to use the fallbacks.
  13849. */
  13850. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13851. /**
  13852. * Checks to see if more fallbacks are still availible.
  13853. */
  13854. get hasMoreFallbacks(): boolean;
  13855. /**
  13856. * Removes the defines that should be removed when falling back.
  13857. * @param currentDefines defines the current define statements for the shader.
  13858. * @param effect defines the current effect we try to compile
  13859. * @returns The resulting defines with defines of the current rank removed.
  13860. */
  13861. reduce(currentDefines: string, effect: Effect): string;
  13862. }
  13863. }
  13864. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13865. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13867. import { Nullable } from "babylonjs/types";
  13868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13869. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13870. import { Effect } from "babylonjs/Materials/effect";
  13871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13872. import { Mesh } from "babylonjs/Meshes/mesh";
  13873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13875. import { Scene } from "babylonjs/scene";
  13876. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13877. /**
  13878. * Defines a block that can be used inside a node based material
  13879. */
  13880. export class NodeMaterialBlock {
  13881. private _buildId;
  13882. private _buildTarget;
  13883. private _target;
  13884. private _isFinalMerger;
  13885. private _isInput;
  13886. private _name;
  13887. protected _isUnique: boolean;
  13888. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13889. inputsAreExclusive: boolean;
  13890. /** @hidden */
  13891. _codeVariableName: string;
  13892. /** @hidden */
  13893. _inputs: NodeMaterialConnectionPoint[];
  13894. /** @hidden */
  13895. _outputs: NodeMaterialConnectionPoint[];
  13896. /** @hidden */
  13897. _preparationId: number;
  13898. /**
  13899. * Gets the name of the block
  13900. */
  13901. get name(): string;
  13902. /**
  13903. * Sets the name of the block. Will check if the name is valid.
  13904. */
  13905. set name(newName: string);
  13906. /**
  13907. * Gets or sets the unique id of the node
  13908. */
  13909. uniqueId: number;
  13910. /**
  13911. * Gets or sets the comments associated with this block
  13912. */
  13913. comments: string;
  13914. /**
  13915. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13916. */
  13917. get isUnique(): boolean;
  13918. /**
  13919. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13920. */
  13921. get isFinalMerger(): boolean;
  13922. /**
  13923. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13924. */
  13925. get isInput(): boolean;
  13926. /**
  13927. * Gets or sets the build Id
  13928. */
  13929. get buildId(): number;
  13930. set buildId(value: number);
  13931. /**
  13932. * Gets or sets the target of the block
  13933. */
  13934. get target(): NodeMaterialBlockTargets;
  13935. set target(value: NodeMaterialBlockTargets);
  13936. /**
  13937. * Gets the list of input points
  13938. */
  13939. get inputs(): NodeMaterialConnectionPoint[];
  13940. /** Gets the list of output points */
  13941. get outputs(): NodeMaterialConnectionPoint[];
  13942. /**
  13943. * Find an input by its name
  13944. * @param name defines the name of the input to look for
  13945. * @returns the input or null if not found
  13946. */
  13947. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13948. /**
  13949. * Find an output by its name
  13950. * @param name defines the name of the outputto look for
  13951. * @returns the output or null if not found
  13952. */
  13953. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13954. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13955. visibleInInspector: boolean;
  13956. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13957. visibleOnFrame: boolean;
  13958. /**
  13959. * Creates a new NodeMaterialBlock
  13960. * @param name defines the block name
  13961. * @param target defines the target of that block (Vertex by default)
  13962. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13963. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13964. */
  13965. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13966. /**
  13967. * Initialize the block and prepare the context for build
  13968. * @param state defines the state that will be used for the build
  13969. */
  13970. initialize(state: NodeMaterialBuildState): void;
  13971. /**
  13972. * Bind data to effect. Will only be called for blocks with isBindable === true
  13973. * @param effect defines the effect to bind data to
  13974. * @param nodeMaterial defines the hosting NodeMaterial
  13975. * @param mesh defines the mesh that will be rendered
  13976. * @param subMesh defines the submesh that will be rendered
  13977. */
  13978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13979. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13980. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13981. protected _writeFloat(value: number): string;
  13982. /**
  13983. * Gets the current class name e.g. "NodeMaterialBlock"
  13984. * @returns the class name
  13985. */
  13986. getClassName(): string;
  13987. /**
  13988. * Register a new input. Must be called inside a block constructor
  13989. * @param name defines the connection point name
  13990. * @param type defines the connection point type
  13991. * @param isOptional defines a boolean indicating that this input can be omitted
  13992. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13993. * @param point an already created connection point. If not provided, create a new one
  13994. * @returns the current block
  13995. */
  13996. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13997. /**
  13998. * Register a new output. Must be called inside a block constructor
  13999. * @param name defines the connection point name
  14000. * @param type defines the connection point type
  14001. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14002. * @param point an already created connection point. If not provided, create a new one
  14003. * @returns the current block
  14004. */
  14005. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14006. /**
  14007. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  14008. * @param forOutput defines an optional connection point to check compatibility with
  14009. * @returns the first available input or null
  14010. */
  14011. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  14012. /**
  14013. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14014. * @param forBlock defines an optional block to check compatibility with
  14015. * @returns the first available input or null
  14016. */
  14017. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14018. /**
  14019. * Gets the sibling of the given output
  14020. * @param current defines the current output
  14021. * @returns the next output in the list or null
  14022. */
  14023. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14024. /**
  14025. * Connect current block with another block
  14026. * @param other defines the block to connect with
  14027. * @param options define the various options to help pick the right connections
  14028. * @returns the current block
  14029. */
  14030. connectTo(other: NodeMaterialBlock, options?: {
  14031. input?: string;
  14032. output?: string;
  14033. outputSwizzle?: string;
  14034. }): this | undefined;
  14035. protected _buildBlock(state: NodeMaterialBuildState): void;
  14036. /**
  14037. * Add uniforms, samplers and uniform buffers at compilation time
  14038. * @param state defines the state to update
  14039. * @param nodeMaterial defines the node material requesting the update
  14040. * @param defines defines the material defines to update
  14041. * @param uniformBuffers defines the list of uniform buffer names
  14042. */
  14043. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14044. /**
  14045. * Add potential fallbacks if shader compilation fails
  14046. * @param mesh defines the mesh to be rendered
  14047. * @param fallbacks defines the current prioritized list of fallbacks
  14048. */
  14049. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14050. /**
  14051. * Initialize defines for shader compilation
  14052. * @param mesh defines the mesh to be rendered
  14053. * @param nodeMaterial defines the node material requesting the update
  14054. * @param defines defines the material defines to update
  14055. * @param useInstances specifies that instances should be used
  14056. */
  14057. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14058. /**
  14059. * Update defines for shader compilation
  14060. * @param mesh defines the mesh to be rendered
  14061. * @param nodeMaterial defines the node material requesting the update
  14062. * @param defines defines the material defines to update
  14063. * @param useInstances specifies that instances should be used
  14064. * @param subMesh defines which submesh to render
  14065. */
  14066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14067. /**
  14068. * Lets the block try to connect some inputs automatically
  14069. * @param material defines the hosting NodeMaterial
  14070. */
  14071. autoConfigure(material: NodeMaterial): void;
  14072. /**
  14073. * Function called when a block is declared as repeatable content generator
  14074. * @param vertexShaderState defines the current compilation state for the vertex shader
  14075. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14076. * @param mesh defines the mesh to be rendered
  14077. * @param defines defines the material defines to update
  14078. */
  14079. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14080. /**
  14081. * Checks if the block is ready
  14082. * @param mesh defines the mesh to be rendered
  14083. * @param nodeMaterial defines the node material requesting the update
  14084. * @param defines defines the material defines to update
  14085. * @param useInstances specifies that instances should be used
  14086. * @returns true if the block is ready
  14087. */
  14088. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14089. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14090. private _processBuild;
  14091. /**
  14092. * Validates the new name for the block node.
  14093. * @param newName the new name to be given to the node.
  14094. * @returns false if the name is a reserve word, else true.
  14095. */
  14096. validateBlockName(newName: string): boolean;
  14097. /**
  14098. * Compile the current node and generate the shader code
  14099. * @param state defines the current compilation state (uniforms, samplers, current string)
  14100. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14101. * @returns true if already built
  14102. */
  14103. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14104. protected _inputRename(name: string): string;
  14105. protected _outputRename(name: string): string;
  14106. protected _dumpPropertiesCode(): string;
  14107. /** @hidden */
  14108. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14109. /** @hidden */
  14110. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14111. /**
  14112. * Clone the current block to a new identical block
  14113. * @param scene defines the hosting scene
  14114. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14115. * @returns a copy of the current block
  14116. */
  14117. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14118. /**
  14119. * Serializes this block in a JSON representation
  14120. * @returns the serialized block object
  14121. */
  14122. serialize(): any;
  14123. /** @hidden */
  14124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14125. private _deserializePortDisplayNamesAndExposedOnFrame;
  14126. /**
  14127. * Release resources
  14128. */
  14129. dispose(): void;
  14130. }
  14131. }
  14132. declare module "babylonjs/Materials/pushMaterial" {
  14133. import { Nullable } from "babylonjs/types";
  14134. import { Scene } from "babylonjs/scene";
  14135. import { Matrix } from "babylonjs/Maths/math.vector";
  14136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14137. import { Mesh } from "babylonjs/Meshes/mesh";
  14138. import { Material } from "babylonjs/Materials/material";
  14139. import { Effect } from "babylonjs/Materials/effect";
  14140. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14141. /**
  14142. * Base class of materials working in push mode in babylon JS
  14143. * @hidden
  14144. */
  14145. export class PushMaterial extends Material {
  14146. protected _activeEffect: Effect;
  14147. protected _normalMatrix: Matrix;
  14148. constructor(name: string, scene: Scene);
  14149. getEffect(): Effect;
  14150. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14151. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14152. /**
  14153. * Binds the given world matrix to the active effect
  14154. *
  14155. * @param world the matrix to bind
  14156. */
  14157. bindOnlyWorldMatrix(world: Matrix): void;
  14158. /**
  14159. * Binds the given normal matrix to the active effect
  14160. *
  14161. * @param normalMatrix the matrix to bind
  14162. */
  14163. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14164. bind(world: Matrix, mesh?: Mesh): void;
  14165. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14166. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14167. }
  14168. }
  14169. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  14170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14171. /**
  14172. * Root class for all node material optimizers
  14173. */
  14174. export class NodeMaterialOptimizer {
  14175. /**
  14176. * Function used to optimize a NodeMaterial graph
  14177. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14178. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14179. */
  14180. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14181. }
  14182. }
  14183. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  14184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14187. import { Scene } from "babylonjs/scene";
  14188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14189. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  14190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14191. /**
  14192. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14193. */
  14194. export class TransformBlock extends NodeMaterialBlock {
  14195. /**
  14196. * Defines the value to use to complement W value to transform it to a Vector4
  14197. */
  14198. complementW: number;
  14199. /**
  14200. * Defines the value to use to complement z value to transform it to a Vector4
  14201. */
  14202. complementZ: number;
  14203. /**
  14204. * Creates a new TransformBlock
  14205. * @param name defines the block name
  14206. */
  14207. constructor(name: string);
  14208. /**
  14209. * Gets the current class name
  14210. * @returns the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Gets the vector input
  14215. */
  14216. get vector(): NodeMaterialConnectionPoint;
  14217. /**
  14218. * Gets the output component
  14219. */
  14220. get output(): NodeMaterialConnectionPoint;
  14221. /**
  14222. * Gets the xyz output component
  14223. */
  14224. get xyz(): NodeMaterialConnectionPoint;
  14225. /**
  14226. * Gets the matrix transform input
  14227. */
  14228. get transform(): NodeMaterialConnectionPoint;
  14229. protected _buildBlock(state: NodeMaterialBuildState): this;
  14230. /**
  14231. * Update defines for shader compilation
  14232. * @param mesh defines the mesh to be rendered
  14233. * @param nodeMaterial defines the node material requesting the update
  14234. * @param defines defines the material defines to update
  14235. * @param useInstances specifies that instances should be used
  14236. * @param subMesh defines which submesh to render
  14237. */
  14238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14239. serialize(): any;
  14240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14241. protected _dumpPropertiesCode(): string;
  14242. }
  14243. }
  14244. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  14245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14248. /**
  14249. * Block used to output the vertex position
  14250. */
  14251. export class VertexOutputBlock extends NodeMaterialBlock {
  14252. /**
  14253. * Creates a new VertexOutputBlock
  14254. * @param name defines the block name
  14255. */
  14256. constructor(name: string);
  14257. /**
  14258. * Gets the current class name
  14259. * @returns the class name
  14260. */
  14261. getClassName(): string;
  14262. /**
  14263. * Gets the vector input component
  14264. */
  14265. get vector(): NodeMaterialConnectionPoint;
  14266. protected _buildBlock(state: NodeMaterialBuildState): this;
  14267. }
  14268. }
  14269. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  14270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14273. /**
  14274. * Block used to output the final color
  14275. */
  14276. export class FragmentOutputBlock extends NodeMaterialBlock {
  14277. /**
  14278. * Create a new FragmentOutputBlock
  14279. * @param name defines the block name
  14280. */
  14281. constructor(name: string);
  14282. /**
  14283. * Gets the current class name
  14284. * @returns the class name
  14285. */
  14286. getClassName(): string;
  14287. /**
  14288. * Gets the rgba input component
  14289. */
  14290. get rgba(): NodeMaterialConnectionPoint;
  14291. /**
  14292. * Gets the rgb input component
  14293. */
  14294. get rgb(): NodeMaterialConnectionPoint;
  14295. /**
  14296. * Gets the a input component
  14297. */
  14298. get a(): NodeMaterialConnectionPoint;
  14299. protected _buildBlock(state: NodeMaterialBuildState): this;
  14300. }
  14301. }
  14302. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  14303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14306. /**
  14307. * Block used for the particle ramp gradient section
  14308. */
  14309. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14310. /**
  14311. * Create a new ParticleRampGradientBlock
  14312. * @param name defines the block name
  14313. */
  14314. constructor(name: string);
  14315. /**
  14316. * Gets the current class name
  14317. * @returns the class name
  14318. */
  14319. getClassName(): string;
  14320. /**
  14321. * Gets the color input component
  14322. */
  14323. get color(): NodeMaterialConnectionPoint;
  14324. /**
  14325. * Gets the rampColor output component
  14326. */
  14327. get rampColor(): NodeMaterialConnectionPoint;
  14328. /**
  14329. * Initialize the block and prepare the context for build
  14330. * @param state defines the state that will be used for the build
  14331. */
  14332. initialize(state: NodeMaterialBuildState): void;
  14333. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14334. }
  14335. }
  14336. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  14337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14340. /**
  14341. * Block used for the particle blend multiply section
  14342. */
  14343. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14344. /**
  14345. * Create a new ParticleBlendMultiplyBlock
  14346. * @param name defines the block name
  14347. */
  14348. constructor(name: string);
  14349. /**
  14350. * Gets the current class name
  14351. * @returns the class name
  14352. */
  14353. getClassName(): string;
  14354. /**
  14355. * Gets the color input component
  14356. */
  14357. get color(): NodeMaterialConnectionPoint;
  14358. /**
  14359. * Gets the alphaTexture input component
  14360. */
  14361. get alphaTexture(): NodeMaterialConnectionPoint;
  14362. /**
  14363. * Gets the alphaColor input component
  14364. */
  14365. get alphaColor(): NodeMaterialConnectionPoint;
  14366. /**
  14367. * Gets the blendColor output component
  14368. */
  14369. get blendColor(): NodeMaterialConnectionPoint;
  14370. /**
  14371. * Initialize the block and prepare the context for build
  14372. * @param state defines the state that will be used for the build
  14373. */
  14374. initialize(state: NodeMaterialBuildState): void;
  14375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14376. }
  14377. }
  14378. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  14379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14382. /**
  14383. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14384. */
  14385. export class VectorMergerBlock extends NodeMaterialBlock {
  14386. /**
  14387. * Create a new VectorMergerBlock
  14388. * @param name defines the block name
  14389. */
  14390. constructor(name: string);
  14391. /**
  14392. * Gets the current class name
  14393. * @returns the class name
  14394. */
  14395. getClassName(): string;
  14396. /**
  14397. * Gets the xyz component (input)
  14398. */
  14399. get xyzIn(): NodeMaterialConnectionPoint;
  14400. /**
  14401. * Gets the xy component (input)
  14402. */
  14403. get xyIn(): NodeMaterialConnectionPoint;
  14404. /**
  14405. * Gets the x component (input)
  14406. */
  14407. get x(): NodeMaterialConnectionPoint;
  14408. /**
  14409. * Gets the y component (input)
  14410. */
  14411. get y(): NodeMaterialConnectionPoint;
  14412. /**
  14413. * Gets the z component (input)
  14414. */
  14415. get z(): NodeMaterialConnectionPoint;
  14416. /**
  14417. * Gets the w component (input)
  14418. */
  14419. get w(): NodeMaterialConnectionPoint;
  14420. /**
  14421. * Gets the xyzw component (output)
  14422. */
  14423. get xyzw(): NodeMaterialConnectionPoint;
  14424. /**
  14425. * Gets the xyz component (output)
  14426. */
  14427. get xyzOut(): NodeMaterialConnectionPoint;
  14428. /**
  14429. * Gets the xy component (output)
  14430. */
  14431. get xyOut(): NodeMaterialConnectionPoint;
  14432. /**
  14433. * Gets the xy component (output)
  14434. * @deprecated Please use xyOut instead.
  14435. */
  14436. get xy(): NodeMaterialConnectionPoint;
  14437. /**
  14438. * Gets the xyz component (output)
  14439. * @deprecated Please use xyzOut instead.
  14440. */
  14441. get xyz(): NodeMaterialConnectionPoint;
  14442. protected _buildBlock(state: NodeMaterialBuildState): this;
  14443. }
  14444. }
  14445. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  14446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14449. import { Vector2 } from "babylonjs/Maths/math.vector";
  14450. import { Scene } from "babylonjs/scene";
  14451. /**
  14452. * Block used to remap a float from a range to a new one
  14453. */
  14454. export class RemapBlock extends NodeMaterialBlock {
  14455. /**
  14456. * Gets or sets the source range
  14457. */
  14458. sourceRange: Vector2;
  14459. /**
  14460. * Gets or sets the target range
  14461. */
  14462. targetRange: Vector2;
  14463. /**
  14464. * Creates a new RemapBlock
  14465. * @param name defines the block name
  14466. */
  14467. constructor(name: string);
  14468. /**
  14469. * Gets the current class name
  14470. * @returns the class name
  14471. */
  14472. getClassName(): string;
  14473. /**
  14474. * Gets the input component
  14475. */
  14476. get input(): NodeMaterialConnectionPoint;
  14477. /**
  14478. * Gets the source min input component
  14479. */
  14480. get sourceMin(): NodeMaterialConnectionPoint;
  14481. /**
  14482. * Gets the source max input component
  14483. */
  14484. get sourceMax(): NodeMaterialConnectionPoint;
  14485. /**
  14486. * Gets the target min input component
  14487. */
  14488. get targetMin(): NodeMaterialConnectionPoint;
  14489. /**
  14490. * Gets the target max input component
  14491. */
  14492. get targetMax(): NodeMaterialConnectionPoint;
  14493. /**
  14494. * Gets the output component
  14495. */
  14496. get output(): NodeMaterialConnectionPoint;
  14497. protected _buildBlock(state: NodeMaterialBuildState): this;
  14498. protected _dumpPropertiesCode(): string;
  14499. serialize(): any;
  14500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14501. }
  14502. }
  14503. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  14504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14507. /**
  14508. * Block used to multiply 2 values
  14509. */
  14510. export class MultiplyBlock extends NodeMaterialBlock {
  14511. /**
  14512. * Creates a new MultiplyBlock
  14513. * @param name defines the block name
  14514. */
  14515. constructor(name: string);
  14516. /**
  14517. * Gets the current class name
  14518. * @returns the class name
  14519. */
  14520. getClassName(): string;
  14521. /**
  14522. * Gets the left operand input component
  14523. */
  14524. get left(): NodeMaterialConnectionPoint;
  14525. /**
  14526. * Gets the right operand input component
  14527. */
  14528. get right(): NodeMaterialConnectionPoint;
  14529. /**
  14530. * Gets the output component
  14531. */
  14532. get output(): NodeMaterialConnectionPoint;
  14533. protected _buildBlock(state: NodeMaterialBuildState): this;
  14534. }
  14535. }
  14536. declare module "babylonjs/Misc/gradients" {
  14537. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14538. /** Interface used by value gradients (color, factor, ...) */
  14539. export interface IValueGradient {
  14540. /**
  14541. * Gets or sets the gradient value (between 0 and 1)
  14542. */
  14543. gradient: number;
  14544. }
  14545. /** Class used to store color4 gradient */
  14546. export class ColorGradient implements IValueGradient {
  14547. /**
  14548. * Gets or sets the gradient value (between 0 and 1)
  14549. */
  14550. gradient: number;
  14551. /**
  14552. * Gets or sets first associated color
  14553. */
  14554. color1: Color4;
  14555. /**
  14556. * Gets or sets second associated color
  14557. */
  14558. color2?: Color4 | undefined;
  14559. /**
  14560. * Creates a new color4 gradient
  14561. * @param gradient gets or sets the gradient value (between 0 and 1)
  14562. * @param color1 gets or sets first associated color
  14563. * @param color2 gets or sets first second color
  14564. */
  14565. constructor(
  14566. /**
  14567. * Gets or sets the gradient value (between 0 and 1)
  14568. */
  14569. gradient: number,
  14570. /**
  14571. * Gets or sets first associated color
  14572. */
  14573. color1: Color4,
  14574. /**
  14575. * Gets or sets second associated color
  14576. */
  14577. color2?: Color4 | undefined);
  14578. /**
  14579. * Will get a color picked randomly between color1 and color2.
  14580. * If color2 is undefined then color1 will be used
  14581. * @param result defines the target Color4 to store the result in
  14582. */
  14583. getColorToRef(result: Color4): void;
  14584. }
  14585. /** Class used to store color 3 gradient */
  14586. export class Color3Gradient implements IValueGradient {
  14587. /**
  14588. * Gets or sets the gradient value (between 0 and 1)
  14589. */
  14590. gradient: number;
  14591. /**
  14592. * Gets or sets the associated color
  14593. */
  14594. color: Color3;
  14595. /**
  14596. * Creates a new color3 gradient
  14597. * @param gradient gets or sets the gradient value (between 0 and 1)
  14598. * @param color gets or sets associated color
  14599. */
  14600. constructor(
  14601. /**
  14602. * Gets or sets the gradient value (between 0 and 1)
  14603. */
  14604. gradient: number,
  14605. /**
  14606. * Gets or sets the associated color
  14607. */
  14608. color: Color3);
  14609. }
  14610. /** Class used to store factor gradient */
  14611. export class FactorGradient implements IValueGradient {
  14612. /**
  14613. * Gets or sets the gradient value (between 0 and 1)
  14614. */
  14615. gradient: number;
  14616. /**
  14617. * Gets or sets first associated factor
  14618. */
  14619. factor1: number;
  14620. /**
  14621. * Gets or sets second associated factor
  14622. */
  14623. factor2?: number | undefined;
  14624. /**
  14625. * Creates a new factor gradient
  14626. * @param gradient gets or sets the gradient value (between 0 and 1)
  14627. * @param factor1 gets or sets first associated factor
  14628. * @param factor2 gets or sets second associated factor
  14629. */
  14630. constructor(
  14631. /**
  14632. * Gets or sets the gradient value (between 0 and 1)
  14633. */
  14634. gradient: number,
  14635. /**
  14636. * Gets or sets first associated factor
  14637. */
  14638. factor1: number,
  14639. /**
  14640. * Gets or sets second associated factor
  14641. */
  14642. factor2?: number | undefined);
  14643. /**
  14644. * Will get a number picked randomly between factor1 and factor2.
  14645. * If factor2 is undefined then factor1 will be used
  14646. * @returns the picked number
  14647. */
  14648. getFactor(): number;
  14649. }
  14650. /**
  14651. * Helper used to simplify some generic gradient tasks
  14652. */
  14653. export class GradientHelper {
  14654. /**
  14655. * Gets the current gradient from an array of IValueGradient
  14656. * @param ratio defines the current ratio to get
  14657. * @param gradients defines the array of IValueGradient
  14658. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14659. */
  14660. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14661. }
  14662. }
  14663. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14664. import { Nullable } from "babylonjs/types";
  14665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14666. import { Scene } from "babylonjs/scene";
  14667. module "babylonjs/Engines/thinEngine" {
  14668. interface ThinEngine {
  14669. /**
  14670. * Creates a raw texture
  14671. * @param data defines the data to store in the texture
  14672. * @param width defines the width of the texture
  14673. * @param height defines the height of the texture
  14674. * @param format defines the format of the data
  14675. * @param generateMipMaps defines if the engine should generate the mip levels
  14676. * @param invertY defines if data must be stored with Y axis inverted
  14677. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14678. * @param compression defines the compression used (null by default)
  14679. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14680. * @returns the raw texture inside an InternalTexture
  14681. */
  14682. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14683. /**
  14684. * Update a raw texture
  14685. * @param texture defines the texture to update
  14686. * @param data defines the data to store in the texture
  14687. * @param format defines the format of the data
  14688. * @param invertY defines if data must be stored with Y axis inverted
  14689. */
  14690. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14691. /**
  14692. * Update a raw texture
  14693. * @param texture defines the texture to update
  14694. * @param data defines the data to store in the texture
  14695. * @param format defines the format of the data
  14696. * @param invertY defines if data must be stored with Y axis inverted
  14697. * @param compression defines the compression used (null by default)
  14698. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14699. */
  14700. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14701. /**
  14702. * Creates a new raw cube texture
  14703. * @param data defines the array of data to use to create each face
  14704. * @param size defines the size of the textures
  14705. * @param format defines the format of the data
  14706. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14707. * @param generateMipMaps defines if the engine should generate the mip levels
  14708. * @param invertY defines if data must be stored with Y axis inverted
  14709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14710. * @param compression defines the compression used (null by default)
  14711. * @returns the cube texture as an InternalTexture
  14712. */
  14713. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14714. /**
  14715. * Update a raw cube texture
  14716. * @param texture defines the texture to udpdate
  14717. * @param data defines the data to store
  14718. * @param format defines the data format
  14719. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14720. * @param invertY defines if data must be stored with Y axis inverted
  14721. */
  14722. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14723. /**
  14724. * Update a raw cube texture
  14725. * @param texture defines the texture to udpdate
  14726. * @param data defines the data to store
  14727. * @param format defines the data format
  14728. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14729. * @param invertY defines if data must be stored with Y axis inverted
  14730. * @param compression defines the compression used (null by default)
  14731. */
  14732. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14733. /**
  14734. * Update a raw cube texture
  14735. * @param texture defines the texture to udpdate
  14736. * @param data defines the data to store
  14737. * @param format defines the data format
  14738. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14739. * @param invertY defines if data must be stored with Y axis inverted
  14740. * @param compression defines the compression used (null by default)
  14741. * @param level defines which level of the texture to update
  14742. */
  14743. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14744. /**
  14745. * Creates a new raw cube texture from a specified url
  14746. * @param url defines the url where the data is located
  14747. * @param scene defines the current scene
  14748. * @param size defines the size of the textures
  14749. * @param format defines the format of the data
  14750. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14751. * @param noMipmap defines if the engine should avoid generating the mip levels
  14752. * @param callback defines a callback used to extract texture data from loaded data
  14753. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14754. * @param onLoad defines a callback called when texture is loaded
  14755. * @param onError defines a callback called if there is an error
  14756. * @returns the cube texture as an InternalTexture
  14757. */
  14758. 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;
  14759. /**
  14760. * Creates a new raw cube texture from a specified url
  14761. * @param url defines the url where the data is located
  14762. * @param scene defines the current scene
  14763. * @param size defines the size of the textures
  14764. * @param format defines the format of the data
  14765. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14766. * @param noMipmap defines if the engine should avoid generating the mip levels
  14767. * @param callback defines a callback used to extract texture data from loaded data
  14768. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14769. * @param onLoad defines a callback called when texture is loaded
  14770. * @param onError defines a callback called if there is an error
  14771. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14772. * @param invertY defines if data must be stored with Y axis inverted
  14773. * @returns the cube texture as an InternalTexture
  14774. */
  14775. 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;
  14776. /**
  14777. * Creates a new raw 3D texture
  14778. * @param data defines the data used to create the texture
  14779. * @param width defines the width of the texture
  14780. * @param height defines the height of the texture
  14781. * @param depth defines the depth of the texture
  14782. * @param format defines the format of the texture
  14783. * @param generateMipMaps defines if the engine must generate mip levels
  14784. * @param invertY defines if data must be stored with Y axis inverted
  14785. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14786. * @param compression defines the compressed used (can be null)
  14787. * @param textureType defines the compressed used (can be null)
  14788. * @returns a new raw 3D texture (stored in an InternalTexture)
  14789. */
  14790. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14791. /**
  14792. * Update a raw 3D texture
  14793. * @param texture defines the texture to update
  14794. * @param data defines the data to store
  14795. * @param format defines the data format
  14796. * @param invertY defines if data must be stored with Y axis inverted
  14797. */
  14798. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14799. /**
  14800. * Update a raw 3D texture
  14801. * @param texture defines the texture to update
  14802. * @param data defines the data to store
  14803. * @param format defines the data format
  14804. * @param invertY defines if data must be stored with Y axis inverted
  14805. * @param compression defines the used compression (can be null)
  14806. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14807. */
  14808. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14809. /**
  14810. * Creates a new raw 2D array texture
  14811. * @param data defines the data used to create the texture
  14812. * @param width defines the width of the texture
  14813. * @param height defines the height of the texture
  14814. * @param depth defines the number of layers of the texture
  14815. * @param format defines the format of the texture
  14816. * @param generateMipMaps defines if the engine must generate mip levels
  14817. * @param invertY defines if data must be stored with Y axis inverted
  14818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14819. * @param compression defines the compressed used (can be null)
  14820. * @param textureType defines the compressed used (can be null)
  14821. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14822. */
  14823. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14824. /**
  14825. * Update a raw 2D array texture
  14826. * @param texture defines the texture to update
  14827. * @param data defines the data to store
  14828. * @param format defines the data format
  14829. * @param invertY defines if data must be stored with Y axis inverted
  14830. */
  14831. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14832. /**
  14833. * Update a raw 2D array texture
  14834. * @param texture defines the texture to update
  14835. * @param data defines the data to store
  14836. * @param format defines the data format
  14837. * @param invertY defines if data must be stored with Y axis inverted
  14838. * @param compression defines the used compression (can be null)
  14839. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14840. */
  14841. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14842. }
  14843. }
  14844. }
  14845. declare module "babylonjs/Materials/Textures/rawTexture" {
  14846. import { Texture } from "babylonjs/Materials/Textures/texture";
  14847. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14848. import { Nullable } from "babylonjs/types";
  14849. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14850. import { Scene } from "babylonjs/scene";
  14851. /**
  14852. * Raw texture can help creating a texture directly from an array of data.
  14853. * This can be super useful if you either get the data from an uncompressed source or
  14854. * if you wish to create your texture pixel by pixel.
  14855. */
  14856. export class RawTexture extends Texture {
  14857. /**
  14858. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14859. */
  14860. format: number;
  14861. /**
  14862. * Instantiates a new RawTexture.
  14863. * Raw texture can help creating a texture directly from an array of data.
  14864. * This can be super useful if you either get the data from an uncompressed source or
  14865. * if you wish to create your texture pixel by pixel.
  14866. * @param data define the array of data to use to create the texture
  14867. * @param width define the width of the texture
  14868. * @param height define the height of the texture
  14869. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14870. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14871. * @param generateMipMaps define whether mip maps should be generated or not
  14872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14875. */
  14876. constructor(data: ArrayBufferView, width: number, height: number,
  14877. /**
  14878. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14879. */
  14880. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14881. /**
  14882. * Updates the texture underlying data.
  14883. * @param data Define the new data of the texture
  14884. */
  14885. update(data: ArrayBufferView): void;
  14886. /**
  14887. * Creates a luminance texture from some data.
  14888. * @param data Define the texture data
  14889. * @param width Define the width of the texture
  14890. * @param height Define the height of the texture
  14891. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14892. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14893. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14894. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14895. * @returns the luminance texture
  14896. */
  14897. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14898. /**
  14899. * Creates a luminance alpha texture from some data.
  14900. * @param data Define the texture data
  14901. * @param width Define the width of the texture
  14902. * @param height Define the height of the texture
  14903. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14904. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14905. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14906. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14907. * @returns the luminance alpha texture
  14908. */
  14909. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14910. /**
  14911. * Creates an alpha texture from some data.
  14912. * @param data Define the texture data
  14913. * @param width Define the width of the texture
  14914. * @param height Define the height of the texture
  14915. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14916. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14917. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14918. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14919. * @returns the alpha texture
  14920. */
  14921. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14922. /**
  14923. * Creates a RGB texture from some data.
  14924. * @param data Define the texture data
  14925. * @param width Define the width of the texture
  14926. * @param height Define the height of the texture
  14927. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14928. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14929. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14930. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14931. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14932. * @returns the RGB alpha texture
  14933. */
  14934. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14935. /**
  14936. * Creates a RGBA texture from some data.
  14937. * @param data Define the texture data
  14938. * @param width Define the width of the texture
  14939. * @param height Define the height of the texture
  14940. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14941. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14942. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14943. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14944. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14945. * @returns the RGBA texture
  14946. */
  14947. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14948. /**
  14949. * Creates a R texture from some data.
  14950. * @param data Define the texture data
  14951. * @param width Define the width of the texture
  14952. * @param height Define the height of the texture
  14953. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14954. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14955. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14956. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14957. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14958. * @returns the R texture
  14959. */
  14960. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14961. }
  14962. }
  14963. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14964. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14965. import { IndicesArray, DataArray } from "babylonjs/types";
  14966. module "babylonjs/Engines/thinEngine" {
  14967. interface ThinEngine {
  14968. /**
  14969. * Update a dynamic index buffer
  14970. * @param indexBuffer defines the target index buffer
  14971. * @param indices defines the data to update
  14972. * @param offset defines the offset in the target index buffer where update should start
  14973. */
  14974. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14975. /**
  14976. * Updates a dynamic vertex buffer.
  14977. * @param vertexBuffer the vertex buffer to update
  14978. * @param data the data used to update the vertex buffer
  14979. * @param byteOffset the byte offset of the data
  14980. * @param byteLength the byte length of the data
  14981. */
  14982. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14983. }
  14984. }
  14985. }
  14986. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14987. import { Scene } from "babylonjs/scene";
  14988. import { ISceneComponent } from "babylonjs/sceneComponent";
  14989. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14990. module "babylonjs/abstractScene" {
  14991. interface AbstractScene {
  14992. /**
  14993. * The list of procedural textures added to the scene
  14994. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14995. */
  14996. proceduralTextures: Array<ProceduralTexture>;
  14997. }
  14998. }
  14999. /**
  15000. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15001. * in a given scene.
  15002. */
  15003. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15004. /**
  15005. * The component name helpfull to identify the component in the list of scene components.
  15006. */
  15007. readonly name: string;
  15008. /**
  15009. * The scene the component belongs to.
  15010. */
  15011. scene: Scene;
  15012. /**
  15013. * Creates a new instance of the component for the given scene
  15014. * @param scene Defines the scene to register the component in
  15015. */
  15016. constructor(scene: Scene);
  15017. /**
  15018. * Registers the component in a given scene
  15019. */
  15020. register(): void;
  15021. /**
  15022. * Rebuilds the elements related to this component in case of
  15023. * context lost for instance.
  15024. */
  15025. rebuild(): void;
  15026. /**
  15027. * Disposes the component and the associated ressources.
  15028. */
  15029. dispose(): void;
  15030. private _beforeClear;
  15031. }
  15032. }
  15033. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  15034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15035. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  15036. module "babylonjs/Engines/thinEngine" {
  15037. interface ThinEngine {
  15038. /**
  15039. * Creates a new render target cube texture
  15040. * @param size defines the size of the texture
  15041. * @param options defines the options used to create the texture
  15042. * @returns a new render target cube texture stored in an InternalTexture
  15043. */
  15044. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15045. }
  15046. }
  15047. }
  15048. declare module "babylonjs/Shaders/procedural.vertex" {
  15049. /** @hidden */
  15050. export var proceduralVertexShader: {
  15051. name: string;
  15052. shader: string;
  15053. };
  15054. }
  15055. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  15056. import { Observable } from "babylonjs/Misc/observable";
  15057. import { Nullable } from "babylonjs/types";
  15058. import { Scene } from "babylonjs/scene";
  15059. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  15060. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15061. import { Effect } from "babylonjs/Materials/effect";
  15062. import { Texture } from "babylonjs/Materials/Textures/texture";
  15063. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15064. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  15065. import "babylonjs/Shaders/procedural.vertex";
  15066. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  15067. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  15068. /**
  15069. * 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.
  15070. * This is the base class of any Procedural texture and contains most of the shareable code.
  15071. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15072. */
  15073. export class ProceduralTexture extends Texture {
  15074. /**
  15075. * Define if the texture is enabled or not (disabled texture will not render)
  15076. */
  15077. isEnabled: boolean;
  15078. /**
  15079. * Define if the texture must be cleared before rendering (default is true)
  15080. */
  15081. autoClear: boolean;
  15082. /**
  15083. * Callback called when the texture is generated
  15084. */
  15085. onGenerated: () => void;
  15086. /**
  15087. * Event raised when the texture is generated
  15088. */
  15089. onGeneratedObservable: Observable<ProceduralTexture>;
  15090. /**
  15091. * Event raised before the texture is generated
  15092. */
  15093. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15094. /**
  15095. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15096. */
  15097. nodeMaterialSource: Nullable<NodeMaterial>;
  15098. /** @hidden */
  15099. _generateMipMaps: boolean;
  15100. /** @hidden **/
  15101. _effect: Effect;
  15102. /** @hidden */
  15103. _textures: {
  15104. [key: string]: Texture;
  15105. };
  15106. /** @hidden */
  15107. protected _fallbackTexture: Nullable<Texture>;
  15108. private _size;
  15109. private _textureType;
  15110. private _currentRefreshId;
  15111. private _frameId;
  15112. private _refreshRate;
  15113. private _vertexBuffers;
  15114. private _indexBuffer;
  15115. private _uniforms;
  15116. private _samplers;
  15117. private _fragment;
  15118. private _floats;
  15119. private _ints;
  15120. private _floatsArrays;
  15121. private _colors3;
  15122. private _colors4;
  15123. private _vectors2;
  15124. private _vectors3;
  15125. private _matrices;
  15126. private _fallbackTextureUsed;
  15127. private _fullEngine;
  15128. private _cachedDefines;
  15129. private _contentUpdateId;
  15130. private _contentData;
  15131. /**
  15132. * Instantiates a new procedural texture.
  15133. * 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.
  15134. * This is the base class of any Procedural texture and contains most of the shareable code.
  15135. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15136. * @param name Define the name of the texture
  15137. * @param size Define the size of the texture to create
  15138. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15139. * @param scene Define the scene the texture belongs to
  15140. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15141. * @param generateMipMaps Define if the texture should creates mip maps or not
  15142. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15143. * @param textureType The FBO internal texture type
  15144. */
  15145. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15146. /**
  15147. * The effect that is created when initializing the post process.
  15148. * @returns The created effect corresponding the the postprocess.
  15149. */
  15150. getEffect(): Effect;
  15151. /**
  15152. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15153. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15154. */
  15155. getContent(): Nullable<Promise<ArrayBufferView>>;
  15156. private _createIndexBuffer;
  15157. /** @hidden */
  15158. _rebuild(): void;
  15159. /**
  15160. * Resets the texture in order to recreate its associated resources.
  15161. * This can be called in case of context loss
  15162. */
  15163. reset(): void;
  15164. protected _getDefines(): string;
  15165. /**
  15166. * Is the texture ready to be used ? (rendered at least once)
  15167. * @returns true if ready, otherwise, false.
  15168. */
  15169. isReady(): boolean;
  15170. /**
  15171. * Resets the refresh counter of the texture and start bak from scratch.
  15172. * Could be useful to regenerate the texture if it is setup to render only once.
  15173. */
  15174. resetRefreshCounter(): void;
  15175. /**
  15176. * Set the fragment shader to use in order to render the texture.
  15177. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15178. */
  15179. setFragment(fragment: any): void;
  15180. /**
  15181. * Define the refresh rate of the texture or the rendering frequency.
  15182. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15183. */
  15184. get refreshRate(): number;
  15185. set refreshRate(value: number);
  15186. /** @hidden */
  15187. _shouldRender(): boolean;
  15188. /**
  15189. * Get the size the texture is rendering at.
  15190. * @returns the size (on cube texture it is always squared)
  15191. */
  15192. getRenderSize(): RenderTargetTextureSize;
  15193. /**
  15194. * Resize the texture to new value.
  15195. * @param size Define the new size the texture should have
  15196. * @param generateMipMaps Define whether the new texture should create mip maps
  15197. */
  15198. resize(size: number, generateMipMaps: boolean): void;
  15199. private _checkUniform;
  15200. /**
  15201. * Set a texture in the shader program used to render.
  15202. * @param name Define the name of the uniform samplers as defined in the shader
  15203. * @param texture Define the texture to bind to this sampler
  15204. * @return the texture itself allowing "fluent" like uniform updates
  15205. */
  15206. setTexture(name: string, texture: Texture): ProceduralTexture;
  15207. /**
  15208. * Set a float in the shader.
  15209. * @param name Define the name of the uniform as defined in the shader
  15210. * @param value Define the value to give to the uniform
  15211. * @return the texture itself allowing "fluent" like uniform updates
  15212. */
  15213. setFloat(name: string, value: number): ProceduralTexture;
  15214. /**
  15215. * Set a int in the shader.
  15216. * @param name Define the name of the uniform as defined in the shader
  15217. * @param value Define the value to give to the uniform
  15218. * @return the texture itself allowing "fluent" like uniform updates
  15219. */
  15220. setInt(name: string, value: number): ProceduralTexture;
  15221. /**
  15222. * Set an array of floats in the shader.
  15223. * @param name Define the name of the uniform as defined in the shader
  15224. * @param value Define the value to give to the uniform
  15225. * @return the texture itself allowing "fluent" like uniform updates
  15226. */
  15227. setFloats(name: string, value: number[]): ProceduralTexture;
  15228. /**
  15229. * Set a vec3 in the shader from a Color3.
  15230. * @param name Define the name of the uniform as defined in the shader
  15231. * @param value Define the value to give to the uniform
  15232. * @return the texture itself allowing "fluent" like uniform updates
  15233. */
  15234. setColor3(name: string, value: Color3): ProceduralTexture;
  15235. /**
  15236. * Set a vec4 in the shader from a Color4.
  15237. * @param name Define the name of the uniform as defined in the shader
  15238. * @param value Define the value to give to the uniform
  15239. * @return the texture itself allowing "fluent" like uniform updates
  15240. */
  15241. setColor4(name: string, value: Color4): ProceduralTexture;
  15242. /**
  15243. * Set a vec2 in the shader from a Vector2.
  15244. * @param name Define the name of the uniform as defined in the shader
  15245. * @param value Define the value to give to the uniform
  15246. * @return the texture itself allowing "fluent" like uniform updates
  15247. */
  15248. setVector2(name: string, value: Vector2): ProceduralTexture;
  15249. /**
  15250. * Set a vec3 in the shader from a Vector3.
  15251. * @param name Define the name of the uniform as defined in the shader
  15252. * @param value Define the value to give to the uniform
  15253. * @return the texture itself allowing "fluent" like uniform updates
  15254. */
  15255. setVector3(name: string, value: Vector3): ProceduralTexture;
  15256. /**
  15257. * Set a mat4 in the shader from a MAtrix.
  15258. * @param name Define the name of the uniform as defined in the shader
  15259. * @param value Define the value to give to the uniform
  15260. * @return the texture itself allowing "fluent" like uniform updates
  15261. */
  15262. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15263. /**
  15264. * Render the texture to its associated render target.
  15265. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15266. */
  15267. render(useCameraPostProcess?: boolean): void;
  15268. /**
  15269. * Clone the texture.
  15270. * @returns the cloned texture
  15271. */
  15272. clone(): ProceduralTexture;
  15273. /**
  15274. * Dispose the texture and release its asoociated resources.
  15275. */
  15276. dispose(): void;
  15277. }
  15278. }
  15279. declare module "babylonjs/Particles/baseParticleSystem" {
  15280. import { Nullable } from "babylonjs/types";
  15281. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  15282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15283. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  15284. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  15285. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15287. import { Color4 } from "babylonjs/Maths/math.color";
  15288. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15289. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  15290. import { Animation } from "babylonjs/Animations/animation";
  15291. import { Scene } from "babylonjs/scene";
  15292. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15293. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15294. /**
  15295. * This represents the base class for particle system in Babylon.
  15296. * 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.
  15297. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15298. * @example https://doc.babylonjs.com/babylon101/particles
  15299. */
  15300. export class BaseParticleSystem {
  15301. /**
  15302. * Source color is added to the destination color without alpha affecting the result
  15303. */
  15304. static BLENDMODE_ONEONE: number;
  15305. /**
  15306. * Blend current color and particle color using particle’s alpha
  15307. */
  15308. static BLENDMODE_STANDARD: number;
  15309. /**
  15310. * Add current color and particle color multiplied by particle’s alpha
  15311. */
  15312. static BLENDMODE_ADD: number;
  15313. /**
  15314. * Multiply current color with particle color
  15315. */
  15316. static BLENDMODE_MULTIPLY: number;
  15317. /**
  15318. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15319. */
  15320. static BLENDMODE_MULTIPLYADD: number;
  15321. /**
  15322. * List of animations used by the particle system.
  15323. */
  15324. animations: Animation[];
  15325. /**
  15326. * Gets or sets the unique id of the particle system
  15327. */
  15328. uniqueId: number;
  15329. /**
  15330. * The id of the Particle system.
  15331. */
  15332. id: string;
  15333. /**
  15334. * The friendly name of the Particle system.
  15335. */
  15336. name: string;
  15337. /**
  15338. * Snippet ID if the particle system was created from the snippet server
  15339. */
  15340. snippetId: string;
  15341. /**
  15342. * The rendering group used by the Particle system to chose when to render.
  15343. */
  15344. renderingGroupId: number;
  15345. /**
  15346. * The emitter represents the Mesh or position we are attaching the particle system to.
  15347. */
  15348. emitter: Nullable<AbstractMesh | Vector3>;
  15349. /**
  15350. * The maximum number of particles to emit per frame
  15351. */
  15352. emitRate: number;
  15353. /**
  15354. * If you want to launch only a few particles at once, that can be done, as well.
  15355. */
  15356. manualEmitCount: number;
  15357. /**
  15358. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15359. */
  15360. updateSpeed: number;
  15361. /**
  15362. * The amount of time the particle system is running (depends of the overall update speed).
  15363. */
  15364. targetStopDuration: number;
  15365. /**
  15366. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15367. */
  15368. disposeOnStop: boolean;
  15369. /**
  15370. * Minimum power of emitting particles.
  15371. */
  15372. minEmitPower: number;
  15373. /**
  15374. * Maximum power of emitting particles.
  15375. */
  15376. maxEmitPower: number;
  15377. /**
  15378. * Minimum life time of emitting particles.
  15379. */
  15380. minLifeTime: number;
  15381. /**
  15382. * Maximum life time of emitting particles.
  15383. */
  15384. maxLifeTime: number;
  15385. /**
  15386. * Minimum Size of emitting particles.
  15387. */
  15388. minSize: number;
  15389. /**
  15390. * Maximum Size of emitting particles.
  15391. */
  15392. maxSize: number;
  15393. /**
  15394. * Minimum scale of emitting particles on X axis.
  15395. */
  15396. minScaleX: number;
  15397. /**
  15398. * Maximum scale of emitting particles on X axis.
  15399. */
  15400. maxScaleX: number;
  15401. /**
  15402. * Minimum scale of emitting particles on Y axis.
  15403. */
  15404. minScaleY: number;
  15405. /**
  15406. * Maximum scale of emitting particles on Y axis.
  15407. */
  15408. maxScaleY: number;
  15409. /**
  15410. * Gets or sets the minimal initial rotation in radians.
  15411. */
  15412. minInitialRotation: number;
  15413. /**
  15414. * Gets or sets the maximal initial rotation in radians.
  15415. */
  15416. maxInitialRotation: number;
  15417. /**
  15418. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15419. */
  15420. minAngularSpeed: number;
  15421. /**
  15422. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15423. */
  15424. maxAngularSpeed: number;
  15425. /**
  15426. * The texture used to render each particle. (this can be a spritesheet)
  15427. */
  15428. particleTexture: Nullable<BaseTexture>;
  15429. /**
  15430. * The layer mask we are rendering the particles through.
  15431. */
  15432. layerMask: number;
  15433. /**
  15434. * This can help using your own shader to render the particle system.
  15435. * The according effect will be created
  15436. */
  15437. customShader: any;
  15438. /**
  15439. * By default particle system starts as soon as they are created. This prevents the
  15440. * automatic start to happen and let you decide when to start emitting particles.
  15441. */
  15442. preventAutoStart: boolean;
  15443. private _noiseTexture;
  15444. /**
  15445. * Gets or sets a texture used to add random noise to particle positions
  15446. */
  15447. get noiseTexture(): Nullable<ProceduralTexture>;
  15448. set noiseTexture(value: Nullable<ProceduralTexture>);
  15449. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15450. noiseStrength: Vector3;
  15451. /**
  15452. * Callback triggered when the particle animation is ending.
  15453. */
  15454. onAnimationEnd: Nullable<() => void>;
  15455. /**
  15456. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15457. */
  15458. blendMode: number;
  15459. /**
  15460. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15461. * to override the particles.
  15462. */
  15463. forceDepthWrite: boolean;
  15464. /** 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 */
  15465. preWarmCycles: number;
  15466. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15467. preWarmStepOffset: number;
  15468. /**
  15469. * 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)
  15470. */
  15471. spriteCellChangeSpeed: number;
  15472. /**
  15473. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15474. */
  15475. startSpriteCellID: number;
  15476. /**
  15477. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15478. */
  15479. endSpriteCellID: number;
  15480. /**
  15481. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15482. */
  15483. spriteCellWidth: number;
  15484. /**
  15485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15486. */
  15487. spriteCellHeight: number;
  15488. /**
  15489. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15490. */
  15491. spriteRandomStartCell: boolean;
  15492. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15493. translationPivot: Vector2;
  15494. /** @hidden */
  15495. protected _isAnimationSheetEnabled: boolean;
  15496. /**
  15497. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15498. */
  15499. beginAnimationOnStart: boolean;
  15500. /**
  15501. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15502. */
  15503. beginAnimationFrom: number;
  15504. /**
  15505. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15506. */
  15507. beginAnimationTo: number;
  15508. /**
  15509. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15510. */
  15511. beginAnimationLoop: boolean;
  15512. /**
  15513. * Gets or sets a world offset applied to all particles
  15514. */
  15515. worldOffset: Vector3;
  15516. /**
  15517. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15518. */
  15519. get isAnimationSheetEnabled(): boolean;
  15520. set isAnimationSheetEnabled(value: boolean);
  15521. /**
  15522. * Get hosting scene
  15523. * @returns the scene
  15524. */
  15525. getScene(): Nullable<Scene>;
  15526. /**
  15527. * You can use gravity if you want to give an orientation to your particles.
  15528. */
  15529. gravity: Vector3;
  15530. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15531. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15532. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15533. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15534. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15535. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15536. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15537. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15538. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15539. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15540. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15541. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15542. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15543. /**
  15544. * Defines the delay in milliseconds before starting the system (0 by default)
  15545. */
  15546. startDelay: number;
  15547. /**
  15548. * Gets the current list of drag gradients.
  15549. * You must use addDragGradient and removeDragGradient to udpate this list
  15550. * @returns the list of drag gradients
  15551. */
  15552. getDragGradients(): Nullable<Array<FactorGradient>>;
  15553. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15554. limitVelocityDamping: number;
  15555. /**
  15556. * Gets the current list of limit velocity gradients.
  15557. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15558. * @returns the list of limit velocity gradients
  15559. */
  15560. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15561. /**
  15562. * Gets the current list of color gradients.
  15563. * You must use addColorGradient and removeColorGradient to udpate this list
  15564. * @returns the list of color gradients
  15565. */
  15566. getColorGradients(): Nullable<Array<ColorGradient>>;
  15567. /**
  15568. * Gets the current list of size gradients.
  15569. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15570. * @returns the list of size gradients
  15571. */
  15572. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15573. /**
  15574. * Gets the current list of color remap gradients.
  15575. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15576. * @returns the list of color remap gradients
  15577. */
  15578. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15579. /**
  15580. * Gets the current list of alpha remap gradients.
  15581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15582. * @returns the list of alpha remap gradients
  15583. */
  15584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15585. /**
  15586. * Gets the current list of life time gradients.
  15587. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15588. * @returns the list of life time gradients
  15589. */
  15590. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15591. /**
  15592. * Gets the current list of angular speed gradients.
  15593. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15594. * @returns the list of angular speed gradients
  15595. */
  15596. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15597. /**
  15598. * Gets the current list of velocity gradients.
  15599. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15600. * @returns the list of velocity gradients
  15601. */
  15602. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15603. /**
  15604. * Gets the current list of start size gradients.
  15605. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15606. * @returns the list of start size gradients
  15607. */
  15608. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15609. /**
  15610. * Gets the current list of emit rate gradients.
  15611. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15612. * @returns the list of emit rate gradients
  15613. */
  15614. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15615. /**
  15616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15617. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15618. */
  15619. get direction1(): Vector3;
  15620. set direction1(value: Vector3);
  15621. /**
  15622. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15623. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15624. */
  15625. get direction2(): Vector3;
  15626. set direction2(value: Vector3);
  15627. /**
  15628. * 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.
  15629. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15630. */
  15631. get minEmitBox(): Vector3;
  15632. set minEmitBox(value: Vector3);
  15633. /**
  15634. * 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.
  15635. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15636. */
  15637. get maxEmitBox(): Vector3;
  15638. set maxEmitBox(value: Vector3);
  15639. /**
  15640. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15641. */
  15642. color1: Color4;
  15643. /**
  15644. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15645. */
  15646. color2: Color4;
  15647. /**
  15648. * Color the particle will have at the end of its lifetime
  15649. */
  15650. colorDead: Color4;
  15651. /**
  15652. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15653. */
  15654. textureMask: Color4;
  15655. /**
  15656. * The particle emitter type defines the emitter used by the particle system.
  15657. * It can be for example box, sphere, or cone...
  15658. */
  15659. particleEmitterType: IParticleEmitterType;
  15660. /** @hidden */
  15661. _isSubEmitter: boolean;
  15662. /**
  15663. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15664. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15665. */
  15666. billboardMode: number;
  15667. protected _isBillboardBased: boolean;
  15668. /**
  15669. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15670. */
  15671. get isBillboardBased(): boolean;
  15672. set isBillboardBased(value: boolean);
  15673. /**
  15674. * The scene the particle system belongs to.
  15675. */
  15676. protected _scene: Nullable<Scene>;
  15677. /**
  15678. * The engine the particle system belongs to.
  15679. */
  15680. protected _engine: ThinEngine;
  15681. /**
  15682. * Local cache of defines for image processing.
  15683. */
  15684. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15685. /**
  15686. * Default configuration related to image processing available in the standard Material.
  15687. */
  15688. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15689. /**
  15690. * Gets the image processing configuration used either in this material.
  15691. */
  15692. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15693. /**
  15694. * Sets the Default image processing configuration used either in the this material.
  15695. *
  15696. * If sets to null, the scene one is in use.
  15697. */
  15698. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15699. /**
  15700. * Attaches a new image processing configuration to the Standard Material.
  15701. * @param configuration
  15702. */
  15703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15704. /** @hidden */
  15705. protected _reset(): void;
  15706. /** @hidden */
  15707. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15708. /**
  15709. * Instantiates a particle system.
  15710. * 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.
  15711. * @param name The name of the particle system
  15712. */
  15713. constructor(name: string);
  15714. /**
  15715. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15718. * @returns the emitter
  15719. */
  15720. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15721. /**
  15722. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15723. * @param radius The radius of the hemisphere to emit from
  15724. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15725. * @returns the emitter
  15726. */
  15727. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15728. /**
  15729. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15730. * @param radius The radius of the sphere to emit from
  15731. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15732. * @returns the emitter
  15733. */
  15734. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15735. /**
  15736. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15737. * @param radius The radius of the sphere to emit from
  15738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15740. * @returns the emitter
  15741. */
  15742. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15743. /**
  15744. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15745. * @param radius The radius of the emission cylinder
  15746. * @param height The height of the emission cylinder
  15747. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15748. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15749. * @returns the emitter
  15750. */
  15751. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15752. /**
  15753. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15754. * @param radius The radius of the cylinder to emit from
  15755. * @param height The height of the emission cylinder
  15756. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15759. * @returns the emitter
  15760. */
  15761. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15762. /**
  15763. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15764. * @param radius The radius of the cone to emit from
  15765. * @param angle The base angle of the cone
  15766. * @returns the emitter
  15767. */
  15768. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15769. /**
  15770. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15773. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15774. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15775. * @returns the emitter
  15776. */
  15777. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15778. }
  15779. }
  15780. declare module "babylonjs/Particles/subEmitter" {
  15781. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15782. import { Scene } from "babylonjs/scene";
  15783. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15784. /**
  15785. * Type of sub emitter
  15786. */
  15787. export enum SubEmitterType {
  15788. /**
  15789. * Attached to the particle over it's lifetime
  15790. */
  15791. ATTACHED = 0,
  15792. /**
  15793. * Created when the particle dies
  15794. */
  15795. END = 1
  15796. }
  15797. /**
  15798. * Sub emitter class used to emit particles from an existing particle
  15799. */
  15800. export class SubEmitter {
  15801. /**
  15802. * the particle system to be used by the sub emitter
  15803. */
  15804. particleSystem: ParticleSystem;
  15805. /**
  15806. * Type of the submitter (Default: END)
  15807. */
  15808. type: SubEmitterType;
  15809. /**
  15810. * 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)
  15811. * Note: This only is supported when using an emitter of type Mesh
  15812. */
  15813. inheritDirection: boolean;
  15814. /**
  15815. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15816. */
  15817. inheritedVelocityAmount: number;
  15818. /**
  15819. * Creates a sub emitter
  15820. * @param particleSystem the particle system to be used by the sub emitter
  15821. */
  15822. constructor(
  15823. /**
  15824. * the particle system to be used by the sub emitter
  15825. */
  15826. particleSystem: ParticleSystem);
  15827. /**
  15828. * Clones the sub emitter
  15829. * @returns the cloned sub emitter
  15830. */
  15831. clone(): SubEmitter;
  15832. /**
  15833. * Serialize current object to a JSON object
  15834. * @returns the serialized object
  15835. */
  15836. serialize(): any;
  15837. /** @hidden */
  15838. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15839. /**
  15840. * Creates a new SubEmitter from a serialized JSON version
  15841. * @param serializationObject defines the JSON object to read from
  15842. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15843. * @param rootUrl defines the rootUrl for data loading
  15844. * @returns a new SubEmitter
  15845. */
  15846. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15847. /** Release associated resources */
  15848. dispose(): void;
  15849. }
  15850. }
  15851. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15852. /** @hidden */
  15853. export var clipPlaneFragmentDeclaration: {
  15854. name: string;
  15855. shader: string;
  15856. };
  15857. }
  15858. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15859. /** @hidden */
  15860. export var imageProcessingDeclaration: {
  15861. name: string;
  15862. shader: string;
  15863. };
  15864. }
  15865. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15866. /** @hidden */
  15867. export var imageProcessingFunctions: {
  15868. name: string;
  15869. shader: string;
  15870. };
  15871. }
  15872. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15873. /** @hidden */
  15874. export var clipPlaneFragment: {
  15875. name: string;
  15876. shader: string;
  15877. };
  15878. }
  15879. declare module "babylonjs/Shaders/particles.fragment" {
  15880. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15881. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15882. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15883. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15884. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15885. /** @hidden */
  15886. export var particlesPixelShader: {
  15887. name: string;
  15888. shader: string;
  15889. };
  15890. }
  15891. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15892. /** @hidden */
  15893. export var clipPlaneVertexDeclaration: {
  15894. name: string;
  15895. shader: string;
  15896. };
  15897. }
  15898. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15899. /** @hidden */
  15900. export var clipPlaneVertex: {
  15901. name: string;
  15902. shader: string;
  15903. };
  15904. }
  15905. declare module "babylonjs/Shaders/particles.vertex" {
  15906. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15907. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15908. /** @hidden */
  15909. export var particlesVertexShader: {
  15910. name: string;
  15911. shader: string;
  15912. };
  15913. }
  15914. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15915. import { Nullable } from "babylonjs/types";
  15916. import { Plane } from "babylonjs/Maths/math";
  15917. /**
  15918. * Interface used to define entities containing multiple clip planes
  15919. */
  15920. export interface IClipPlanesHolder {
  15921. /**
  15922. * Gets or sets the active clipplane 1
  15923. */
  15924. clipPlane: Nullable<Plane>;
  15925. /**
  15926. * Gets or sets the active clipplane 2
  15927. */
  15928. clipPlane2: Nullable<Plane>;
  15929. /**
  15930. * Gets or sets the active clipplane 3
  15931. */
  15932. clipPlane3: Nullable<Plane>;
  15933. /**
  15934. * Gets or sets the active clipplane 4
  15935. */
  15936. clipPlane4: Nullable<Plane>;
  15937. /**
  15938. * Gets or sets the active clipplane 5
  15939. */
  15940. clipPlane5: Nullable<Plane>;
  15941. /**
  15942. * Gets or sets the active clipplane 6
  15943. */
  15944. clipPlane6: Nullable<Plane>;
  15945. }
  15946. }
  15947. declare module "babylonjs/Materials/thinMaterialHelper" {
  15948. import { Effect } from "babylonjs/Materials/effect";
  15949. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15950. /**
  15951. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15952. *
  15953. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15954. *
  15955. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15956. */
  15957. export class ThinMaterialHelper {
  15958. /**
  15959. * Binds the clip plane information from the holder to the effect.
  15960. * @param effect The effect we are binding the data to
  15961. * @param holder The entity containing the clip plane information
  15962. */
  15963. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15964. }
  15965. }
  15966. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15967. module "babylonjs/Engines/thinEngine" {
  15968. interface ThinEngine {
  15969. /**
  15970. * Sets alpha constants used by some alpha blending modes
  15971. * @param r defines the red component
  15972. * @param g defines the green component
  15973. * @param b defines the blue component
  15974. * @param a defines the alpha component
  15975. */
  15976. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15977. /**
  15978. * Sets the current alpha mode
  15979. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15980. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15981. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15982. */
  15983. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15984. /**
  15985. * Gets the current alpha mode
  15986. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15987. * @returns the current alpha mode
  15988. */
  15989. getAlphaMode(): number;
  15990. /**
  15991. * Sets the current alpha equation
  15992. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15993. */
  15994. setAlphaEquation(equation: number): void;
  15995. /**
  15996. * Gets the current alpha equation.
  15997. * @returns the current alpha equation
  15998. */
  15999. getAlphaEquation(): number;
  16000. }
  16001. }
  16002. }
  16003. declare module "babylonjs/Particles/particleSystem" {
  16004. import { Nullable } from "babylonjs/types";
  16005. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16006. import { Observable } from "babylonjs/Misc/observable";
  16007. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16008. import { Effect } from "babylonjs/Materials/effect";
  16009. import { IDisposable } from "babylonjs/scene";
  16010. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16011. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  16012. import { Particle } from "babylonjs/Particles/particle";
  16013. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16014. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16015. import "babylonjs/Shaders/particles.fragment";
  16016. import "babylonjs/Shaders/particles.vertex";
  16017. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16019. import "babylonjs/Engines/Extensions/engine.alpha";
  16020. import { Scene } from "babylonjs/scene";
  16021. /**
  16022. * This represents a particle system in Babylon.
  16023. * 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.
  16024. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16025. * @example https://doc.babylonjs.com/babylon101/particles
  16026. */
  16027. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16028. /**
  16029. * Billboard mode will only apply to Y axis
  16030. */
  16031. static readonly BILLBOARDMODE_Y: number;
  16032. /**
  16033. * Billboard mode will apply to all axes
  16034. */
  16035. static readonly BILLBOARDMODE_ALL: number;
  16036. /**
  16037. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16038. */
  16039. static readonly BILLBOARDMODE_STRETCHED: number;
  16040. /**
  16041. * This function can be defined to provide custom update for active particles.
  16042. * This function will be called instead of regular update (age, position, color, etc.).
  16043. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16044. */
  16045. updateFunction: (particles: Particle[]) => void;
  16046. private _emitterWorldMatrix;
  16047. /**
  16048. * This function can be defined to specify initial direction for every new particle.
  16049. * It by default use the emitterType defined function
  16050. */
  16051. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16052. /**
  16053. * This function can be defined to specify initial position for every new particle.
  16054. * It by default use the emitterType defined function
  16055. */
  16056. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16057. /**
  16058. * @hidden
  16059. */
  16060. _inheritedVelocityOffset: Vector3;
  16061. /**
  16062. * An event triggered when the system is disposed
  16063. */
  16064. onDisposeObservable: Observable<IParticleSystem>;
  16065. /**
  16066. * An event triggered when the system is stopped
  16067. */
  16068. onStoppedObservable: Observable<IParticleSystem>;
  16069. private _onDisposeObserver;
  16070. /**
  16071. * Sets a callback that will be triggered when the system is disposed
  16072. */
  16073. set onDispose(callback: () => void);
  16074. private _particles;
  16075. private _epsilon;
  16076. private _capacity;
  16077. private _stockParticles;
  16078. private _newPartsExcess;
  16079. private _vertexData;
  16080. private _vertexBuffer;
  16081. private _vertexBuffers;
  16082. private _spriteBuffer;
  16083. private _indexBuffer;
  16084. private _effect;
  16085. private _customEffect;
  16086. private _cachedDefines;
  16087. private _scaledColorStep;
  16088. private _colorDiff;
  16089. private _scaledDirection;
  16090. private _scaledGravity;
  16091. private _currentRenderId;
  16092. private _alive;
  16093. private _useInstancing;
  16094. private _vertexArrayObject;
  16095. private _started;
  16096. private _stopped;
  16097. private _actualFrame;
  16098. private _scaledUpdateSpeed;
  16099. private _vertexBufferSize;
  16100. /** @hidden */
  16101. _currentEmitRateGradient: Nullable<FactorGradient>;
  16102. /** @hidden */
  16103. _currentEmitRate1: number;
  16104. /** @hidden */
  16105. _currentEmitRate2: number;
  16106. /** @hidden */
  16107. _currentStartSizeGradient: Nullable<FactorGradient>;
  16108. /** @hidden */
  16109. _currentStartSize1: number;
  16110. /** @hidden */
  16111. _currentStartSize2: number;
  16112. private readonly _rawTextureWidth;
  16113. private _rampGradientsTexture;
  16114. private _useRampGradients;
  16115. /** Gets or sets a matrix to use to compute projection */
  16116. defaultProjectionMatrix: Matrix;
  16117. /** Gets or sets a matrix to use to compute view */
  16118. defaultViewMatrix: Matrix;
  16119. /** Gets or sets a boolean indicating that ramp gradients must be used
  16120. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16121. */
  16122. get useRampGradients(): boolean;
  16123. set useRampGradients(value: boolean);
  16124. /**
  16125. * 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.
  16126. * 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: [])
  16127. */
  16128. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16129. private _subEmitters;
  16130. /**
  16131. * @hidden
  16132. * If the particle systems emitter should be disposed when the particle system is disposed
  16133. */
  16134. _disposeEmitterOnDispose: boolean;
  16135. /**
  16136. * The current active Sub-systems, this property is used by the root particle system only.
  16137. */
  16138. activeSubSystems: Array<ParticleSystem>;
  16139. /**
  16140. * Specifies if the particles are updated in emitter local space or world space
  16141. */
  16142. isLocal: boolean;
  16143. private _rootParticleSystem;
  16144. /**
  16145. * Gets the current list of active particles
  16146. */
  16147. get particles(): Particle[];
  16148. /**
  16149. * Gets the number of particles active at the same time.
  16150. * @returns The number of active particles.
  16151. */
  16152. getActiveCount(): number;
  16153. /**
  16154. * Returns the string "ParticleSystem"
  16155. * @returns a string containing the class name
  16156. */
  16157. getClassName(): string;
  16158. /**
  16159. * Gets a boolean indicating that the system is stopping
  16160. * @returns true if the system is currently stopping
  16161. */
  16162. isStopping(): boolean;
  16163. /**
  16164. * Gets the custom effect used to render the particles
  16165. * @param blendMode Blend mode for which the effect should be retrieved
  16166. * @returns The effect
  16167. */
  16168. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16169. /**
  16170. * Sets the custom effect used to render the particles
  16171. * @param effect The effect to set
  16172. * @param blendMode Blend mode for which the effect should be set
  16173. */
  16174. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16175. /** @hidden */
  16176. private _onBeforeDrawParticlesObservable;
  16177. /**
  16178. * Observable that will be called just before the particles are drawn
  16179. */
  16180. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16181. /**
  16182. * Gets the name of the particle vertex shader
  16183. */
  16184. get vertexShaderName(): string;
  16185. /**
  16186. * Instantiates a particle system.
  16187. * 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.
  16188. * @param name The name of the particle system
  16189. * @param capacity The max number of particles alive at the same time
  16190. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16191. * @param customEffect a custom effect used to change the way particles are rendered by default
  16192. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16193. * @param epsilon Offset used to render the particles
  16194. */
  16195. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16196. private _addFactorGradient;
  16197. private _removeFactorGradient;
  16198. /**
  16199. * Adds a new life time gradient
  16200. * @param gradient defines the gradient to use (between 0 and 1)
  16201. * @param factor defines the life time factor to affect to the specified gradient
  16202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16203. * @returns the current particle system
  16204. */
  16205. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16206. /**
  16207. * Remove a specific life time gradient
  16208. * @param gradient defines the gradient to remove
  16209. * @returns the current particle system
  16210. */
  16211. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16212. /**
  16213. * Adds a new size gradient
  16214. * @param gradient defines the gradient to use (between 0 and 1)
  16215. * @param factor defines the size factor to affect to the specified gradient
  16216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16217. * @returns the current particle system
  16218. */
  16219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16220. /**
  16221. * Remove a specific size gradient
  16222. * @param gradient defines the gradient to remove
  16223. * @returns the current particle system
  16224. */
  16225. removeSizeGradient(gradient: number): IParticleSystem;
  16226. /**
  16227. * Adds a new color remap gradient
  16228. * @param gradient defines the gradient to use (between 0 and 1)
  16229. * @param min defines the color remap minimal range
  16230. * @param max defines the color remap maximal range
  16231. * @returns the current particle system
  16232. */
  16233. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16234. /**
  16235. * Remove a specific color remap gradient
  16236. * @param gradient defines the gradient to remove
  16237. * @returns the current particle system
  16238. */
  16239. removeColorRemapGradient(gradient: number): IParticleSystem;
  16240. /**
  16241. * Adds a new alpha remap gradient
  16242. * @param gradient defines the gradient to use (between 0 and 1)
  16243. * @param min defines the alpha remap minimal range
  16244. * @param max defines the alpha remap maximal range
  16245. * @returns the current particle system
  16246. */
  16247. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16248. /**
  16249. * Remove a specific alpha remap gradient
  16250. * @param gradient defines the gradient to remove
  16251. * @returns the current particle system
  16252. */
  16253. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16254. /**
  16255. * Adds a new angular speed gradient
  16256. * @param gradient defines the gradient to use (between 0 and 1)
  16257. * @param factor defines the angular speed to affect to the specified gradient
  16258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16259. * @returns the current particle system
  16260. */
  16261. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16262. /**
  16263. * Remove a specific angular speed gradient
  16264. * @param gradient defines the gradient to remove
  16265. * @returns the current particle system
  16266. */
  16267. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16268. /**
  16269. * Adds a new velocity gradient
  16270. * @param gradient defines the gradient to use (between 0 and 1)
  16271. * @param factor defines the velocity to affect to the specified gradient
  16272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16273. * @returns the current particle system
  16274. */
  16275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16276. /**
  16277. * Remove a specific velocity gradient
  16278. * @param gradient defines the gradient to remove
  16279. * @returns the current particle system
  16280. */
  16281. removeVelocityGradient(gradient: number): IParticleSystem;
  16282. /**
  16283. * Adds a new limit velocity gradient
  16284. * @param gradient defines the gradient to use (between 0 and 1)
  16285. * @param factor defines the limit velocity value to affect to the specified gradient
  16286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16287. * @returns the current particle system
  16288. */
  16289. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16290. /**
  16291. * Remove a specific limit velocity gradient
  16292. * @param gradient defines the gradient to remove
  16293. * @returns the current particle system
  16294. */
  16295. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16296. /**
  16297. * Adds a new drag gradient
  16298. * @param gradient defines the gradient to use (between 0 and 1)
  16299. * @param factor defines the drag value to affect to the specified gradient
  16300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16301. * @returns the current particle system
  16302. */
  16303. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16304. /**
  16305. * Remove a specific drag gradient
  16306. * @param gradient defines the gradient to remove
  16307. * @returns the current particle system
  16308. */
  16309. removeDragGradient(gradient: number): IParticleSystem;
  16310. /**
  16311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16312. * @param gradient defines the gradient to use (between 0 and 1)
  16313. * @param factor defines the emit rate value to affect to the specified gradient
  16314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16315. * @returns the current particle system
  16316. */
  16317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16318. /**
  16319. * Remove a specific emit rate gradient
  16320. * @param gradient defines the gradient to remove
  16321. * @returns the current particle system
  16322. */
  16323. removeEmitRateGradient(gradient: number): IParticleSystem;
  16324. /**
  16325. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16326. * @param gradient defines the gradient to use (between 0 and 1)
  16327. * @param factor defines the start size value to affect to the specified gradient
  16328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16329. * @returns the current particle system
  16330. */
  16331. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16332. /**
  16333. * Remove a specific start size gradient
  16334. * @param gradient defines the gradient to remove
  16335. * @returns the current particle system
  16336. */
  16337. removeStartSizeGradient(gradient: number): IParticleSystem;
  16338. private _createRampGradientTexture;
  16339. /**
  16340. * Gets the current list of ramp gradients.
  16341. * You must use addRampGradient and removeRampGradient to udpate this list
  16342. * @returns the list of ramp gradients
  16343. */
  16344. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16345. /** Force the system to rebuild all gradients that need to be resync */
  16346. forceRefreshGradients(): void;
  16347. private _syncRampGradientTexture;
  16348. /**
  16349. * Adds a new ramp gradient used to remap particle colors
  16350. * @param gradient defines the gradient to use (between 0 and 1)
  16351. * @param color defines the color to affect to the specified gradient
  16352. * @returns the current particle system
  16353. */
  16354. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16355. /**
  16356. * Remove a specific ramp gradient
  16357. * @param gradient defines the gradient to remove
  16358. * @returns the current particle system
  16359. */
  16360. removeRampGradient(gradient: number): ParticleSystem;
  16361. /**
  16362. * Adds a new color gradient
  16363. * @param gradient defines the gradient to use (between 0 and 1)
  16364. * @param color1 defines the color to affect to the specified gradient
  16365. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16366. * @returns this particle system
  16367. */
  16368. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16369. /**
  16370. * Remove a specific color gradient
  16371. * @param gradient defines the gradient to remove
  16372. * @returns this particle system
  16373. */
  16374. removeColorGradient(gradient: number): IParticleSystem;
  16375. private _fetchR;
  16376. protected _reset(): void;
  16377. private _resetEffect;
  16378. private _createVertexBuffers;
  16379. private _createIndexBuffer;
  16380. /**
  16381. * Gets the maximum number of particles active at the same time.
  16382. * @returns The max number of active particles.
  16383. */
  16384. getCapacity(): number;
  16385. /**
  16386. * Gets whether there are still active particles in the system.
  16387. * @returns True if it is alive, otherwise false.
  16388. */
  16389. isAlive(): boolean;
  16390. /**
  16391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16392. * @returns True if it has been started, otherwise false.
  16393. */
  16394. isStarted(): boolean;
  16395. private _prepareSubEmitterInternalArray;
  16396. /**
  16397. * Starts the particle system and begins to emit
  16398. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16399. */
  16400. start(delay?: number): void;
  16401. /**
  16402. * Stops the particle system.
  16403. * @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.
  16404. */
  16405. stop(stopSubEmitters?: boolean): void;
  16406. /**
  16407. * Remove all active particles
  16408. */
  16409. reset(): void;
  16410. /**
  16411. * @hidden (for internal use only)
  16412. */
  16413. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16414. /**
  16415. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16416. * Its lifetime will start back at 0.
  16417. */
  16418. recycleParticle: (particle: Particle) => void;
  16419. private _stopSubEmitters;
  16420. private _createParticle;
  16421. private _removeFromRoot;
  16422. private _emitFromParticle;
  16423. private _update;
  16424. /** @hidden */
  16425. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16426. /** @hidden */
  16427. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16428. /**
  16429. * Fill the defines array according to the current settings of the particle system
  16430. * @param defines Array to be updated
  16431. * @param blendMode blend mode to take into account when updating the array
  16432. */
  16433. fillDefines(defines: Array<string>, blendMode: number): void;
  16434. /**
  16435. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16436. * @param uniforms Uniforms array to fill
  16437. * @param attributes Attributes array to fill
  16438. * @param samplers Samplers array to fill
  16439. */
  16440. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16441. /** @hidden */
  16442. private _getEffect;
  16443. /**
  16444. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16445. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16446. */
  16447. animate(preWarmOnly?: boolean): void;
  16448. private _appendParticleVertices;
  16449. /**
  16450. * Rebuilds the particle system.
  16451. */
  16452. rebuild(): void;
  16453. /**
  16454. * Is this system ready to be used/rendered
  16455. * @return true if the system is ready
  16456. */
  16457. isReady(): boolean;
  16458. private _render;
  16459. /**
  16460. * Renders the particle system in its current state.
  16461. * @returns the current number of particles
  16462. */
  16463. render(): number;
  16464. /**
  16465. * Disposes the particle system and free the associated resources
  16466. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16467. */
  16468. dispose(disposeTexture?: boolean): void;
  16469. /**
  16470. * Clones the particle system.
  16471. * @param name The name of the cloned object
  16472. * @param newEmitter The new emitter to use
  16473. * @returns the cloned particle system
  16474. */
  16475. clone(name: string, newEmitter: any): ParticleSystem;
  16476. /**
  16477. * Serializes the particle system to a JSON object
  16478. * @param serializeTexture defines if the texture must be serialized as well
  16479. * @returns the JSON object
  16480. */
  16481. serialize(serializeTexture?: boolean): any;
  16482. /** @hidden */
  16483. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16484. /** @hidden */
  16485. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16486. /**
  16487. * Parses a JSON object to create a particle system.
  16488. * @param parsedParticleSystem The JSON object to parse
  16489. * @param sceneOrEngine The scene or the engine to create the particle system in
  16490. * @param rootUrl The root url to use to load external dependencies like texture
  16491. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16492. * @returns the Parsed particle system
  16493. */
  16494. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16495. }
  16496. }
  16497. declare module "babylonjs/Particles/particle" {
  16498. import { Nullable } from "babylonjs/types";
  16499. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  16500. import { Color4 } from "babylonjs/Maths/math.color";
  16501. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16502. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16503. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  16504. /**
  16505. * A particle represents one of the element emitted by a particle system.
  16506. * This is mainly define by its coordinates, direction, velocity and age.
  16507. */
  16508. export class Particle {
  16509. /**
  16510. * The particle system the particle belongs to.
  16511. */
  16512. particleSystem: ParticleSystem;
  16513. private static _Count;
  16514. /**
  16515. * Unique ID of the particle
  16516. */
  16517. id: number;
  16518. /**
  16519. * The world position of the particle in the scene.
  16520. */
  16521. position: Vector3;
  16522. /**
  16523. * The world direction of the particle in the scene.
  16524. */
  16525. direction: Vector3;
  16526. /**
  16527. * The color of the particle.
  16528. */
  16529. color: Color4;
  16530. /**
  16531. * The color change of the particle per step.
  16532. */
  16533. colorStep: Color4;
  16534. /**
  16535. * Defines how long will the life of the particle be.
  16536. */
  16537. lifeTime: number;
  16538. /**
  16539. * The current age of the particle.
  16540. */
  16541. age: number;
  16542. /**
  16543. * The current size of the particle.
  16544. */
  16545. size: number;
  16546. /**
  16547. * The current scale of the particle.
  16548. */
  16549. scale: Vector2;
  16550. /**
  16551. * The current angle of the particle.
  16552. */
  16553. angle: number;
  16554. /**
  16555. * Defines how fast is the angle changing.
  16556. */
  16557. angularSpeed: number;
  16558. /**
  16559. * Defines the cell index used by the particle to be rendered from a sprite.
  16560. */
  16561. cellIndex: number;
  16562. /**
  16563. * The information required to support color remapping
  16564. */
  16565. remapData: Vector4;
  16566. /** @hidden */
  16567. _randomCellOffset?: number;
  16568. /** @hidden */
  16569. _initialDirection: Nullable<Vector3>;
  16570. /** @hidden */
  16571. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16572. /** @hidden */
  16573. _initialStartSpriteCellID: number;
  16574. /** @hidden */
  16575. _initialEndSpriteCellID: number;
  16576. /** @hidden */
  16577. _currentColorGradient: Nullable<ColorGradient>;
  16578. /** @hidden */
  16579. _currentColor1: Color4;
  16580. /** @hidden */
  16581. _currentColor2: Color4;
  16582. /** @hidden */
  16583. _currentSizeGradient: Nullable<FactorGradient>;
  16584. /** @hidden */
  16585. _currentSize1: number;
  16586. /** @hidden */
  16587. _currentSize2: number;
  16588. /** @hidden */
  16589. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16590. /** @hidden */
  16591. _currentAngularSpeed1: number;
  16592. /** @hidden */
  16593. _currentAngularSpeed2: number;
  16594. /** @hidden */
  16595. _currentVelocityGradient: Nullable<FactorGradient>;
  16596. /** @hidden */
  16597. _currentVelocity1: number;
  16598. /** @hidden */
  16599. _currentVelocity2: number;
  16600. /** @hidden */
  16601. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16602. /** @hidden */
  16603. _currentLimitVelocity1: number;
  16604. /** @hidden */
  16605. _currentLimitVelocity2: number;
  16606. /** @hidden */
  16607. _currentDragGradient: Nullable<FactorGradient>;
  16608. /** @hidden */
  16609. _currentDrag1: number;
  16610. /** @hidden */
  16611. _currentDrag2: number;
  16612. /** @hidden */
  16613. _randomNoiseCoordinates1: Vector3;
  16614. /** @hidden */
  16615. _randomNoiseCoordinates2: Vector3;
  16616. /** @hidden */
  16617. _localPosition?: Vector3;
  16618. /**
  16619. * Creates a new instance Particle
  16620. * @param particleSystem the particle system the particle belongs to
  16621. */
  16622. constructor(
  16623. /**
  16624. * The particle system the particle belongs to.
  16625. */
  16626. particleSystem: ParticleSystem);
  16627. private updateCellInfoFromSystem;
  16628. /**
  16629. * Defines how the sprite cell index is updated for the particle
  16630. */
  16631. updateCellIndex(): void;
  16632. /** @hidden */
  16633. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16634. /** @hidden */
  16635. _inheritParticleInfoToSubEmitters(): void;
  16636. /** @hidden */
  16637. _reset(): void;
  16638. /**
  16639. * Copy the properties of particle to another one.
  16640. * @param other the particle to copy the information to.
  16641. */
  16642. copyTo(other: Particle): void;
  16643. }
  16644. }
  16645. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16646. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16647. import { Effect } from "babylonjs/Materials/effect";
  16648. import { Particle } from "babylonjs/Particles/particle";
  16649. import { Nullable } from "babylonjs/types";
  16650. import { Scene } from "babylonjs/scene";
  16651. /**
  16652. * Particle emitter represents a volume emitting particles.
  16653. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16654. */
  16655. export interface IParticleEmitterType {
  16656. /**
  16657. * Called by the particle System when the direction is computed for the created particle.
  16658. * @param worldMatrix is the world matrix of the particle system
  16659. * @param directionToUpdate is the direction vector to update with the result
  16660. * @param particle is the particle we are computed the direction for
  16661. * @param isLocal defines if the direction should be set in local space
  16662. */
  16663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16664. /**
  16665. * Called by the particle System when the position is computed for the created particle.
  16666. * @param worldMatrix is the world matrix of the particle system
  16667. * @param positionToUpdate is the position vector to update with the result
  16668. * @param particle is the particle we are computed the position for
  16669. * @param isLocal defines if the position should be set in local space
  16670. */
  16671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16672. /**
  16673. * Clones the current emitter and returns a copy of it
  16674. * @returns the new emitter
  16675. */
  16676. clone(): IParticleEmitterType;
  16677. /**
  16678. * Called by the GPUParticleSystem to setup the update shader
  16679. * @param effect defines the update shader
  16680. */
  16681. applyToShader(effect: Effect): void;
  16682. /**
  16683. * Returns a string to use to update the GPU particles update shader
  16684. * @returns the effect defines string
  16685. */
  16686. getEffectDefines(): string;
  16687. /**
  16688. * Returns a string representing the class name
  16689. * @returns a string containing the class name
  16690. */
  16691. getClassName(): string;
  16692. /**
  16693. * Serializes the particle system to a JSON object.
  16694. * @returns the JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Parse properties from a JSON object
  16699. * @param serializationObject defines the JSON object
  16700. * @param scene defines the hosting scene
  16701. */
  16702. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16703. }
  16704. }
  16705. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16706. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16707. import { Effect } from "babylonjs/Materials/effect";
  16708. import { Particle } from "babylonjs/Particles/particle";
  16709. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16710. /**
  16711. * Particle emitter emitting particles from the inside of a box.
  16712. * It emits the particles randomly between 2 given directions.
  16713. */
  16714. export class BoxParticleEmitter implements IParticleEmitterType {
  16715. /**
  16716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16717. */
  16718. direction1: Vector3;
  16719. /**
  16720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16721. */
  16722. direction2: Vector3;
  16723. /**
  16724. * 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.
  16725. */
  16726. minEmitBox: Vector3;
  16727. /**
  16728. * 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.
  16729. */
  16730. maxEmitBox: Vector3;
  16731. /**
  16732. * Creates a new instance BoxParticleEmitter
  16733. */
  16734. constructor();
  16735. /**
  16736. * Called by the particle System when the direction is computed for the created particle.
  16737. * @param worldMatrix is the world matrix of the particle system
  16738. * @param directionToUpdate is the direction vector to update with the result
  16739. * @param particle is the particle we are computed the direction for
  16740. * @param isLocal defines if the direction should be set in local space
  16741. */
  16742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16743. /**
  16744. * Called by the particle System when the position is computed for the created particle.
  16745. * @param worldMatrix is the world matrix of the particle system
  16746. * @param positionToUpdate is the position vector to update with the result
  16747. * @param particle is the particle we are computed the position for
  16748. * @param isLocal defines if the position should be set in local space
  16749. */
  16750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16751. /**
  16752. * Clones the current emitter and returns a copy of it
  16753. * @returns the new emitter
  16754. */
  16755. clone(): BoxParticleEmitter;
  16756. /**
  16757. * Called by the GPUParticleSystem to setup the update shader
  16758. * @param effect defines the update shader
  16759. */
  16760. applyToShader(effect: Effect): void;
  16761. /**
  16762. * Returns a string to use to update the GPU particles update shader
  16763. * @returns a string containng the defines string
  16764. */
  16765. getEffectDefines(): string;
  16766. /**
  16767. * Returns the string "BoxParticleEmitter"
  16768. * @returns a string containing the class name
  16769. */
  16770. getClassName(): string;
  16771. /**
  16772. * Serializes the particle system to a JSON object.
  16773. * @returns the JSON object
  16774. */
  16775. serialize(): any;
  16776. /**
  16777. * Parse properties from a JSON object
  16778. * @param serializationObject defines the JSON object
  16779. */
  16780. parse(serializationObject: any): void;
  16781. }
  16782. }
  16783. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16784. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16785. import { Effect } from "babylonjs/Materials/effect";
  16786. import { Particle } from "babylonjs/Particles/particle";
  16787. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16788. /**
  16789. * Particle emitter emitting particles from the inside of a cone.
  16790. * It emits the particles alongside the cone volume from the base to the particle.
  16791. * The emission direction might be randomized.
  16792. */
  16793. export class ConeParticleEmitter implements IParticleEmitterType {
  16794. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16795. directionRandomizer: number;
  16796. private _radius;
  16797. private _angle;
  16798. private _height;
  16799. /**
  16800. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16801. */
  16802. radiusRange: number;
  16803. /**
  16804. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16805. */
  16806. heightRange: number;
  16807. /**
  16808. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16809. */
  16810. emitFromSpawnPointOnly: boolean;
  16811. /**
  16812. * Gets or sets the radius of the emission cone
  16813. */
  16814. get radius(): number;
  16815. set radius(value: number);
  16816. /**
  16817. * Gets or sets the angle of the emission cone
  16818. */
  16819. get angle(): number;
  16820. set angle(value: number);
  16821. private _buildHeight;
  16822. /**
  16823. * Creates a new instance ConeParticleEmitter
  16824. * @param radius the radius of the emission cone (1 by default)
  16825. * @param angle the cone base angle (PI by default)
  16826. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16827. */
  16828. constructor(radius?: number, angle?: number,
  16829. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16830. directionRandomizer?: number);
  16831. /**
  16832. * Called by the particle System when the direction is computed for the created particle.
  16833. * @param worldMatrix is the world matrix of the particle system
  16834. * @param directionToUpdate is the direction vector to update with the result
  16835. * @param particle is the particle we are computed the direction for
  16836. * @param isLocal defines if the direction should be set in local space
  16837. */
  16838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16839. /**
  16840. * Called by the particle System when the position is computed for the created particle.
  16841. * @param worldMatrix is the world matrix of the particle system
  16842. * @param positionToUpdate is the position vector to update with the result
  16843. * @param particle is the particle we are computed the position for
  16844. * @param isLocal defines if the position should be set in local space
  16845. */
  16846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16847. /**
  16848. * Clones the current emitter and returns a copy of it
  16849. * @returns the new emitter
  16850. */
  16851. clone(): ConeParticleEmitter;
  16852. /**
  16853. * Called by the GPUParticleSystem to setup the update shader
  16854. * @param effect defines the update shader
  16855. */
  16856. applyToShader(effect: Effect): void;
  16857. /**
  16858. * Returns a string to use to update the GPU particles update shader
  16859. * @returns a string containng the defines string
  16860. */
  16861. getEffectDefines(): string;
  16862. /**
  16863. * Returns the string "ConeParticleEmitter"
  16864. * @returns a string containing the class name
  16865. */
  16866. getClassName(): string;
  16867. /**
  16868. * Serializes the particle system to a JSON object.
  16869. * @returns the JSON object
  16870. */
  16871. serialize(): any;
  16872. /**
  16873. * Parse properties from a JSON object
  16874. * @param serializationObject defines the JSON object
  16875. */
  16876. parse(serializationObject: any): void;
  16877. }
  16878. }
  16879. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16881. import { Effect } from "babylonjs/Materials/effect";
  16882. import { Particle } from "babylonjs/Particles/particle";
  16883. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16884. /**
  16885. * Particle emitter emitting particles from the inside of a cylinder.
  16886. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16887. */
  16888. export class CylinderParticleEmitter implements IParticleEmitterType {
  16889. /**
  16890. * The radius of the emission cylinder.
  16891. */
  16892. radius: number;
  16893. /**
  16894. * The height of the emission cylinder.
  16895. */
  16896. height: number;
  16897. /**
  16898. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16899. */
  16900. radiusRange: number;
  16901. /**
  16902. * How much to randomize the particle direction [0-1].
  16903. */
  16904. directionRandomizer: number;
  16905. /**
  16906. * Creates a new instance CylinderParticleEmitter
  16907. * @param radius the radius of the emission cylinder (1 by default)
  16908. * @param height the height of the emission cylinder (1 by default)
  16909. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16910. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16911. */
  16912. constructor(
  16913. /**
  16914. * The radius of the emission cylinder.
  16915. */
  16916. radius?: number,
  16917. /**
  16918. * The height of the emission cylinder.
  16919. */
  16920. height?: number,
  16921. /**
  16922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16923. */
  16924. radiusRange?: number,
  16925. /**
  16926. * How much to randomize the particle direction [0-1].
  16927. */
  16928. directionRandomizer?: number);
  16929. /**
  16930. * Called by the particle System when the direction is computed for the created particle.
  16931. * @param worldMatrix is the world matrix of the particle system
  16932. * @param directionToUpdate is the direction vector to update with the result
  16933. * @param particle is the particle we are computed the direction for
  16934. * @param isLocal defines if the direction should be set in local space
  16935. */
  16936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16937. /**
  16938. * Called by the particle System when the position is computed for the created particle.
  16939. * @param worldMatrix is the world matrix of the particle system
  16940. * @param positionToUpdate is the position vector to update with the result
  16941. * @param particle is the particle we are computed the position for
  16942. * @param isLocal defines if the position should be set in local space
  16943. */
  16944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16945. /**
  16946. * Clones the current emitter and returns a copy of it
  16947. * @returns the new emitter
  16948. */
  16949. clone(): CylinderParticleEmitter;
  16950. /**
  16951. * Called by the GPUParticleSystem to setup the update shader
  16952. * @param effect defines the update shader
  16953. */
  16954. applyToShader(effect: Effect): void;
  16955. /**
  16956. * Returns a string to use to update the GPU particles update shader
  16957. * @returns a string containng the defines string
  16958. */
  16959. getEffectDefines(): string;
  16960. /**
  16961. * Returns the string "CylinderParticleEmitter"
  16962. * @returns a string containing the class name
  16963. */
  16964. getClassName(): string;
  16965. /**
  16966. * Serializes the particle system to a JSON object.
  16967. * @returns the JSON object
  16968. */
  16969. serialize(): any;
  16970. /**
  16971. * Parse properties from a JSON object
  16972. * @param serializationObject defines the JSON object
  16973. */
  16974. parse(serializationObject: any): void;
  16975. }
  16976. /**
  16977. * Particle emitter emitting particles from the inside of a cylinder.
  16978. * It emits the particles randomly between two vectors.
  16979. */
  16980. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16981. /**
  16982. * The min limit of the emission direction.
  16983. */
  16984. direction1: Vector3;
  16985. /**
  16986. * The max limit of the emission direction.
  16987. */
  16988. direction2: Vector3;
  16989. /**
  16990. * Creates a new instance CylinderDirectedParticleEmitter
  16991. * @param radius the radius of the emission cylinder (1 by default)
  16992. * @param height the height of the emission cylinder (1 by default)
  16993. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16994. * @param direction1 the min limit of the emission direction (up vector by default)
  16995. * @param direction2 the max limit of the emission direction (up vector by default)
  16996. */
  16997. constructor(radius?: number, height?: number, radiusRange?: number,
  16998. /**
  16999. * The min limit of the emission direction.
  17000. */
  17001. direction1?: Vector3,
  17002. /**
  17003. * The max limit of the emission direction.
  17004. */
  17005. direction2?: Vector3);
  17006. /**
  17007. * Called by the particle System when the direction is computed for the created particle.
  17008. * @param worldMatrix is the world matrix of the particle system
  17009. * @param directionToUpdate is the direction vector to update with the result
  17010. * @param particle is the particle we are computed the direction for
  17011. */
  17012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17013. /**
  17014. * Clones the current emitter and returns a copy of it
  17015. * @returns the new emitter
  17016. */
  17017. clone(): CylinderDirectedParticleEmitter;
  17018. /**
  17019. * Called by the GPUParticleSystem to setup the update shader
  17020. * @param effect defines the update shader
  17021. */
  17022. applyToShader(effect: Effect): void;
  17023. /**
  17024. * Returns a string to use to update the GPU particles update shader
  17025. * @returns a string containng the defines string
  17026. */
  17027. getEffectDefines(): string;
  17028. /**
  17029. * Returns the string "CylinderDirectedParticleEmitter"
  17030. * @returns a string containing the class name
  17031. */
  17032. getClassName(): string;
  17033. /**
  17034. * Serializes the particle system to a JSON object.
  17035. * @returns the JSON object
  17036. */
  17037. serialize(): any;
  17038. /**
  17039. * Parse properties from a JSON object
  17040. * @param serializationObject defines the JSON object
  17041. */
  17042. parse(serializationObject: any): void;
  17043. }
  17044. }
  17045. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  17046. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17047. import { Effect } from "babylonjs/Materials/effect";
  17048. import { Particle } from "babylonjs/Particles/particle";
  17049. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17050. /**
  17051. * Particle emitter emitting particles from the inside of a hemisphere.
  17052. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17053. */
  17054. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17055. /**
  17056. * The radius of the emission hemisphere.
  17057. */
  17058. radius: number;
  17059. /**
  17060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17061. */
  17062. radiusRange: number;
  17063. /**
  17064. * How much to randomize the particle direction [0-1].
  17065. */
  17066. directionRandomizer: number;
  17067. /**
  17068. * Creates a new instance HemisphericParticleEmitter
  17069. * @param radius the radius of the emission hemisphere (1 by default)
  17070. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17071. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17072. */
  17073. constructor(
  17074. /**
  17075. * The radius of the emission hemisphere.
  17076. */
  17077. radius?: number,
  17078. /**
  17079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17080. */
  17081. radiusRange?: number,
  17082. /**
  17083. * How much to randomize the particle direction [0-1].
  17084. */
  17085. directionRandomizer?: number);
  17086. /**
  17087. * Called by the particle System when the direction is computed for the created particle.
  17088. * @param worldMatrix is the world matrix of the particle system
  17089. * @param directionToUpdate is the direction vector to update with the result
  17090. * @param particle is the particle we are computed the direction for
  17091. * @param isLocal defines if the direction should be set in local space
  17092. */
  17093. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17094. /**
  17095. * Called by the particle System when the position is computed for the created particle.
  17096. * @param worldMatrix is the world matrix of the particle system
  17097. * @param positionToUpdate is the position vector to update with the result
  17098. * @param particle is the particle we are computed the position for
  17099. * @param isLocal defines if the position should be set in local space
  17100. */
  17101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17102. /**
  17103. * Clones the current emitter and returns a copy of it
  17104. * @returns the new emitter
  17105. */
  17106. clone(): HemisphericParticleEmitter;
  17107. /**
  17108. * Called by the GPUParticleSystem to setup the update shader
  17109. * @param effect defines the update shader
  17110. */
  17111. applyToShader(effect: Effect): void;
  17112. /**
  17113. * Returns a string to use to update the GPU particles update shader
  17114. * @returns a string containng the defines string
  17115. */
  17116. getEffectDefines(): string;
  17117. /**
  17118. * Returns the string "HemisphericParticleEmitter"
  17119. * @returns a string containing the class name
  17120. */
  17121. getClassName(): string;
  17122. /**
  17123. * Serializes the particle system to a JSON object.
  17124. * @returns the JSON object
  17125. */
  17126. serialize(): any;
  17127. /**
  17128. * Parse properties from a JSON object
  17129. * @param serializationObject defines the JSON object
  17130. */
  17131. parse(serializationObject: any): void;
  17132. }
  17133. }
  17134. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  17135. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17136. import { Effect } from "babylonjs/Materials/effect";
  17137. import { Particle } from "babylonjs/Particles/particle";
  17138. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17139. /**
  17140. * Particle emitter emitting particles from a point.
  17141. * It emits the particles randomly between 2 given directions.
  17142. */
  17143. export class PointParticleEmitter implements IParticleEmitterType {
  17144. /**
  17145. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17146. */
  17147. direction1: Vector3;
  17148. /**
  17149. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17150. */
  17151. direction2: Vector3;
  17152. /**
  17153. * Creates a new instance PointParticleEmitter
  17154. */
  17155. constructor();
  17156. /**
  17157. * Called by the particle System when the direction is computed for the created particle.
  17158. * @param worldMatrix is the world matrix of the particle system
  17159. * @param directionToUpdate is the direction vector to update with the result
  17160. * @param particle is the particle we are computed the direction for
  17161. * @param isLocal defines if the direction should be set in local space
  17162. */
  17163. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17164. /**
  17165. * Called by the particle System when the position is computed for the created particle.
  17166. * @param worldMatrix is the world matrix of the particle system
  17167. * @param positionToUpdate is the position vector to update with the result
  17168. * @param particle is the particle we are computed the position for
  17169. * @param isLocal defines if the position should be set in local space
  17170. */
  17171. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17172. /**
  17173. * Clones the current emitter and returns a copy of it
  17174. * @returns the new emitter
  17175. */
  17176. clone(): PointParticleEmitter;
  17177. /**
  17178. * Called by the GPUParticleSystem to setup the update shader
  17179. * @param effect defines the update shader
  17180. */
  17181. applyToShader(effect: Effect): void;
  17182. /**
  17183. * Returns a string to use to update the GPU particles update shader
  17184. * @returns a string containng the defines string
  17185. */
  17186. getEffectDefines(): string;
  17187. /**
  17188. * Returns the string "PointParticleEmitter"
  17189. * @returns a string containing the class name
  17190. */
  17191. getClassName(): string;
  17192. /**
  17193. * Serializes the particle system to a JSON object.
  17194. * @returns the JSON object
  17195. */
  17196. serialize(): any;
  17197. /**
  17198. * Parse properties from a JSON object
  17199. * @param serializationObject defines the JSON object
  17200. */
  17201. parse(serializationObject: any): void;
  17202. }
  17203. }
  17204. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  17205. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17206. import { Effect } from "babylonjs/Materials/effect";
  17207. import { Particle } from "babylonjs/Particles/particle";
  17208. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17209. /**
  17210. * Particle emitter emitting particles from the inside of a sphere.
  17211. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17212. */
  17213. export class SphereParticleEmitter implements IParticleEmitterType {
  17214. /**
  17215. * The radius of the emission sphere.
  17216. */
  17217. radius: number;
  17218. /**
  17219. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17220. */
  17221. radiusRange: number;
  17222. /**
  17223. * How much to randomize the particle direction [0-1].
  17224. */
  17225. directionRandomizer: number;
  17226. /**
  17227. * Creates a new instance SphereParticleEmitter
  17228. * @param radius the radius of the emission sphere (1 by default)
  17229. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17230. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17231. */
  17232. constructor(
  17233. /**
  17234. * The radius of the emission sphere.
  17235. */
  17236. radius?: number,
  17237. /**
  17238. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17239. */
  17240. radiusRange?: number,
  17241. /**
  17242. * How much to randomize the particle direction [0-1].
  17243. */
  17244. directionRandomizer?: number);
  17245. /**
  17246. * Called by the particle System when the direction is computed for the created particle.
  17247. * @param worldMatrix is the world matrix of the particle system
  17248. * @param directionToUpdate is the direction vector to update with the result
  17249. * @param particle is the particle we are computed the direction for
  17250. * @param isLocal defines if the direction should be set in local space
  17251. */
  17252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17253. /**
  17254. * Called by the particle System when the position is computed for the created particle.
  17255. * @param worldMatrix is the world matrix of the particle system
  17256. * @param positionToUpdate is the position vector to update with the result
  17257. * @param particle is the particle we are computed the position for
  17258. * @param isLocal defines if the position should be set in local space
  17259. */
  17260. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17261. /**
  17262. * Clones the current emitter and returns a copy of it
  17263. * @returns the new emitter
  17264. */
  17265. clone(): SphereParticleEmitter;
  17266. /**
  17267. * Called by the GPUParticleSystem to setup the update shader
  17268. * @param effect defines the update shader
  17269. */
  17270. applyToShader(effect: Effect): void;
  17271. /**
  17272. * Returns a string to use to update the GPU particles update shader
  17273. * @returns a string containng the defines string
  17274. */
  17275. getEffectDefines(): string;
  17276. /**
  17277. * Returns the string "SphereParticleEmitter"
  17278. * @returns a string containing the class name
  17279. */
  17280. getClassName(): string;
  17281. /**
  17282. * Serializes the particle system to a JSON object.
  17283. * @returns the JSON object
  17284. */
  17285. serialize(): any;
  17286. /**
  17287. * Parse properties from a JSON object
  17288. * @param serializationObject defines the JSON object
  17289. */
  17290. parse(serializationObject: any): void;
  17291. }
  17292. /**
  17293. * Particle emitter emitting particles from the inside of a sphere.
  17294. * It emits the particles randomly between two vectors.
  17295. */
  17296. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17297. /**
  17298. * The min limit of the emission direction.
  17299. */
  17300. direction1: Vector3;
  17301. /**
  17302. * The max limit of the emission direction.
  17303. */
  17304. direction2: Vector3;
  17305. /**
  17306. * Creates a new instance SphereDirectedParticleEmitter
  17307. * @param radius the radius of the emission sphere (1 by default)
  17308. * @param direction1 the min limit of the emission direction (up vector by default)
  17309. * @param direction2 the max limit of the emission direction (up vector by default)
  17310. */
  17311. constructor(radius?: number,
  17312. /**
  17313. * The min limit of the emission direction.
  17314. */
  17315. direction1?: Vector3,
  17316. /**
  17317. * The max limit of the emission direction.
  17318. */
  17319. direction2?: Vector3);
  17320. /**
  17321. * Called by the particle System when the direction is computed for the created particle.
  17322. * @param worldMatrix is the world matrix of the particle system
  17323. * @param directionToUpdate is the direction vector to update with the result
  17324. * @param particle is the particle we are computed the direction for
  17325. */
  17326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17327. /**
  17328. * Clones the current emitter and returns a copy of it
  17329. * @returns the new emitter
  17330. */
  17331. clone(): SphereDirectedParticleEmitter;
  17332. /**
  17333. * Called by the GPUParticleSystem to setup the update shader
  17334. * @param effect defines the update shader
  17335. */
  17336. applyToShader(effect: Effect): void;
  17337. /**
  17338. * Returns a string to use to update the GPU particles update shader
  17339. * @returns a string containng the defines string
  17340. */
  17341. getEffectDefines(): string;
  17342. /**
  17343. * Returns the string "SphereDirectedParticleEmitter"
  17344. * @returns a string containing the class name
  17345. */
  17346. getClassName(): string;
  17347. /**
  17348. * Serializes the particle system to a JSON object.
  17349. * @returns the JSON object
  17350. */
  17351. serialize(): any;
  17352. /**
  17353. * Parse properties from a JSON object
  17354. * @param serializationObject defines the JSON object
  17355. */
  17356. parse(serializationObject: any): void;
  17357. }
  17358. }
  17359. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  17360. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17361. import { Effect } from "babylonjs/Materials/effect";
  17362. import { Particle } from "babylonjs/Particles/particle";
  17363. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17364. import { Nullable } from "babylonjs/types";
  17365. /**
  17366. * Particle emitter emitting particles from a custom list of positions.
  17367. */
  17368. export class CustomParticleEmitter implements IParticleEmitterType {
  17369. /**
  17370. * Gets or sets the position generator that will create the inital position of each particle.
  17371. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17372. */
  17373. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17374. /**
  17375. * Gets or sets the destination generator that will create the final destination of each particle.
  17376. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17377. */
  17378. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17379. /**
  17380. * Creates a new instance CustomParticleEmitter
  17381. */
  17382. constructor();
  17383. /**
  17384. * Called by the particle System when the direction is computed for the created particle.
  17385. * @param worldMatrix is the world matrix of the particle system
  17386. * @param directionToUpdate is the direction vector to update with the result
  17387. * @param particle is the particle we are computed the direction for
  17388. * @param isLocal defines if the direction should be set in local space
  17389. */
  17390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17391. /**
  17392. * Called by the particle System when the position is computed for the created particle.
  17393. * @param worldMatrix is the world matrix of the particle system
  17394. * @param positionToUpdate is the position vector to update with the result
  17395. * @param particle is the particle we are computed the position for
  17396. * @param isLocal defines if the position should be set in local space
  17397. */
  17398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17399. /**
  17400. * Clones the current emitter and returns a copy of it
  17401. * @returns the new emitter
  17402. */
  17403. clone(): CustomParticleEmitter;
  17404. /**
  17405. * Called by the GPUParticleSystem to setup the update shader
  17406. * @param effect defines the update shader
  17407. */
  17408. applyToShader(effect: Effect): void;
  17409. /**
  17410. * Returns a string to use to update the GPU particles update shader
  17411. * @returns a string containng the defines string
  17412. */
  17413. getEffectDefines(): string;
  17414. /**
  17415. * Returns the string "PointParticleEmitter"
  17416. * @returns a string containing the class name
  17417. */
  17418. getClassName(): string;
  17419. /**
  17420. * Serializes the particle system to a JSON object.
  17421. * @returns the JSON object
  17422. */
  17423. serialize(): any;
  17424. /**
  17425. * Parse properties from a JSON object
  17426. * @param serializationObject defines the JSON object
  17427. */
  17428. parse(serializationObject: any): void;
  17429. }
  17430. }
  17431. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  17432. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17433. import { Effect } from "babylonjs/Materials/effect";
  17434. import { Particle } from "babylonjs/Particles/particle";
  17435. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17436. import { Nullable } from "babylonjs/types";
  17437. import { Scene } from "babylonjs/scene";
  17438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17439. /**
  17440. * Particle emitter emitting particles from the inside of a box.
  17441. * It emits the particles randomly between 2 given directions.
  17442. */
  17443. export class MeshParticleEmitter implements IParticleEmitterType {
  17444. private _indices;
  17445. private _positions;
  17446. private _normals;
  17447. private _storedNormal;
  17448. private _mesh;
  17449. /**
  17450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17451. */
  17452. direction1: Vector3;
  17453. /**
  17454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17455. */
  17456. direction2: Vector3;
  17457. /**
  17458. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17459. */
  17460. useMeshNormalsForDirection: boolean;
  17461. /** Defines the mesh to use as source */
  17462. get mesh(): Nullable<AbstractMesh>;
  17463. set mesh(value: Nullable<AbstractMesh>);
  17464. /**
  17465. * Creates a new instance MeshParticleEmitter
  17466. * @param mesh defines the mesh to use as source
  17467. */
  17468. constructor(mesh?: Nullable<AbstractMesh>);
  17469. /**
  17470. * Called by the particle System when the direction is computed for the created particle.
  17471. * @param worldMatrix is the world matrix of the particle system
  17472. * @param directionToUpdate is the direction vector to update with the result
  17473. * @param particle is the particle we are computed the direction for
  17474. * @param isLocal defines if the direction should be set in local space
  17475. */
  17476. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17477. /**
  17478. * Called by the particle System when the position is computed for the created particle.
  17479. * @param worldMatrix is the world matrix of the particle system
  17480. * @param positionToUpdate is the position vector to update with the result
  17481. * @param particle is the particle we are computed the position for
  17482. * @param isLocal defines if the position should be set in local space
  17483. */
  17484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17485. /**
  17486. * Clones the current emitter and returns a copy of it
  17487. * @returns the new emitter
  17488. */
  17489. clone(): MeshParticleEmitter;
  17490. /**
  17491. * Called by the GPUParticleSystem to setup the update shader
  17492. * @param effect defines the update shader
  17493. */
  17494. applyToShader(effect: Effect): void;
  17495. /**
  17496. * Returns a string to use to update the GPU particles update shader
  17497. * @returns a string containng the defines string
  17498. */
  17499. getEffectDefines(): string;
  17500. /**
  17501. * Returns the string "BoxParticleEmitter"
  17502. * @returns a string containing the class name
  17503. */
  17504. getClassName(): string;
  17505. /**
  17506. * Serializes the particle system to a JSON object.
  17507. * @returns the JSON object
  17508. */
  17509. serialize(): any;
  17510. /**
  17511. * Parse properties from a JSON object
  17512. * @param serializationObject defines the JSON object
  17513. * @param scene defines the hosting scene
  17514. */
  17515. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17516. }
  17517. }
  17518. declare module "babylonjs/Particles/EmitterTypes/index" {
  17519. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  17520. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  17521. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  17522. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  17523. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17524. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  17525. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  17526. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  17527. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  17528. }
  17529. declare module "babylonjs/Particles/IParticleSystem" {
  17530. import { Nullable } from "babylonjs/types";
  17531. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17532. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17534. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17535. import { Scene } from "babylonjs/scene";
  17536. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17537. import { Effect } from "babylonjs/Materials/effect";
  17538. import { Observable } from "babylonjs/Misc/observable";
  17539. import { Animation } from "babylonjs/Animations/animation";
  17540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17541. /**
  17542. * Interface representing a particle system in Babylon.js.
  17543. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17544. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17545. */
  17546. export interface IParticleSystem {
  17547. /**
  17548. * List of animations used by the particle system.
  17549. */
  17550. animations: Animation[];
  17551. /**
  17552. * The id of the Particle system.
  17553. */
  17554. id: string;
  17555. /**
  17556. * The name of the Particle system.
  17557. */
  17558. name: string;
  17559. /**
  17560. * The emitter represents the Mesh or position we are attaching the particle system to.
  17561. */
  17562. emitter: Nullable<AbstractMesh | Vector3>;
  17563. /**
  17564. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17565. */
  17566. isBillboardBased: boolean;
  17567. /**
  17568. * The rendering group used by the Particle system to chose when to render.
  17569. */
  17570. renderingGroupId: number;
  17571. /**
  17572. * The layer mask we are rendering the particles through.
  17573. */
  17574. layerMask: number;
  17575. /**
  17576. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17577. */
  17578. updateSpeed: number;
  17579. /**
  17580. * The amount of time the particle system is running (depends of the overall update speed).
  17581. */
  17582. targetStopDuration: number;
  17583. /**
  17584. * The texture used to render each particle. (this can be a spritesheet)
  17585. */
  17586. particleTexture: Nullable<BaseTexture>;
  17587. /**
  17588. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17589. */
  17590. blendMode: number;
  17591. /**
  17592. * Minimum life time of emitting particles.
  17593. */
  17594. minLifeTime: number;
  17595. /**
  17596. * Maximum life time of emitting particles.
  17597. */
  17598. maxLifeTime: number;
  17599. /**
  17600. * Minimum Size of emitting particles.
  17601. */
  17602. minSize: number;
  17603. /**
  17604. * Maximum Size of emitting particles.
  17605. */
  17606. maxSize: number;
  17607. /**
  17608. * Minimum scale of emitting particles on X axis.
  17609. */
  17610. minScaleX: number;
  17611. /**
  17612. * Maximum scale of emitting particles on X axis.
  17613. */
  17614. maxScaleX: number;
  17615. /**
  17616. * Minimum scale of emitting particles on Y axis.
  17617. */
  17618. minScaleY: number;
  17619. /**
  17620. * Maximum scale of emitting particles on Y axis.
  17621. */
  17622. maxScaleY: number;
  17623. /**
  17624. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17625. */
  17626. color1: Color4;
  17627. /**
  17628. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17629. */
  17630. color2: Color4;
  17631. /**
  17632. * Color the particle will have at the end of its lifetime.
  17633. */
  17634. colorDead: Color4;
  17635. /**
  17636. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17637. */
  17638. emitRate: number;
  17639. /**
  17640. * You can use gravity if you want to give an orientation to your particles.
  17641. */
  17642. gravity: Vector3;
  17643. /**
  17644. * Minimum power of emitting particles.
  17645. */
  17646. minEmitPower: number;
  17647. /**
  17648. * Maximum power of emitting particles.
  17649. */
  17650. maxEmitPower: number;
  17651. /**
  17652. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17653. */
  17654. minAngularSpeed: number;
  17655. /**
  17656. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17657. */
  17658. maxAngularSpeed: number;
  17659. /**
  17660. * Gets or sets the minimal initial rotation in radians.
  17661. */
  17662. minInitialRotation: number;
  17663. /**
  17664. * Gets or sets the maximal initial rotation in radians.
  17665. */
  17666. maxInitialRotation: number;
  17667. /**
  17668. * The particle emitter type defines the emitter used by the particle system.
  17669. * It can be for example box, sphere, or cone...
  17670. */
  17671. particleEmitterType: Nullable<IParticleEmitterType>;
  17672. /**
  17673. * Defines the delay in milliseconds before starting the system (0 by default)
  17674. */
  17675. startDelay: number;
  17676. /**
  17677. * 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
  17678. */
  17679. preWarmCycles: number;
  17680. /**
  17681. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17682. */
  17683. preWarmStepOffset: number;
  17684. /**
  17685. * 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)
  17686. */
  17687. spriteCellChangeSpeed: number;
  17688. /**
  17689. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17690. */
  17691. startSpriteCellID: number;
  17692. /**
  17693. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17694. */
  17695. endSpriteCellID: number;
  17696. /**
  17697. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17698. */
  17699. spriteCellWidth: number;
  17700. /**
  17701. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17702. */
  17703. spriteCellHeight: number;
  17704. /**
  17705. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17706. */
  17707. spriteRandomStartCell: boolean;
  17708. /**
  17709. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17710. */
  17711. isAnimationSheetEnabled: boolean;
  17712. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17713. translationPivot: Vector2;
  17714. /**
  17715. * Gets or sets a texture used to add random noise to particle positions
  17716. */
  17717. noiseTexture: Nullable<BaseTexture>;
  17718. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17719. noiseStrength: Vector3;
  17720. /**
  17721. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17722. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17723. */
  17724. billboardMode: number;
  17725. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17726. limitVelocityDamping: number;
  17727. /**
  17728. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17729. */
  17730. beginAnimationOnStart: boolean;
  17731. /**
  17732. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17733. */
  17734. beginAnimationFrom: number;
  17735. /**
  17736. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17737. */
  17738. beginAnimationTo: number;
  17739. /**
  17740. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17741. */
  17742. beginAnimationLoop: boolean;
  17743. /**
  17744. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17745. */
  17746. disposeOnStop: boolean;
  17747. /**
  17748. * Specifies if the particles are updated in emitter local space or world space
  17749. */
  17750. isLocal: boolean;
  17751. /** Snippet ID if the particle system was created from the snippet server */
  17752. snippetId: string;
  17753. /** Gets or sets a matrix to use to compute projection */
  17754. defaultProjectionMatrix: Matrix;
  17755. /**
  17756. * Gets the maximum number of particles active at the same time.
  17757. * @returns The max number of active particles.
  17758. */
  17759. getCapacity(): number;
  17760. /**
  17761. * Gets the number of particles active at the same time.
  17762. * @returns The number of active particles.
  17763. */
  17764. getActiveCount(): number;
  17765. /**
  17766. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17767. * @returns True if it has been started, otherwise false.
  17768. */
  17769. isStarted(): boolean;
  17770. /**
  17771. * Animates the particle system for this frame.
  17772. */
  17773. animate(): void;
  17774. /**
  17775. * Renders the particle system in its current state.
  17776. * @returns the current number of particles
  17777. */
  17778. render(): number;
  17779. /**
  17780. * Dispose the particle system and frees its associated resources.
  17781. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17782. */
  17783. dispose(disposeTexture?: boolean): void;
  17784. /**
  17785. * An event triggered when the system is disposed
  17786. */
  17787. onDisposeObservable: Observable<IParticleSystem>;
  17788. /**
  17789. * An event triggered when the system is stopped
  17790. */
  17791. onStoppedObservable: Observable<IParticleSystem>;
  17792. /**
  17793. * Clones the particle system.
  17794. * @param name The name of the cloned object
  17795. * @param newEmitter The new emitter to use
  17796. * @returns the cloned particle system
  17797. */
  17798. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17799. /**
  17800. * Serializes the particle system to a JSON object
  17801. * @param serializeTexture defines if the texture must be serialized as well
  17802. * @returns the JSON object
  17803. */
  17804. serialize(serializeTexture: boolean): any;
  17805. /**
  17806. * Rebuild the particle system
  17807. */
  17808. rebuild(): void;
  17809. /** Force the system to rebuild all gradients that need to be resync */
  17810. forceRefreshGradients(): void;
  17811. /**
  17812. * Starts the particle system and begins to emit
  17813. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17814. */
  17815. start(delay?: number): void;
  17816. /**
  17817. * Stops the particle system.
  17818. */
  17819. stop(): void;
  17820. /**
  17821. * Remove all active particles
  17822. */
  17823. reset(): void;
  17824. /**
  17825. * Gets a boolean indicating that the system is stopping
  17826. * @returns true if the system is currently stopping
  17827. */
  17828. isStopping(): boolean;
  17829. /**
  17830. * Is this system ready to be used/rendered
  17831. * @return true if the system is ready
  17832. */
  17833. isReady(): boolean;
  17834. /**
  17835. * Returns the string "ParticleSystem"
  17836. * @returns a string containing the class name
  17837. */
  17838. getClassName(): string;
  17839. /**
  17840. * Gets the custom effect used to render the particles
  17841. * @param blendMode Blend mode for which the effect should be retrieved
  17842. * @returns The effect
  17843. */
  17844. getCustomEffect(blendMode: number): Nullable<Effect>;
  17845. /**
  17846. * Sets the custom effect used to render the particles
  17847. * @param effect The effect to set
  17848. * @param blendMode Blend mode for which the effect should be set
  17849. */
  17850. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17851. /**
  17852. * Fill the defines array according to the current settings of the particle system
  17853. * @param defines Array to be updated
  17854. * @param blendMode blend mode to take into account when updating the array
  17855. */
  17856. fillDefines(defines: Array<string>, blendMode: number): void;
  17857. /**
  17858. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17859. * @param uniforms Uniforms array to fill
  17860. * @param attributes Attributes array to fill
  17861. * @param samplers Samplers array to fill
  17862. */
  17863. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17864. /**
  17865. * Observable that will be called just before the particles are drawn
  17866. */
  17867. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17868. /**
  17869. * Gets the name of the particle vertex shader
  17870. */
  17871. vertexShaderName: string;
  17872. /**
  17873. * Adds a new color gradient
  17874. * @param gradient defines the gradient to use (between 0 and 1)
  17875. * @param color1 defines the color to affect to the specified gradient
  17876. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17877. * @returns the current particle system
  17878. */
  17879. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17880. /**
  17881. * Remove a specific color gradient
  17882. * @param gradient defines the gradient to remove
  17883. * @returns the current particle system
  17884. */
  17885. removeColorGradient(gradient: number): IParticleSystem;
  17886. /**
  17887. * Adds a new size gradient
  17888. * @param gradient defines the gradient to use (between 0 and 1)
  17889. * @param factor defines the size factor to affect to the specified gradient
  17890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17891. * @returns the current particle system
  17892. */
  17893. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17894. /**
  17895. * Remove a specific size gradient
  17896. * @param gradient defines the gradient to remove
  17897. * @returns the current particle system
  17898. */
  17899. removeSizeGradient(gradient: number): IParticleSystem;
  17900. /**
  17901. * Gets the current list of color gradients.
  17902. * You must use addColorGradient and removeColorGradient to udpate this list
  17903. * @returns the list of color gradients
  17904. */
  17905. getColorGradients(): Nullable<Array<ColorGradient>>;
  17906. /**
  17907. * Gets the current list of size gradients.
  17908. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17909. * @returns the list of size gradients
  17910. */
  17911. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17912. /**
  17913. * Gets the current list of angular speed gradients.
  17914. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17915. * @returns the list of angular speed gradients
  17916. */
  17917. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17918. /**
  17919. * Adds a new angular speed gradient
  17920. * @param gradient defines the gradient to use (between 0 and 1)
  17921. * @param factor defines the angular speed to affect to the specified gradient
  17922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17923. * @returns the current particle system
  17924. */
  17925. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17926. /**
  17927. * Remove a specific angular speed gradient
  17928. * @param gradient defines the gradient to remove
  17929. * @returns the current particle system
  17930. */
  17931. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17932. /**
  17933. * Gets the current list of velocity gradients.
  17934. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17935. * @returns the list of velocity gradients
  17936. */
  17937. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17938. /**
  17939. * Adds a new velocity gradient
  17940. * @param gradient defines the gradient to use (between 0 and 1)
  17941. * @param factor defines the velocity to affect to the specified gradient
  17942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17943. * @returns the current particle system
  17944. */
  17945. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17946. /**
  17947. * Remove a specific velocity gradient
  17948. * @param gradient defines the gradient to remove
  17949. * @returns the current particle system
  17950. */
  17951. removeVelocityGradient(gradient: number): IParticleSystem;
  17952. /**
  17953. * Gets the current list of limit velocity gradients.
  17954. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17955. * @returns the list of limit velocity gradients
  17956. */
  17957. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17958. /**
  17959. * Adds a new limit velocity gradient
  17960. * @param gradient defines the gradient to use (between 0 and 1)
  17961. * @param factor defines the limit velocity to affect to the specified gradient
  17962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17963. * @returns the current particle system
  17964. */
  17965. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17966. /**
  17967. * Remove a specific limit velocity gradient
  17968. * @param gradient defines the gradient to remove
  17969. * @returns the current particle system
  17970. */
  17971. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17972. /**
  17973. * Adds a new drag gradient
  17974. * @param gradient defines the gradient to use (between 0 and 1)
  17975. * @param factor defines the drag to affect to the specified gradient
  17976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17977. * @returns the current particle system
  17978. */
  17979. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17980. /**
  17981. * Remove a specific drag gradient
  17982. * @param gradient defines the gradient to remove
  17983. * @returns the current particle system
  17984. */
  17985. removeDragGradient(gradient: number): IParticleSystem;
  17986. /**
  17987. * Gets the current list of drag gradients.
  17988. * You must use addDragGradient and removeDragGradient to udpate this list
  17989. * @returns the list of drag gradients
  17990. */
  17991. getDragGradients(): Nullable<Array<FactorGradient>>;
  17992. /**
  17993. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17994. * @param gradient defines the gradient to use (between 0 and 1)
  17995. * @param factor defines the emit rate to affect to the specified gradient
  17996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17997. * @returns the current particle system
  17998. */
  17999. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18000. /**
  18001. * Remove a specific emit rate gradient
  18002. * @param gradient defines the gradient to remove
  18003. * @returns the current particle system
  18004. */
  18005. removeEmitRateGradient(gradient: number): IParticleSystem;
  18006. /**
  18007. * Gets the current list of emit rate gradients.
  18008. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18009. * @returns the list of emit rate gradients
  18010. */
  18011. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18012. /**
  18013. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18014. * @param gradient defines the gradient to use (between 0 and 1)
  18015. * @param factor defines the start size to affect to the specified gradient
  18016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18017. * @returns the current particle system
  18018. */
  18019. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18020. /**
  18021. * Remove a specific start size gradient
  18022. * @param gradient defines the gradient to remove
  18023. * @returns the current particle system
  18024. */
  18025. removeStartSizeGradient(gradient: number): IParticleSystem;
  18026. /**
  18027. * Gets the current list of start size gradients.
  18028. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18029. * @returns the list of start size gradients
  18030. */
  18031. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18032. /**
  18033. * Adds a new life time gradient
  18034. * @param gradient defines the gradient to use (between 0 and 1)
  18035. * @param factor defines the life time factor to affect to the specified gradient
  18036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18037. * @returns the current particle system
  18038. */
  18039. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18040. /**
  18041. * Remove a specific life time gradient
  18042. * @param gradient defines the gradient to remove
  18043. * @returns the current particle system
  18044. */
  18045. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18046. /**
  18047. * Gets the current list of life time gradients.
  18048. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18049. * @returns the list of life time gradients
  18050. */
  18051. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18052. /**
  18053. * Gets the current list of color gradients.
  18054. * You must use addColorGradient and removeColorGradient to udpate this list
  18055. * @returns the list of color gradients
  18056. */
  18057. getColorGradients(): Nullable<Array<ColorGradient>>;
  18058. /**
  18059. * Adds a new ramp gradient used to remap particle colors
  18060. * @param gradient defines the gradient to use (between 0 and 1)
  18061. * @param color defines the color to affect to the specified gradient
  18062. * @returns the current particle system
  18063. */
  18064. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18065. /**
  18066. * Gets the current list of ramp gradients.
  18067. * You must use addRampGradient and removeRampGradient to udpate this list
  18068. * @returns the list of ramp gradients
  18069. */
  18070. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18071. /** Gets or sets a boolean indicating that ramp gradients must be used
  18072. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18073. */
  18074. useRampGradients: boolean;
  18075. /**
  18076. * Adds a new color remap gradient
  18077. * @param gradient defines the gradient to use (between 0 and 1)
  18078. * @param min defines the color remap minimal range
  18079. * @param max defines the color remap maximal range
  18080. * @returns the current particle system
  18081. */
  18082. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18083. /**
  18084. * Gets the current list of color remap gradients.
  18085. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18086. * @returns the list of color remap gradients
  18087. */
  18088. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18089. /**
  18090. * Adds a new alpha remap gradient
  18091. * @param gradient defines the gradient to use (between 0 and 1)
  18092. * @param min defines the alpha remap minimal range
  18093. * @param max defines the alpha remap maximal range
  18094. * @returns the current particle system
  18095. */
  18096. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18097. /**
  18098. * Gets the current list of alpha remap gradients.
  18099. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18100. * @returns the list of alpha remap gradients
  18101. */
  18102. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18103. /**
  18104. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18105. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18106. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18107. * @returns the emitter
  18108. */
  18109. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18110. /**
  18111. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18112. * @param radius The radius of the hemisphere to emit from
  18113. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18114. * @returns the emitter
  18115. */
  18116. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18117. /**
  18118. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18119. * @param radius The radius of the sphere to emit from
  18120. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18121. * @returns the emitter
  18122. */
  18123. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18124. /**
  18125. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18126. * @param radius The radius of the sphere to emit from
  18127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18129. * @returns the emitter
  18130. */
  18131. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18132. /**
  18133. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18134. * @param radius The radius of the emission cylinder
  18135. * @param height The height of the emission cylinder
  18136. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18137. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18138. * @returns the emitter
  18139. */
  18140. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18141. /**
  18142. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18143. * @param radius The radius of the cylinder to emit from
  18144. * @param height The height of the emission cylinder
  18145. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18148. * @returns the emitter
  18149. */
  18150. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18151. /**
  18152. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18153. * @param radius The radius of the cone to emit from
  18154. * @param angle The base angle of the cone
  18155. * @returns the emitter
  18156. */
  18157. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18158. /**
  18159. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18162. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18163. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18164. * @returns the emitter
  18165. */
  18166. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18167. /**
  18168. * Get hosting scene
  18169. * @returns the scene
  18170. */
  18171. getScene(): Nullable<Scene>;
  18172. }
  18173. }
  18174. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  18175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18178. /**
  18179. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18180. */
  18181. export class ColorSplitterBlock extends NodeMaterialBlock {
  18182. /**
  18183. * Create a new ColorSplitterBlock
  18184. * @param name defines the block name
  18185. */
  18186. constructor(name: string);
  18187. /**
  18188. * Gets the current class name
  18189. * @returns the class name
  18190. */
  18191. getClassName(): string;
  18192. /**
  18193. * Gets the rgba component (input)
  18194. */
  18195. get rgba(): NodeMaterialConnectionPoint;
  18196. /**
  18197. * Gets the rgb component (input)
  18198. */
  18199. get rgbIn(): NodeMaterialConnectionPoint;
  18200. /**
  18201. * Gets the rgb component (output)
  18202. */
  18203. get rgbOut(): NodeMaterialConnectionPoint;
  18204. /**
  18205. * Gets the r component (output)
  18206. */
  18207. get r(): NodeMaterialConnectionPoint;
  18208. /**
  18209. * Gets the g component (output)
  18210. */
  18211. get g(): NodeMaterialConnectionPoint;
  18212. /**
  18213. * Gets the b component (output)
  18214. */
  18215. get b(): NodeMaterialConnectionPoint;
  18216. /**
  18217. * Gets the a component (output)
  18218. */
  18219. get a(): NodeMaterialConnectionPoint;
  18220. protected _inputRename(name: string): string;
  18221. protected _outputRename(name: string): string;
  18222. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18223. }
  18224. }
  18225. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  18226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18229. import { Scene } from "babylonjs/scene";
  18230. /**
  18231. * Operations supported by the Trigonometry block
  18232. */
  18233. export enum TrigonometryBlockOperations {
  18234. /** Cos */
  18235. Cos = 0,
  18236. /** Sin */
  18237. Sin = 1,
  18238. /** Abs */
  18239. Abs = 2,
  18240. /** Exp */
  18241. Exp = 3,
  18242. /** Exp2 */
  18243. Exp2 = 4,
  18244. /** Round */
  18245. Round = 5,
  18246. /** Floor */
  18247. Floor = 6,
  18248. /** Ceiling */
  18249. Ceiling = 7,
  18250. /** Square root */
  18251. Sqrt = 8,
  18252. /** Log */
  18253. Log = 9,
  18254. /** Tangent */
  18255. Tan = 10,
  18256. /** Arc tangent */
  18257. ArcTan = 11,
  18258. /** Arc cosinus */
  18259. ArcCos = 12,
  18260. /** Arc sinus */
  18261. ArcSin = 13,
  18262. /** Fraction */
  18263. Fract = 14,
  18264. /** Sign */
  18265. Sign = 15,
  18266. /** To radians (from degrees) */
  18267. Radians = 16,
  18268. /** To degrees (from radians) */
  18269. Degrees = 17
  18270. }
  18271. /**
  18272. * Block used to apply trigonometry operation to floats
  18273. */
  18274. export class TrigonometryBlock extends NodeMaterialBlock {
  18275. /**
  18276. * Gets or sets the operation applied by the block
  18277. */
  18278. operation: TrigonometryBlockOperations;
  18279. /**
  18280. * Creates a new TrigonometryBlock
  18281. * @param name defines the block name
  18282. */
  18283. constructor(name: string);
  18284. /**
  18285. * Gets the current class name
  18286. * @returns the class name
  18287. */
  18288. getClassName(): string;
  18289. /**
  18290. * Gets the input component
  18291. */
  18292. get input(): NodeMaterialConnectionPoint;
  18293. /**
  18294. * Gets the output component
  18295. */
  18296. get output(): NodeMaterialConnectionPoint;
  18297. protected _buildBlock(state: NodeMaterialBuildState): this;
  18298. serialize(): any;
  18299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18300. protected _dumpPropertiesCode(): string;
  18301. }
  18302. }
  18303. declare module "babylonjs/Materials/Node/nodeMaterial" {
  18304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18305. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  18306. import { Scene } from "babylonjs/scene";
  18307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18308. import { Matrix } from "babylonjs/Maths/math.vector";
  18309. import { Mesh } from "babylonjs/Meshes/mesh";
  18310. import { Engine } from "babylonjs/Engines/engine";
  18311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18312. import { Observable } from "babylonjs/Misc/observable";
  18313. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18314. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18315. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  18316. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  18317. import { Nullable } from "babylonjs/types";
  18318. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  18319. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  18320. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  18321. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  18322. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  18323. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  18324. import { Effect } from "babylonjs/Materials/effect";
  18325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18326. import { Camera } from "babylonjs/Cameras/camera";
  18327. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  18328. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18329. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  18330. /**
  18331. * Interface used to configure the node material editor
  18332. */
  18333. export interface INodeMaterialEditorOptions {
  18334. /** Define the URl to load node editor script */
  18335. editorURL?: string;
  18336. }
  18337. /** @hidden */
  18338. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18339. NORMAL: boolean;
  18340. TANGENT: boolean;
  18341. UV1: boolean;
  18342. /** BONES */
  18343. NUM_BONE_INFLUENCERS: number;
  18344. BonesPerMesh: number;
  18345. BONETEXTURE: boolean;
  18346. /** MORPH TARGETS */
  18347. MORPHTARGETS: boolean;
  18348. MORPHTARGETS_NORMAL: boolean;
  18349. MORPHTARGETS_TANGENT: boolean;
  18350. MORPHTARGETS_UV: boolean;
  18351. NUM_MORPH_INFLUENCERS: number;
  18352. /** IMAGE PROCESSING */
  18353. IMAGEPROCESSING: boolean;
  18354. VIGNETTE: boolean;
  18355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18356. VIGNETTEBLENDMODEOPAQUE: boolean;
  18357. TONEMAPPING: boolean;
  18358. TONEMAPPING_ACES: boolean;
  18359. CONTRAST: boolean;
  18360. EXPOSURE: boolean;
  18361. COLORCURVES: boolean;
  18362. COLORGRADING: boolean;
  18363. COLORGRADING3D: boolean;
  18364. SAMPLER3DGREENDEPTH: boolean;
  18365. SAMPLER3DBGRMAP: boolean;
  18366. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18367. /** MISC. */
  18368. BUMPDIRECTUV: number;
  18369. constructor();
  18370. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18371. }
  18372. /**
  18373. * Class used to configure NodeMaterial
  18374. */
  18375. export interface INodeMaterialOptions {
  18376. /**
  18377. * Defines if blocks should emit comments
  18378. */
  18379. emitComments: boolean;
  18380. }
  18381. /**
  18382. * Class used to create a node based material built by assembling shader blocks
  18383. */
  18384. export class NodeMaterial extends PushMaterial {
  18385. private static _BuildIdGenerator;
  18386. private _options;
  18387. private _vertexCompilationState;
  18388. private _fragmentCompilationState;
  18389. private _sharedData;
  18390. private _buildId;
  18391. private _buildWasSuccessful;
  18392. private _cachedWorldViewMatrix;
  18393. private _cachedWorldViewProjectionMatrix;
  18394. private _optimizers;
  18395. private _animationFrame;
  18396. /** Define the Url to load node editor script */
  18397. static EditorURL: string;
  18398. /** Define the Url to load snippets */
  18399. static SnippetUrl: string;
  18400. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18401. static IgnoreTexturesAtLoadTime: boolean;
  18402. private BJSNODEMATERIALEDITOR;
  18403. /** Get the inspector from bundle or global */
  18404. private _getGlobalNodeMaterialEditor;
  18405. /**
  18406. * Snippet ID if the material was created from the snippet server
  18407. */
  18408. snippetId: string;
  18409. /**
  18410. * Gets or sets data used by visual editor
  18411. * @see https://nme.babylonjs.com
  18412. */
  18413. editorData: any;
  18414. /**
  18415. * 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)
  18416. */
  18417. ignoreAlpha: boolean;
  18418. /**
  18419. * Defines the maximum number of lights that can be used in the material
  18420. */
  18421. maxSimultaneousLights: number;
  18422. /**
  18423. * Observable raised when the material is built
  18424. */
  18425. onBuildObservable: Observable<NodeMaterial>;
  18426. /**
  18427. * Gets or sets the root nodes of the material vertex shader
  18428. */
  18429. _vertexOutputNodes: NodeMaterialBlock[];
  18430. /**
  18431. * Gets or sets the root nodes of the material fragment (pixel) shader
  18432. */
  18433. _fragmentOutputNodes: NodeMaterialBlock[];
  18434. /** Gets or sets options to control the node material overall behavior */
  18435. get options(): INodeMaterialOptions;
  18436. set options(options: INodeMaterialOptions);
  18437. /**
  18438. * Default configuration related to image processing available in the standard Material.
  18439. */
  18440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18441. /**
  18442. * Gets the image processing configuration used either in this material.
  18443. */
  18444. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18445. /**
  18446. * Sets the Default image processing configuration used either in the this material.
  18447. *
  18448. * If sets to null, the scene one is in use.
  18449. */
  18450. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18451. /**
  18452. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18453. */
  18454. attachedBlocks: NodeMaterialBlock[];
  18455. /**
  18456. * Specifies the mode of the node material
  18457. * @hidden
  18458. */
  18459. _mode: NodeMaterialModes;
  18460. /**
  18461. * Gets the mode property
  18462. */
  18463. get mode(): NodeMaterialModes;
  18464. /**
  18465. * A free comment about the material
  18466. */
  18467. comment: string;
  18468. /**
  18469. * Create a new node based material
  18470. * @param name defines the material name
  18471. * @param scene defines the hosting scene
  18472. * @param options defines creation option
  18473. */
  18474. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18475. /**
  18476. * Gets the current class name of the material e.g. "NodeMaterial"
  18477. * @returns the class name
  18478. */
  18479. getClassName(): string;
  18480. /**
  18481. * Keep track of the image processing observer to allow dispose and replace.
  18482. */
  18483. private _imageProcessingObserver;
  18484. /**
  18485. * Attaches a new image processing configuration to the Standard Material.
  18486. * @param configuration
  18487. */
  18488. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18489. /**
  18490. * Get a block by its name
  18491. * @param name defines the name of the block to retrieve
  18492. * @returns the required block or null if not found
  18493. */
  18494. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18495. /**
  18496. * Get a block by its name
  18497. * @param predicate defines the predicate used to find the good candidate
  18498. * @returns the required block or null if not found
  18499. */
  18500. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18501. /**
  18502. * Get an input block by its name
  18503. * @param predicate defines the predicate used to find the good candidate
  18504. * @returns the required input block or null if not found
  18505. */
  18506. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18507. /**
  18508. * Gets the list of input blocks attached to this material
  18509. * @returns an array of InputBlocks
  18510. */
  18511. getInputBlocks(): InputBlock[];
  18512. /**
  18513. * Adds a new optimizer to the list of optimizers
  18514. * @param optimizer defines the optimizers to add
  18515. * @returns the current material
  18516. */
  18517. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18518. /**
  18519. * Remove an optimizer from the list of optimizers
  18520. * @param optimizer defines the optimizers to remove
  18521. * @returns the current material
  18522. */
  18523. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18524. /**
  18525. * Add a new block to the list of output nodes
  18526. * @param node defines the node to add
  18527. * @returns the current material
  18528. */
  18529. addOutputNode(node: NodeMaterialBlock): this;
  18530. /**
  18531. * Remove a block from the list of root nodes
  18532. * @param node defines the node to remove
  18533. * @returns the current material
  18534. */
  18535. removeOutputNode(node: NodeMaterialBlock): this;
  18536. private _addVertexOutputNode;
  18537. private _removeVertexOutputNode;
  18538. private _addFragmentOutputNode;
  18539. private _removeFragmentOutputNode;
  18540. /**
  18541. * Specifies if the material will require alpha blending
  18542. * @returns a boolean specifying if alpha blending is needed
  18543. */
  18544. needAlphaBlending(): boolean;
  18545. /**
  18546. * Specifies if this material should be rendered in alpha test mode
  18547. * @returns a boolean specifying if an alpha test is needed.
  18548. */
  18549. needAlphaTesting(): boolean;
  18550. private _initializeBlock;
  18551. private _resetDualBlocks;
  18552. /**
  18553. * Remove a block from the current node material
  18554. * @param block defines the block to remove
  18555. */
  18556. removeBlock(block: NodeMaterialBlock): void;
  18557. /**
  18558. * Build the material and generates the inner effect
  18559. * @param verbose defines if the build should log activity
  18560. */
  18561. build(verbose?: boolean): void;
  18562. /**
  18563. * Runs an otpimization phase to try to improve the shader code
  18564. */
  18565. optimize(): void;
  18566. private _prepareDefinesForAttributes;
  18567. /**
  18568. * Create a post process from the material
  18569. * @param camera The camera to apply the render pass to.
  18570. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18572. * @param engine The engine which the post process will be applied. (default: current engine)
  18573. * @param reusable If the post process can be reused on the same frame. (default: false)
  18574. * @param textureType Type of textures used when performing the post process. (default: 0)
  18575. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18576. * @returns the post process created
  18577. */
  18578. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18579. /**
  18580. * Create the post process effect from the material
  18581. * @param postProcess The post process to create the effect for
  18582. */
  18583. createEffectForPostProcess(postProcess: PostProcess): void;
  18584. private _createEffectForPostProcess;
  18585. /**
  18586. * Create a new procedural texture based on this node material
  18587. * @param size defines the size of the texture
  18588. * @param scene defines the hosting scene
  18589. * @returns the new procedural texture attached to this node material
  18590. */
  18591. createProceduralTexture(size: number | {
  18592. width: number;
  18593. height: number;
  18594. layers?: number;
  18595. }, scene: Scene): Nullable<ProceduralTexture>;
  18596. private _createEffectForParticles;
  18597. private _checkInternals;
  18598. /**
  18599. * Create the effect to be used as the custom effect for a particle system
  18600. * @param particleSystem Particle system to create the effect for
  18601. * @param onCompiled defines a function to call when the effect creation is successful
  18602. * @param onError defines a function to call when the effect creation has failed
  18603. */
  18604. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18605. private _processDefines;
  18606. /**
  18607. * Get if the submesh is ready to be used and all its information available.
  18608. * Child classes can use it to update shaders
  18609. * @param mesh defines the mesh to check
  18610. * @param subMesh defines which submesh to check
  18611. * @param useInstances specifies that instances should be used
  18612. * @returns a boolean indicating that the submesh is ready or not
  18613. */
  18614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18615. /**
  18616. * Get a string representing the shaders built by the current node graph
  18617. */
  18618. get compiledShaders(): string;
  18619. /**
  18620. * Binds the world matrix to the material
  18621. * @param world defines the world transformation matrix
  18622. */
  18623. bindOnlyWorldMatrix(world: Matrix): void;
  18624. /**
  18625. * Binds the submesh to this material by preparing the effect and shader to draw
  18626. * @param world defines the world transformation matrix
  18627. * @param mesh defines the mesh containing the submesh
  18628. * @param subMesh defines the submesh to bind the material to
  18629. */
  18630. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18631. /**
  18632. * Gets the active textures from the material
  18633. * @returns an array of textures
  18634. */
  18635. getActiveTextures(): BaseTexture[];
  18636. /**
  18637. * Gets the list of texture blocks
  18638. * @returns an array of texture blocks
  18639. */
  18640. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18641. /**
  18642. * Specifies if the material uses a texture
  18643. * @param texture defines the texture to check against the material
  18644. * @returns a boolean specifying if the material uses the texture
  18645. */
  18646. hasTexture(texture: BaseTexture): boolean;
  18647. /**
  18648. * Disposes the material
  18649. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18650. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18651. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18652. */
  18653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18654. /** Creates the node editor window. */
  18655. private _createNodeEditor;
  18656. /**
  18657. * Launch the node material editor
  18658. * @param config Define the configuration of the editor
  18659. * @return a promise fulfilled when the node editor is visible
  18660. */
  18661. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18662. /**
  18663. * Clear the current material
  18664. */
  18665. clear(): void;
  18666. /**
  18667. * Clear the current material and set it to a default state
  18668. */
  18669. setToDefault(): void;
  18670. /**
  18671. * Clear the current material and set it to a default state for post process
  18672. */
  18673. setToDefaultPostProcess(): void;
  18674. /**
  18675. * Clear the current material and set it to a default state for procedural texture
  18676. */
  18677. setToDefaultProceduralTexture(): void;
  18678. /**
  18679. * Clear the current material and set it to a default state for particle
  18680. */
  18681. setToDefaultParticle(): void;
  18682. /**
  18683. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18684. * @param url defines the url to load from
  18685. * @returns a promise that will fullfil when the material is fully loaded
  18686. */
  18687. loadAsync(url: string): Promise<void>;
  18688. private _gatherBlocks;
  18689. /**
  18690. * Generate a string containing the code declaration required to create an equivalent of this material
  18691. * @returns a string
  18692. */
  18693. generateCode(): string;
  18694. /**
  18695. * Serializes this material in a JSON representation
  18696. * @returns the serialized material object
  18697. */
  18698. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18699. private _restoreConnections;
  18700. /**
  18701. * Clear the current graph and load a new one from a serialization object
  18702. * @param source defines the JSON representation of the material
  18703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18704. * @param merge defines whether or not the source must be merged or replace the current content
  18705. */
  18706. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18707. /**
  18708. * Makes a duplicate of the current material.
  18709. * @param name - name to use for the new material.
  18710. */
  18711. clone(name: string): NodeMaterial;
  18712. /**
  18713. * Creates a node material from parsed material data
  18714. * @param source defines the JSON representation of the material
  18715. * @param scene defines the hosting scene
  18716. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18717. * @returns a new node material
  18718. */
  18719. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18720. /**
  18721. * Creates a node material from a snippet saved in a remote file
  18722. * @param name defines the name of the material to create
  18723. * @param url defines the url to load from
  18724. * @param scene defines the hosting scene
  18725. * @returns a promise that will resolve to the new node material
  18726. */
  18727. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18728. /**
  18729. * Creates a node material from a snippet saved by the node material editor
  18730. * @param snippetId defines the snippet to load
  18731. * @param scene defines the hosting scene
  18732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18733. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18734. * @returns a promise that will resolve to the new node material
  18735. */
  18736. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18737. /**
  18738. * Creates a new node material set to default basic configuration
  18739. * @param name defines the name of the material
  18740. * @param scene defines the hosting scene
  18741. * @returns a new NodeMaterial
  18742. */
  18743. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18744. }
  18745. }
  18746. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18748. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18749. import { IColor4Like } from "babylonjs/Maths/math.like";
  18750. import { Nullable } from "babylonjs/types";
  18751. module "babylonjs/Engines/thinEngine" {
  18752. interface ThinEngine {
  18753. /**
  18754. * Unbind a list of render target textures from the webGL context
  18755. * This is used only when drawBuffer extension or webGL2 are active
  18756. * @param textures defines the render target textures to unbind
  18757. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18758. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18759. */
  18760. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18761. /**
  18762. * Create a multi render target texture
  18763. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18764. * @param size defines the size of the texture
  18765. * @param options defines the creation options
  18766. * @returns the cube texture as an InternalTexture
  18767. */
  18768. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18769. /**
  18770. * Update the sample count for a given multiple render target texture
  18771. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18772. * @param textures defines the textures to update
  18773. * @param samples defines the sample count to set
  18774. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18775. */
  18776. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18777. /**
  18778. * Select a subsets of attachments to draw to.
  18779. * @param attachments gl attachments
  18780. */
  18781. bindAttachments(attachments: number[]): void;
  18782. /**
  18783. * Creates a layout object to draw/clear on specific textures in a MRT
  18784. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18785. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18786. */
  18787. buildTextureLayout(textureStatus: boolean[]): number[];
  18788. /**
  18789. * Restores the webgl state to only draw on the main color attachment
  18790. */
  18791. restoreSingleAttachment(): void;
  18792. /**
  18793. * Clears a list of attachments
  18794. * @param attachments list of the attachments
  18795. * @param colorMain clear color for the main attachment (the first one)
  18796. * @param colorOthers clear color for the other attachments
  18797. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18798. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18799. */
  18800. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18801. }
  18802. }
  18803. }
  18804. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18805. import { Scene } from "babylonjs/scene";
  18806. import { Engine } from "babylonjs/Engines/engine";
  18807. import { Texture } from "babylonjs/Materials/Textures/texture";
  18808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18809. import "babylonjs/Engines/Extensions/engine.multiRender";
  18810. /**
  18811. * Creation options of the multi render target texture.
  18812. */
  18813. export interface IMultiRenderTargetOptions {
  18814. /**
  18815. * Define if the texture needs to create mip maps after render.
  18816. */
  18817. generateMipMaps?: boolean;
  18818. /**
  18819. * Define the types of all the draw buffers we want to create
  18820. */
  18821. types?: number[];
  18822. /**
  18823. * Define the sampling modes of all the draw buffers we want to create
  18824. */
  18825. samplingModes?: number[];
  18826. /**
  18827. * Define if a depth buffer is required
  18828. */
  18829. generateDepthBuffer?: boolean;
  18830. /**
  18831. * Define if a stencil buffer is required
  18832. */
  18833. generateStencilBuffer?: boolean;
  18834. /**
  18835. * Define if a depth texture is required instead of a depth buffer
  18836. */
  18837. generateDepthTexture?: boolean;
  18838. /**
  18839. * Define the number of desired draw buffers
  18840. */
  18841. textureCount?: number;
  18842. /**
  18843. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18844. */
  18845. doNotChangeAspectRatio?: boolean;
  18846. /**
  18847. * Define the default type of the buffers we are creating
  18848. */
  18849. defaultType?: number;
  18850. }
  18851. /**
  18852. * A multi render target, like a render target provides the ability to render to a texture.
  18853. * Unlike the render target, it can render to several draw buffers in one draw.
  18854. * This is specially interesting in deferred rendering or for any effects requiring more than
  18855. * just one color from a single pass.
  18856. */
  18857. export class MultiRenderTarget extends RenderTargetTexture {
  18858. private _internalTextures;
  18859. private _textures;
  18860. private _multiRenderTargetOptions;
  18861. private _count;
  18862. /**
  18863. * Get if draw buffers are currently supported by the used hardware and browser.
  18864. */
  18865. get isSupported(): boolean;
  18866. /**
  18867. * Get the list of textures generated by the multi render target.
  18868. */
  18869. get textures(): Texture[];
  18870. /**
  18871. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18872. */
  18873. get count(): number;
  18874. /**
  18875. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18876. */
  18877. get depthTexture(): Texture;
  18878. /**
  18879. * Set the wrapping mode on U of all the textures we are rendering to.
  18880. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18881. */
  18882. set wrapU(wrap: number);
  18883. /**
  18884. * Set the wrapping mode on V of all the textures we are rendering to.
  18885. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18886. */
  18887. set wrapV(wrap: number);
  18888. /**
  18889. * Instantiate a new multi render target texture.
  18890. * A multi render target, like a render target provides the ability to render to a texture.
  18891. * Unlike the render target, it can render to several draw buffers in one draw.
  18892. * This is specially interesting in deferred rendering or for any effects requiring more than
  18893. * just one color from a single pass.
  18894. * @param name Define the name of the texture
  18895. * @param size Define the size of the buffers to render to
  18896. * @param count Define the number of target we are rendering into
  18897. * @param scene Define the scene the texture belongs to
  18898. * @param options Define the options used to create the multi render target
  18899. */
  18900. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18901. private _initTypes;
  18902. /** @hidden */
  18903. _rebuild(forceFullRebuild?: boolean): void;
  18904. private _createInternalTextures;
  18905. private _createTextures;
  18906. /**
  18907. * Replaces a texture within the MRT.
  18908. * @param texture The new texture to insert in the MRT
  18909. * @param index The index of the texture to replace
  18910. */
  18911. replaceTexture(texture: Texture, index: number): void;
  18912. /**
  18913. * Define the number of samples used if MSAA is enabled.
  18914. */
  18915. get samples(): number;
  18916. set samples(value: number);
  18917. /**
  18918. * Resize all the textures in the multi render target.
  18919. * Be careful as it will recreate all the data in the new texture.
  18920. * @param size Define the new size
  18921. */
  18922. resize(size: any): void;
  18923. /**
  18924. * Changes the number of render targets in this MRT
  18925. * Be careful as it will recreate all the data in the new texture.
  18926. * @param count new texture count
  18927. * @param options Specifies texture types and sampling modes for new textures
  18928. */
  18929. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18931. /**
  18932. * Dispose the render targets and their associated resources
  18933. */
  18934. dispose(): void;
  18935. /**
  18936. * Release all the underlying texture used as draw buffers.
  18937. */
  18938. releaseInternalTextures(): void;
  18939. }
  18940. }
  18941. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18942. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18944. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18945. /** @hidden */
  18946. export var imageProcessingPixelShader: {
  18947. name: string;
  18948. shader: string;
  18949. };
  18950. }
  18951. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18952. import { Nullable } from "babylonjs/types";
  18953. import { Color4 } from "babylonjs/Maths/math.color";
  18954. import { Camera } from "babylonjs/Cameras/camera";
  18955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18956. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18957. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18958. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18959. import { Engine } from "babylonjs/Engines/engine";
  18960. import "babylonjs/Shaders/imageProcessing.fragment";
  18961. import "babylonjs/Shaders/postprocess.vertex";
  18962. /**
  18963. * ImageProcessingPostProcess
  18964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18965. */
  18966. export class ImageProcessingPostProcess extends PostProcess {
  18967. /**
  18968. * Default configuration related to image processing available in the PBR Material.
  18969. */
  18970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18971. /**
  18972. * Gets the image processing configuration used either in this material.
  18973. */
  18974. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18975. /**
  18976. * Sets the Default image processing configuration used either in the this material.
  18977. *
  18978. * If sets to null, the scene one is in use.
  18979. */
  18980. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18981. /**
  18982. * Keep track of the image processing observer to allow dispose and replace.
  18983. */
  18984. private _imageProcessingObserver;
  18985. /**
  18986. * Attaches a new image processing configuration to the PBR Material.
  18987. * @param configuration
  18988. */
  18989. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18990. /**
  18991. * If the post process is supported.
  18992. */
  18993. get isSupported(): boolean;
  18994. /**
  18995. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18996. */
  18997. get colorCurves(): Nullable<ColorCurves>;
  18998. /**
  18999. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19000. */
  19001. set colorCurves(value: Nullable<ColorCurves>);
  19002. /**
  19003. * Gets wether the color curves effect is enabled.
  19004. */
  19005. get colorCurvesEnabled(): boolean;
  19006. /**
  19007. * Sets wether the color curves effect is enabled.
  19008. */
  19009. set colorCurvesEnabled(value: boolean);
  19010. /**
  19011. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19012. */
  19013. get colorGradingTexture(): Nullable<BaseTexture>;
  19014. /**
  19015. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19016. */
  19017. set colorGradingTexture(value: Nullable<BaseTexture>);
  19018. /**
  19019. * Gets wether the color grading effect is enabled.
  19020. */
  19021. get colorGradingEnabled(): boolean;
  19022. /**
  19023. * Gets wether the color grading effect is enabled.
  19024. */
  19025. set colorGradingEnabled(value: boolean);
  19026. /**
  19027. * Gets exposure used in the effect.
  19028. */
  19029. get exposure(): number;
  19030. /**
  19031. * Sets exposure used in the effect.
  19032. */
  19033. set exposure(value: number);
  19034. /**
  19035. * Gets wether tonemapping is enabled or not.
  19036. */
  19037. get toneMappingEnabled(): boolean;
  19038. /**
  19039. * Sets wether tonemapping is enabled or not
  19040. */
  19041. set toneMappingEnabled(value: boolean);
  19042. /**
  19043. * Gets the type of tone mapping effect.
  19044. */
  19045. get toneMappingType(): number;
  19046. /**
  19047. * Sets the type of tone mapping effect.
  19048. */
  19049. set toneMappingType(value: number);
  19050. /**
  19051. * Gets contrast used in the effect.
  19052. */
  19053. get contrast(): number;
  19054. /**
  19055. * Sets contrast used in the effect.
  19056. */
  19057. set contrast(value: number);
  19058. /**
  19059. * Gets Vignette stretch size.
  19060. */
  19061. get vignetteStretch(): number;
  19062. /**
  19063. * Sets Vignette stretch size.
  19064. */
  19065. set vignetteStretch(value: number);
  19066. /**
  19067. * Gets Vignette centre X Offset.
  19068. */
  19069. get vignetteCentreX(): number;
  19070. /**
  19071. * Sets Vignette centre X Offset.
  19072. */
  19073. set vignetteCentreX(value: number);
  19074. /**
  19075. * Gets Vignette centre Y Offset.
  19076. */
  19077. get vignetteCentreY(): number;
  19078. /**
  19079. * Sets Vignette centre Y Offset.
  19080. */
  19081. set vignetteCentreY(value: number);
  19082. /**
  19083. * Gets Vignette weight or intensity of the vignette effect.
  19084. */
  19085. get vignetteWeight(): number;
  19086. /**
  19087. * Sets Vignette weight or intensity of the vignette effect.
  19088. */
  19089. set vignetteWeight(value: number);
  19090. /**
  19091. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19092. * if vignetteEnabled is set to true.
  19093. */
  19094. get vignetteColor(): Color4;
  19095. /**
  19096. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19097. * if vignetteEnabled is set to true.
  19098. */
  19099. set vignetteColor(value: Color4);
  19100. /**
  19101. * Gets Camera field of view used by the Vignette effect.
  19102. */
  19103. get vignetteCameraFov(): number;
  19104. /**
  19105. * Sets Camera field of view used by the Vignette effect.
  19106. */
  19107. set vignetteCameraFov(value: number);
  19108. /**
  19109. * Gets the vignette blend mode allowing different kind of effect.
  19110. */
  19111. get vignetteBlendMode(): number;
  19112. /**
  19113. * Sets the vignette blend mode allowing different kind of effect.
  19114. */
  19115. set vignetteBlendMode(value: number);
  19116. /**
  19117. * Gets wether the vignette effect is enabled.
  19118. */
  19119. get vignetteEnabled(): boolean;
  19120. /**
  19121. * Sets wether the vignette effect is enabled.
  19122. */
  19123. set vignetteEnabled(value: boolean);
  19124. private _fromLinearSpace;
  19125. /**
  19126. * Gets wether the input of the processing is in Gamma or Linear Space.
  19127. */
  19128. get fromLinearSpace(): boolean;
  19129. /**
  19130. * Sets wether the input of the processing is in Gamma or Linear Space.
  19131. */
  19132. set fromLinearSpace(value: boolean);
  19133. /**
  19134. * Defines cache preventing GC.
  19135. */
  19136. private _defines;
  19137. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19138. /**
  19139. * "ImageProcessingPostProcess"
  19140. * @returns "ImageProcessingPostProcess"
  19141. */
  19142. getClassName(): string;
  19143. /**
  19144. * @hidden
  19145. */
  19146. _updateParameters(): void;
  19147. dispose(camera?: Camera): void;
  19148. }
  19149. }
  19150. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  19151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19152. /**
  19153. * Interface for defining prepass effects in the prepass post-process pipeline
  19154. */
  19155. export interface PrePassEffectConfiguration {
  19156. /**
  19157. * Name of the effect
  19158. */
  19159. name: string;
  19160. /**
  19161. * Post process to attach for this effect
  19162. */
  19163. postProcess?: PostProcess;
  19164. /**
  19165. * Textures required in the MRT
  19166. */
  19167. texturesRequired: number[];
  19168. /**
  19169. * Is the effect enabled
  19170. */
  19171. enabled: boolean;
  19172. /**
  19173. * Disposes the effect configuration
  19174. */
  19175. dispose?: () => void;
  19176. /**
  19177. * Creates the associated post process
  19178. */
  19179. createPostProcess?: () => PostProcess;
  19180. }
  19181. }
  19182. declare module "babylonjs/Materials/fresnelParameters" {
  19183. import { DeepImmutable } from "babylonjs/types";
  19184. import { Color3 } from "babylonjs/Maths/math.color";
  19185. /**
  19186. * Options to be used when creating a FresnelParameters.
  19187. */
  19188. export type IFresnelParametersCreationOptions = {
  19189. /**
  19190. * Define the color used on edges (grazing angle)
  19191. */
  19192. leftColor?: Color3;
  19193. /**
  19194. * Define the color used on center
  19195. */
  19196. rightColor?: Color3;
  19197. /**
  19198. * Define bias applied to computed fresnel term
  19199. */
  19200. bias?: number;
  19201. /**
  19202. * Defined the power exponent applied to fresnel term
  19203. */
  19204. power?: number;
  19205. /**
  19206. * Define if the fresnel effect is enable or not.
  19207. */
  19208. isEnabled?: boolean;
  19209. };
  19210. /**
  19211. * Serialized format for FresnelParameters.
  19212. */
  19213. export type IFresnelParametersSerialized = {
  19214. /**
  19215. * Define the color used on edges (grazing angle) [as an array]
  19216. */
  19217. leftColor: number[];
  19218. /**
  19219. * Define the color used on center [as an array]
  19220. */
  19221. rightColor: number[];
  19222. /**
  19223. * Define bias applied to computed fresnel term
  19224. */
  19225. bias: number;
  19226. /**
  19227. * Defined the power exponent applied to fresnel term
  19228. */
  19229. power?: number;
  19230. /**
  19231. * Define if the fresnel effect is enable or not.
  19232. */
  19233. isEnabled: boolean;
  19234. };
  19235. /**
  19236. * This represents all the required information to add a fresnel effect on a material:
  19237. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19238. */
  19239. export class FresnelParameters {
  19240. private _isEnabled;
  19241. /**
  19242. * Define if the fresnel effect is enable or not.
  19243. */
  19244. get isEnabled(): boolean;
  19245. set isEnabled(value: boolean);
  19246. /**
  19247. * Define the color used on edges (grazing angle)
  19248. */
  19249. leftColor: Color3;
  19250. /**
  19251. * Define the color used on center
  19252. */
  19253. rightColor: Color3;
  19254. /**
  19255. * Define bias applied to computed fresnel term
  19256. */
  19257. bias: number;
  19258. /**
  19259. * Defined the power exponent applied to fresnel term
  19260. */
  19261. power: number;
  19262. /**
  19263. * Creates a new FresnelParameters object.
  19264. *
  19265. * @param options provide your own settings to optionally to override defaults
  19266. */
  19267. constructor(options?: IFresnelParametersCreationOptions);
  19268. /**
  19269. * Clones the current fresnel and its valuues
  19270. * @returns a clone fresnel configuration
  19271. */
  19272. clone(): FresnelParameters;
  19273. /**
  19274. * Determines equality between FresnelParameters objects
  19275. * @param otherFresnelParameters defines the second operand
  19276. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19277. */
  19278. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19279. /**
  19280. * Serializes the current fresnel parameters to a JSON representation.
  19281. * @return the JSON serialization
  19282. */
  19283. serialize(): IFresnelParametersSerialized;
  19284. /**
  19285. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19286. * @param parsedFresnelParameters Define the JSON representation
  19287. * @returns the parsed parameters
  19288. */
  19289. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19290. }
  19291. }
  19292. declare module "babylonjs/Materials/materialFlags" {
  19293. /**
  19294. * This groups all the flags used to control the materials channel.
  19295. */
  19296. export class MaterialFlags {
  19297. private static _DiffuseTextureEnabled;
  19298. /**
  19299. * Are diffuse textures enabled in the application.
  19300. */
  19301. static get DiffuseTextureEnabled(): boolean;
  19302. static set DiffuseTextureEnabled(value: boolean);
  19303. private static _DetailTextureEnabled;
  19304. /**
  19305. * Are detail textures enabled in the application.
  19306. */
  19307. static get DetailTextureEnabled(): boolean;
  19308. static set DetailTextureEnabled(value: boolean);
  19309. private static _AmbientTextureEnabled;
  19310. /**
  19311. * Are ambient textures enabled in the application.
  19312. */
  19313. static get AmbientTextureEnabled(): boolean;
  19314. static set AmbientTextureEnabled(value: boolean);
  19315. private static _OpacityTextureEnabled;
  19316. /**
  19317. * Are opacity textures enabled in the application.
  19318. */
  19319. static get OpacityTextureEnabled(): boolean;
  19320. static set OpacityTextureEnabled(value: boolean);
  19321. private static _ReflectionTextureEnabled;
  19322. /**
  19323. * Are reflection textures enabled in the application.
  19324. */
  19325. static get ReflectionTextureEnabled(): boolean;
  19326. static set ReflectionTextureEnabled(value: boolean);
  19327. private static _EmissiveTextureEnabled;
  19328. /**
  19329. * Are emissive textures enabled in the application.
  19330. */
  19331. static get EmissiveTextureEnabled(): boolean;
  19332. static set EmissiveTextureEnabled(value: boolean);
  19333. private static _SpecularTextureEnabled;
  19334. /**
  19335. * Are specular textures enabled in the application.
  19336. */
  19337. static get SpecularTextureEnabled(): boolean;
  19338. static set SpecularTextureEnabled(value: boolean);
  19339. private static _BumpTextureEnabled;
  19340. /**
  19341. * Are bump textures enabled in the application.
  19342. */
  19343. static get BumpTextureEnabled(): boolean;
  19344. static set BumpTextureEnabled(value: boolean);
  19345. private static _LightmapTextureEnabled;
  19346. /**
  19347. * Are lightmap textures enabled in the application.
  19348. */
  19349. static get LightmapTextureEnabled(): boolean;
  19350. static set LightmapTextureEnabled(value: boolean);
  19351. private static _RefractionTextureEnabled;
  19352. /**
  19353. * Are refraction textures enabled in the application.
  19354. */
  19355. static get RefractionTextureEnabled(): boolean;
  19356. static set RefractionTextureEnabled(value: boolean);
  19357. private static _ColorGradingTextureEnabled;
  19358. /**
  19359. * Are color grading textures enabled in the application.
  19360. */
  19361. static get ColorGradingTextureEnabled(): boolean;
  19362. static set ColorGradingTextureEnabled(value: boolean);
  19363. private static _FresnelEnabled;
  19364. /**
  19365. * Are fresnels enabled in the application.
  19366. */
  19367. static get FresnelEnabled(): boolean;
  19368. static set FresnelEnabled(value: boolean);
  19369. private static _ClearCoatTextureEnabled;
  19370. /**
  19371. * Are clear coat textures enabled in the application.
  19372. */
  19373. static get ClearCoatTextureEnabled(): boolean;
  19374. static set ClearCoatTextureEnabled(value: boolean);
  19375. private static _ClearCoatBumpTextureEnabled;
  19376. /**
  19377. * Are clear coat bump textures enabled in the application.
  19378. */
  19379. static get ClearCoatBumpTextureEnabled(): boolean;
  19380. static set ClearCoatBumpTextureEnabled(value: boolean);
  19381. private static _ClearCoatTintTextureEnabled;
  19382. /**
  19383. * Are clear coat tint textures enabled in the application.
  19384. */
  19385. static get ClearCoatTintTextureEnabled(): boolean;
  19386. static set ClearCoatTintTextureEnabled(value: boolean);
  19387. private static _SheenTextureEnabled;
  19388. /**
  19389. * Are sheen textures enabled in the application.
  19390. */
  19391. static get SheenTextureEnabled(): boolean;
  19392. static set SheenTextureEnabled(value: boolean);
  19393. private static _AnisotropicTextureEnabled;
  19394. /**
  19395. * Are anisotropic textures enabled in the application.
  19396. */
  19397. static get AnisotropicTextureEnabled(): boolean;
  19398. static set AnisotropicTextureEnabled(value: boolean);
  19399. private static _ThicknessTextureEnabled;
  19400. /**
  19401. * Are thickness textures enabled in the application.
  19402. */
  19403. static get ThicknessTextureEnabled(): boolean;
  19404. static set ThicknessTextureEnabled(value: boolean);
  19405. }
  19406. }
  19407. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  19408. /** @hidden */
  19409. export var defaultFragmentDeclaration: {
  19410. name: string;
  19411. shader: string;
  19412. };
  19413. }
  19414. declare module "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration" {
  19415. /** @hidden */
  19416. export var sceneUboDeclaration: {
  19417. name: string;
  19418. shader: string;
  19419. };
  19420. }
  19421. declare module "babylonjs/Shaders/ShadersInclude/meshUboDeclaration" {
  19422. /** @hidden */
  19423. export var meshUboDeclaration: {
  19424. name: string;
  19425. shader: string;
  19426. };
  19427. }
  19428. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  19429. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  19430. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  19431. /** @hidden */
  19432. export var defaultUboDeclaration: {
  19433. name: string;
  19434. shader: string;
  19435. };
  19436. }
  19437. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  19438. /** @hidden */
  19439. export var prePassDeclaration: {
  19440. name: string;
  19441. shader: string;
  19442. };
  19443. }
  19444. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  19445. /** @hidden */
  19446. export var lightFragmentDeclaration: {
  19447. name: string;
  19448. shader: string;
  19449. };
  19450. }
  19451. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  19452. /** @hidden */
  19453. export var lightUboDeclaration: {
  19454. name: string;
  19455. shader: string;
  19456. };
  19457. }
  19458. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  19459. /** @hidden */
  19460. export var lightsFragmentFunctions: {
  19461. name: string;
  19462. shader: string;
  19463. };
  19464. }
  19465. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  19466. /** @hidden */
  19467. export var shadowsFragmentFunctions: {
  19468. name: string;
  19469. shader: string;
  19470. };
  19471. }
  19472. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  19473. /** @hidden */
  19474. export var fresnelFunction: {
  19475. name: string;
  19476. shader: string;
  19477. };
  19478. }
  19479. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  19480. /** @hidden */
  19481. export var bumpFragmentMainFunctions: {
  19482. name: string;
  19483. shader: string;
  19484. };
  19485. }
  19486. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  19487. /** @hidden */
  19488. export var bumpFragmentFunctions: {
  19489. name: string;
  19490. shader: string;
  19491. };
  19492. }
  19493. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  19494. /** @hidden */
  19495. export var logDepthDeclaration: {
  19496. name: string;
  19497. shader: string;
  19498. };
  19499. }
  19500. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  19501. /** @hidden */
  19502. export var fogFragmentDeclaration: {
  19503. name: string;
  19504. shader: string;
  19505. };
  19506. }
  19507. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  19508. /** @hidden */
  19509. export var bumpFragment: {
  19510. name: string;
  19511. shader: string;
  19512. };
  19513. }
  19514. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  19515. /** @hidden */
  19516. export var depthPrePass: {
  19517. name: string;
  19518. shader: string;
  19519. };
  19520. }
  19521. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  19522. /** @hidden */
  19523. export var lightFragment: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  19529. /** @hidden */
  19530. export var logDepthFragment: {
  19531. name: string;
  19532. shader: string;
  19533. };
  19534. }
  19535. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  19536. /** @hidden */
  19537. export var fogFragment: {
  19538. name: string;
  19539. shader: string;
  19540. };
  19541. }
  19542. declare module "babylonjs/Shaders/default.fragment" {
  19543. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  19544. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19545. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  19546. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19547. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19548. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19549. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  19550. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  19551. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  19552. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  19553. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19555. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  19556. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  19557. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19558. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19559. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  19560. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19561. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  19562. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  19563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  19564. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  19565. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  19566. /** @hidden */
  19567. export var defaultPixelShader: {
  19568. name: string;
  19569. shader: string;
  19570. };
  19571. }
  19572. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  19573. /** @hidden */
  19574. export var defaultVertexDeclaration: {
  19575. name: string;
  19576. shader: string;
  19577. };
  19578. }
  19579. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  19580. /** @hidden */
  19581. export var bonesDeclaration: {
  19582. name: string;
  19583. shader: string;
  19584. };
  19585. }
  19586. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  19587. /** @hidden */
  19588. export var prePassVertexDeclaration: {
  19589. name: string;
  19590. shader: string;
  19591. };
  19592. }
  19593. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  19594. /** @hidden */
  19595. export var bumpVertexDeclaration: {
  19596. name: string;
  19597. shader: string;
  19598. };
  19599. }
  19600. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19601. /** @hidden */
  19602. export var fogVertexDeclaration: {
  19603. name: string;
  19604. shader: string;
  19605. };
  19606. }
  19607. declare module "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration" {
  19608. /** @hidden */
  19609. export var lightVxFragmentDeclaration: {
  19610. name: string;
  19611. shader: string;
  19612. };
  19613. }
  19614. declare module "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration" {
  19615. /** @hidden */
  19616. export var lightVxUboDeclaration: {
  19617. name: string;
  19618. shader: string;
  19619. };
  19620. }
  19621. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19622. /** @hidden */
  19623. export var morphTargetsVertexGlobalDeclaration: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19629. /** @hidden */
  19630. export var morphTargetsVertexDeclaration: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19636. /** @hidden */
  19637. export var morphTargetsVertex: {
  19638. name: string;
  19639. shader: string;
  19640. };
  19641. }
  19642. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19643. /** @hidden */
  19644. export var instancesVertex: {
  19645. name: string;
  19646. shader: string;
  19647. };
  19648. }
  19649. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19650. /** @hidden */
  19651. export var bonesVertex: {
  19652. name: string;
  19653. shader: string;
  19654. };
  19655. }
  19656. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19657. /** @hidden */
  19658. export var prePassVertex: {
  19659. name: string;
  19660. shader: string;
  19661. };
  19662. }
  19663. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19664. /** @hidden */
  19665. export var bumpVertex: {
  19666. name: string;
  19667. shader: string;
  19668. };
  19669. }
  19670. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19671. /** @hidden */
  19672. export var fogVertex: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19678. /** @hidden */
  19679. export var shadowsVertex: {
  19680. name: string;
  19681. shader: string;
  19682. };
  19683. }
  19684. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19685. /** @hidden */
  19686. export var pointCloudVertex: {
  19687. name: string;
  19688. shader: string;
  19689. };
  19690. }
  19691. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19692. /** @hidden */
  19693. export var logDepthVertex: {
  19694. name: string;
  19695. shader: string;
  19696. };
  19697. }
  19698. declare module "babylonjs/Shaders/default.vertex" {
  19699. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19700. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19701. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19703. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19704. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19705. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19706. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19707. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  19708. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  19709. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19710. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19711. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19712. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19713. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19714. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19715. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19716. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19718. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19719. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19720. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19721. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19722. /** @hidden */
  19723. export var defaultVertexShader: {
  19724. name: string;
  19725. shader: string;
  19726. };
  19727. }
  19728. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19729. import { Nullable } from "babylonjs/types";
  19730. import { Scene } from "babylonjs/scene";
  19731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19732. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19733. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19734. /**
  19735. * @hidden
  19736. */
  19737. export interface IMaterialDetailMapDefines {
  19738. DETAIL: boolean;
  19739. DETAILDIRECTUV: number;
  19740. DETAIL_NORMALBLENDMETHOD: number;
  19741. /** @hidden */
  19742. _areTexturesDirty: boolean;
  19743. }
  19744. /**
  19745. * Define the code related to the detail map parameters of a material
  19746. *
  19747. * Inspired from:
  19748. * 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
  19749. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19750. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19751. */
  19752. export class DetailMapConfiguration {
  19753. private _texture;
  19754. /**
  19755. * The detail texture of the material.
  19756. */
  19757. texture: Nullable<BaseTexture>;
  19758. /**
  19759. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19760. * Bigger values mean stronger blending
  19761. */
  19762. diffuseBlendLevel: number;
  19763. /**
  19764. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19765. * Bigger values mean stronger blending. Only used with PBR materials
  19766. */
  19767. roughnessBlendLevel: number;
  19768. /**
  19769. * Defines how strong the bump effect from the detail map is
  19770. * Bigger values mean stronger effect
  19771. */
  19772. bumpLevel: number;
  19773. private _normalBlendMethod;
  19774. /**
  19775. * The method used to blend the bump and detail normals together
  19776. */
  19777. normalBlendMethod: number;
  19778. private _isEnabled;
  19779. /**
  19780. * Enable or disable the detail map on this material
  19781. */
  19782. isEnabled: boolean;
  19783. /** @hidden */
  19784. private _internalMarkAllSubMeshesAsTexturesDirty;
  19785. /** @hidden */
  19786. _markAllSubMeshesAsTexturesDirty(): void;
  19787. /**
  19788. * Instantiate a new detail map
  19789. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19790. */
  19791. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19792. /**
  19793. * Gets whether the submesh is ready to be used or not.
  19794. * @param defines the list of "defines" to update.
  19795. * @param scene defines the scene the material belongs to.
  19796. * @returns - boolean indicating that the submesh is ready or not.
  19797. */
  19798. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19799. /**
  19800. * Update the defines for detail map usage
  19801. * @param defines the list of "defines" to update.
  19802. * @param scene defines the scene the material belongs to.
  19803. */
  19804. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19805. /**
  19806. * Binds the material data.
  19807. * @param uniformBuffer defines the Uniform buffer to fill in.
  19808. * @param scene defines the scene the material belongs to.
  19809. * @param isFrozen defines whether the material is frozen or not.
  19810. */
  19811. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19812. /**
  19813. * Checks to see if a texture is used in the material.
  19814. * @param texture - Base texture to use.
  19815. * @returns - Boolean specifying if a texture is used in the material.
  19816. */
  19817. hasTexture(texture: BaseTexture): boolean;
  19818. /**
  19819. * Returns an array of the actively used textures.
  19820. * @param activeTextures Array of BaseTextures
  19821. */
  19822. getActiveTextures(activeTextures: BaseTexture[]): void;
  19823. /**
  19824. * Returns the animatable textures.
  19825. * @param animatables Array of animatable textures.
  19826. */
  19827. getAnimatables(animatables: IAnimatable[]): void;
  19828. /**
  19829. * Disposes the resources of the material.
  19830. * @param forceDisposeTextures - Forces the disposal of all textures.
  19831. */
  19832. dispose(forceDisposeTextures?: boolean): void;
  19833. /**
  19834. * Get the current class name useful for serialization or dynamic coding.
  19835. * @returns "DetailMap"
  19836. */
  19837. getClassName(): string;
  19838. /**
  19839. * Add the required uniforms to the current list.
  19840. * @param uniforms defines the current uniform list.
  19841. */
  19842. static AddUniforms(uniforms: string[]): void;
  19843. /**
  19844. * Add the required samplers to the current list.
  19845. * @param samplers defines the current sampler list.
  19846. */
  19847. static AddSamplers(samplers: string[]): void;
  19848. /**
  19849. * Add the required uniforms to the current buffer.
  19850. * @param uniformBuffer defines the current uniform buffer.
  19851. */
  19852. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19853. /**
  19854. * Makes a duplicate of the current instance into another one.
  19855. * @param detailMap define the instance where to copy the info
  19856. */
  19857. copyTo(detailMap: DetailMapConfiguration): void;
  19858. /**
  19859. * Serializes this detail map instance
  19860. * @returns - An object with the serialized instance.
  19861. */
  19862. serialize(): any;
  19863. /**
  19864. * Parses a detail map setting from a serialized object.
  19865. * @param source - Serialized object.
  19866. * @param scene Defines the scene we are parsing for
  19867. * @param rootUrl Defines the rootUrl to load from
  19868. */
  19869. parse(source: any, scene: Scene, rootUrl: string): void;
  19870. }
  19871. }
  19872. declare module "babylonjs/Materials/standardMaterial" {
  19873. import { SmartArray } from "babylonjs/Misc/smartArray";
  19874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19875. import { Nullable } from "babylonjs/types";
  19876. import { Scene } from "babylonjs/scene";
  19877. import { Matrix } from "babylonjs/Maths/math.vector";
  19878. import { Color3 } from "babylonjs/Maths/math.color";
  19879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19881. import { Mesh } from "babylonjs/Meshes/mesh";
  19882. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19883. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19884. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19885. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19886. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19887. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19890. import "babylonjs/Shaders/default.fragment";
  19891. import "babylonjs/Shaders/default.vertex";
  19892. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19893. /** @hidden */
  19894. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19895. MAINUV1: boolean;
  19896. MAINUV2: boolean;
  19897. DIFFUSE: boolean;
  19898. DIFFUSEDIRECTUV: number;
  19899. DETAIL: boolean;
  19900. DETAILDIRECTUV: number;
  19901. DETAIL_NORMALBLENDMETHOD: number;
  19902. AMBIENT: boolean;
  19903. AMBIENTDIRECTUV: number;
  19904. OPACITY: boolean;
  19905. OPACITYDIRECTUV: number;
  19906. OPACITYRGB: boolean;
  19907. REFLECTION: boolean;
  19908. EMISSIVE: boolean;
  19909. EMISSIVEDIRECTUV: number;
  19910. SPECULAR: boolean;
  19911. SPECULARDIRECTUV: number;
  19912. BUMP: boolean;
  19913. BUMPDIRECTUV: number;
  19914. PARALLAX: boolean;
  19915. PARALLAXOCCLUSION: boolean;
  19916. SPECULAROVERALPHA: boolean;
  19917. CLIPPLANE: boolean;
  19918. CLIPPLANE2: boolean;
  19919. CLIPPLANE3: boolean;
  19920. CLIPPLANE4: boolean;
  19921. CLIPPLANE5: boolean;
  19922. CLIPPLANE6: boolean;
  19923. ALPHATEST: boolean;
  19924. DEPTHPREPASS: boolean;
  19925. ALPHAFROMDIFFUSE: boolean;
  19926. POINTSIZE: boolean;
  19927. FOG: boolean;
  19928. SPECULARTERM: boolean;
  19929. DIFFUSEFRESNEL: boolean;
  19930. OPACITYFRESNEL: boolean;
  19931. REFLECTIONFRESNEL: boolean;
  19932. REFRACTIONFRESNEL: boolean;
  19933. EMISSIVEFRESNEL: boolean;
  19934. FRESNEL: boolean;
  19935. NORMAL: boolean;
  19936. UV1: boolean;
  19937. UV2: boolean;
  19938. VERTEXCOLOR: boolean;
  19939. VERTEXALPHA: boolean;
  19940. NUM_BONE_INFLUENCERS: number;
  19941. BonesPerMesh: number;
  19942. BONETEXTURE: boolean;
  19943. BONES_VELOCITY_ENABLED: boolean;
  19944. INSTANCES: boolean;
  19945. THIN_INSTANCES: boolean;
  19946. GLOSSINESS: boolean;
  19947. ROUGHNESS: boolean;
  19948. EMISSIVEASILLUMINATION: boolean;
  19949. LINKEMISSIVEWITHDIFFUSE: boolean;
  19950. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19951. LIGHTMAP: boolean;
  19952. LIGHTMAPDIRECTUV: number;
  19953. OBJECTSPACE_NORMALMAP: boolean;
  19954. USELIGHTMAPASSHADOWMAP: boolean;
  19955. REFLECTIONMAP_3D: boolean;
  19956. REFLECTIONMAP_SPHERICAL: boolean;
  19957. REFLECTIONMAP_PLANAR: boolean;
  19958. REFLECTIONMAP_CUBIC: boolean;
  19959. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19960. REFLECTIONMAP_PROJECTION: boolean;
  19961. REFLECTIONMAP_SKYBOX: boolean;
  19962. REFLECTIONMAP_EXPLICIT: boolean;
  19963. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19964. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19965. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19966. INVERTCUBICMAP: boolean;
  19967. LOGARITHMICDEPTH: boolean;
  19968. REFRACTION: boolean;
  19969. REFRACTIONMAP_3D: boolean;
  19970. REFLECTIONOVERALPHA: boolean;
  19971. TWOSIDEDLIGHTING: boolean;
  19972. SHADOWFLOAT: boolean;
  19973. MORPHTARGETS: boolean;
  19974. MORPHTARGETS_NORMAL: boolean;
  19975. MORPHTARGETS_TANGENT: boolean;
  19976. MORPHTARGETS_UV: boolean;
  19977. NUM_MORPH_INFLUENCERS: number;
  19978. NONUNIFORMSCALING: boolean;
  19979. PREMULTIPLYALPHA: boolean;
  19980. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19981. ALPHABLEND: boolean;
  19982. PREPASS: boolean;
  19983. PREPASS_IRRADIANCE: boolean;
  19984. PREPASS_IRRADIANCE_INDEX: number;
  19985. PREPASS_ALBEDO: boolean;
  19986. PREPASS_ALBEDO_INDEX: number;
  19987. PREPASS_DEPTHNORMAL: boolean;
  19988. PREPASS_DEPTHNORMAL_INDEX: number;
  19989. PREPASS_POSITION: boolean;
  19990. PREPASS_POSITION_INDEX: number;
  19991. PREPASS_VELOCITY: boolean;
  19992. PREPASS_VELOCITY_INDEX: number;
  19993. PREPASS_REFLECTIVITY: boolean;
  19994. PREPASS_REFLECTIVITY_INDEX: number;
  19995. SCENE_MRT_COUNT: number;
  19996. RGBDLIGHTMAP: boolean;
  19997. RGBDREFLECTION: boolean;
  19998. RGBDREFRACTION: boolean;
  19999. IMAGEPROCESSING: boolean;
  20000. VIGNETTE: boolean;
  20001. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20002. VIGNETTEBLENDMODEOPAQUE: boolean;
  20003. TONEMAPPING: boolean;
  20004. TONEMAPPING_ACES: boolean;
  20005. CONTRAST: boolean;
  20006. COLORCURVES: boolean;
  20007. COLORGRADING: boolean;
  20008. COLORGRADING3D: boolean;
  20009. SAMPLER3DGREENDEPTH: boolean;
  20010. SAMPLER3DBGRMAP: boolean;
  20011. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20012. MULTIVIEW: boolean;
  20013. /**
  20014. * If the reflection texture on this material is in linear color space
  20015. * @hidden
  20016. */
  20017. IS_REFLECTION_LINEAR: boolean;
  20018. /**
  20019. * If the refraction texture on this material is in linear color space
  20020. * @hidden
  20021. */
  20022. IS_REFRACTION_LINEAR: boolean;
  20023. EXPOSURE: boolean;
  20024. constructor();
  20025. setReflectionMode(modeToEnable: string): void;
  20026. }
  20027. /**
  20028. * This is the default material used in Babylon. It is the best trade off between quality
  20029. * and performances.
  20030. * @see https://doc.babylonjs.com/babylon101/materials
  20031. */
  20032. export class StandardMaterial extends PushMaterial {
  20033. private _diffuseTexture;
  20034. /**
  20035. * The basic texture of the material as viewed under a light.
  20036. */
  20037. diffuseTexture: Nullable<BaseTexture>;
  20038. private _ambientTexture;
  20039. /**
  20040. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  20041. */
  20042. ambientTexture: Nullable<BaseTexture>;
  20043. private _opacityTexture;
  20044. /**
  20045. * Define the transparency of the material from a texture.
  20046. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  20047. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  20048. */
  20049. opacityTexture: Nullable<BaseTexture>;
  20050. private _reflectionTexture;
  20051. /**
  20052. * Define the texture used to display the reflection.
  20053. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20054. */
  20055. reflectionTexture: Nullable<BaseTexture>;
  20056. private _emissiveTexture;
  20057. /**
  20058. * Define texture of the material as if self lit.
  20059. * This will be mixed in the final result even in the absence of light.
  20060. */
  20061. emissiveTexture: Nullable<BaseTexture>;
  20062. private _specularTexture;
  20063. /**
  20064. * Define how the color and intensity of the highlight given by the light in the material.
  20065. */
  20066. specularTexture: Nullable<BaseTexture>;
  20067. private _bumpTexture;
  20068. /**
  20069. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  20070. * 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.
  20071. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  20072. */
  20073. bumpTexture: Nullable<BaseTexture>;
  20074. private _lightmapTexture;
  20075. /**
  20076. * Complex lighting can be computationally expensive to compute at runtime.
  20077. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  20078. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  20079. */
  20080. lightmapTexture: Nullable<BaseTexture>;
  20081. private _refractionTexture;
  20082. /**
  20083. * Define the texture used to display the refraction.
  20084. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20085. */
  20086. refractionTexture: Nullable<BaseTexture>;
  20087. /**
  20088. * The color of the material lit by the environmental background lighting.
  20089. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  20090. */
  20091. ambientColor: Color3;
  20092. /**
  20093. * The basic color of the material as viewed under a light.
  20094. */
  20095. diffuseColor: Color3;
  20096. /**
  20097. * Define how the color and intensity of the highlight given by the light in the material.
  20098. */
  20099. specularColor: Color3;
  20100. /**
  20101. * Define the color of the material as if self lit.
  20102. * This will be mixed in the final result even in the absence of light.
  20103. */
  20104. emissiveColor: Color3;
  20105. /**
  20106. * Defines how sharp are the highlights in the material.
  20107. * The bigger the value the sharper giving a more glossy feeling to the result.
  20108. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  20109. */
  20110. specularPower: number;
  20111. private _useAlphaFromDiffuseTexture;
  20112. /**
  20113. * Does the transparency come from the diffuse texture alpha channel.
  20114. */
  20115. useAlphaFromDiffuseTexture: boolean;
  20116. private _useEmissiveAsIllumination;
  20117. /**
  20118. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  20119. */
  20120. useEmissiveAsIllumination: boolean;
  20121. private _linkEmissiveWithDiffuse;
  20122. /**
  20123. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  20124. * the emissive level when the final color is close to one.
  20125. */
  20126. linkEmissiveWithDiffuse: boolean;
  20127. private _useSpecularOverAlpha;
  20128. /**
  20129. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  20130. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20131. */
  20132. useSpecularOverAlpha: boolean;
  20133. private _useReflectionOverAlpha;
  20134. /**
  20135. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20136. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20137. */
  20138. useReflectionOverAlpha: boolean;
  20139. private _disableLighting;
  20140. /**
  20141. * Does lights from the scene impacts this material.
  20142. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  20143. */
  20144. disableLighting: boolean;
  20145. private _useObjectSpaceNormalMap;
  20146. /**
  20147. * Allows using an object space normal map (instead of tangent space).
  20148. */
  20149. useObjectSpaceNormalMap: boolean;
  20150. private _useParallax;
  20151. /**
  20152. * Is parallax enabled or not.
  20153. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20154. */
  20155. useParallax: boolean;
  20156. private _useParallaxOcclusion;
  20157. /**
  20158. * Is parallax occlusion enabled or not.
  20159. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  20160. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20161. */
  20162. useParallaxOcclusion: boolean;
  20163. /**
  20164. * 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.
  20165. */
  20166. parallaxScaleBias: number;
  20167. private _roughness;
  20168. /**
  20169. * Helps to define how blurry the reflections should appears in the material.
  20170. */
  20171. roughness: number;
  20172. /**
  20173. * In case of refraction, define the value of the index of refraction.
  20174. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20175. */
  20176. indexOfRefraction: number;
  20177. /**
  20178. * Invert the refraction texture alongside the y axis.
  20179. * It can be useful with procedural textures or probe for instance.
  20180. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20181. */
  20182. invertRefractionY: boolean;
  20183. /**
  20184. * Defines the alpha limits in alpha test mode.
  20185. */
  20186. alphaCutOff: number;
  20187. private _useLightmapAsShadowmap;
  20188. /**
  20189. * In case of light mapping, define whether the map contains light or shadow informations.
  20190. */
  20191. useLightmapAsShadowmap: boolean;
  20192. private _diffuseFresnelParameters;
  20193. /**
  20194. * Define the diffuse fresnel parameters of the material.
  20195. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20196. */
  20197. diffuseFresnelParameters: FresnelParameters;
  20198. private _opacityFresnelParameters;
  20199. /**
  20200. * Define the opacity fresnel parameters of the material.
  20201. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20202. */
  20203. opacityFresnelParameters: FresnelParameters;
  20204. private _reflectionFresnelParameters;
  20205. /**
  20206. * Define the reflection fresnel parameters of the material.
  20207. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20208. */
  20209. reflectionFresnelParameters: FresnelParameters;
  20210. private _refractionFresnelParameters;
  20211. /**
  20212. * Define the refraction fresnel parameters of the material.
  20213. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20214. */
  20215. refractionFresnelParameters: FresnelParameters;
  20216. private _emissiveFresnelParameters;
  20217. /**
  20218. * Define the emissive fresnel parameters of the material.
  20219. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20220. */
  20221. emissiveFresnelParameters: FresnelParameters;
  20222. private _useReflectionFresnelFromSpecular;
  20223. /**
  20224. * If true automatically deducts the fresnels values from the material specularity.
  20225. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20226. */
  20227. useReflectionFresnelFromSpecular: boolean;
  20228. private _useGlossinessFromSpecularMapAlpha;
  20229. /**
  20230. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20231. */
  20232. useGlossinessFromSpecularMapAlpha: boolean;
  20233. private _maxSimultaneousLights;
  20234. /**
  20235. * Defines the maximum number of lights that can be used in the material
  20236. */
  20237. maxSimultaneousLights: number;
  20238. private _invertNormalMapX;
  20239. /**
  20240. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20241. */
  20242. invertNormalMapX: boolean;
  20243. private _invertNormalMapY;
  20244. /**
  20245. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20246. */
  20247. invertNormalMapY: boolean;
  20248. private _twoSidedLighting;
  20249. /**
  20250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20251. */
  20252. twoSidedLighting: boolean;
  20253. /**
  20254. * Default configuration related to image processing available in the standard Material.
  20255. */
  20256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20257. /**
  20258. * Gets the image processing configuration used either in this material.
  20259. */
  20260. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20261. /**
  20262. * Sets the Default image processing configuration used either in the this material.
  20263. *
  20264. * If sets to null, the scene one is in use.
  20265. */
  20266. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20267. /**
  20268. * Keep track of the image processing observer to allow dispose and replace.
  20269. */
  20270. private _imageProcessingObserver;
  20271. /**
  20272. * Attaches a new image processing configuration to the Standard Material.
  20273. * @param configuration
  20274. */
  20275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20276. /**
  20277. * Defines additionnal PrePass parameters for the material.
  20278. */
  20279. readonly prePassConfiguration: PrePassConfiguration;
  20280. /**
  20281. * Gets wether the color curves effect is enabled.
  20282. */
  20283. get cameraColorCurvesEnabled(): boolean;
  20284. /**
  20285. * Sets wether the color curves effect is enabled.
  20286. */
  20287. set cameraColorCurvesEnabled(value: boolean);
  20288. /**
  20289. * Gets wether the color grading effect is enabled.
  20290. */
  20291. get cameraColorGradingEnabled(): boolean;
  20292. /**
  20293. * Gets wether the color grading effect is enabled.
  20294. */
  20295. set cameraColorGradingEnabled(value: boolean);
  20296. /**
  20297. * Gets wether tonemapping is enabled or not.
  20298. */
  20299. get cameraToneMappingEnabled(): boolean;
  20300. /**
  20301. * Sets wether tonemapping is enabled or not
  20302. */
  20303. set cameraToneMappingEnabled(value: boolean);
  20304. /**
  20305. * The camera exposure used on this material.
  20306. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20307. * This corresponds to a photographic exposure.
  20308. */
  20309. get cameraExposure(): number;
  20310. /**
  20311. * The camera exposure used on this material.
  20312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20313. * This corresponds to a photographic exposure.
  20314. */
  20315. set cameraExposure(value: number);
  20316. /**
  20317. * Gets The camera contrast used on this material.
  20318. */
  20319. get cameraContrast(): number;
  20320. /**
  20321. * Sets The camera contrast used on this material.
  20322. */
  20323. set cameraContrast(value: number);
  20324. /**
  20325. * Gets the Color Grading 2D Lookup Texture.
  20326. */
  20327. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20328. /**
  20329. * Sets the Color Grading 2D Lookup Texture.
  20330. */
  20331. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20332. /**
  20333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20335. * 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;
  20336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20337. */
  20338. get cameraColorCurves(): Nullable<ColorCurves>;
  20339. /**
  20340. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20341. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20342. * 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;
  20343. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20344. */
  20345. set cameraColorCurves(value: Nullable<ColorCurves>);
  20346. /**
  20347. * Can this material render to several textures at once
  20348. */
  20349. get canRenderToMRT(): boolean;
  20350. /**
  20351. * Defines the detail map parameters for the material.
  20352. */
  20353. readonly detailMap: DetailMapConfiguration;
  20354. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20355. protected _worldViewProjectionMatrix: Matrix;
  20356. protected _globalAmbientColor: Color3;
  20357. protected _useLogarithmicDepth: boolean;
  20358. protected _rebuildInParallel: boolean;
  20359. /**
  20360. * Instantiates a new standard material.
  20361. * This is the default material used in Babylon. It is the best trade off between quality
  20362. * and performances.
  20363. * @see https://doc.babylonjs.com/babylon101/materials
  20364. * @param name Define the name of the material in the scene
  20365. * @param scene Define the scene the material belong to
  20366. */
  20367. constructor(name: string, scene: Scene);
  20368. /**
  20369. * Gets a boolean indicating that current material needs to register RTT
  20370. */
  20371. get hasRenderTargetTextures(): boolean;
  20372. /**
  20373. * Gets the current class name of the material e.g. "StandardMaterial"
  20374. * Mainly use in serialization.
  20375. * @returns the class name
  20376. */
  20377. getClassName(): string;
  20378. /**
  20379. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20380. * You can try switching to logarithmic depth.
  20381. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20382. */
  20383. get useLogarithmicDepth(): boolean;
  20384. set useLogarithmicDepth(value: boolean);
  20385. /**
  20386. * Specifies if the material will require alpha blending
  20387. * @returns a boolean specifying if alpha blending is needed
  20388. */
  20389. needAlphaBlending(): boolean;
  20390. /**
  20391. * Specifies if this material should be rendered in alpha test mode
  20392. * @returns a boolean specifying if an alpha test is needed.
  20393. */
  20394. needAlphaTesting(): boolean;
  20395. /**
  20396. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20397. */
  20398. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20399. /**
  20400. * Specifies whether or not there is a usable alpha channel for transparency.
  20401. */
  20402. protected _hasAlphaChannel(): boolean;
  20403. /**
  20404. * Get the texture used for alpha test purpose.
  20405. * @returns the diffuse texture in case of the standard material.
  20406. */
  20407. getAlphaTestTexture(): Nullable<BaseTexture>;
  20408. /**
  20409. * Get if the submesh is ready to be used and all its information available.
  20410. * Child classes can use it to update shaders
  20411. * @param mesh defines the mesh to check
  20412. * @param subMesh defines which submesh to check
  20413. * @param useInstances specifies that instances should be used
  20414. * @returns a boolean indicating that the submesh is ready or not
  20415. */
  20416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20417. /**
  20418. * Builds the material UBO layouts.
  20419. * Used internally during the effect preparation.
  20420. */
  20421. buildUniformLayout(): void;
  20422. /**
  20423. * Unbinds the material from the mesh
  20424. */
  20425. unbind(): void;
  20426. /**
  20427. * Binds the submesh to this material by preparing the effect and shader to draw
  20428. * @param world defines the world transformation matrix
  20429. * @param mesh defines the mesh containing the submesh
  20430. * @param subMesh defines the submesh to bind the material to
  20431. */
  20432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20433. /**
  20434. * Get the list of animatables in the material.
  20435. * @returns the list of animatables object used in the material
  20436. */
  20437. getAnimatables(): IAnimatable[];
  20438. /**
  20439. * Gets the active textures from the material
  20440. * @returns an array of textures
  20441. */
  20442. getActiveTextures(): BaseTexture[];
  20443. /**
  20444. * Specifies if the material uses a texture
  20445. * @param texture defines the texture to check against the material
  20446. * @returns a boolean specifying if the material uses the texture
  20447. */
  20448. hasTexture(texture: BaseTexture): boolean;
  20449. /**
  20450. * Disposes the material
  20451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20453. */
  20454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20455. /**
  20456. * Makes a duplicate of the material, and gives it a new name
  20457. * @param name defines the new name for the duplicated material
  20458. * @returns the cloned material
  20459. */
  20460. clone(name: string): StandardMaterial;
  20461. /**
  20462. * Serializes this material in a JSON representation
  20463. * @returns the serialized material object
  20464. */
  20465. serialize(): any;
  20466. /**
  20467. * Creates a standard material from parsed material data
  20468. * @param source defines the JSON representation of the material
  20469. * @param scene defines the hosting scene
  20470. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20471. * @returns a new standard material
  20472. */
  20473. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20474. /**
  20475. * Are diffuse textures enabled in the application.
  20476. */
  20477. static get DiffuseTextureEnabled(): boolean;
  20478. static set DiffuseTextureEnabled(value: boolean);
  20479. /**
  20480. * Are detail textures enabled in the application.
  20481. */
  20482. static get DetailTextureEnabled(): boolean;
  20483. static set DetailTextureEnabled(value: boolean);
  20484. /**
  20485. * Are ambient textures enabled in the application.
  20486. */
  20487. static get AmbientTextureEnabled(): boolean;
  20488. static set AmbientTextureEnabled(value: boolean);
  20489. /**
  20490. * Are opacity textures enabled in the application.
  20491. */
  20492. static get OpacityTextureEnabled(): boolean;
  20493. static set OpacityTextureEnabled(value: boolean);
  20494. /**
  20495. * Are reflection textures enabled in the application.
  20496. */
  20497. static get ReflectionTextureEnabled(): boolean;
  20498. static set ReflectionTextureEnabled(value: boolean);
  20499. /**
  20500. * Are emissive textures enabled in the application.
  20501. */
  20502. static get EmissiveTextureEnabled(): boolean;
  20503. static set EmissiveTextureEnabled(value: boolean);
  20504. /**
  20505. * Are specular textures enabled in the application.
  20506. */
  20507. static get SpecularTextureEnabled(): boolean;
  20508. static set SpecularTextureEnabled(value: boolean);
  20509. /**
  20510. * Are bump textures enabled in the application.
  20511. */
  20512. static get BumpTextureEnabled(): boolean;
  20513. static set BumpTextureEnabled(value: boolean);
  20514. /**
  20515. * Are lightmap textures enabled in the application.
  20516. */
  20517. static get LightmapTextureEnabled(): boolean;
  20518. static set LightmapTextureEnabled(value: boolean);
  20519. /**
  20520. * Are refraction textures enabled in the application.
  20521. */
  20522. static get RefractionTextureEnabled(): boolean;
  20523. static set RefractionTextureEnabled(value: boolean);
  20524. /**
  20525. * Are color grading textures enabled in the application.
  20526. */
  20527. static get ColorGradingTextureEnabled(): boolean;
  20528. static set ColorGradingTextureEnabled(value: boolean);
  20529. /**
  20530. * Are fresnels enabled in the application.
  20531. */
  20532. static get FresnelEnabled(): boolean;
  20533. static set FresnelEnabled(value: boolean);
  20534. }
  20535. }
  20536. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  20537. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20538. /** @hidden */
  20539. export var rgbdDecodePixelShader: {
  20540. name: string;
  20541. shader: string;
  20542. };
  20543. }
  20544. declare module "babylonjs/Shaders/pass.fragment" {
  20545. /** @hidden */
  20546. export var passPixelShader: {
  20547. name: string;
  20548. shader: string;
  20549. };
  20550. }
  20551. declare module "babylonjs/Shaders/passCube.fragment" {
  20552. /** @hidden */
  20553. export var passCubePixelShader: {
  20554. name: string;
  20555. shader: string;
  20556. };
  20557. }
  20558. declare module "babylonjs/PostProcesses/passPostProcess" {
  20559. import { Nullable } from "babylonjs/types";
  20560. import { Camera } from "babylonjs/Cameras/camera";
  20561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20562. import { Engine } from "babylonjs/Engines/engine";
  20563. import "babylonjs/Shaders/pass.fragment";
  20564. import "babylonjs/Shaders/passCube.fragment";
  20565. import { Scene } from "babylonjs/scene";
  20566. /**
  20567. * PassPostProcess which produces an output the same as it's input
  20568. */
  20569. export class PassPostProcess extends PostProcess {
  20570. /**
  20571. * Gets a string identifying the name of the class
  20572. * @returns "PassPostProcess" string
  20573. */
  20574. getClassName(): string;
  20575. /**
  20576. * Creates the PassPostProcess
  20577. * @param name The name of the effect.
  20578. * @param options The required width/height ratio to downsize to before computing the render pass.
  20579. * @param camera The camera to apply the render pass to.
  20580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20581. * @param engine The engine which the post process will be applied. (default: current engine)
  20582. * @param reusable If the post process can be reused on the same frame. (default: false)
  20583. * @param textureType The type of texture to be used when performing the post processing.
  20584. * @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)
  20585. */
  20586. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20587. /** @hidden */
  20588. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20589. }
  20590. /**
  20591. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20592. */
  20593. export class PassCubePostProcess extends PostProcess {
  20594. private _face;
  20595. /**
  20596. * Gets or sets the cube face to display.
  20597. * * 0 is +X
  20598. * * 1 is -X
  20599. * * 2 is +Y
  20600. * * 3 is -Y
  20601. * * 4 is +Z
  20602. * * 5 is -Z
  20603. */
  20604. get face(): number;
  20605. set face(value: number);
  20606. /**
  20607. * Gets a string identifying the name of the class
  20608. * @returns "PassCubePostProcess" string
  20609. */
  20610. getClassName(): string;
  20611. /**
  20612. * Creates the PassCubePostProcess
  20613. * @param name The name of the effect.
  20614. * @param options The required width/height ratio to downsize to before computing the render pass.
  20615. * @param camera The camera to apply the render pass to.
  20616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20617. * @param engine The engine which the post process will be applied. (default: current engine)
  20618. * @param reusable If the post process can be reused on the same frame. (default: false)
  20619. * @param textureType The type of texture to be used when performing the post processing.
  20620. * @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)
  20621. */
  20622. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20623. /** @hidden */
  20624. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20625. }
  20626. }
  20627. declare module "babylonjs/Misc/textureTools" {
  20628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20629. import { Texture } from "babylonjs/Materials/Textures/texture";
  20630. import { Scene } from "babylonjs/scene";
  20631. /**
  20632. * Class used to host texture specific utilities
  20633. */
  20634. export class TextureTools {
  20635. /**
  20636. * Uses the GPU to create a copy texture rescaled at a given size
  20637. * @param texture Texture to copy from
  20638. * @param width defines the desired width
  20639. * @param height defines the desired height
  20640. * @param useBilinearMode defines if bilinear mode has to be used
  20641. * @return the generated texture
  20642. */
  20643. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20644. /**
  20645. * Apply a post process to a texture
  20646. * @param postProcessName name of the fragment post process
  20647. * @param internalTexture the texture to encode
  20648. * @param scene the scene hosting the texture
  20649. * @param type type of the output texture. If not provided, use the one from internalTexture
  20650. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20651. * @param format format of the output texture. If not provided, use the one from internalTexture
  20652. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20653. */
  20654. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20655. }
  20656. }
  20657. declare module "babylonjs/Misc/rgbdTextureTools" {
  20658. import "babylonjs/Shaders/rgbdDecode.fragment";
  20659. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20660. import { Texture } from "babylonjs/Materials/Textures/texture";
  20661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20662. import { Scene } from "babylonjs/scene";
  20663. /**
  20664. * Class used to host RGBD texture specific utilities
  20665. */
  20666. export class RGBDTextureTools {
  20667. /**
  20668. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20669. * @param texture the texture to expand.
  20670. */
  20671. static ExpandRGBDTexture(texture: Texture): void;
  20672. /**
  20673. * Encode the texture to RGBD if possible.
  20674. * @param internalTexture the texture to encode
  20675. * @param scene the scene hosting the texture
  20676. * @param outputTextureType type of the texture in which the encoding is performed
  20677. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20678. */
  20679. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20680. }
  20681. }
  20682. declare module "babylonjs/Misc/brdfTextureTools" {
  20683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20684. import { Scene } from "babylonjs/scene";
  20685. /**
  20686. * Class used to host texture specific utilities
  20687. */
  20688. export class BRDFTextureTools {
  20689. /**
  20690. * Prevents texture cache collision
  20691. */
  20692. private static _instanceNumber;
  20693. /**
  20694. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20695. * @param scene defines the hosting scene
  20696. * @returns the environment BRDF texture
  20697. */
  20698. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20699. private static _environmentBRDFBase64Texture;
  20700. }
  20701. }
  20702. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  20703. import { Nullable } from "babylonjs/types";
  20704. import { Color3 } from "babylonjs/Maths/math.color";
  20705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20706. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20707. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20708. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20710. import { Engine } from "babylonjs/Engines/engine";
  20711. import { Scene } from "babylonjs/scene";
  20712. /**
  20713. * @hidden
  20714. */
  20715. export interface IMaterialClearCoatDefines {
  20716. CLEARCOAT: boolean;
  20717. CLEARCOAT_DEFAULTIOR: boolean;
  20718. CLEARCOAT_TEXTURE: boolean;
  20719. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20720. CLEARCOAT_TEXTUREDIRECTUV: number;
  20721. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20722. CLEARCOAT_BUMP: boolean;
  20723. CLEARCOAT_BUMPDIRECTUV: number;
  20724. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20725. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20726. CLEARCOAT_REMAP_F0: boolean;
  20727. CLEARCOAT_TINT: boolean;
  20728. CLEARCOAT_TINT_TEXTURE: boolean;
  20729. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20730. /** @hidden */
  20731. _areTexturesDirty: boolean;
  20732. }
  20733. /**
  20734. * Define the code related to the clear coat parameters of the pbr material.
  20735. */
  20736. export class PBRClearCoatConfiguration {
  20737. /**
  20738. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20739. * The default fits with a polyurethane material.
  20740. * @hidden
  20741. */
  20742. static readonly _DefaultIndexOfRefraction: number;
  20743. private _isEnabled;
  20744. /**
  20745. * Defines if the clear coat is enabled in the material.
  20746. */
  20747. isEnabled: boolean;
  20748. /**
  20749. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20750. */
  20751. intensity: number;
  20752. /**
  20753. * Defines the clear coat layer roughness.
  20754. */
  20755. roughness: number;
  20756. private _indexOfRefraction;
  20757. /**
  20758. * Defines the index of refraction of the clear coat.
  20759. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20760. * The default fits with a polyurethane material.
  20761. * Changing the default value is more performance intensive.
  20762. */
  20763. indexOfRefraction: number;
  20764. private _texture;
  20765. /**
  20766. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20767. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20768. * if textureRoughness is not empty, else no texture roughness is used
  20769. */
  20770. texture: Nullable<BaseTexture>;
  20771. private _useRoughnessFromMainTexture;
  20772. /**
  20773. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20774. * If false, the green channel from textureRoughness is used for roughness
  20775. */
  20776. useRoughnessFromMainTexture: boolean;
  20777. private _textureRoughness;
  20778. /**
  20779. * Stores the clear coat roughness in a texture (green channel)
  20780. * Not used if useRoughnessFromMainTexture is true
  20781. */
  20782. textureRoughness: Nullable<BaseTexture>;
  20783. private _remapF0OnInterfaceChange;
  20784. /**
  20785. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20786. */
  20787. remapF0OnInterfaceChange: boolean;
  20788. private _bumpTexture;
  20789. /**
  20790. * Define the clear coat specific bump texture.
  20791. */
  20792. bumpTexture: Nullable<BaseTexture>;
  20793. private _isTintEnabled;
  20794. /**
  20795. * Defines if the clear coat tint is enabled in the material.
  20796. */
  20797. isTintEnabled: boolean;
  20798. /**
  20799. * Defines the clear coat tint of the material.
  20800. * This is only use if tint is enabled
  20801. */
  20802. tintColor: Color3;
  20803. /**
  20804. * Defines the distance at which the tint color should be found in the
  20805. * clear coat media.
  20806. * This is only use if tint is enabled
  20807. */
  20808. tintColorAtDistance: number;
  20809. /**
  20810. * Defines the clear coat layer thickness.
  20811. * This is only use if tint is enabled
  20812. */
  20813. tintThickness: number;
  20814. private _tintTexture;
  20815. /**
  20816. * Stores the clear tint values in a texture.
  20817. * rgb is tint
  20818. * a is a thickness factor
  20819. */
  20820. tintTexture: Nullable<BaseTexture>;
  20821. /** @hidden */
  20822. private _internalMarkAllSubMeshesAsTexturesDirty;
  20823. /** @hidden */
  20824. _markAllSubMeshesAsTexturesDirty(): void;
  20825. /**
  20826. * Instantiate a new istance of clear coat configuration.
  20827. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20828. */
  20829. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20830. /**
  20831. * Gets wehter the submesh is ready to be used or not.
  20832. * @param defines the list of "defines" to update.
  20833. * @param scene defines the scene the material belongs to.
  20834. * @param engine defines the engine the material belongs to.
  20835. * @param disableBumpMap defines wether the material disables bump or not.
  20836. * @returns - boolean indicating that the submesh is ready or not.
  20837. */
  20838. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20839. /**
  20840. * Checks to see if a texture is used in the material.
  20841. * @param defines the list of "defines" to update.
  20842. * @param scene defines the scene to the material belongs to.
  20843. */
  20844. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20845. /**
  20846. * Binds the material data.
  20847. * @param uniformBuffer defines the Uniform buffer to fill in.
  20848. * @param scene defines the scene the material belongs to.
  20849. * @param engine defines the engine the material belongs to.
  20850. * @param disableBumpMap defines wether the material disables bump or not.
  20851. * @param isFrozen defines wether the material is frozen or not.
  20852. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20853. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20854. * @param subMesh the submesh to bind data for
  20855. */
  20856. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20857. /**
  20858. * Checks to see if a texture is used in the material.
  20859. * @param texture - Base texture to use.
  20860. * @returns - Boolean specifying if a texture is used in the material.
  20861. */
  20862. hasTexture(texture: BaseTexture): boolean;
  20863. /**
  20864. * Returns an array of the actively used textures.
  20865. * @param activeTextures Array of BaseTextures
  20866. */
  20867. getActiveTextures(activeTextures: BaseTexture[]): void;
  20868. /**
  20869. * Returns the animatable textures.
  20870. * @param animatables Array of animatable textures.
  20871. */
  20872. getAnimatables(animatables: IAnimatable[]): void;
  20873. /**
  20874. * Disposes the resources of the material.
  20875. * @param forceDisposeTextures - Forces the disposal of all textures.
  20876. */
  20877. dispose(forceDisposeTextures?: boolean): void;
  20878. /**
  20879. * Get the current class name of the texture useful for serialization or dynamic coding.
  20880. * @returns "PBRClearCoatConfiguration"
  20881. */
  20882. getClassName(): string;
  20883. /**
  20884. * Add fallbacks to the effect fallbacks list.
  20885. * @param defines defines the Base texture to use.
  20886. * @param fallbacks defines the current fallback list.
  20887. * @param currentRank defines the current fallback rank.
  20888. * @returns the new fallback rank.
  20889. */
  20890. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20891. /**
  20892. * Add the required uniforms to the current list.
  20893. * @param uniforms defines the current uniform list.
  20894. */
  20895. static AddUniforms(uniforms: string[]): void;
  20896. /**
  20897. * Add the required samplers to the current list.
  20898. * @param samplers defines the current sampler list.
  20899. */
  20900. static AddSamplers(samplers: string[]): void;
  20901. /**
  20902. * Add the required uniforms to the current buffer.
  20903. * @param uniformBuffer defines the current uniform buffer.
  20904. */
  20905. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20906. /**
  20907. * Makes a duplicate of the current configuration into another one.
  20908. * @param clearCoatConfiguration define the config where to copy the info
  20909. */
  20910. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20911. /**
  20912. * Serializes this clear coat configuration.
  20913. * @returns - An object with the serialized config.
  20914. */
  20915. serialize(): any;
  20916. /**
  20917. * Parses a anisotropy Configuration from a serialized object.
  20918. * @param source - Serialized object.
  20919. * @param scene Defines the scene we are parsing for
  20920. * @param rootUrl Defines the rootUrl to load from
  20921. */
  20922. parse(source: any, scene: Scene, rootUrl: string): void;
  20923. }
  20924. }
  20925. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20926. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20928. import { Vector2 } from "babylonjs/Maths/math.vector";
  20929. import { Scene } from "babylonjs/scene";
  20930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20931. import { Nullable } from "babylonjs/types";
  20932. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20933. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20934. /**
  20935. * @hidden
  20936. */
  20937. export interface IMaterialAnisotropicDefines {
  20938. ANISOTROPIC: boolean;
  20939. ANISOTROPIC_TEXTURE: boolean;
  20940. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20941. MAINUV1: boolean;
  20942. _areTexturesDirty: boolean;
  20943. _needUVs: boolean;
  20944. }
  20945. /**
  20946. * Define the code related to the anisotropic parameters of the pbr material.
  20947. */
  20948. export class PBRAnisotropicConfiguration {
  20949. private _isEnabled;
  20950. /**
  20951. * Defines if the anisotropy is enabled in the material.
  20952. */
  20953. isEnabled: boolean;
  20954. /**
  20955. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20956. */
  20957. intensity: number;
  20958. /**
  20959. * Defines if the effect is along the tangents, bitangents or in between.
  20960. * By default, the effect is "strectching" the highlights along the tangents.
  20961. */
  20962. direction: Vector2;
  20963. private _texture;
  20964. /**
  20965. * Stores the anisotropy values in a texture.
  20966. * rg is direction (like normal from -1 to 1)
  20967. * b is a intensity
  20968. */
  20969. texture: Nullable<BaseTexture>;
  20970. /** @hidden */
  20971. private _internalMarkAllSubMeshesAsTexturesDirty;
  20972. /** @hidden */
  20973. _markAllSubMeshesAsTexturesDirty(): void;
  20974. /**
  20975. * Instantiate a new istance of anisotropy configuration.
  20976. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20977. */
  20978. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20979. /**
  20980. * Specifies that the submesh is ready to be used.
  20981. * @param defines the list of "defines" to update.
  20982. * @param scene defines the scene the material belongs to.
  20983. * @returns - boolean indicating that the submesh is ready or not.
  20984. */
  20985. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20986. /**
  20987. * Checks to see if a texture is used in the material.
  20988. * @param defines the list of "defines" to update.
  20989. * @param mesh the mesh we are preparing the defines for.
  20990. * @param scene defines the scene the material belongs to.
  20991. */
  20992. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20993. /**
  20994. * Binds the material data.
  20995. * @param uniformBuffer defines the Uniform buffer to fill in.
  20996. * @param scene defines the scene the material belongs to.
  20997. * @param isFrozen defines wether the material is frozen or not.
  20998. */
  20999. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  21000. /**
  21001. * Checks to see if a texture is used in the material.
  21002. * @param texture - Base texture to use.
  21003. * @returns - Boolean specifying if a texture is used in the material.
  21004. */
  21005. hasTexture(texture: BaseTexture): boolean;
  21006. /**
  21007. * Returns an array of the actively used textures.
  21008. * @param activeTextures Array of BaseTextures
  21009. */
  21010. getActiveTextures(activeTextures: BaseTexture[]): void;
  21011. /**
  21012. * Returns the animatable textures.
  21013. * @param animatables Array of animatable textures.
  21014. */
  21015. getAnimatables(animatables: IAnimatable[]): void;
  21016. /**
  21017. * Disposes the resources of the material.
  21018. * @param forceDisposeTextures - Forces the disposal of all textures.
  21019. */
  21020. dispose(forceDisposeTextures?: boolean): void;
  21021. /**
  21022. * Get the current class name of the texture useful for serialization or dynamic coding.
  21023. * @returns "PBRAnisotropicConfiguration"
  21024. */
  21025. getClassName(): string;
  21026. /**
  21027. * Add fallbacks to the effect fallbacks list.
  21028. * @param defines defines the Base texture to use.
  21029. * @param fallbacks defines the current fallback list.
  21030. * @param currentRank defines the current fallback rank.
  21031. * @returns the new fallback rank.
  21032. */
  21033. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21034. /**
  21035. * Add the required uniforms to the current list.
  21036. * @param uniforms defines the current uniform list.
  21037. */
  21038. static AddUniforms(uniforms: string[]): void;
  21039. /**
  21040. * Add the required uniforms to the current buffer.
  21041. * @param uniformBuffer defines the current uniform buffer.
  21042. */
  21043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21044. /**
  21045. * Add the required samplers to the current list.
  21046. * @param samplers defines the current sampler list.
  21047. */
  21048. static AddSamplers(samplers: string[]): void;
  21049. /**
  21050. * Makes a duplicate of the current configuration into another one.
  21051. * @param anisotropicConfiguration define the config where to copy the info
  21052. */
  21053. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  21054. /**
  21055. * Serializes this anisotropy configuration.
  21056. * @returns - An object with the serialized config.
  21057. */
  21058. serialize(): any;
  21059. /**
  21060. * Parses a anisotropy Configuration from a serialized object.
  21061. * @param source - Serialized object.
  21062. * @param scene Defines the scene we are parsing for
  21063. * @param rootUrl Defines the rootUrl to load from
  21064. */
  21065. parse(source: any, scene: Scene, rootUrl: string): void;
  21066. }
  21067. }
  21068. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  21069. import { Scene } from "babylonjs/scene";
  21070. /**
  21071. * @hidden
  21072. */
  21073. export interface IMaterialBRDFDefines {
  21074. BRDF_V_HEIGHT_CORRELATED: boolean;
  21075. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21076. SPHERICAL_HARMONICS: boolean;
  21077. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21078. /** @hidden */
  21079. _areMiscDirty: boolean;
  21080. }
  21081. /**
  21082. * Define the code related to the BRDF parameters of the pbr material.
  21083. */
  21084. export class PBRBRDFConfiguration {
  21085. /**
  21086. * Default value used for the energy conservation.
  21087. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21088. */
  21089. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  21090. /**
  21091. * Default value used for the Smith Visibility Height Correlated mode.
  21092. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21093. */
  21094. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  21095. /**
  21096. * Default value used for the IBL diffuse part.
  21097. * This can help switching back to the polynomials mode globally which is a tiny bit
  21098. * less GPU intensive at the drawback of a lower quality.
  21099. */
  21100. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  21101. /**
  21102. * Default value used for activating energy conservation for the specular workflow.
  21103. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21104. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21105. */
  21106. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  21107. private _useEnergyConservation;
  21108. /**
  21109. * Defines if the material uses energy conservation.
  21110. */
  21111. useEnergyConservation: boolean;
  21112. private _useSmithVisibilityHeightCorrelated;
  21113. /**
  21114. * LEGACY Mode set to false
  21115. * Defines if the material uses height smith correlated visibility term.
  21116. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  21117. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  21118. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  21119. * Not relying on height correlated will also disable energy conservation.
  21120. */
  21121. useSmithVisibilityHeightCorrelated: boolean;
  21122. private _useSphericalHarmonics;
  21123. /**
  21124. * LEGACY Mode set to false
  21125. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  21126. * diffuse part of the IBL.
  21127. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  21128. * to the ground truth.
  21129. */
  21130. useSphericalHarmonics: boolean;
  21131. private _useSpecularGlossinessInputEnergyConservation;
  21132. /**
  21133. * Defines if the material uses energy conservation, when the specular workflow is active.
  21134. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21135. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21136. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  21137. */
  21138. useSpecularGlossinessInputEnergyConservation: boolean;
  21139. /** @hidden */
  21140. private _internalMarkAllSubMeshesAsMiscDirty;
  21141. /** @hidden */
  21142. _markAllSubMeshesAsMiscDirty(): void;
  21143. /**
  21144. * Instantiate a new istance of clear coat configuration.
  21145. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  21146. */
  21147. constructor(markAllSubMeshesAsMiscDirty: () => void);
  21148. /**
  21149. * Checks to see if a texture is used in the material.
  21150. * @param defines the list of "defines" to update.
  21151. */
  21152. prepareDefines(defines: IMaterialBRDFDefines): void;
  21153. /**
  21154. * Get the current class name of the texture useful for serialization or dynamic coding.
  21155. * @returns "PBRClearCoatConfiguration"
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Makes a duplicate of the current configuration into another one.
  21160. * @param brdfConfiguration define the config where to copy the info
  21161. */
  21162. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  21163. /**
  21164. * Serializes this BRDF configuration.
  21165. * @returns - An object with the serialized config.
  21166. */
  21167. serialize(): any;
  21168. /**
  21169. * Parses a anisotropy Configuration from a serialized object.
  21170. * @param source - Serialized object.
  21171. * @param scene Defines the scene we are parsing for
  21172. * @param rootUrl Defines the rootUrl to load from
  21173. */
  21174. parse(source: any, scene: Scene, rootUrl: string): void;
  21175. }
  21176. }
  21177. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  21178. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21179. import { Color3 } from "babylonjs/Maths/math.color";
  21180. import { Scene } from "babylonjs/scene";
  21181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21182. import { Nullable } from "babylonjs/types";
  21183. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21184. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21185. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21186. /**
  21187. * @hidden
  21188. */
  21189. export interface IMaterialSheenDefines {
  21190. SHEEN: boolean;
  21191. SHEEN_TEXTURE: boolean;
  21192. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21193. SHEEN_TEXTUREDIRECTUV: number;
  21194. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21195. SHEEN_LINKWITHALBEDO: boolean;
  21196. SHEEN_ROUGHNESS: boolean;
  21197. SHEEN_ALBEDOSCALING: boolean;
  21198. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21199. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21200. /** @hidden */
  21201. _areTexturesDirty: boolean;
  21202. }
  21203. /**
  21204. * Define the code related to the Sheen parameters of the pbr material.
  21205. */
  21206. export class PBRSheenConfiguration {
  21207. private _isEnabled;
  21208. /**
  21209. * Defines if the material uses sheen.
  21210. */
  21211. isEnabled: boolean;
  21212. private _linkSheenWithAlbedo;
  21213. /**
  21214. * Defines if the sheen is linked to the sheen color.
  21215. */
  21216. linkSheenWithAlbedo: boolean;
  21217. /**
  21218. * Defines the sheen intensity.
  21219. */
  21220. intensity: number;
  21221. /**
  21222. * Defines the sheen color.
  21223. */
  21224. color: Color3;
  21225. private _texture;
  21226. /**
  21227. * Stores the sheen tint values in a texture.
  21228. * rgb is tint
  21229. * 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)
  21230. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21231. */
  21232. texture: Nullable<BaseTexture>;
  21233. private _useRoughnessFromMainTexture;
  21234. /**
  21235. * Indicates that the alpha channel of the texture property will be used for roughness.
  21236. * Has no effect if the roughness (and texture!) property is not defined
  21237. */
  21238. useRoughnessFromMainTexture: boolean;
  21239. private _roughness;
  21240. /**
  21241. * Defines the sheen roughness.
  21242. * It is not taken into account if linkSheenWithAlbedo is true.
  21243. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21244. */
  21245. roughness: Nullable<number>;
  21246. private _textureRoughness;
  21247. /**
  21248. * Stores the sheen roughness in a texture.
  21249. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21250. */
  21251. textureRoughness: Nullable<BaseTexture>;
  21252. private _albedoScaling;
  21253. /**
  21254. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21255. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21256. * making it easier to setup and tweak the effect
  21257. */
  21258. albedoScaling: boolean;
  21259. /** @hidden */
  21260. private _internalMarkAllSubMeshesAsTexturesDirty;
  21261. /** @hidden */
  21262. _markAllSubMeshesAsTexturesDirty(): void;
  21263. /**
  21264. * Instantiate a new istance of clear coat configuration.
  21265. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21266. */
  21267. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21268. /**
  21269. * Specifies that the submesh is ready to be used.
  21270. * @param defines the list of "defines" to update.
  21271. * @param scene defines the scene the material belongs to.
  21272. * @returns - boolean indicating that the submesh is ready or not.
  21273. */
  21274. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21275. /**
  21276. * Checks to see if a texture is used in the material.
  21277. * @param defines the list of "defines" to update.
  21278. * @param scene defines the scene the material belongs to.
  21279. */
  21280. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21281. /**
  21282. * Binds the material data.
  21283. * @param uniformBuffer defines the Uniform buffer to fill in.
  21284. * @param scene defines the scene the material belongs to.
  21285. * @param isFrozen defines wether the material is frozen or not.
  21286. * @param subMesh the submesh to bind data for
  21287. */
  21288. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21289. /**
  21290. * Checks to see if a texture is used in the material.
  21291. * @param texture - Base texture to use.
  21292. * @returns - Boolean specifying if a texture is used in the material.
  21293. */
  21294. hasTexture(texture: BaseTexture): boolean;
  21295. /**
  21296. * Returns an array of the actively used textures.
  21297. * @param activeTextures Array of BaseTextures
  21298. */
  21299. getActiveTextures(activeTextures: BaseTexture[]): void;
  21300. /**
  21301. * Returns the animatable textures.
  21302. * @param animatables Array of animatable textures.
  21303. */
  21304. getAnimatables(animatables: IAnimatable[]): void;
  21305. /**
  21306. * Disposes the resources of the material.
  21307. * @param forceDisposeTextures - Forces the disposal of all textures.
  21308. */
  21309. dispose(forceDisposeTextures?: boolean): void;
  21310. /**
  21311. * Get the current class name of the texture useful for serialization or dynamic coding.
  21312. * @returns "PBRSheenConfiguration"
  21313. */
  21314. getClassName(): string;
  21315. /**
  21316. * Add fallbacks to the effect fallbacks list.
  21317. * @param defines defines the Base texture to use.
  21318. * @param fallbacks defines the current fallback list.
  21319. * @param currentRank defines the current fallback rank.
  21320. * @returns the new fallback rank.
  21321. */
  21322. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21323. /**
  21324. * Add the required uniforms to the current list.
  21325. * @param uniforms defines the current uniform list.
  21326. */
  21327. static AddUniforms(uniforms: string[]): void;
  21328. /**
  21329. * Add the required uniforms to the current buffer.
  21330. * @param uniformBuffer defines the current uniform buffer.
  21331. */
  21332. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21333. /**
  21334. * Add the required samplers to the current list.
  21335. * @param samplers defines the current sampler list.
  21336. */
  21337. static AddSamplers(samplers: string[]): void;
  21338. /**
  21339. * Makes a duplicate of the current configuration into another one.
  21340. * @param sheenConfiguration define the config where to copy the info
  21341. */
  21342. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21343. /**
  21344. * Serializes this BRDF configuration.
  21345. * @returns - An object with the serialized config.
  21346. */
  21347. serialize(): any;
  21348. /**
  21349. * Parses a anisotropy Configuration from a serialized object.
  21350. * @param source - Serialized object.
  21351. * @param scene Defines the scene we are parsing for
  21352. * @param rootUrl Defines the rootUrl to load from
  21353. */
  21354. parse(source: any, scene: Scene, rootUrl: string): void;
  21355. }
  21356. }
  21357. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  21358. import { Nullable } from "babylonjs/types";
  21359. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21360. import { Color3 } from "babylonjs/Maths/math.color";
  21361. import { SmartArray } from "babylonjs/Misc/smartArray";
  21362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21364. import { Effect } from "babylonjs/Materials/effect";
  21365. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21366. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21367. import { Engine } from "babylonjs/Engines/engine";
  21368. import { Scene } from "babylonjs/scene";
  21369. /**
  21370. * @hidden
  21371. */
  21372. export interface IMaterialSubSurfaceDefines {
  21373. SUBSURFACE: boolean;
  21374. SS_REFRACTION: boolean;
  21375. SS_TRANSLUCENCY: boolean;
  21376. SS_SCATTERING: boolean;
  21377. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21378. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21379. SS_REFRACTIONMAP_3D: boolean;
  21380. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21381. SS_LODINREFRACTIONALPHA: boolean;
  21382. SS_GAMMAREFRACTION: boolean;
  21383. SS_RGBDREFRACTION: boolean;
  21384. SS_LINEARSPECULARREFRACTION: boolean;
  21385. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21386. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21387. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21388. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21389. /** @hidden */
  21390. _areTexturesDirty: boolean;
  21391. }
  21392. /**
  21393. * Define the code related to the sub surface parameters of the pbr material.
  21394. */
  21395. export class PBRSubSurfaceConfiguration {
  21396. private _isRefractionEnabled;
  21397. /**
  21398. * Defines if the refraction is enabled in the material.
  21399. */
  21400. isRefractionEnabled: boolean;
  21401. private _isTranslucencyEnabled;
  21402. /**
  21403. * Defines if the translucency is enabled in the material.
  21404. */
  21405. isTranslucencyEnabled: boolean;
  21406. private _isScatteringEnabled;
  21407. /**
  21408. * Defines if the sub surface scattering is enabled in the material.
  21409. */
  21410. isScatteringEnabled: boolean;
  21411. private _scatteringDiffusionProfileIndex;
  21412. /**
  21413. * Diffusion profile for subsurface scattering.
  21414. * Useful for better scattering in the skins or foliages.
  21415. */
  21416. get scatteringDiffusionProfile(): Nullable<Color3>;
  21417. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21418. /**
  21419. * Defines the refraction intensity of the material.
  21420. * The refraction when enabled replaces the Diffuse part of the material.
  21421. * The intensity helps transitionning between diffuse and refraction.
  21422. */
  21423. refractionIntensity: number;
  21424. /**
  21425. * Defines the translucency intensity of the material.
  21426. * When translucency has been enabled, this defines how much of the "translucency"
  21427. * is addded to the diffuse part of the material.
  21428. */
  21429. translucencyIntensity: number;
  21430. /**
  21431. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21432. */
  21433. useAlbedoToTintRefraction: boolean;
  21434. private _thicknessTexture;
  21435. /**
  21436. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21437. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21438. * 0 would mean minimumThickness
  21439. * 1 would mean maximumThickness
  21440. * The other channels might be use as a mask to vary the different effects intensity.
  21441. */
  21442. thicknessTexture: Nullable<BaseTexture>;
  21443. private _refractionTexture;
  21444. /**
  21445. * Defines the texture to use for refraction.
  21446. */
  21447. refractionTexture: Nullable<BaseTexture>;
  21448. private _indexOfRefraction;
  21449. /**
  21450. * Index of refraction of the material base layer.
  21451. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21452. *
  21453. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21454. *
  21455. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21456. */
  21457. indexOfRefraction: number;
  21458. private _volumeIndexOfRefraction;
  21459. /**
  21460. * Index of refraction of the material's volume.
  21461. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21462. *
  21463. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21464. * the volume will use the same IOR as the surface.
  21465. */
  21466. get volumeIndexOfRefraction(): number;
  21467. set volumeIndexOfRefraction(value: number);
  21468. private _invertRefractionY;
  21469. /**
  21470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21471. */
  21472. invertRefractionY: boolean;
  21473. private _linkRefractionWithTransparency;
  21474. /**
  21475. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21476. * Materials half opaque for instance using refraction could benefit from this control.
  21477. */
  21478. linkRefractionWithTransparency: boolean;
  21479. /**
  21480. * Defines the minimum thickness stored in the thickness map.
  21481. * If no thickness map is defined, this value will be used to simulate thickness.
  21482. */
  21483. minimumThickness: number;
  21484. /**
  21485. * Defines the maximum thickness stored in the thickness map.
  21486. */
  21487. maximumThickness: number;
  21488. /**
  21489. * Defines the volume tint of the material.
  21490. * This is used for both translucency and scattering.
  21491. */
  21492. tintColor: Color3;
  21493. /**
  21494. * Defines the distance at which the tint color should be found in the media.
  21495. * This is used for refraction only.
  21496. */
  21497. tintColorAtDistance: number;
  21498. /**
  21499. * Defines how far each channel transmit through the media.
  21500. * It is defined as a color to simplify it selection.
  21501. */
  21502. diffusionDistance: Color3;
  21503. private _useMaskFromThicknessTexture;
  21504. /**
  21505. * Stores the intensity of the different subsurface effects in the thickness texture.
  21506. * * the green channel is the translucency intensity.
  21507. * * the blue channel is the scattering intensity.
  21508. * * the alpha channel is the refraction intensity.
  21509. */
  21510. useMaskFromThicknessTexture: boolean;
  21511. private _scene;
  21512. private _useMaskFromThicknessTextureGltf;
  21513. /**
  21514. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21515. * matches the channel-packing that is used by glTF.
  21516. * * the red channel is the transmission/translucency intensity.
  21517. * * the green channel is the thickness.
  21518. */
  21519. useMaskFromThicknessTextureGltf: boolean;
  21520. /** @hidden */
  21521. private _internalMarkAllSubMeshesAsTexturesDirty;
  21522. private _internalMarkScenePrePassDirty;
  21523. /** @hidden */
  21524. _markAllSubMeshesAsTexturesDirty(): void;
  21525. /** @hidden */
  21526. _markScenePrePassDirty(): void;
  21527. /**
  21528. * Instantiate a new istance of sub surface configuration.
  21529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21530. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21531. * @param scene The scene
  21532. */
  21533. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21534. /**
  21535. * Gets wehter the submesh is ready to be used or not.
  21536. * @param defines the list of "defines" to update.
  21537. * @param scene defines the scene the material belongs to.
  21538. * @returns - boolean indicating that the submesh is ready or not.
  21539. */
  21540. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21541. /**
  21542. * Checks to see if a texture is used in the material.
  21543. * @param defines the list of "defines" to update.
  21544. * @param scene defines the scene to the material belongs to.
  21545. */
  21546. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21547. /**
  21548. * Binds the material data.
  21549. * @param uniformBuffer defines the Uniform buffer to fill in.
  21550. * @param scene defines the scene the material belongs to.
  21551. * @param engine defines the engine the material belongs to.
  21552. * @param isFrozen defines whether the material is frozen or not.
  21553. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21554. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21555. */
  21556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21557. /**
  21558. * Unbinds the material from the mesh.
  21559. * @param activeEffect defines the effect that should be unbound from.
  21560. * @returns true if unbound, otherwise false
  21561. */
  21562. unbind(activeEffect: Effect): boolean;
  21563. /**
  21564. * Returns the texture used for refraction or null if none is used.
  21565. * @param scene defines the scene the material belongs to.
  21566. * @returns - Refraction texture if present. If no refraction texture and refraction
  21567. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21568. */
  21569. private _getRefractionTexture;
  21570. /**
  21571. * Returns true if alpha blending should be disabled.
  21572. */
  21573. get disableAlphaBlending(): boolean;
  21574. /**
  21575. * Fills the list of render target textures.
  21576. * @param renderTargets the list of render targets to update
  21577. */
  21578. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21579. /**
  21580. * Checks to see if a texture is used in the material.
  21581. * @param texture - Base texture to use.
  21582. * @returns - Boolean specifying if a texture is used in the material.
  21583. */
  21584. hasTexture(texture: BaseTexture): boolean;
  21585. /**
  21586. * Gets a boolean indicating that current material needs to register RTT
  21587. * @returns true if this uses a render target otherwise false.
  21588. */
  21589. hasRenderTargetTextures(): boolean;
  21590. /**
  21591. * Returns an array of the actively used textures.
  21592. * @param activeTextures Array of BaseTextures
  21593. */
  21594. getActiveTextures(activeTextures: BaseTexture[]): void;
  21595. /**
  21596. * Returns the animatable textures.
  21597. * @param animatables Array of animatable textures.
  21598. */
  21599. getAnimatables(animatables: IAnimatable[]): void;
  21600. /**
  21601. * Disposes the resources of the material.
  21602. * @param forceDisposeTextures - Forces the disposal of all textures.
  21603. */
  21604. dispose(forceDisposeTextures?: boolean): void;
  21605. /**
  21606. * Get the current class name of the texture useful for serialization or dynamic coding.
  21607. * @returns "PBRSubSurfaceConfiguration"
  21608. */
  21609. getClassName(): string;
  21610. /**
  21611. * Add fallbacks to the effect fallbacks list.
  21612. * @param defines defines the Base texture to use.
  21613. * @param fallbacks defines the current fallback list.
  21614. * @param currentRank defines the current fallback rank.
  21615. * @returns the new fallback rank.
  21616. */
  21617. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21618. /**
  21619. * Add the required uniforms to the current list.
  21620. * @param uniforms defines the current uniform list.
  21621. */
  21622. static AddUniforms(uniforms: string[]): void;
  21623. /**
  21624. * Add the required samplers to the current list.
  21625. * @param samplers defines the current sampler list.
  21626. */
  21627. static AddSamplers(samplers: string[]): void;
  21628. /**
  21629. * Add the required uniforms to the current buffer.
  21630. * @param uniformBuffer defines the current uniform buffer.
  21631. */
  21632. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21633. /**
  21634. * Makes a duplicate of the current configuration into another one.
  21635. * @param configuration define the config where to copy the info
  21636. */
  21637. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21638. /**
  21639. * Serializes this Sub Surface configuration.
  21640. * @returns - An object with the serialized config.
  21641. */
  21642. serialize(): any;
  21643. /**
  21644. * Parses a anisotropy Configuration from a serialized object.
  21645. * @param source - Serialized object.
  21646. * @param scene Defines the scene we are parsing for
  21647. * @param rootUrl Defines the rootUrl to load from
  21648. */
  21649. parse(source: any, scene: Scene, rootUrl: string): void;
  21650. }
  21651. }
  21652. declare module "babylonjs/Maths/sphericalPolynomial" {
  21653. import { Vector3 } from "babylonjs/Maths/math.vector";
  21654. import { Color3 } from "babylonjs/Maths/math.color";
  21655. /**
  21656. * Class representing spherical harmonics coefficients to the 3rd degree
  21657. */
  21658. export class SphericalHarmonics {
  21659. /**
  21660. * Defines whether or not the harmonics have been prescaled for rendering.
  21661. */
  21662. preScaled: boolean;
  21663. /**
  21664. * The l0,0 coefficients of the spherical harmonics
  21665. */
  21666. l00: Vector3;
  21667. /**
  21668. * The l1,-1 coefficients of the spherical harmonics
  21669. */
  21670. l1_1: Vector3;
  21671. /**
  21672. * The l1,0 coefficients of the spherical harmonics
  21673. */
  21674. l10: Vector3;
  21675. /**
  21676. * The l1,1 coefficients of the spherical harmonics
  21677. */
  21678. l11: Vector3;
  21679. /**
  21680. * The l2,-2 coefficients of the spherical harmonics
  21681. */
  21682. l2_2: Vector3;
  21683. /**
  21684. * The l2,-1 coefficients of the spherical harmonics
  21685. */
  21686. l2_1: Vector3;
  21687. /**
  21688. * The l2,0 coefficients of the spherical harmonics
  21689. */
  21690. l20: Vector3;
  21691. /**
  21692. * The l2,1 coefficients of the spherical harmonics
  21693. */
  21694. l21: Vector3;
  21695. /**
  21696. * The l2,2 coefficients of the spherical harmonics
  21697. */
  21698. l22: Vector3;
  21699. /**
  21700. * Adds a light to the spherical harmonics
  21701. * @param direction the direction of the light
  21702. * @param color the color of the light
  21703. * @param deltaSolidAngle the delta solid angle of the light
  21704. */
  21705. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21706. /**
  21707. * Scales the spherical harmonics by the given amount
  21708. * @param scale the amount to scale
  21709. */
  21710. scaleInPlace(scale: number): void;
  21711. /**
  21712. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21713. *
  21714. * ```
  21715. * E_lm = A_l * L_lm
  21716. * ```
  21717. *
  21718. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21719. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21720. * the scaling factors are given in equation 9.
  21721. */
  21722. convertIncidentRadianceToIrradiance(): void;
  21723. /**
  21724. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21725. *
  21726. * ```
  21727. * L = (1/pi) * E * rho
  21728. * ```
  21729. *
  21730. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21731. */
  21732. convertIrradianceToLambertianRadiance(): void;
  21733. /**
  21734. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21735. * required operations at run time.
  21736. *
  21737. * This is simply done by scaling back the SH with Ylm constants parameter.
  21738. * The trigonometric part being applied by the shader at run time.
  21739. */
  21740. preScaleForRendering(): void;
  21741. /**
  21742. * Constructs a spherical harmonics from an array.
  21743. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21744. * @returns the spherical harmonics
  21745. */
  21746. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21747. /**
  21748. * Gets the spherical harmonics from polynomial
  21749. * @param polynomial the spherical polynomial
  21750. * @returns the spherical harmonics
  21751. */
  21752. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21753. }
  21754. /**
  21755. * Class representing spherical polynomial coefficients to the 3rd degree
  21756. */
  21757. export class SphericalPolynomial {
  21758. private _harmonics;
  21759. /**
  21760. * The spherical harmonics used to create the polynomials.
  21761. */
  21762. get preScaledHarmonics(): SphericalHarmonics;
  21763. /**
  21764. * The x coefficients of the spherical polynomial
  21765. */
  21766. x: Vector3;
  21767. /**
  21768. * The y coefficients of the spherical polynomial
  21769. */
  21770. y: Vector3;
  21771. /**
  21772. * The z coefficients of the spherical polynomial
  21773. */
  21774. z: Vector3;
  21775. /**
  21776. * The xx coefficients of the spherical polynomial
  21777. */
  21778. xx: Vector3;
  21779. /**
  21780. * The yy coefficients of the spherical polynomial
  21781. */
  21782. yy: Vector3;
  21783. /**
  21784. * The zz coefficients of the spherical polynomial
  21785. */
  21786. zz: Vector3;
  21787. /**
  21788. * The xy coefficients of the spherical polynomial
  21789. */
  21790. xy: Vector3;
  21791. /**
  21792. * The yz coefficients of the spherical polynomial
  21793. */
  21794. yz: Vector3;
  21795. /**
  21796. * The zx coefficients of the spherical polynomial
  21797. */
  21798. zx: Vector3;
  21799. /**
  21800. * Adds an ambient color to the spherical polynomial
  21801. * @param color the color to add
  21802. */
  21803. addAmbient(color: Color3): void;
  21804. /**
  21805. * Scales the spherical polynomial by the given amount
  21806. * @param scale the amount to scale
  21807. */
  21808. scaleInPlace(scale: number): void;
  21809. /**
  21810. * Gets the spherical polynomial from harmonics
  21811. * @param harmonics the spherical harmonics
  21812. * @returns the spherical polynomial
  21813. */
  21814. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21815. /**
  21816. * Constructs a spherical polynomial from an array.
  21817. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21818. * @returns the spherical polynomial
  21819. */
  21820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21821. }
  21822. }
  21823. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21824. import { Nullable } from "babylonjs/types";
  21825. /**
  21826. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21827. */
  21828. export interface CubeMapInfo {
  21829. /**
  21830. * The pixel array for the front face.
  21831. * This is stored in format, left to right, up to down format.
  21832. */
  21833. front: Nullable<ArrayBufferView>;
  21834. /**
  21835. * The pixel array for the back face.
  21836. * This is stored in format, left to right, up to down format.
  21837. */
  21838. back: Nullable<ArrayBufferView>;
  21839. /**
  21840. * The pixel array for the left face.
  21841. * This is stored in format, left to right, up to down format.
  21842. */
  21843. left: Nullable<ArrayBufferView>;
  21844. /**
  21845. * The pixel array for the right face.
  21846. * This is stored in format, left to right, up to down format.
  21847. */
  21848. right: Nullable<ArrayBufferView>;
  21849. /**
  21850. * The pixel array for the up face.
  21851. * This is stored in format, left to right, up to down format.
  21852. */
  21853. up: Nullable<ArrayBufferView>;
  21854. /**
  21855. * The pixel array for the down face.
  21856. * This is stored in format, left to right, up to down format.
  21857. */
  21858. down: Nullable<ArrayBufferView>;
  21859. /**
  21860. * The size of the cubemap stored.
  21861. *
  21862. * Each faces will be size * size pixels.
  21863. */
  21864. size: number;
  21865. /**
  21866. * The format of the texture.
  21867. *
  21868. * RGBA, RGB.
  21869. */
  21870. format: number;
  21871. /**
  21872. * The type of the texture data.
  21873. *
  21874. * UNSIGNED_INT, FLOAT.
  21875. */
  21876. type: number;
  21877. /**
  21878. * Specifies whether the texture is in gamma space.
  21879. */
  21880. gammaSpace: boolean;
  21881. }
  21882. /**
  21883. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21884. */
  21885. export class PanoramaToCubeMapTools {
  21886. private static FACE_LEFT;
  21887. private static FACE_RIGHT;
  21888. private static FACE_FRONT;
  21889. private static FACE_BACK;
  21890. private static FACE_DOWN;
  21891. private static FACE_UP;
  21892. /**
  21893. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21894. *
  21895. * @param float32Array The source data.
  21896. * @param inputWidth The width of the input panorama.
  21897. * @param inputHeight The height of the input panorama.
  21898. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21899. * @return The cubemap data
  21900. */
  21901. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21902. private static CreateCubemapTexture;
  21903. private static CalcProjectionSpherical;
  21904. }
  21905. }
  21906. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21907. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21909. import { Nullable } from "babylonjs/types";
  21910. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21911. /**
  21912. * Helper class dealing with the extraction of spherical polynomial dataArray
  21913. * from a cube map.
  21914. */
  21915. export class CubeMapToSphericalPolynomialTools {
  21916. private static FileFaces;
  21917. /**
  21918. * Converts a texture to the according Spherical Polynomial data.
  21919. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21920. *
  21921. * @param texture The texture to extract the information from.
  21922. * @return The Spherical Polynomial data.
  21923. */
  21924. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21925. /**
  21926. * Converts a cubemap to the according Spherical Polynomial data.
  21927. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21928. *
  21929. * @param cubeInfo The Cube map to extract the information from.
  21930. * @return The Spherical Polynomial data.
  21931. */
  21932. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21933. }
  21934. }
  21935. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21936. import { Nullable } from "babylonjs/types";
  21937. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21938. module "babylonjs/Materials/Textures/baseTexture" {
  21939. interface BaseTexture {
  21940. /**
  21941. * Get the polynomial representation of the texture data.
  21942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21944. */
  21945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21946. }
  21947. }
  21948. }
  21949. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21950. /** @hidden */
  21951. export var pbrFragmentDeclaration: {
  21952. name: string;
  21953. shader: string;
  21954. };
  21955. }
  21956. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21957. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  21958. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  21959. /** @hidden */
  21960. export var pbrUboDeclaration: {
  21961. name: string;
  21962. shader: string;
  21963. };
  21964. }
  21965. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21966. /** @hidden */
  21967. export var pbrFragmentExtraDeclaration: {
  21968. name: string;
  21969. shader: string;
  21970. };
  21971. }
  21972. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21973. /** @hidden */
  21974. export var pbrFragmentSamplersDeclaration: {
  21975. name: string;
  21976. shader: string;
  21977. };
  21978. }
  21979. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21980. /** @hidden */
  21981. export var subSurfaceScatteringFunctions: {
  21982. name: string;
  21983. shader: string;
  21984. };
  21985. }
  21986. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21987. /** @hidden */
  21988. export var importanceSampling: {
  21989. name: string;
  21990. shader: string;
  21991. };
  21992. }
  21993. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21994. /** @hidden */
  21995. export var pbrHelperFunctions: {
  21996. name: string;
  21997. shader: string;
  21998. };
  21999. }
  22000. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  22001. /** @hidden */
  22002. export var harmonicsFunctions: {
  22003. name: string;
  22004. shader: string;
  22005. };
  22006. }
  22007. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  22008. /** @hidden */
  22009. export var pbrDirectLightingSetupFunctions: {
  22010. name: string;
  22011. shader: string;
  22012. };
  22013. }
  22014. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  22015. /** @hidden */
  22016. export var pbrDirectLightingFalloffFunctions: {
  22017. name: string;
  22018. shader: string;
  22019. };
  22020. }
  22021. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  22022. /** @hidden */
  22023. export var pbrBRDFFunctions: {
  22024. name: string;
  22025. shader: string;
  22026. };
  22027. }
  22028. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  22029. /** @hidden */
  22030. export var hdrFilteringFunctions: {
  22031. name: string;
  22032. shader: string;
  22033. };
  22034. }
  22035. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  22036. /** @hidden */
  22037. export var pbrDirectLightingFunctions: {
  22038. name: string;
  22039. shader: string;
  22040. };
  22041. }
  22042. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  22043. /** @hidden */
  22044. export var pbrIBLFunctions: {
  22045. name: string;
  22046. shader: string;
  22047. };
  22048. }
  22049. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  22050. /** @hidden */
  22051. export var pbrBlockAlbedoOpacity: {
  22052. name: string;
  22053. shader: string;
  22054. };
  22055. }
  22056. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  22057. /** @hidden */
  22058. export var pbrBlockReflectivity: {
  22059. name: string;
  22060. shader: string;
  22061. };
  22062. }
  22063. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  22064. /** @hidden */
  22065. export var pbrBlockAmbientOcclusion: {
  22066. name: string;
  22067. shader: string;
  22068. };
  22069. }
  22070. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  22071. /** @hidden */
  22072. export var pbrBlockAlphaFresnel: {
  22073. name: string;
  22074. shader: string;
  22075. };
  22076. }
  22077. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  22078. /** @hidden */
  22079. export var pbrBlockAnisotropic: {
  22080. name: string;
  22081. shader: string;
  22082. };
  22083. }
  22084. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  22085. /** @hidden */
  22086. export var pbrBlockReflection: {
  22087. name: string;
  22088. shader: string;
  22089. };
  22090. }
  22091. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  22092. /** @hidden */
  22093. export var pbrBlockSheen: {
  22094. name: string;
  22095. shader: string;
  22096. };
  22097. }
  22098. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  22099. /** @hidden */
  22100. export var pbrBlockClearcoat: {
  22101. name: string;
  22102. shader: string;
  22103. };
  22104. }
  22105. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  22106. /** @hidden */
  22107. export var pbrBlockSubSurface: {
  22108. name: string;
  22109. shader: string;
  22110. };
  22111. }
  22112. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  22113. /** @hidden */
  22114. export var pbrBlockNormalGeometric: {
  22115. name: string;
  22116. shader: string;
  22117. };
  22118. }
  22119. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  22120. /** @hidden */
  22121. export var pbrBlockNormalFinal: {
  22122. name: string;
  22123. shader: string;
  22124. };
  22125. }
  22126. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  22127. /** @hidden */
  22128. export var pbrBlockLightmapInit: {
  22129. name: string;
  22130. shader: string;
  22131. };
  22132. }
  22133. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  22134. /** @hidden */
  22135. export var pbrBlockGeometryInfo: {
  22136. name: string;
  22137. shader: string;
  22138. };
  22139. }
  22140. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  22141. /** @hidden */
  22142. export var pbrBlockReflectance0: {
  22143. name: string;
  22144. shader: string;
  22145. };
  22146. }
  22147. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  22148. /** @hidden */
  22149. export var pbrBlockReflectance: {
  22150. name: string;
  22151. shader: string;
  22152. };
  22153. }
  22154. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  22155. /** @hidden */
  22156. export var pbrBlockDirectLighting: {
  22157. name: string;
  22158. shader: string;
  22159. };
  22160. }
  22161. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  22162. /** @hidden */
  22163. export var pbrBlockFinalLitComponents: {
  22164. name: string;
  22165. shader: string;
  22166. };
  22167. }
  22168. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  22169. /** @hidden */
  22170. export var pbrBlockFinalUnlitComponents: {
  22171. name: string;
  22172. shader: string;
  22173. };
  22174. }
  22175. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  22176. /** @hidden */
  22177. export var pbrBlockFinalColorComposition: {
  22178. name: string;
  22179. shader: string;
  22180. };
  22181. }
  22182. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  22183. /** @hidden */
  22184. export var pbrBlockImageProcessing: {
  22185. name: string;
  22186. shader: string;
  22187. };
  22188. }
  22189. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  22190. /** @hidden */
  22191. export var pbrDebug: {
  22192. name: string;
  22193. shader: string;
  22194. };
  22195. }
  22196. declare module "babylonjs/Shaders/pbr.fragment" {
  22197. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  22198. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  22199. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22200. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  22201. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  22202. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  22203. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  22204. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  22205. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  22206. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22207. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  22208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22209. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  22210. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  22211. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  22212. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  22213. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  22214. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22215. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  22216. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  22217. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  22218. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  22219. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  22220. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  22221. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22222. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22223. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  22224. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  22225. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  22226. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  22227. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  22228. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  22229. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  22230. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  22231. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  22232. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  22233. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  22234. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  22235. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22236. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  22237. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  22238. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  22239. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  22240. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  22241. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  22242. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  22243. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  22244. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  22245. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  22246. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  22247. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  22248. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  22249. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  22250. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  22251. /** @hidden */
  22252. export var pbrPixelShader: {
  22253. name: string;
  22254. shader: string;
  22255. };
  22256. }
  22257. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  22258. /** @hidden */
  22259. export var pbrVertexDeclaration: {
  22260. name: string;
  22261. shader: string;
  22262. };
  22263. }
  22264. declare module "babylonjs/Shaders/pbr.vertex" {
  22265. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  22266. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22267. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22268. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22269. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  22270. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22271. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  22272. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  22273. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  22274. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  22275. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  22276. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22277. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22278. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22280. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22281. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22282. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  22283. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22284. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  22285. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  22286. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  22287. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  22288. /** @hidden */
  22289. export var pbrVertexShader: {
  22290. name: string;
  22291. shader: string;
  22292. };
  22293. }
  22294. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  22295. import { Nullable } from "babylonjs/types";
  22296. import { Scene } from "babylonjs/scene";
  22297. import { Matrix } from "babylonjs/Maths/math.vector";
  22298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22300. import { Mesh } from "babylonjs/Meshes/mesh";
  22301. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  22302. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  22303. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  22304. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  22305. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  22306. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  22307. import { Color3 } from "babylonjs/Maths/math.color";
  22308. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22309. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  22310. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22311. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22314. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  22315. import "babylonjs/Shaders/pbr.fragment";
  22316. import "babylonjs/Shaders/pbr.vertex";
  22317. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  22318. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22319. /**
  22320. * Manages the defines for the PBR Material.
  22321. * @hidden
  22322. */
  22323. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  22324. PBR: boolean;
  22325. NUM_SAMPLES: string;
  22326. REALTIME_FILTERING: boolean;
  22327. MAINUV1: boolean;
  22328. MAINUV2: boolean;
  22329. UV1: boolean;
  22330. UV2: boolean;
  22331. ALBEDO: boolean;
  22332. GAMMAALBEDO: boolean;
  22333. ALBEDODIRECTUV: number;
  22334. VERTEXCOLOR: boolean;
  22335. DETAIL: boolean;
  22336. DETAILDIRECTUV: number;
  22337. DETAIL_NORMALBLENDMETHOD: number;
  22338. AMBIENT: boolean;
  22339. AMBIENTDIRECTUV: number;
  22340. AMBIENTINGRAYSCALE: boolean;
  22341. OPACITY: boolean;
  22342. VERTEXALPHA: boolean;
  22343. OPACITYDIRECTUV: number;
  22344. OPACITYRGB: boolean;
  22345. ALPHATEST: boolean;
  22346. DEPTHPREPASS: boolean;
  22347. ALPHABLEND: boolean;
  22348. ALPHAFROMALBEDO: boolean;
  22349. ALPHATESTVALUE: string;
  22350. SPECULAROVERALPHA: boolean;
  22351. RADIANCEOVERALPHA: boolean;
  22352. ALPHAFRESNEL: boolean;
  22353. LINEARALPHAFRESNEL: boolean;
  22354. PREMULTIPLYALPHA: boolean;
  22355. EMISSIVE: boolean;
  22356. EMISSIVEDIRECTUV: number;
  22357. REFLECTIVITY: boolean;
  22358. REFLECTIVITYDIRECTUV: number;
  22359. SPECULARTERM: boolean;
  22360. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22361. MICROSURFACEAUTOMATIC: boolean;
  22362. LODBASEDMICROSFURACE: boolean;
  22363. MICROSURFACEMAP: boolean;
  22364. MICROSURFACEMAPDIRECTUV: number;
  22365. METALLICWORKFLOW: boolean;
  22366. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22367. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22368. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22369. AOSTOREINMETALMAPRED: boolean;
  22370. METALLIC_REFLECTANCE: boolean;
  22371. METALLIC_REFLECTANCEDIRECTUV: number;
  22372. ENVIRONMENTBRDF: boolean;
  22373. ENVIRONMENTBRDF_RGBD: boolean;
  22374. NORMAL: boolean;
  22375. TANGENT: boolean;
  22376. BUMP: boolean;
  22377. BUMPDIRECTUV: number;
  22378. OBJECTSPACE_NORMALMAP: boolean;
  22379. PARALLAX: boolean;
  22380. PARALLAXOCCLUSION: boolean;
  22381. NORMALXYSCALE: boolean;
  22382. LIGHTMAP: boolean;
  22383. LIGHTMAPDIRECTUV: number;
  22384. USELIGHTMAPASSHADOWMAP: boolean;
  22385. GAMMALIGHTMAP: boolean;
  22386. RGBDLIGHTMAP: boolean;
  22387. REFLECTION: boolean;
  22388. REFLECTIONMAP_3D: boolean;
  22389. REFLECTIONMAP_SPHERICAL: boolean;
  22390. REFLECTIONMAP_PLANAR: boolean;
  22391. REFLECTIONMAP_CUBIC: boolean;
  22392. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22393. REFLECTIONMAP_PROJECTION: boolean;
  22394. REFLECTIONMAP_SKYBOX: boolean;
  22395. REFLECTIONMAP_EXPLICIT: boolean;
  22396. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22397. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22398. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22399. INVERTCUBICMAP: boolean;
  22400. USESPHERICALFROMREFLECTIONMAP: boolean;
  22401. USEIRRADIANCEMAP: boolean;
  22402. SPHERICAL_HARMONICS: boolean;
  22403. USESPHERICALINVERTEX: boolean;
  22404. REFLECTIONMAP_OPPOSITEZ: boolean;
  22405. LODINREFLECTIONALPHA: boolean;
  22406. GAMMAREFLECTION: boolean;
  22407. RGBDREFLECTION: boolean;
  22408. LINEARSPECULARREFLECTION: boolean;
  22409. RADIANCEOCCLUSION: boolean;
  22410. HORIZONOCCLUSION: boolean;
  22411. INSTANCES: boolean;
  22412. THIN_INSTANCES: boolean;
  22413. PREPASS: boolean;
  22414. PREPASS_IRRADIANCE: boolean;
  22415. PREPASS_IRRADIANCE_INDEX: number;
  22416. PREPASS_ALBEDO: boolean;
  22417. PREPASS_ALBEDO_INDEX: number;
  22418. PREPASS_DEPTHNORMAL: boolean;
  22419. PREPASS_DEPTHNORMAL_INDEX: number;
  22420. PREPASS_POSITION: boolean;
  22421. PREPASS_POSITION_INDEX: number;
  22422. PREPASS_VELOCITY: boolean;
  22423. PREPASS_VELOCITY_INDEX: number;
  22424. PREPASS_REFLECTIVITY: boolean;
  22425. PREPASS_REFLECTIVITY_INDEX: number;
  22426. SCENE_MRT_COUNT: number;
  22427. NUM_BONE_INFLUENCERS: number;
  22428. BonesPerMesh: number;
  22429. BONETEXTURE: boolean;
  22430. BONES_VELOCITY_ENABLED: boolean;
  22431. NONUNIFORMSCALING: boolean;
  22432. MORPHTARGETS: boolean;
  22433. MORPHTARGETS_NORMAL: boolean;
  22434. MORPHTARGETS_TANGENT: boolean;
  22435. MORPHTARGETS_UV: boolean;
  22436. NUM_MORPH_INFLUENCERS: number;
  22437. IMAGEPROCESSING: boolean;
  22438. VIGNETTE: boolean;
  22439. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22440. VIGNETTEBLENDMODEOPAQUE: boolean;
  22441. TONEMAPPING: boolean;
  22442. TONEMAPPING_ACES: boolean;
  22443. CONTRAST: boolean;
  22444. COLORCURVES: boolean;
  22445. COLORGRADING: boolean;
  22446. COLORGRADING3D: boolean;
  22447. SAMPLER3DGREENDEPTH: boolean;
  22448. SAMPLER3DBGRMAP: boolean;
  22449. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22450. EXPOSURE: boolean;
  22451. MULTIVIEW: boolean;
  22452. USEPHYSICALLIGHTFALLOFF: boolean;
  22453. USEGLTFLIGHTFALLOFF: boolean;
  22454. TWOSIDEDLIGHTING: boolean;
  22455. SHADOWFLOAT: boolean;
  22456. CLIPPLANE: boolean;
  22457. CLIPPLANE2: boolean;
  22458. CLIPPLANE3: boolean;
  22459. CLIPPLANE4: boolean;
  22460. CLIPPLANE5: boolean;
  22461. CLIPPLANE6: boolean;
  22462. POINTSIZE: boolean;
  22463. FOG: boolean;
  22464. LOGARITHMICDEPTH: boolean;
  22465. FORCENORMALFORWARD: boolean;
  22466. SPECULARAA: boolean;
  22467. CLEARCOAT: boolean;
  22468. CLEARCOAT_DEFAULTIOR: boolean;
  22469. CLEARCOAT_TEXTURE: boolean;
  22470. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22471. CLEARCOAT_TEXTUREDIRECTUV: number;
  22472. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22473. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22474. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22475. CLEARCOAT_BUMP: boolean;
  22476. CLEARCOAT_BUMPDIRECTUV: number;
  22477. CLEARCOAT_REMAP_F0: boolean;
  22478. CLEARCOAT_TINT: boolean;
  22479. CLEARCOAT_TINT_TEXTURE: boolean;
  22480. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22481. ANISOTROPIC: boolean;
  22482. ANISOTROPIC_TEXTURE: boolean;
  22483. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22484. BRDF_V_HEIGHT_CORRELATED: boolean;
  22485. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22486. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22487. SHEEN: boolean;
  22488. SHEEN_TEXTURE: boolean;
  22489. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22490. SHEEN_TEXTUREDIRECTUV: number;
  22491. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22492. SHEEN_LINKWITHALBEDO: boolean;
  22493. SHEEN_ROUGHNESS: boolean;
  22494. SHEEN_ALBEDOSCALING: boolean;
  22495. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22496. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22497. SUBSURFACE: boolean;
  22498. SS_REFRACTION: boolean;
  22499. SS_TRANSLUCENCY: boolean;
  22500. SS_SCATTERING: boolean;
  22501. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22502. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22503. SS_REFRACTIONMAP_3D: boolean;
  22504. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22505. SS_LODINREFRACTIONALPHA: boolean;
  22506. SS_GAMMAREFRACTION: boolean;
  22507. SS_RGBDREFRACTION: boolean;
  22508. SS_LINEARSPECULARREFRACTION: boolean;
  22509. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22510. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22511. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22512. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22513. UNLIT: boolean;
  22514. DEBUGMODE: number;
  22515. /**
  22516. * Initializes the PBR Material defines.
  22517. */
  22518. constructor();
  22519. /**
  22520. * Resets the PBR Material defines.
  22521. */
  22522. reset(): void;
  22523. }
  22524. /**
  22525. * The Physically based material base class of BJS.
  22526. *
  22527. * This offers the main features of a standard PBR material.
  22528. * For more information, please refer to the documentation :
  22529. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22530. */
  22531. export abstract class PBRBaseMaterial extends PushMaterial {
  22532. /**
  22533. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22534. */
  22535. static readonly PBRMATERIAL_OPAQUE: number;
  22536. /**
  22537. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22538. */
  22539. static readonly PBRMATERIAL_ALPHATEST: number;
  22540. /**
  22541. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22542. */
  22543. static readonly PBRMATERIAL_ALPHABLEND: number;
  22544. /**
  22545. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22546. * They are also discarded below the alpha cutoff threshold to improve performances.
  22547. */
  22548. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22549. /**
  22550. * Defines the default value of how much AO map is occluding the analytical lights
  22551. * (point spot...).
  22552. */
  22553. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22554. /**
  22555. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22556. */
  22557. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22558. /**
  22559. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22560. * to enhance interoperability with other engines.
  22561. */
  22562. static readonly LIGHTFALLOFF_GLTF: number;
  22563. /**
  22564. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22565. * to enhance interoperability with other materials.
  22566. */
  22567. static readonly LIGHTFALLOFF_STANDARD: number;
  22568. /**
  22569. * Intensity of the direct lights e.g. the four lights available in your scene.
  22570. * This impacts both the direct diffuse and specular highlights.
  22571. */
  22572. protected _directIntensity: number;
  22573. /**
  22574. * Intensity of the emissive part of the material.
  22575. * This helps controlling the emissive effect without modifying the emissive color.
  22576. */
  22577. protected _emissiveIntensity: number;
  22578. /**
  22579. * Intensity of the environment e.g. how much the environment will light the object
  22580. * either through harmonics for rough material or through the refelction for shiny ones.
  22581. */
  22582. protected _environmentIntensity: number;
  22583. /**
  22584. * This is a special control allowing the reduction of the specular highlights coming from the
  22585. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22586. */
  22587. protected _specularIntensity: number;
  22588. /**
  22589. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22590. */
  22591. private _lightingInfos;
  22592. /**
  22593. * Debug Control allowing disabling the bump map on this material.
  22594. */
  22595. protected _disableBumpMap: boolean;
  22596. /**
  22597. * AKA Diffuse Texture in standard nomenclature.
  22598. */
  22599. protected _albedoTexture: Nullable<BaseTexture>;
  22600. /**
  22601. * AKA Occlusion Texture in other nomenclature.
  22602. */
  22603. protected _ambientTexture: Nullable<BaseTexture>;
  22604. /**
  22605. * AKA Occlusion Texture Intensity in other nomenclature.
  22606. */
  22607. protected _ambientTextureStrength: number;
  22608. /**
  22609. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22610. * 1 means it completely occludes it
  22611. * 0 mean it has no impact
  22612. */
  22613. protected _ambientTextureImpactOnAnalyticalLights: number;
  22614. /**
  22615. * Stores the alpha values in a texture.
  22616. */
  22617. protected _opacityTexture: Nullable<BaseTexture>;
  22618. /**
  22619. * Stores the reflection values in a texture.
  22620. */
  22621. protected _reflectionTexture: Nullable<BaseTexture>;
  22622. /**
  22623. * Stores the emissive values in a texture.
  22624. */
  22625. protected _emissiveTexture: Nullable<BaseTexture>;
  22626. /**
  22627. * AKA Specular texture in other nomenclature.
  22628. */
  22629. protected _reflectivityTexture: Nullable<BaseTexture>;
  22630. /**
  22631. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22632. */
  22633. protected _metallicTexture: Nullable<BaseTexture>;
  22634. /**
  22635. * Specifies the metallic scalar of the metallic/roughness workflow.
  22636. * Can also be used to scale the metalness values of the metallic texture.
  22637. */
  22638. protected _metallic: Nullable<number>;
  22639. /**
  22640. * Specifies the roughness scalar of the metallic/roughness workflow.
  22641. * Can also be used to scale the roughness values of the metallic texture.
  22642. */
  22643. protected _roughness: Nullable<number>;
  22644. /**
  22645. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22646. * By default the indexOfrefraction is used to compute F0;
  22647. *
  22648. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22649. *
  22650. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22651. * F90 = metallicReflectanceColor;
  22652. */
  22653. protected _metallicF0Factor: number;
  22654. /**
  22655. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22656. * By default the F90 is always 1;
  22657. *
  22658. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22659. *
  22660. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22661. * F90 = metallicReflectanceColor;
  22662. */
  22663. protected _metallicReflectanceColor: Color3;
  22664. /**
  22665. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22666. * This is multiply against the scalar values defined in the material.
  22667. */
  22668. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22669. /**
  22670. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22671. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22672. */
  22673. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22674. /**
  22675. * Stores surface normal data used to displace a mesh in a texture.
  22676. */
  22677. protected _bumpTexture: Nullable<BaseTexture>;
  22678. /**
  22679. * Stores the pre-calculated light information of a mesh in a texture.
  22680. */
  22681. protected _lightmapTexture: Nullable<BaseTexture>;
  22682. /**
  22683. * The color of a material in ambient lighting.
  22684. */
  22685. protected _ambientColor: Color3;
  22686. /**
  22687. * AKA Diffuse Color in other nomenclature.
  22688. */
  22689. protected _albedoColor: Color3;
  22690. /**
  22691. * AKA Specular Color in other nomenclature.
  22692. */
  22693. protected _reflectivityColor: Color3;
  22694. /**
  22695. * The color applied when light is reflected from a material.
  22696. */
  22697. protected _reflectionColor: Color3;
  22698. /**
  22699. * The color applied when light is emitted from a material.
  22700. */
  22701. protected _emissiveColor: Color3;
  22702. /**
  22703. * AKA Glossiness in other nomenclature.
  22704. */
  22705. protected _microSurface: number;
  22706. /**
  22707. * Specifies that the material will use the light map as a show map.
  22708. */
  22709. protected _useLightmapAsShadowmap: boolean;
  22710. /**
  22711. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22712. * makes the reflect vector face the model (under horizon).
  22713. */
  22714. protected _useHorizonOcclusion: boolean;
  22715. /**
  22716. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22717. * too much the area relying on ambient texture to define their ambient occlusion.
  22718. */
  22719. protected _useRadianceOcclusion: boolean;
  22720. /**
  22721. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22722. */
  22723. protected _useAlphaFromAlbedoTexture: boolean;
  22724. /**
  22725. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  22726. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22727. */
  22728. protected _useSpecularOverAlpha: boolean;
  22729. /**
  22730. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22731. */
  22732. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22733. /**
  22734. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22735. */
  22736. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22737. /**
  22738. * Specifies if the metallic texture contains the roughness information in its green channel.
  22739. */
  22740. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22741. /**
  22742. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22743. */
  22744. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22745. /**
  22746. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22747. */
  22748. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22749. /**
  22750. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22751. */
  22752. protected _useAmbientInGrayScale: boolean;
  22753. /**
  22754. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22755. * The material will try to infer what glossiness each pixel should be.
  22756. */
  22757. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22758. /**
  22759. * Defines the falloff type used in this material.
  22760. * It by default is Physical.
  22761. */
  22762. protected _lightFalloff: number;
  22763. /**
  22764. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22765. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22766. */
  22767. protected _useRadianceOverAlpha: boolean;
  22768. /**
  22769. * Allows using an object space normal map (instead of tangent space).
  22770. */
  22771. protected _useObjectSpaceNormalMap: boolean;
  22772. /**
  22773. * Allows using the bump map in parallax mode.
  22774. */
  22775. protected _useParallax: boolean;
  22776. /**
  22777. * Allows using the bump map in parallax occlusion mode.
  22778. */
  22779. protected _useParallaxOcclusion: boolean;
  22780. /**
  22781. * Controls the scale bias of the parallax mode.
  22782. */
  22783. protected _parallaxScaleBias: number;
  22784. /**
  22785. * If sets to true, disables all the lights affecting the material.
  22786. */
  22787. protected _disableLighting: boolean;
  22788. /**
  22789. * Number of Simultaneous lights allowed on the material.
  22790. */
  22791. protected _maxSimultaneousLights: number;
  22792. /**
  22793. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22794. */
  22795. protected _invertNormalMapX: boolean;
  22796. /**
  22797. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22798. */
  22799. protected _invertNormalMapY: boolean;
  22800. /**
  22801. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22802. */
  22803. protected _twoSidedLighting: boolean;
  22804. /**
  22805. * Defines the alpha limits in alpha test mode.
  22806. */
  22807. protected _alphaCutOff: number;
  22808. /**
  22809. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22810. */
  22811. protected _forceAlphaTest: boolean;
  22812. /**
  22813. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22814. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22815. */
  22816. protected _useAlphaFresnel: boolean;
  22817. /**
  22818. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22819. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22820. */
  22821. protected _useLinearAlphaFresnel: boolean;
  22822. /**
  22823. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22824. * from cos thetav and roughness:
  22825. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22826. */
  22827. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22828. /**
  22829. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22830. */
  22831. protected _forceIrradianceInFragment: boolean;
  22832. private _realTimeFiltering;
  22833. /**
  22834. * Enables realtime filtering on the texture.
  22835. */
  22836. get realTimeFiltering(): boolean;
  22837. set realTimeFiltering(b: boolean);
  22838. private _realTimeFilteringQuality;
  22839. /**
  22840. * Quality switch for realtime filtering
  22841. */
  22842. get realTimeFilteringQuality(): number;
  22843. set realTimeFilteringQuality(n: number);
  22844. /**
  22845. * Can this material render to several textures at once
  22846. */
  22847. get canRenderToMRT(): boolean;
  22848. /**
  22849. * Force normal to face away from face.
  22850. */
  22851. protected _forceNormalForward: boolean;
  22852. /**
  22853. * Enables specular anti aliasing in the PBR shader.
  22854. * It will both interacts on the Geometry for analytical and IBL lighting.
  22855. * It also prefilter the roughness map based on the bump values.
  22856. */
  22857. protected _enableSpecularAntiAliasing: boolean;
  22858. /**
  22859. * Default configuration related to image processing available in the PBR Material.
  22860. */
  22861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22862. /**
  22863. * Keep track of the image processing observer to allow dispose and replace.
  22864. */
  22865. private _imageProcessingObserver;
  22866. /**
  22867. * Attaches a new image processing configuration to the PBR Material.
  22868. * @param configuration
  22869. */
  22870. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22871. /**
  22872. * Stores the available render targets.
  22873. */
  22874. private _renderTargets;
  22875. /**
  22876. * Sets the global ambient color for the material used in lighting calculations.
  22877. */
  22878. private _globalAmbientColor;
  22879. /**
  22880. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22881. */
  22882. private _useLogarithmicDepth;
  22883. /**
  22884. * If set to true, no lighting calculations will be applied.
  22885. */
  22886. private _unlit;
  22887. private _debugMode;
  22888. /**
  22889. * @hidden
  22890. * This is reserved for the inspector.
  22891. * Defines the material debug mode.
  22892. * It helps seeing only some components of the material while troubleshooting.
  22893. */
  22894. debugMode: number;
  22895. /**
  22896. * @hidden
  22897. * This is reserved for the inspector.
  22898. * Specify from where on screen the debug mode should start.
  22899. * The value goes from -1 (full screen) to 1 (not visible)
  22900. * It helps with side by side comparison against the final render
  22901. * This defaults to -1
  22902. */
  22903. private debugLimit;
  22904. /**
  22905. * @hidden
  22906. * This is reserved for the inspector.
  22907. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22908. * You can use the factor to better multiply the final value.
  22909. */
  22910. private debugFactor;
  22911. /**
  22912. * Defines the clear coat layer parameters for the material.
  22913. */
  22914. readonly clearCoat: PBRClearCoatConfiguration;
  22915. /**
  22916. * Defines the anisotropic parameters for the material.
  22917. */
  22918. readonly anisotropy: PBRAnisotropicConfiguration;
  22919. /**
  22920. * Defines the BRDF parameters for the material.
  22921. */
  22922. readonly brdf: PBRBRDFConfiguration;
  22923. /**
  22924. * Defines the Sheen parameters for the material.
  22925. */
  22926. readonly sheen: PBRSheenConfiguration;
  22927. /**
  22928. * Defines the SubSurface parameters for the material.
  22929. */
  22930. readonly subSurface: PBRSubSurfaceConfiguration;
  22931. /**
  22932. * Defines additionnal PrePass parameters for the material.
  22933. */
  22934. readonly prePassConfiguration: PrePassConfiguration;
  22935. /**
  22936. * Defines the detail map parameters for the material.
  22937. */
  22938. readonly detailMap: DetailMapConfiguration;
  22939. protected _rebuildInParallel: boolean;
  22940. /**
  22941. * Instantiates a new PBRMaterial instance.
  22942. *
  22943. * @param name The material name
  22944. * @param scene The scene the material will be use in.
  22945. */
  22946. constructor(name: string, scene: Scene);
  22947. /**
  22948. * Gets a boolean indicating that current material needs to register RTT
  22949. */
  22950. get hasRenderTargetTextures(): boolean;
  22951. /**
  22952. * Gets the name of the material class.
  22953. */
  22954. getClassName(): string;
  22955. /**
  22956. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22957. */
  22958. get useLogarithmicDepth(): boolean;
  22959. /**
  22960. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22961. */
  22962. set useLogarithmicDepth(value: boolean);
  22963. /**
  22964. * Returns true if alpha blending should be disabled.
  22965. */
  22966. protected get _disableAlphaBlending(): boolean;
  22967. /**
  22968. * Specifies whether or not this material should be rendered in alpha blend mode.
  22969. */
  22970. needAlphaBlending(): boolean;
  22971. /**
  22972. * Specifies whether or not this material should be rendered in alpha test mode.
  22973. */
  22974. needAlphaTesting(): boolean;
  22975. /**
  22976. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22977. */
  22978. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22979. /**
  22980. * Specifies whether or not there is a usable alpha channel for transparency.
  22981. */
  22982. protected _hasAlphaChannel(): boolean;
  22983. /**
  22984. * Gets the texture used for the alpha test.
  22985. */
  22986. getAlphaTestTexture(): Nullable<BaseTexture>;
  22987. /**
  22988. * Specifies that the submesh is ready to be used.
  22989. * @param mesh - BJS mesh.
  22990. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22991. * @param useInstances - Specifies that instances should be used.
  22992. * @returns - boolean indicating that the submesh is ready or not.
  22993. */
  22994. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22995. /**
  22996. * Specifies if the material uses metallic roughness workflow.
  22997. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22998. */
  22999. isMetallicWorkflow(): boolean;
  23000. private _prepareEffect;
  23001. private _prepareDefines;
  23002. /**
  23003. * Force shader compilation
  23004. */
  23005. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  23006. /**
  23007. * Initializes the uniform buffer layout for the shader.
  23008. */
  23009. buildUniformLayout(): void;
  23010. /**
  23011. * Unbinds the material from the mesh
  23012. */
  23013. unbind(): void;
  23014. /**
  23015. * Binds the submesh data.
  23016. * @param world - The world matrix.
  23017. * @param mesh - The BJS mesh.
  23018. * @param subMesh - A submesh of the BJS mesh.
  23019. */
  23020. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23021. /**
  23022. * Returns the animatable textures.
  23023. * @returns - Array of animatable textures.
  23024. */
  23025. getAnimatables(): IAnimatable[];
  23026. /**
  23027. * Returns the texture used for reflections.
  23028. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  23029. */
  23030. private _getReflectionTexture;
  23031. /**
  23032. * Returns an array of the actively used textures.
  23033. * @returns - Array of BaseTextures
  23034. */
  23035. getActiveTextures(): BaseTexture[];
  23036. /**
  23037. * Checks to see if a texture is used in the material.
  23038. * @param texture - Base texture to use.
  23039. * @returns - Boolean specifying if a texture is used in the material.
  23040. */
  23041. hasTexture(texture: BaseTexture): boolean;
  23042. /**
  23043. * Sets the required values to the prepass renderer.
  23044. * @param prePassRenderer defines the prepass renderer to setup
  23045. */
  23046. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23047. /**
  23048. * Disposes the resources of the material.
  23049. * @param forceDisposeEffect - Forces the disposal of effects.
  23050. * @param forceDisposeTextures - Forces the disposal of all textures.
  23051. */
  23052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23053. }
  23054. }
  23055. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  23056. import { Nullable } from "babylonjs/types";
  23057. import { Scene } from "babylonjs/scene";
  23058. import { Color3 } from "babylonjs/Maths/math.color";
  23059. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23060. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23062. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  23063. /**
  23064. * The Physically based material of BJS.
  23065. *
  23066. * This offers the main features of a standard PBR material.
  23067. * For more information, please refer to the documentation :
  23068. * https://doc.babylonjs.com/how_to/physically_based_rendering
  23069. */
  23070. export class PBRMaterial extends PBRBaseMaterial {
  23071. /**
  23072. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23073. */
  23074. static readonly PBRMATERIAL_OPAQUE: number;
  23075. /**
  23076. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23077. */
  23078. static readonly PBRMATERIAL_ALPHATEST: number;
  23079. /**
  23080. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23081. */
  23082. static readonly PBRMATERIAL_ALPHABLEND: number;
  23083. /**
  23084. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23085. * They are also discarded below the alpha cutoff threshold to improve performances.
  23086. */
  23087. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23088. /**
  23089. * Defines the default value of how much AO map is occluding the analytical lights
  23090. * (point spot...).
  23091. */
  23092. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  23093. /**
  23094. * Intensity of the direct lights e.g. the four lights available in your scene.
  23095. * This impacts both the direct diffuse and specular highlights.
  23096. */
  23097. directIntensity: number;
  23098. /**
  23099. * Intensity of the emissive part of the material.
  23100. * This helps controlling the emissive effect without modifying the emissive color.
  23101. */
  23102. emissiveIntensity: number;
  23103. /**
  23104. * Intensity of the environment e.g. how much the environment will light the object
  23105. * either through harmonics for rough material or through the refelction for shiny ones.
  23106. */
  23107. environmentIntensity: number;
  23108. /**
  23109. * This is a special control allowing the reduction of the specular highlights coming from the
  23110. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23111. */
  23112. specularIntensity: number;
  23113. /**
  23114. * Debug Control allowing disabling the bump map on this material.
  23115. */
  23116. disableBumpMap: boolean;
  23117. /**
  23118. * AKA Diffuse Texture in standard nomenclature.
  23119. */
  23120. albedoTexture: BaseTexture;
  23121. /**
  23122. * AKA Occlusion Texture in other nomenclature.
  23123. */
  23124. ambientTexture: BaseTexture;
  23125. /**
  23126. * AKA Occlusion Texture Intensity in other nomenclature.
  23127. */
  23128. ambientTextureStrength: number;
  23129. /**
  23130. * Defines how much the AO map is occluding the analytical lights (point spot...).
  23131. * 1 means it completely occludes it
  23132. * 0 mean it has no impact
  23133. */
  23134. ambientTextureImpactOnAnalyticalLights: number;
  23135. /**
  23136. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  23137. */
  23138. opacityTexture: BaseTexture;
  23139. /**
  23140. * Stores the reflection values in a texture.
  23141. */
  23142. reflectionTexture: Nullable<BaseTexture>;
  23143. /**
  23144. * Stores the emissive values in a texture.
  23145. */
  23146. emissiveTexture: BaseTexture;
  23147. /**
  23148. * AKA Specular texture in other nomenclature.
  23149. */
  23150. reflectivityTexture: BaseTexture;
  23151. /**
  23152. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23153. */
  23154. metallicTexture: BaseTexture;
  23155. /**
  23156. * Specifies the metallic scalar of the metallic/roughness workflow.
  23157. * Can also be used to scale the metalness values of the metallic texture.
  23158. */
  23159. metallic: Nullable<number>;
  23160. /**
  23161. * Specifies the roughness scalar of the metallic/roughness workflow.
  23162. * Can also be used to scale the roughness values of the metallic texture.
  23163. */
  23164. roughness: Nullable<number>;
  23165. /**
  23166. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  23167. * By default the indexOfrefraction is used to compute F0;
  23168. *
  23169. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  23170. *
  23171. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  23172. * F90 = metallicReflectanceColor;
  23173. */
  23174. metallicF0Factor: number;
  23175. /**
  23176. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  23177. * By default the F90 is always 1;
  23178. *
  23179. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  23180. *
  23181. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  23182. * F90 = metallicReflectanceColor;
  23183. */
  23184. metallicReflectanceColor: Color3;
  23185. /**
  23186. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  23187. * This is multiply against the scalar values defined in the material.
  23188. */
  23189. metallicReflectanceTexture: Nullable<BaseTexture>;
  23190. /**
  23191. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  23192. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23193. */
  23194. microSurfaceTexture: BaseTexture;
  23195. /**
  23196. * Stores surface normal data used to displace a mesh in a texture.
  23197. */
  23198. bumpTexture: BaseTexture;
  23199. /**
  23200. * Stores the pre-calculated light information of a mesh in a texture.
  23201. */
  23202. lightmapTexture: BaseTexture;
  23203. /**
  23204. * Stores the refracted light information in a texture.
  23205. */
  23206. get refractionTexture(): Nullable<BaseTexture>;
  23207. set refractionTexture(value: Nullable<BaseTexture>);
  23208. /**
  23209. * The color of a material in ambient lighting.
  23210. */
  23211. ambientColor: Color3;
  23212. /**
  23213. * AKA Diffuse Color in other nomenclature.
  23214. */
  23215. albedoColor: Color3;
  23216. /**
  23217. * AKA Specular Color in other nomenclature.
  23218. */
  23219. reflectivityColor: Color3;
  23220. /**
  23221. * The color reflected from the material.
  23222. */
  23223. reflectionColor: Color3;
  23224. /**
  23225. * The color emitted from the material.
  23226. */
  23227. emissiveColor: Color3;
  23228. /**
  23229. * AKA Glossiness in other nomenclature.
  23230. */
  23231. microSurface: number;
  23232. /**
  23233. * Index of refraction of the material base layer.
  23234. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  23235. *
  23236. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  23237. *
  23238. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  23239. */
  23240. get indexOfRefraction(): number;
  23241. set indexOfRefraction(value: number);
  23242. /**
  23243. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  23244. */
  23245. get invertRefractionY(): boolean;
  23246. set invertRefractionY(value: boolean);
  23247. /**
  23248. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23249. * Materials half opaque for instance using refraction could benefit from this control.
  23250. */
  23251. get linkRefractionWithTransparency(): boolean;
  23252. set linkRefractionWithTransparency(value: boolean);
  23253. /**
  23254. * If true, the light map contains occlusion information instead of lighting info.
  23255. */
  23256. useLightmapAsShadowmap: boolean;
  23257. /**
  23258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23259. */
  23260. useAlphaFromAlbedoTexture: boolean;
  23261. /**
  23262. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23263. */
  23264. forceAlphaTest: boolean;
  23265. /**
  23266. * Defines the alpha limits in alpha test mode.
  23267. */
  23268. alphaCutOff: number;
  23269. /**
  23270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23272. */
  23273. useSpecularOverAlpha: boolean;
  23274. /**
  23275. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23276. */
  23277. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23278. /**
  23279. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23280. */
  23281. useRoughnessFromMetallicTextureAlpha: boolean;
  23282. /**
  23283. * Specifies if the metallic texture contains the roughness information in its green channel.
  23284. */
  23285. useRoughnessFromMetallicTextureGreen: boolean;
  23286. /**
  23287. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23288. */
  23289. useMetallnessFromMetallicTextureBlue: boolean;
  23290. /**
  23291. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23292. */
  23293. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23294. /**
  23295. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23296. */
  23297. useAmbientInGrayScale: boolean;
  23298. /**
  23299. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23300. * The material will try to infer what glossiness each pixel should be.
  23301. */
  23302. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23303. /**
  23304. * BJS is using an harcoded light falloff based on a manually sets up range.
  23305. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23306. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23307. */
  23308. get usePhysicalLightFalloff(): boolean;
  23309. /**
  23310. * BJS is using an harcoded light falloff based on a manually sets up range.
  23311. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23312. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23313. */
  23314. set usePhysicalLightFalloff(value: boolean);
  23315. /**
  23316. * In order to support the falloff compatibility with gltf, a special mode has been added
  23317. * to reproduce the gltf light falloff.
  23318. */
  23319. get useGLTFLightFalloff(): boolean;
  23320. /**
  23321. * In order to support the falloff compatibility with gltf, a special mode has been added
  23322. * to reproduce the gltf light falloff.
  23323. */
  23324. set useGLTFLightFalloff(value: boolean);
  23325. /**
  23326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23328. */
  23329. useRadianceOverAlpha: boolean;
  23330. /**
  23331. * Allows using an object space normal map (instead of tangent space).
  23332. */
  23333. useObjectSpaceNormalMap: boolean;
  23334. /**
  23335. * Allows using the bump map in parallax mode.
  23336. */
  23337. useParallax: boolean;
  23338. /**
  23339. * Allows using the bump map in parallax occlusion mode.
  23340. */
  23341. useParallaxOcclusion: boolean;
  23342. /**
  23343. * Controls the scale bias of the parallax mode.
  23344. */
  23345. parallaxScaleBias: number;
  23346. /**
  23347. * If sets to true, disables all the lights affecting the material.
  23348. */
  23349. disableLighting: boolean;
  23350. /**
  23351. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23352. */
  23353. forceIrradianceInFragment: boolean;
  23354. /**
  23355. * Number of Simultaneous lights allowed on the material.
  23356. */
  23357. maxSimultaneousLights: number;
  23358. /**
  23359. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23360. */
  23361. invertNormalMapX: boolean;
  23362. /**
  23363. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23364. */
  23365. invertNormalMapY: boolean;
  23366. /**
  23367. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23368. */
  23369. twoSidedLighting: boolean;
  23370. /**
  23371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23372. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23373. */
  23374. useAlphaFresnel: boolean;
  23375. /**
  23376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23377. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23378. */
  23379. useLinearAlphaFresnel: boolean;
  23380. /**
  23381. * Let user defines the brdf lookup texture used for IBL.
  23382. * A default 8bit version is embedded but you could point at :
  23383. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23384. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23385. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23386. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23387. */
  23388. environmentBRDFTexture: Nullable<BaseTexture>;
  23389. /**
  23390. * Force normal to face away from face.
  23391. */
  23392. forceNormalForward: boolean;
  23393. /**
  23394. * Enables specular anti aliasing in the PBR shader.
  23395. * It will both interacts on the Geometry for analytical and IBL lighting.
  23396. * It also prefilter the roughness map based on the bump values.
  23397. */
  23398. enableSpecularAntiAliasing: boolean;
  23399. /**
  23400. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23401. * makes the reflect vector face the model (under horizon).
  23402. */
  23403. useHorizonOcclusion: boolean;
  23404. /**
  23405. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23406. * too much the area relying on ambient texture to define their ambient occlusion.
  23407. */
  23408. useRadianceOcclusion: boolean;
  23409. /**
  23410. * If set to true, no lighting calculations will be applied.
  23411. */
  23412. unlit: boolean;
  23413. /**
  23414. * Gets the image processing configuration used either in this material.
  23415. */
  23416. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23417. /**
  23418. * Sets the Default image processing configuration used either in the this material.
  23419. *
  23420. * If sets to null, the scene one is in use.
  23421. */
  23422. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23423. /**
  23424. * Gets wether the color curves effect is enabled.
  23425. */
  23426. get cameraColorCurvesEnabled(): boolean;
  23427. /**
  23428. * Sets wether the color curves effect is enabled.
  23429. */
  23430. set cameraColorCurvesEnabled(value: boolean);
  23431. /**
  23432. * Gets wether the color grading effect is enabled.
  23433. */
  23434. get cameraColorGradingEnabled(): boolean;
  23435. /**
  23436. * Gets wether the color grading effect is enabled.
  23437. */
  23438. set cameraColorGradingEnabled(value: boolean);
  23439. /**
  23440. * Gets wether tonemapping is enabled or not.
  23441. */
  23442. get cameraToneMappingEnabled(): boolean;
  23443. /**
  23444. * Sets wether tonemapping is enabled or not
  23445. */
  23446. set cameraToneMappingEnabled(value: boolean);
  23447. /**
  23448. * The camera exposure used on this material.
  23449. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23450. * This corresponds to a photographic exposure.
  23451. */
  23452. get cameraExposure(): number;
  23453. /**
  23454. * The camera exposure used on this material.
  23455. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23456. * This corresponds to a photographic exposure.
  23457. */
  23458. set cameraExposure(value: number);
  23459. /**
  23460. * Gets The camera contrast used on this material.
  23461. */
  23462. get cameraContrast(): number;
  23463. /**
  23464. * Sets The camera contrast used on this material.
  23465. */
  23466. set cameraContrast(value: number);
  23467. /**
  23468. * Gets the Color Grading 2D Lookup Texture.
  23469. */
  23470. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23471. /**
  23472. * Sets the Color Grading 2D Lookup Texture.
  23473. */
  23474. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23475. /**
  23476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23478. * 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;
  23479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23480. */
  23481. get cameraColorCurves(): Nullable<ColorCurves>;
  23482. /**
  23483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23485. * 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;
  23486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23487. */
  23488. set cameraColorCurves(value: Nullable<ColorCurves>);
  23489. /**
  23490. * Instantiates a new PBRMaterial instance.
  23491. *
  23492. * @param name The material name
  23493. * @param scene The scene the material will be use in.
  23494. */
  23495. constructor(name: string, scene: Scene);
  23496. /**
  23497. * Returns the name of this material class.
  23498. */
  23499. getClassName(): string;
  23500. /**
  23501. * Makes a duplicate of the current material.
  23502. * @param name - name to use for the new material.
  23503. */
  23504. clone(name: string): PBRMaterial;
  23505. /**
  23506. * Serializes this PBR Material.
  23507. * @returns - An object with the serialized material.
  23508. */
  23509. serialize(): any;
  23510. /**
  23511. * Parses a PBR Material from a serialized object.
  23512. * @param source - Serialized object.
  23513. * @param scene - BJS scene instance.
  23514. * @param rootUrl - url for the scene object
  23515. * @returns - PBRMaterial
  23516. */
  23517. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23518. }
  23519. }
  23520. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  23521. /** @hidden */
  23522. export var mrtFragmentDeclaration: {
  23523. name: string;
  23524. shader: string;
  23525. };
  23526. }
  23527. declare module "babylonjs/Shaders/geometry.fragment" {
  23528. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  23529. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  23530. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  23531. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  23532. /** @hidden */
  23533. export var geometryPixelShader: {
  23534. name: string;
  23535. shader: string;
  23536. };
  23537. }
  23538. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  23539. /** @hidden */
  23540. export var instancesDeclaration: {
  23541. name: string;
  23542. shader: string;
  23543. };
  23544. }
  23545. declare module "babylonjs/Shaders/geometry.vertex" {
  23546. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  23547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  23548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  23549. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  23550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  23551. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  23552. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  23553. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  23554. /** @hidden */
  23555. export var geometryVertexShader: {
  23556. name: string;
  23557. shader: string;
  23558. };
  23559. }
  23560. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  23561. import { Matrix } from "babylonjs/Maths/math.vector";
  23562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23564. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23565. import { Effect } from "babylonjs/Materials/effect";
  23566. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23567. import { Scene } from "babylonjs/scene";
  23568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23569. import { Nullable } from "babylonjs/types";
  23570. import "babylonjs/Shaders/geometry.fragment";
  23571. import "babylonjs/Shaders/geometry.vertex";
  23572. /** @hidden */
  23573. interface ISavedTransformationMatrix {
  23574. world: Matrix;
  23575. viewProjection: Matrix;
  23576. }
  23577. /**
  23578. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23579. */
  23580. export class GeometryBufferRenderer {
  23581. /**
  23582. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  23583. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  23584. */
  23585. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  23586. /**
  23587. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23588. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23589. */
  23590. static readonly POSITION_TEXTURE_TYPE: number;
  23591. /**
  23592. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23593. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23594. */
  23595. static readonly VELOCITY_TEXTURE_TYPE: number;
  23596. /**
  23597. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23598. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23599. */
  23600. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23601. /**
  23602. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23603. * in order to compute objects velocities when enableVelocity is set to "true"
  23604. * @hidden
  23605. */
  23606. _previousTransformationMatrices: {
  23607. [index: number]: ISavedTransformationMatrix;
  23608. };
  23609. /**
  23610. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23611. * in order to compute objects velocities when enableVelocity is set to "true"
  23612. * @hidden
  23613. */
  23614. _previousBonesTransformationMatrices: {
  23615. [index: number]: Float32Array;
  23616. };
  23617. /**
  23618. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23619. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23620. */
  23621. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23622. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23623. renderTransparentMeshes: boolean;
  23624. private _scene;
  23625. private _resizeObserver;
  23626. private _multiRenderTarget;
  23627. private _ratio;
  23628. private _enablePosition;
  23629. private _enableVelocity;
  23630. private _enableReflectivity;
  23631. private _positionIndex;
  23632. private _velocityIndex;
  23633. private _reflectivityIndex;
  23634. private _depthNormalIndex;
  23635. private _linkedWithPrePass;
  23636. private _prePassRenderer;
  23637. private _attachments;
  23638. protected _effect: Effect;
  23639. protected _cachedDefines: string;
  23640. /**
  23641. * @hidden
  23642. * Sets up internal structures to share outputs with PrePassRenderer
  23643. * This method should only be called by the PrePassRenderer itself
  23644. */
  23645. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23646. /**
  23647. * @hidden
  23648. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23649. * This method should only be called by the PrePassRenderer itself
  23650. */
  23651. _unlinkPrePassRenderer(): void;
  23652. /**
  23653. * @hidden
  23654. * Resets the geometry buffer layout
  23655. */
  23656. _resetLayout(): void;
  23657. /**
  23658. * @hidden
  23659. * Replaces a texture in the geometry buffer renderer
  23660. * Useful when linking textures of the prepass renderer
  23661. */
  23662. _forceTextureType(geometryBufferType: number, index: number): void;
  23663. /**
  23664. * @hidden
  23665. * Sets texture attachments
  23666. * Useful when linking textures of the prepass renderer
  23667. */
  23668. _setAttachments(attachments: number[]): void;
  23669. /**
  23670. * @hidden
  23671. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23672. * Useful when linking textures of the prepass renderer
  23673. */
  23674. _linkInternalTexture(internalTexture: InternalTexture): void;
  23675. /**
  23676. * Gets the render list (meshes to be rendered) used in the G buffer.
  23677. */
  23678. get renderList(): Nullable<AbstractMesh[]>;
  23679. /**
  23680. * Set the render list (meshes to be rendered) used in the G buffer.
  23681. */
  23682. set renderList(meshes: Nullable<AbstractMesh[]>);
  23683. /**
  23684. * Gets wether or not G buffer are supported by the running hardware.
  23685. * This requires draw buffer supports
  23686. */
  23687. get isSupported(): boolean;
  23688. /**
  23689. * Returns the index of the given texture type in the G-Buffer textures array
  23690. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23691. * @returns the index of the given texture type in the G-Buffer textures array
  23692. */
  23693. getTextureIndex(textureType: number): number;
  23694. /**
  23695. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23696. */
  23697. get enablePosition(): boolean;
  23698. /**
  23699. * Sets whether or not objects positions are enabled for the G buffer.
  23700. */
  23701. set enablePosition(enable: boolean);
  23702. /**
  23703. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23704. */
  23705. get enableVelocity(): boolean;
  23706. /**
  23707. * Sets wether or not objects velocities are enabled for the G buffer.
  23708. */
  23709. set enableVelocity(enable: boolean);
  23710. /**
  23711. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23712. */
  23713. get enableReflectivity(): boolean;
  23714. /**
  23715. * Sets wether or not objects roughness are enabled for the G buffer.
  23716. */
  23717. set enableReflectivity(enable: boolean);
  23718. /**
  23719. * Gets the scene associated with the buffer.
  23720. */
  23721. get scene(): Scene;
  23722. /**
  23723. * Gets the ratio used by the buffer during its creation.
  23724. * How big is the buffer related to the main canvas.
  23725. */
  23726. get ratio(): number;
  23727. /** @hidden */
  23728. static _SceneComponentInitialization: (scene: Scene) => void;
  23729. /**
  23730. * Creates a new G Buffer for the scene
  23731. * @param scene The scene the buffer belongs to
  23732. * @param ratio How big is the buffer related to the main canvas.
  23733. */
  23734. constructor(scene: Scene, ratio?: number);
  23735. /**
  23736. * Checks wether everything is ready to render a submesh to the G buffer.
  23737. * @param subMesh the submesh to check readiness for
  23738. * @param useInstances is the mesh drawn using instance or not
  23739. * @returns true if ready otherwise false
  23740. */
  23741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23742. /**
  23743. * Gets the current underlying G Buffer.
  23744. * @returns the buffer
  23745. */
  23746. getGBuffer(): MultiRenderTarget;
  23747. /**
  23748. * Gets the number of samples used to render the buffer (anti aliasing).
  23749. */
  23750. get samples(): number;
  23751. /**
  23752. * Sets the number of samples used to render the buffer (anti aliasing).
  23753. */
  23754. set samples(value: number);
  23755. /**
  23756. * Disposes the renderer and frees up associated resources.
  23757. */
  23758. dispose(): void;
  23759. private _assignRenderTargetIndices;
  23760. protected _createRenderTargets(): void;
  23761. private _copyBonesTransformationMatrices;
  23762. }
  23763. }
  23764. declare module "babylonjs/Rendering/prePassRenderer" {
  23765. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23766. import { Scene } from "babylonjs/scene";
  23767. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23768. import { Effect } from "babylonjs/Materials/effect";
  23769. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23771. import { Material } from "babylonjs/Materials/material";
  23772. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23773. /**
  23774. * Renders a pre pass of the scene
  23775. * This means every mesh in the scene will be rendered to a render target texture
  23776. * And then this texture will be composited to the rendering canvas with post processes
  23777. * It is necessary for effects like subsurface scattering or deferred shading
  23778. */
  23779. export class PrePassRenderer {
  23780. /** @hidden */
  23781. static _SceneComponentInitialization: (scene: Scene) => void;
  23782. private _textureFormats;
  23783. /**
  23784. * To save performance, we can excluded skinned meshes from the prepass
  23785. */
  23786. excludedSkinnedMesh: AbstractMesh[];
  23787. /**
  23788. * Force material to be excluded from the prepass
  23789. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23790. * and you don't want a material to show in the effect.
  23791. */
  23792. excludedMaterials: Material[];
  23793. private _textureIndices;
  23794. private _scene;
  23795. private _engine;
  23796. private _isDirty;
  23797. /**
  23798. * Number of textures in the multi render target texture where the scene is directly rendered
  23799. */
  23800. mrtCount: number;
  23801. /**
  23802. * The render target where the scene is directly rendered
  23803. */
  23804. prePassRT: MultiRenderTarget;
  23805. private _multiRenderAttachments;
  23806. private _defaultAttachments;
  23807. private _postProcesses;
  23808. private readonly _clearColor;
  23809. /**
  23810. * Image processing post process for composition
  23811. */
  23812. imageProcessingPostProcess: ImageProcessingPostProcess;
  23813. /**
  23814. * Configuration for prepass effects
  23815. */
  23816. private _effectConfigurations;
  23817. private _mrtFormats;
  23818. private _mrtLayout;
  23819. private _enabled;
  23820. /**
  23821. * Indicates if the prepass is enabled
  23822. */
  23823. get enabled(): boolean;
  23824. /**
  23825. * How many samples are used for MSAA of the scene render target
  23826. */
  23827. get samples(): number;
  23828. set samples(n: number);
  23829. private _geometryBuffer;
  23830. private _useGeometryBufferFallback;
  23831. /**
  23832. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23833. */
  23834. get useGeometryBufferFallback(): boolean;
  23835. set useGeometryBufferFallback(value: boolean);
  23836. /**
  23837. * Set to true to disable gamma transform in PrePass.
  23838. * Can be useful in case you already proceed to gamma transform on a material level
  23839. * and your post processes don't need to be in linear color space.
  23840. */
  23841. disableGammaTransform: boolean;
  23842. /**
  23843. * Instanciates a prepass renderer
  23844. * @param scene The scene
  23845. */
  23846. constructor(scene: Scene);
  23847. private _initializeAttachments;
  23848. private _createCompositionEffect;
  23849. /**
  23850. * Indicates if rendering a prepass is supported
  23851. */
  23852. get isSupported(): boolean;
  23853. /**
  23854. * Sets the proper output textures to draw in the engine.
  23855. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23856. * @param subMesh Submesh on which the effect is applied
  23857. */
  23858. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23859. /**
  23860. * Restores attachments for single texture draw.
  23861. */
  23862. restoreAttachments(): void;
  23863. /**
  23864. * @hidden
  23865. */
  23866. _beforeCameraDraw(): void;
  23867. /**
  23868. * @hidden
  23869. */
  23870. _afterCameraDraw(): void;
  23871. private _checkRTSize;
  23872. private _bindFrameBuffer;
  23873. /**
  23874. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23875. */
  23876. clear(): void;
  23877. private _setState;
  23878. private _updateGeometryBufferLayout;
  23879. /**
  23880. * Adds an effect configuration to the prepass.
  23881. * If an effect has already been added, it won't add it twice and will return the configuration
  23882. * already present.
  23883. * @param cfg the effect configuration
  23884. * @return the effect configuration now used by the prepass
  23885. */
  23886. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23887. /**
  23888. * Returns the index of a texture in the multi render target texture array.
  23889. * @param type Texture type
  23890. * @return The index
  23891. */
  23892. getIndex(type: number): number;
  23893. private _enable;
  23894. private _disable;
  23895. private _resetLayout;
  23896. private _resetPostProcessChain;
  23897. private _bindPostProcessChain;
  23898. /**
  23899. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23900. */
  23901. markAsDirty(): void;
  23902. /**
  23903. * Enables a texture on the MultiRenderTarget for prepass
  23904. */
  23905. private _enableTextures;
  23906. private _update;
  23907. private _markAllMaterialsAsPrePassDirty;
  23908. /**
  23909. * Disposes the prepass renderer.
  23910. */
  23911. dispose(): void;
  23912. }
  23913. }
  23914. declare module "babylonjs/PostProcesses/postProcess" {
  23915. import { Nullable } from "babylonjs/types";
  23916. import { SmartArray } from "babylonjs/Misc/smartArray";
  23917. import { Observable } from "babylonjs/Misc/observable";
  23918. import { Vector2 } from "babylonjs/Maths/math.vector";
  23919. import { Camera } from "babylonjs/Cameras/camera";
  23920. import { Effect } from "babylonjs/Materials/effect";
  23921. import "babylonjs/Shaders/postprocess.vertex";
  23922. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23923. import { Engine } from "babylonjs/Engines/engine";
  23924. import { Color4 } from "babylonjs/Maths/math.color";
  23925. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23926. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23927. import { Scene } from "babylonjs/scene";
  23928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23929. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23930. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23931. /**
  23932. * Size options for a post process
  23933. */
  23934. export type PostProcessOptions = {
  23935. width: number;
  23936. height: number;
  23937. };
  23938. /**
  23939. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23940. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23941. */
  23942. export class PostProcess {
  23943. /**
  23944. * Gets or sets the unique id of the post process
  23945. */
  23946. uniqueId: number;
  23947. /** Name of the PostProcess. */
  23948. name: string;
  23949. /**
  23950. * Width of the texture to apply the post process on
  23951. */
  23952. width: number;
  23953. /**
  23954. * Height of the texture to apply the post process on
  23955. */
  23956. height: number;
  23957. /**
  23958. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23959. */
  23960. nodeMaterialSource: Nullable<NodeMaterial>;
  23961. /**
  23962. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23963. * @hidden
  23964. */
  23965. _outputTexture: Nullable<InternalTexture>;
  23966. /**
  23967. * Sampling mode used by the shader
  23968. * See https://doc.babylonjs.com/classes/3.1/texture
  23969. */
  23970. renderTargetSamplingMode: number;
  23971. /**
  23972. * Clear color to use when screen clearing
  23973. */
  23974. clearColor: Color4;
  23975. /**
  23976. * If the buffer needs to be cleared before applying the post process. (default: true)
  23977. * Should be set to false if shader will overwrite all previous pixels.
  23978. */
  23979. autoClear: boolean;
  23980. /**
  23981. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23982. */
  23983. alphaMode: number;
  23984. /**
  23985. * Sets the setAlphaBlendConstants of the babylon engine
  23986. */
  23987. alphaConstants: Color4;
  23988. /**
  23989. * Animations to be used for the post processing
  23990. */
  23991. animations: import("babylonjs/Animations/animation").Animation[];
  23992. /**
  23993. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23994. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23995. */
  23996. enablePixelPerfectMode: boolean;
  23997. /**
  23998. * Force the postprocess to be applied without taking in account viewport
  23999. */
  24000. forceFullscreenViewport: boolean;
  24001. /**
  24002. * List of inspectable custom properties (used by the Inspector)
  24003. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24004. */
  24005. inspectableCustomProperties: IInspectable[];
  24006. /**
  24007. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24008. *
  24009. * | Value | Type | Description |
  24010. * | ----- | ----------------------------------- | ----------- |
  24011. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24012. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24013. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24014. *
  24015. */
  24016. scaleMode: number;
  24017. /**
  24018. * Force textures to be a power of two (default: false)
  24019. */
  24020. alwaysForcePOT: boolean;
  24021. private _samples;
  24022. /**
  24023. * Number of sample textures (default: 1)
  24024. */
  24025. get samples(): number;
  24026. set samples(n: number);
  24027. /**
  24028. * Modify the scale of the post process to be the same as the viewport (default: false)
  24029. */
  24030. adaptScaleToCurrentViewport: boolean;
  24031. private _camera;
  24032. protected _scene: Scene;
  24033. private _engine;
  24034. private _options;
  24035. private _reusable;
  24036. private _textureType;
  24037. private _textureFormat;
  24038. /**
  24039. * Smart array of input and output textures for the post process.
  24040. * @hidden
  24041. */
  24042. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24043. /**
  24044. * The index in _textures that corresponds to the output texture.
  24045. * @hidden
  24046. */
  24047. _currentRenderTextureInd: number;
  24048. private _effect;
  24049. private _samplers;
  24050. private _fragmentUrl;
  24051. private _vertexUrl;
  24052. private _parameters;
  24053. private _scaleRatio;
  24054. protected _indexParameters: any;
  24055. private _shareOutputWithPostProcess;
  24056. private _texelSize;
  24057. private _forcedOutputTexture;
  24058. /**
  24059. * Prepass configuration in case this post process needs a texture from prepass
  24060. * @hidden
  24061. */
  24062. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24063. /**
  24064. * Returns the fragment url or shader name used in the post process.
  24065. * @returns the fragment url or name in the shader store.
  24066. */
  24067. getEffectName(): string;
  24068. /**
  24069. * An event triggered when the postprocess is activated.
  24070. */
  24071. onActivateObservable: Observable<Camera>;
  24072. private _onActivateObserver;
  24073. /**
  24074. * A function that is added to the onActivateObservable
  24075. */
  24076. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24077. /**
  24078. * An event triggered when the postprocess changes its size.
  24079. */
  24080. onSizeChangedObservable: Observable<PostProcess>;
  24081. private _onSizeChangedObserver;
  24082. /**
  24083. * A function that is added to the onSizeChangedObservable
  24084. */
  24085. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24086. /**
  24087. * An event triggered when the postprocess applies its effect.
  24088. */
  24089. onApplyObservable: Observable<Effect>;
  24090. private _onApplyObserver;
  24091. /**
  24092. * A function that is added to the onApplyObservable
  24093. */
  24094. set onApply(callback: (effect: Effect) => void);
  24095. /**
  24096. * An event triggered before rendering the postprocess
  24097. */
  24098. onBeforeRenderObservable: Observable<Effect>;
  24099. private _onBeforeRenderObserver;
  24100. /**
  24101. * A function that is added to the onBeforeRenderObservable
  24102. */
  24103. set onBeforeRender(callback: (effect: Effect) => void);
  24104. /**
  24105. * An event triggered after rendering the postprocess
  24106. */
  24107. onAfterRenderObservable: Observable<Effect>;
  24108. private _onAfterRenderObserver;
  24109. /**
  24110. * A function that is added to the onAfterRenderObservable
  24111. */
  24112. set onAfterRender(callback: (efect: Effect) => void);
  24113. /**
  24114. * 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
  24115. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24116. */
  24117. get inputTexture(): InternalTexture;
  24118. set inputTexture(value: InternalTexture);
  24119. /**
  24120. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24121. * the only way to unset it is to use this function to restore its internal state
  24122. */
  24123. restoreDefaultInputTexture(): void;
  24124. /**
  24125. * Gets the camera which post process is applied to.
  24126. * @returns The camera the post process is applied to.
  24127. */
  24128. getCamera(): Camera;
  24129. /**
  24130. * Gets the texel size of the postprocess.
  24131. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24132. */
  24133. get texelSize(): Vector2;
  24134. /**
  24135. * Creates a new instance PostProcess
  24136. * @param name The name of the PostProcess.
  24137. * @param fragmentUrl The url of the fragment shader to be used.
  24138. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24139. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24140. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24141. * @param camera The camera to apply the render pass to.
  24142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24143. * @param engine The engine which the post process will be applied. (default: current engine)
  24144. * @param reusable If the post process can be reused on the same frame. (default: false)
  24145. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24146. * @param textureType Type of textures used when performing the post process. (default: 0)
  24147. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24148. * @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
  24149. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24150. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24151. */
  24152. 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);
  24153. /**
  24154. * Gets a string identifying the name of the class
  24155. * @returns "PostProcess" string
  24156. */
  24157. getClassName(): string;
  24158. /**
  24159. * Gets the engine which this post process belongs to.
  24160. * @returns The engine the post process was enabled with.
  24161. */
  24162. getEngine(): Engine;
  24163. /**
  24164. * The effect that is created when initializing the post process.
  24165. * @returns The created effect corresponding the the postprocess.
  24166. */
  24167. getEffect(): Effect;
  24168. /**
  24169. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24170. * @param postProcess The post process to share the output with.
  24171. * @returns This post process.
  24172. */
  24173. shareOutputWith(postProcess: PostProcess): PostProcess;
  24174. /**
  24175. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24176. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24177. */
  24178. useOwnOutput(): void;
  24179. /**
  24180. * Updates the effect with the current post process compile time values and recompiles the shader.
  24181. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24182. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24183. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24184. * @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
  24185. * @param onCompiled Called when the shader has been compiled.
  24186. * @param onError Called if there is an error when compiling a shader.
  24187. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24188. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24189. */
  24190. 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;
  24191. /**
  24192. * The post process is reusable if it can be used multiple times within one frame.
  24193. * @returns If the post process is reusable
  24194. */
  24195. isReusable(): boolean;
  24196. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24197. markTextureDirty(): void;
  24198. /**
  24199. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24200. * 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.
  24201. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24202. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24203. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24204. * @returns The target texture that was bound to be written to.
  24205. */
  24206. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24207. /**
  24208. * If the post process is supported.
  24209. */
  24210. get isSupported(): boolean;
  24211. /**
  24212. * The aspect ratio of the output texture.
  24213. */
  24214. get aspectRatio(): number;
  24215. /**
  24216. * Get a value indicating if the post-process is ready to be used
  24217. * @returns true if the post-process is ready (shader is compiled)
  24218. */
  24219. isReady(): boolean;
  24220. /**
  24221. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24222. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24223. */
  24224. apply(): Nullable<Effect>;
  24225. private _disposeTextures;
  24226. /**
  24227. * Sets the required values to the prepass renderer.
  24228. * @param prePassRenderer defines the prepass renderer to setup.
  24229. * @returns true if the pre pass is needed.
  24230. */
  24231. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24232. /**
  24233. * Disposes the post process.
  24234. * @param camera The camera to dispose the post process on.
  24235. */
  24236. dispose(camera?: Camera): void;
  24237. /**
  24238. * Serializes the particle system to a JSON object
  24239. * @returns the JSON object
  24240. */
  24241. serialize(): any;
  24242. /**
  24243. * Creates a material from parsed material data
  24244. * @param parsedPostProcess defines parsed post process data
  24245. * @param scene defines the hosting scene
  24246. * @param rootUrl defines the root URL to use to load textures
  24247. * @returns a new post process
  24248. */
  24249. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24250. }
  24251. }
  24252. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24253. /** @hidden */
  24254. export var kernelBlurVaryingDeclaration: {
  24255. name: string;
  24256. shader: string;
  24257. };
  24258. }
  24259. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  24260. /** @hidden */
  24261. export var packingFunctions: {
  24262. name: string;
  24263. shader: string;
  24264. };
  24265. }
  24266. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24267. /** @hidden */
  24268. export var kernelBlurFragment: {
  24269. name: string;
  24270. shader: string;
  24271. };
  24272. }
  24273. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24274. /** @hidden */
  24275. export var kernelBlurFragment2: {
  24276. name: string;
  24277. shader: string;
  24278. };
  24279. }
  24280. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24281. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24282. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24283. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24284. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24285. /** @hidden */
  24286. export var kernelBlurPixelShader: {
  24287. name: string;
  24288. shader: string;
  24289. };
  24290. }
  24291. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24292. /** @hidden */
  24293. export var kernelBlurVertex: {
  24294. name: string;
  24295. shader: string;
  24296. };
  24297. }
  24298. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24299. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24300. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24301. /** @hidden */
  24302. export var kernelBlurVertexShader: {
  24303. name: string;
  24304. shader: string;
  24305. };
  24306. }
  24307. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24308. import { Vector2 } from "babylonjs/Maths/math.vector";
  24309. import { Nullable } from "babylonjs/types";
  24310. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24311. import { Camera } from "babylonjs/Cameras/camera";
  24312. import { Effect } from "babylonjs/Materials/effect";
  24313. import { Engine } from "babylonjs/Engines/engine";
  24314. import "babylonjs/Shaders/kernelBlur.fragment";
  24315. import "babylonjs/Shaders/kernelBlur.vertex";
  24316. import { Scene } from "babylonjs/scene";
  24317. /**
  24318. * The Blur Post Process which blurs an image based on a kernel and direction.
  24319. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24320. */
  24321. export class BlurPostProcess extends PostProcess {
  24322. private blockCompilation;
  24323. protected _kernel: number;
  24324. protected _idealKernel: number;
  24325. protected _packedFloat: boolean;
  24326. private _staticDefines;
  24327. /** The direction in which to blur the image. */
  24328. direction: Vector2;
  24329. /**
  24330. * Sets the length in pixels of the blur sample region
  24331. */
  24332. set kernel(v: number);
  24333. /**
  24334. * Gets the length in pixels of the blur sample region
  24335. */
  24336. get kernel(): number;
  24337. /**
  24338. * Sets wether or not the blur needs to unpack/repack floats
  24339. */
  24340. set packedFloat(v: boolean);
  24341. /**
  24342. * Gets wether or not the blur is unpacking/repacking floats
  24343. */
  24344. get packedFloat(): boolean;
  24345. /**
  24346. * Gets a string identifying the name of the class
  24347. * @returns "BlurPostProcess" string
  24348. */
  24349. getClassName(): string;
  24350. /**
  24351. * Creates a new instance BlurPostProcess
  24352. * @param name The name of the effect.
  24353. * @param direction The direction in which to blur the image.
  24354. * @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.
  24355. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24356. * @param camera The camera to apply the render pass to.
  24357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24358. * @param engine The engine which the post process will be applied. (default: current engine)
  24359. * @param reusable If the post process can be reused on the same frame. (default: false)
  24360. * @param textureType Type of textures used when performing the post process. (default: 0)
  24361. * @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)
  24362. */
  24363. 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);
  24364. /**
  24365. * Updates the effect with the current post process compile time values and recompiles the shader.
  24366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24369. * @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
  24370. * @param onCompiled Called when the shader has been compiled.
  24371. * @param onError Called if there is an error when compiling a shader.
  24372. */
  24373. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24374. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24375. /**
  24376. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24377. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24378. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24379. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24380. * The gaps between physical kernels are compensated for in the weighting of the samples
  24381. * @param idealKernel Ideal blur kernel.
  24382. * @return Nearest best kernel.
  24383. */
  24384. protected _nearestBestKernel(idealKernel: number): number;
  24385. /**
  24386. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24387. * @param x The point on the Gaussian distribution to sample.
  24388. * @return the value of the Gaussian function at x.
  24389. */
  24390. protected _gaussianWeight(x: number): number;
  24391. /**
  24392. * Generates a string that can be used as a floating point number in GLSL.
  24393. * @param x Value to print.
  24394. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24395. * @return GLSL float string.
  24396. */
  24397. protected _glslFloat(x: number, decimalFigures?: number): string;
  24398. /** @hidden */
  24399. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24400. }
  24401. }
  24402. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24403. import { Scene } from "babylonjs/scene";
  24404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24405. import { Plane } from "babylonjs/Maths/math.plane";
  24406. /**
  24407. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24408. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24409. * You can then easily use it as a reflectionTexture on a flat surface.
  24410. * In case the surface is not a plane, please consider relying on reflection probes.
  24411. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24412. */
  24413. export class MirrorTexture extends RenderTargetTexture {
  24414. private scene;
  24415. /**
  24416. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24417. * 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.
  24418. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24419. */
  24420. mirrorPlane: Plane;
  24421. /**
  24422. * Define the blur ratio used to blur the reflection if needed.
  24423. */
  24424. set blurRatio(value: number);
  24425. get blurRatio(): number;
  24426. /**
  24427. * Define the adaptive blur kernel used to blur the reflection if needed.
  24428. * This will autocompute the closest best match for the `blurKernel`
  24429. */
  24430. set adaptiveBlurKernel(value: number);
  24431. /**
  24432. * Define the blur kernel used to blur the reflection if needed.
  24433. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24434. */
  24435. set blurKernel(value: number);
  24436. /**
  24437. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24438. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24439. */
  24440. set blurKernelX(value: number);
  24441. get blurKernelX(): number;
  24442. /**
  24443. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24444. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24445. */
  24446. set blurKernelY(value: number);
  24447. get blurKernelY(): number;
  24448. private _autoComputeBlurKernel;
  24449. protected _onRatioRescale(): void;
  24450. private _updateGammaSpace;
  24451. private _imageProcessingConfigChangeObserver;
  24452. private _transformMatrix;
  24453. private _mirrorMatrix;
  24454. private _savedViewMatrix;
  24455. private _blurX;
  24456. private _blurY;
  24457. private _adaptiveBlurKernel;
  24458. private _blurKernelX;
  24459. private _blurKernelY;
  24460. private _blurRatio;
  24461. /**
  24462. * Instantiates a Mirror Texture.
  24463. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24464. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24465. * You can then easily use it as a reflectionTexture on a flat surface.
  24466. * In case the surface is not a plane, please consider relying on reflection probes.
  24467. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24468. * @param name
  24469. * @param size
  24470. * @param scene
  24471. * @param generateMipMaps
  24472. * @param type
  24473. * @param samplingMode
  24474. * @param generateDepthBuffer
  24475. */
  24476. constructor(name: string, size: number | {
  24477. width: number;
  24478. height: number;
  24479. } | {
  24480. ratio: number;
  24481. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24482. private _preparePostProcesses;
  24483. /**
  24484. * Clone the mirror texture.
  24485. * @returns the cloned texture
  24486. */
  24487. clone(): MirrorTexture;
  24488. /**
  24489. * Serialize the texture to a JSON representation you could use in Parse later on
  24490. * @returns the serialized JSON representation
  24491. */
  24492. serialize(): any;
  24493. /**
  24494. * Dispose the texture and release its associated resources.
  24495. */
  24496. dispose(): void;
  24497. }
  24498. }
  24499. declare module "babylonjs/Materials/Textures/texture" {
  24500. import { Observable } from "babylonjs/Misc/observable";
  24501. import { Nullable } from "babylonjs/types";
  24502. import { Matrix } from "babylonjs/Maths/math.vector";
  24503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24505. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24506. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24507. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24508. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24509. import { Scene } from "babylonjs/scene";
  24510. /**
  24511. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24512. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24513. */
  24514. export class Texture extends BaseTexture {
  24515. /**
  24516. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24517. */
  24518. static SerializeBuffers: boolean;
  24519. /**
  24520. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24521. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24522. */
  24523. static ForceSerializeBuffers: boolean;
  24524. /** @hidden */
  24525. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24526. /** @hidden */
  24527. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24528. /** @hidden */
  24529. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24530. /** nearest is mag = nearest and min = nearest and mip = linear */
  24531. static readonly NEAREST_SAMPLINGMODE: number;
  24532. /** nearest is mag = nearest and min = nearest and mip = linear */
  24533. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24535. static readonly BILINEAR_SAMPLINGMODE: number;
  24536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24537. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24538. /** Trilinear is mag = linear and min = linear and mip = linear */
  24539. static readonly TRILINEAR_SAMPLINGMODE: number;
  24540. /** Trilinear is mag = linear and min = linear and mip = linear */
  24541. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24542. /** mag = nearest and min = nearest and mip = nearest */
  24543. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24544. /** mag = nearest and min = linear and mip = nearest */
  24545. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24546. /** mag = nearest and min = linear and mip = linear */
  24547. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24548. /** mag = nearest and min = linear and mip = none */
  24549. static readonly NEAREST_LINEAR: number;
  24550. /** mag = nearest and min = nearest and mip = none */
  24551. static readonly NEAREST_NEAREST: number;
  24552. /** mag = linear and min = nearest and mip = nearest */
  24553. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24554. /** mag = linear and min = nearest and mip = linear */
  24555. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24556. /** mag = linear and min = linear and mip = none */
  24557. static readonly LINEAR_LINEAR: number;
  24558. /** mag = linear and min = nearest and mip = none */
  24559. static readonly LINEAR_NEAREST: number;
  24560. /** Explicit coordinates mode */
  24561. static readonly EXPLICIT_MODE: number;
  24562. /** Spherical coordinates mode */
  24563. static readonly SPHERICAL_MODE: number;
  24564. /** Planar coordinates mode */
  24565. static readonly PLANAR_MODE: number;
  24566. /** Cubic coordinates mode */
  24567. static readonly CUBIC_MODE: number;
  24568. /** Projection coordinates mode */
  24569. static readonly PROJECTION_MODE: number;
  24570. /** Inverse Cubic coordinates mode */
  24571. static readonly SKYBOX_MODE: number;
  24572. /** Inverse Cubic coordinates mode */
  24573. static readonly INVCUBIC_MODE: number;
  24574. /** Equirectangular coordinates mode */
  24575. static readonly EQUIRECTANGULAR_MODE: number;
  24576. /** Equirectangular Fixed coordinates mode */
  24577. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24578. /** Equirectangular Fixed Mirrored coordinates mode */
  24579. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24580. /** Texture is not repeating outside of 0..1 UVs */
  24581. static readonly CLAMP_ADDRESSMODE: number;
  24582. /** Texture is repeating outside of 0..1 UVs */
  24583. static readonly WRAP_ADDRESSMODE: number;
  24584. /** Texture is repeating and mirrored */
  24585. static readonly MIRROR_ADDRESSMODE: number;
  24586. /**
  24587. * 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
  24588. */
  24589. static UseSerializedUrlIfAny: boolean;
  24590. /**
  24591. * Define the url of the texture.
  24592. */
  24593. url: Nullable<string>;
  24594. /**
  24595. * Define an offset on the texture to offset the u coordinates of the UVs
  24596. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24597. */
  24598. uOffset: number;
  24599. /**
  24600. * Define an offset on the texture to offset the v coordinates of the UVs
  24601. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24602. */
  24603. vOffset: number;
  24604. /**
  24605. * Define an offset on the texture to scale the u coordinates of the UVs
  24606. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24607. */
  24608. uScale: number;
  24609. /**
  24610. * Define an offset on the texture to scale the v coordinates of the UVs
  24611. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24612. */
  24613. vScale: number;
  24614. /**
  24615. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24616. * @see https://doc.babylonjs.com/how_to/more_materials
  24617. */
  24618. uAng: number;
  24619. /**
  24620. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24621. * @see https://doc.babylonjs.com/how_to/more_materials
  24622. */
  24623. vAng: number;
  24624. /**
  24625. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24626. * @see https://doc.babylonjs.com/how_to/more_materials
  24627. */
  24628. wAng: number;
  24629. /**
  24630. * Defines the center of rotation (U)
  24631. */
  24632. uRotationCenter: number;
  24633. /**
  24634. * Defines the center of rotation (V)
  24635. */
  24636. vRotationCenter: number;
  24637. /**
  24638. * Defines the center of rotation (W)
  24639. */
  24640. wRotationCenter: number;
  24641. /**
  24642. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24643. */
  24644. homogeneousRotationInUVTransform: boolean;
  24645. /**
  24646. * Are mip maps generated for this texture or not.
  24647. */
  24648. get noMipmap(): boolean;
  24649. /**
  24650. * List of inspectable custom properties (used by the Inspector)
  24651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24652. */
  24653. inspectableCustomProperties: Nullable<IInspectable[]>;
  24654. private _noMipmap;
  24655. /** @hidden */
  24656. _invertY: boolean;
  24657. private _rowGenerationMatrix;
  24658. private _cachedTextureMatrix;
  24659. private _projectionModeMatrix;
  24660. private _t0;
  24661. private _t1;
  24662. private _t2;
  24663. private _cachedUOffset;
  24664. private _cachedVOffset;
  24665. private _cachedUScale;
  24666. private _cachedVScale;
  24667. private _cachedUAng;
  24668. private _cachedVAng;
  24669. private _cachedWAng;
  24670. private _cachedProjectionMatrixId;
  24671. private _cachedURotationCenter;
  24672. private _cachedVRotationCenter;
  24673. private _cachedWRotationCenter;
  24674. private _cachedHomogeneousRotationInUVTransform;
  24675. private _cachedCoordinatesMode;
  24676. /** @hidden */
  24677. protected _initialSamplingMode: number;
  24678. /** @hidden */
  24679. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24680. private _deleteBuffer;
  24681. protected _format: Nullable<number>;
  24682. private _delayedOnLoad;
  24683. private _delayedOnError;
  24684. private _mimeType?;
  24685. private _loaderOptions?;
  24686. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24687. get mimeType(): string | undefined;
  24688. /**
  24689. * Observable triggered once the texture has been loaded.
  24690. */
  24691. onLoadObservable: Observable<Texture>;
  24692. protected _isBlocking: boolean;
  24693. /**
  24694. * Is the texture preventing material to render while loading.
  24695. * If false, a default texture will be used instead of the loading one during the preparation step.
  24696. */
  24697. set isBlocking(value: boolean);
  24698. get isBlocking(): boolean;
  24699. /**
  24700. * Get the current sampling mode associated with the texture.
  24701. */
  24702. get samplingMode(): number;
  24703. /**
  24704. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24705. */
  24706. get invertY(): boolean;
  24707. /**
  24708. * Instantiates a new texture.
  24709. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24710. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24711. * @param url defines the url of the picture to load as a texture
  24712. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24713. * @param noMipmap defines if the texture will require mip maps or not
  24714. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24715. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24716. * @param onLoad defines a callback triggered when the texture has been loaded
  24717. * @param onError defines a callback triggered when an error occurred during the loading session
  24718. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24719. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24720. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24721. * @param mimeType defines an optional mime type information
  24722. * @param loaderOptions options to be passed to the loader
  24723. */
  24724. 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);
  24725. /**
  24726. * Update the url (and optional buffer) of this texture if url was null during construction.
  24727. * @param url the url of the texture
  24728. * @param buffer the buffer of the texture (defaults to null)
  24729. * @param onLoad callback called when the texture is loaded (defaults to null)
  24730. */
  24731. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24732. /**
  24733. * Finish the loading sequence of a texture flagged as delayed load.
  24734. * @hidden
  24735. */
  24736. delayLoad(): void;
  24737. private _prepareRowForTextureGeneration;
  24738. /**
  24739. * Checks if the texture has the same transform matrix than another texture
  24740. * @param texture texture to check against
  24741. * @returns true if the transforms are the same, else false
  24742. */
  24743. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24744. /**
  24745. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24746. * @returns the transform matrix of the texture.
  24747. */
  24748. getTextureMatrix(uBase?: number): Matrix;
  24749. /**
  24750. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24751. * @returns The reflection texture transform
  24752. */
  24753. getReflectionTextureMatrix(): Matrix;
  24754. /**
  24755. * Clones the texture.
  24756. * @returns the cloned texture
  24757. */
  24758. clone(): Texture;
  24759. /**
  24760. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24761. * @returns The JSON representation of the texture
  24762. */
  24763. serialize(): any;
  24764. /**
  24765. * Get the current class name of the texture useful for serialization or dynamic coding.
  24766. * @returns "Texture"
  24767. */
  24768. getClassName(): string;
  24769. /**
  24770. * Dispose the texture and release its associated resources.
  24771. */
  24772. dispose(): void;
  24773. /**
  24774. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24775. * @param parsedTexture Define the JSON representation of the texture
  24776. * @param scene Define the scene the parsed texture should be instantiated in
  24777. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24778. * @returns The parsed texture if successful
  24779. */
  24780. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24781. /**
  24782. * Creates a texture from its base 64 representation.
  24783. * @param data Define the base64 payload without the data: prefix
  24784. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24785. * @param scene Define the scene the texture should belong to
  24786. * @param noMipmap Forces the texture to not create mip map information if true
  24787. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24788. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24789. * @param onLoad define a callback triggered when the texture has been loaded
  24790. * @param onError define a callback triggered when an error occurred during the loading session
  24791. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24792. * @returns the created texture
  24793. */
  24794. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24795. /**
  24796. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24797. * @param data Define the base64 payload without the data: prefix
  24798. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24799. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24800. * @param scene Define the scene the texture should belong to
  24801. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24802. * @param noMipmap Forces the texture to not create mip map information if true
  24803. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24804. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24805. * @param onLoad define a callback triggered when the texture has been loaded
  24806. * @param onError define a callback triggered when an error occurred during the loading session
  24807. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24808. * @returns the created texture
  24809. */
  24810. 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;
  24811. }
  24812. }
  24813. declare module "babylonjs/Sprites/thinSprite" {
  24814. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24815. import { Nullable } from "babylonjs/types";
  24816. /**
  24817. * ThinSprite Class used to represent a thin sprite
  24818. * This is the base class for sprites but can also directly be used with ThinEngine
  24819. * @see https://doc.babylonjs.com/babylon101/sprites
  24820. */
  24821. export class ThinSprite {
  24822. /** Gets or sets the cell index in the sprite sheet */
  24823. cellIndex: number;
  24824. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24825. cellRef: string;
  24826. /** Gets or sets the current world position */
  24827. position: IVector3Like;
  24828. /** Gets or sets the main color */
  24829. color: IColor4Like;
  24830. /** Gets or sets the width */
  24831. width: number;
  24832. /** Gets or sets the height */
  24833. height: number;
  24834. /** Gets or sets rotation angle */
  24835. angle: number;
  24836. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24837. invertU: boolean;
  24838. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24839. invertV: boolean;
  24840. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24841. isVisible: boolean;
  24842. /**
  24843. * Returns a boolean indicating if the animation is started
  24844. */
  24845. get animationStarted(): boolean;
  24846. /** Gets the initial key for the animation (setting it will restart the animation) */
  24847. get fromIndex(): number;
  24848. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24849. get toIndex(): number;
  24850. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24851. get loopAnimation(): boolean;
  24852. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24853. get delay(): number;
  24854. /** @hidden */
  24855. _xOffset: number;
  24856. /** @hidden */
  24857. _yOffset: number;
  24858. /** @hidden */
  24859. _xSize: number;
  24860. /** @hidden */
  24861. _ySize: number;
  24862. private _animationStarted;
  24863. protected _loopAnimation: boolean;
  24864. protected _fromIndex: number;
  24865. protected _toIndex: number;
  24866. protected _delay: number;
  24867. private _direction;
  24868. private _time;
  24869. private _onBaseAnimationEnd;
  24870. /**
  24871. * Creates a new Thin Sprite
  24872. */
  24873. constructor();
  24874. /**
  24875. * Starts an animation
  24876. * @param from defines the initial key
  24877. * @param to defines the end key
  24878. * @param loop defines if the animation must loop
  24879. * @param delay defines the start delay (in ms)
  24880. * @param onAnimationEnd defines a callback for when the animation ends
  24881. */
  24882. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24883. /** Stops current animation (if any) */
  24884. stopAnimation(): void;
  24885. /** @hidden */
  24886. _animate(deltaTime: number): void;
  24887. }
  24888. }
  24889. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24890. /** @hidden */
  24891. export var imageProcessingCompatibility: {
  24892. name: string;
  24893. shader: string;
  24894. };
  24895. }
  24896. declare module "babylonjs/Shaders/sprites.fragment" {
  24897. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24898. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24899. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24900. /** @hidden */
  24901. export var spritesPixelShader: {
  24902. name: string;
  24903. shader: string;
  24904. };
  24905. }
  24906. declare module "babylonjs/Shaders/sprites.vertex" {
  24907. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24908. /** @hidden */
  24909. export var spritesVertexShader: {
  24910. name: string;
  24911. shader: string;
  24912. };
  24913. }
  24914. declare module "babylonjs/Sprites/spriteRenderer" {
  24915. import { Nullable } from "babylonjs/types";
  24916. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24917. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24918. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24919. import { ISize } from "babylonjs/Maths/math.size";
  24920. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24921. import { Scene } from "babylonjs/scene";
  24922. import "babylonjs/Engines/Extensions/engine.alpha";
  24923. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24924. import "babylonjs/Shaders/sprites.fragment";
  24925. import "babylonjs/Shaders/sprites.vertex";
  24926. /**
  24927. * Class used to render sprites.
  24928. *
  24929. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24930. */
  24931. export class SpriteRenderer {
  24932. /**
  24933. * Defines the texture of the spritesheet
  24934. */
  24935. texture: Nullable<ThinTexture>;
  24936. /**
  24937. * Defines the default width of a cell in the spritesheet
  24938. */
  24939. cellWidth: number;
  24940. /**
  24941. * Defines the default height of a cell in the spritesheet
  24942. */
  24943. cellHeight: number;
  24944. /**
  24945. * Blend mode use to render the particle, it can be any of
  24946. * the static Constants.ALPHA_x properties provided in this class.
  24947. * Default value is Constants.ALPHA_COMBINE
  24948. */
  24949. blendMode: number;
  24950. /**
  24951. * Gets or sets a boolean indicating if alpha mode is automatically
  24952. * reset.
  24953. */
  24954. autoResetAlpha: boolean;
  24955. /**
  24956. * Disables writing to the depth buffer when rendering the sprites.
  24957. * It can be handy to disable depth writing when using textures without alpha channel
  24958. * and setting some specific blend modes.
  24959. */
  24960. disableDepthWrite: boolean;
  24961. /**
  24962. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24963. */
  24964. fogEnabled: boolean;
  24965. /**
  24966. * Gets the capacity of the manager
  24967. */
  24968. get capacity(): number;
  24969. private readonly _engine;
  24970. private readonly _useVAO;
  24971. private readonly _useInstancing;
  24972. private readonly _scene;
  24973. private readonly _capacity;
  24974. private readonly _epsilon;
  24975. private _vertexBufferSize;
  24976. private _vertexData;
  24977. private _buffer;
  24978. private _vertexBuffers;
  24979. private _spriteBuffer;
  24980. private _indexBuffer;
  24981. private _effectBase;
  24982. private _effectFog;
  24983. private _vertexArrayObject;
  24984. /**
  24985. * Creates a new sprite Renderer
  24986. * @param engine defines the engine the renderer works with
  24987. * @param capacity defines the maximum allowed number of sprites
  24988. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24989. * @param scene defines the hosting scene
  24990. */
  24991. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24992. /**
  24993. * Render all child sprites
  24994. * @param sprites defines the list of sprites to render
  24995. * @param deltaTime defines the time since last frame
  24996. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24997. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24998. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24999. */
  25000. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  25001. private _appendSpriteVertex;
  25002. /**
  25003. * Release associated resources
  25004. */
  25005. dispose(): void;
  25006. }
  25007. }
  25008. declare module "babylonjs/Sprites/spriteManager" {
  25009. import { IDisposable, Scene } from "babylonjs/scene";
  25010. import { Nullable } from "babylonjs/types";
  25011. import { Observable } from "babylonjs/Misc/observable";
  25012. import { Sprite } from "babylonjs/Sprites/sprite";
  25013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25014. import { Camera } from "babylonjs/Cameras/camera";
  25015. import { Texture } from "babylonjs/Materials/Textures/texture";
  25016. import { Ray } from "babylonjs/Culling/ray";
  25017. /**
  25018. * Defines the minimum interface to fullfil in order to be a sprite manager.
  25019. */
  25020. export interface ISpriteManager extends IDisposable {
  25021. /**
  25022. * Gets manager's name
  25023. */
  25024. name: string;
  25025. /**
  25026. * Restricts the camera to viewing objects with the same layerMask.
  25027. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  25028. */
  25029. layerMask: number;
  25030. /**
  25031. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25032. */
  25033. isPickable: boolean;
  25034. /**
  25035. * Gets the hosting scene
  25036. */
  25037. scene: Scene;
  25038. /**
  25039. * Specifies the rendering group id for this mesh (0 by default)
  25040. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25041. */
  25042. renderingGroupId: number;
  25043. /**
  25044. * Defines the list of sprites managed by the manager.
  25045. */
  25046. sprites: Array<Sprite>;
  25047. /**
  25048. * Gets or sets the spritesheet texture
  25049. */
  25050. texture: Texture;
  25051. /** Defines the default width of a cell in the spritesheet */
  25052. cellWidth: number;
  25053. /** Defines the default height of a cell in the spritesheet */
  25054. cellHeight: number;
  25055. /**
  25056. * Tests the intersection of a sprite with a specific ray.
  25057. * @param ray The ray we are sending to test the collision
  25058. * @param camera The camera space we are sending rays in
  25059. * @param predicate A predicate allowing excluding sprites from the list of object to test
  25060. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25061. * @returns picking info or null.
  25062. */
  25063. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25064. /**
  25065. * Intersects the sprites with a ray
  25066. * @param ray defines the ray to intersect with
  25067. * @param camera defines the current active camera
  25068. * @param predicate defines a predicate used to select candidate sprites
  25069. * @returns null if no hit or a PickingInfo array
  25070. */
  25071. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25072. /**
  25073. * Renders the list of sprites on screen.
  25074. */
  25075. render(): void;
  25076. }
  25077. /**
  25078. * Class used to manage multiple sprites on the same spritesheet
  25079. * @see https://doc.babylonjs.com/babylon101/sprites
  25080. */
  25081. export class SpriteManager implements ISpriteManager {
  25082. /** defines the manager's name */
  25083. name: string;
  25084. /** Define the Url to load snippets */
  25085. static SnippetUrl: string;
  25086. /** Snippet ID if the manager was created from the snippet server */
  25087. snippetId: string;
  25088. /** Gets the list of sprites */
  25089. sprites: Sprite[];
  25090. /** Gets or sets the rendering group id (0 by default) */
  25091. renderingGroupId: number;
  25092. /** Gets or sets camera layer mask */
  25093. layerMask: number;
  25094. /** Gets or sets a boolean indicating if the sprites are pickable */
  25095. isPickable: boolean;
  25096. /**
  25097. * An event triggered when the manager is disposed.
  25098. */
  25099. onDisposeObservable: Observable<SpriteManager>;
  25100. /**
  25101. * Callback called when the manager is disposed
  25102. */
  25103. set onDispose(callback: () => void);
  25104. /**
  25105. * Gets or sets the unique id of the sprite
  25106. */
  25107. uniqueId: number;
  25108. /**
  25109. * Gets the array of sprites
  25110. */
  25111. get children(): Sprite[];
  25112. /**
  25113. * Gets the hosting scene
  25114. */
  25115. get scene(): Scene;
  25116. /**
  25117. * Gets the capacity of the manager
  25118. */
  25119. get capacity(): number;
  25120. /**
  25121. * Gets or sets the spritesheet texture
  25122. */
  25123. get texture(): Texture;
  25124. set texture(value: Texture);
  25125. /** Defines the default width of a cell in the spritesheet */
  25126. get cellWidth(): number;
  25127. set cellWidth(value: number);
  25128. /** Defines the default height of a cell in the spritesheet */
  25129. get cellHeight(): number;
  25130. set cellHeight(value: number);
  25131. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  25132. get fogEnabled(): boolean;
  25133. set fogEnabled(value: boolean);
  25134. /**
  25135. * Blend mode use to render the particle, it can be any of
  25136. * the static Constants.ALPHA_x properties provided in this class.
  25137. * Default value is Constants.ALPHA_COMBINE
  25138. */
  25139. get blendMode(): number;
  25140. set blendMode(blendMode: number);
  25141. /** Disables writing to the depth buffer when rendering the sprites.
  25142. * It can be handy to disable depth writing when using textures without alpha channel
  25143. * and setting some specific blend modes.
  25144. */
  25145. disableDepthWrite: boolean;
  25146. private _spriteRenderer;
  25147. /** Associative array from JSON sprite data file */
  25148. private _cellData;
  25149. /** Array of sprite names from JSON sprite data file */
  25150. private _spriteMap;
  25151. /** True when packed cell data from JSON file is ready*/
  25152. private _packedAndReady;
  25153. private _textureContent;
  25154. private _onDisposeObserver;
  25155. private _fromPacked;
  25156. private _scene;
  25157. /**
  25158. * Creates a new sprite manager
  25159. * @param name defines the manager's name
  25160. * @param imgUrl defines the sprite sheet url
  25161. * @param capacity defines the maximum allowed number of sprites
  25162. * @param cellSize defines the size of a sprite cell
  25163. * @param scene defines the hosting scene
  25164. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25165. * @param samplingMode defines the smapling mode to use with spritesheet
  25166. * @param fromPacked set to false; do not alter
  25167. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  25168. */
  25169. constructor(
  25170. /** defines the manager's name */
  25171. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  25172. /**
  25173. * Returns the string "SpriteManager"
  25174. * @returns "SpriteManager"
  25175. */
  25176. getClassName(): string;
  25177. private _makePacked;
  25178. private _checkTextureAlpha;
  25179. /**
  25180. * Intersects the sprites with a ray
  25181. * @param ray defines the ray to intersect with
  25182. * @param camera defines the current active camera
  25183. * @param predicate defines a predicate used to select candidate sprites
  25184. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  25185. * @returns null if no hit or a PickingInfo
  25186. */
  25187. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25188. /**
  25189. * Intersects the sprites with a ray
  25190. * @param ray defines the ray to intersect with
  25191. * @param camera defines the current active camera
  25192. * @param predicate defines a predicate used to select candidate sprites
  25193. * @returns null if no hit or a PickingInfo array
  25194. */
  25195. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25196. /**
  25197. * Render all child sprites
  25198. */
  25199. render(): void;
  25200. private _customUpdate;
  25201. /**
  25202. * Release associated resources
  25203. */
  25204. dispose(): void;
  25205. /**
  25206. * Serializes the sprite manager to a JSON object
  25207. * @param serializeTexture defines if the texture must be serialized as well
  25208. * @returns the JSON object
  25209. */
  25210. serialize(serializeTexture?: boolean): any;
  25211. /**
  25212. * Parses a JSON object to create a new sprite manager.
  25213. * @param parsedManager The JSON object to parse
  25214. * @param scene The scene to create the sprite managerin
  25215. * @param rootUrl The root url to use to load external dependencies like texture
  25216. * @returns the new sprite manager
  25217. */
  25218. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  25219. /**
  25220. * Creates a sprite manager from a snippet saved in a remote file
  25221. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  25222. * @param url defines the url to load from
  25223. * @param scene defines the hosting scene
  25224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25225. * @returns a promise that will resolve to the new sprite manager
  25226. */
  25227. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25228. /**
  25229. * Creates a sprite manager from a snippet saved by the sprite editor
  25230. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  25231. * @param scene defines the hosting scene
  25232. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25233. * @returns a promise that will resolve to the new sprite manager
  25234. */
  25235. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25236. }
  25237. }
  25238. declare module "babylonjs/Sprites/sprite" {
  25239. import { Vector3 } from "babylonjs/Maths/math.vector";
  25240. import { Nullable } from "babylonjs/types";
  25241. import { ActionManager } from "babylonjs/Actions/actionManager";
  25242. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  25243. import { Color4 } from "babylonjs/Maths/math.color";
  25244. import { Observable } from "babylonjs/Misc/observable";
  25245. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25246. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25247. import { Animation } from "babylonjs/Animations/animation";
  25248. /**
  25249. * Class used to represent a sprite
  25250. * @see https://doc.babylonjs.com/babylon101/sprites
  25251. */
  25252. export class Sprite extends ThinSprite implements IAnimatable {
  25253. /** defines the name */
  25254. name: string;
  25255. /** Gets or sets the current world position */
  25256. position: Vector3;
  25257. /** Gets or sets the main color */
  25258. color: Color4;
  25259. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  25260. disposeWhenFinishedAnimating: boolean;
  25261. /** Gets the list of attached animations */
  25262. animations: Nullable<Array<Animation>>;
  25263. /** Gets or sets a boolean indicating if the sprite can be picked */
  25264. isPickable: boolean;
  25265. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  25266. useAlphaForPicking: boolean;
  25267. /**
  25268. * Gets or sets the associated action manager
  25269. */
  25270. actionManager: Nullable<ActionManager>;
  25271. /**
  25272. * An event triggered when the control has been disposed
  25273. */
  25274. onDisposeObservable: Observable<Sprite>;
  25275. private _manager;
  25276. private _onAnimationEnd;
  25277. /**
  25278. * Gets or sets the sprite size
  25279. */
  25280. get size(): number;
  25281. set size(value: number);
  25282. /**
  25283. * Gets or sets the unique id of the sprite
  25284. */
  25285. uniqueId: number;
  25286. /**
  25287. * Gets the manager of this sprite
  25288. */
  25289. get manager(): ISpriteManager;
  25290. /**
  25291. * Creates a new Sprite
  25292. * @param name defines the name
  25293. * @param manager defines the manager
  25294. */
  25295. constructor(
  25296. /** defines the name */
  25297. name: string, manager: ISpriteManager);
  25298. /**
  25299. * Returns the string "Sprite"
  25300. * @returns "Sprite"
  25301. */
  25302. getClassName(): string;
  25303. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  25304. get fromIndex(): number;
  25305. set fromIndex(value: number);
  25306. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25307. get toIndex(): number;
  25308. set toIndex(value: number);
  25309. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25310. get loopAnimation(): boolean;
  25311. set loopAnimation(value: boolean);
  25312. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25313. get delay(): number;
  25314. set delay(value: number);
  25315. /**
  25316. * Starts an animation
  25317. * @param from defines the initial key
  25318. * @param to defines the end key
  25319. * @param loop defines if the animation must loop
  25320. * @param delay defines the start delay (in ms)
  25321. * @param onAnimationEnd defines a callback to call when animation ends
  25322. */
  25323. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  25324. private _endAnimation;
  25325. /** Release associated resources */
  25326. dispose(): void;
  25327. /**
  25328. * Serializes the sprite to a JSON object
  25329. * @returns the JSON object
  25330. */
  25331. serialize(): any;
  25332. /**
  25333. * Parses a JSON object to create a new sprite
  25334. * @param parsedSprite The JSON object to parse
  25335. * @param manager defines the hosting manager
  25336. * @returns the new sprite
  25337. */
  25338. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  25339. }
  25340. }
  25341. declare module "babylonjs/Collisions/pickingInfo" {
  25342. import { Nullable } from "babylonjs/types";
  25343. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25345. import { Sprite } from "babylonjs/Sprites/sprite";
  25346. import { Ray } from "babylonjs/Culling/ray";
  25347. /**
  25348. * Information about the result of picking within a scene
  25349. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25350. */
  25351. export class PickingInfo {
  25352. /** @hidden */
  25353. _pickingUnavailable: boolean;
  25354. /**
  25355. * If the pick collided with an object
  25356. */
  25357. hit: boolean;
  25358. /**
  25359. * Distance away where the pick collided
  25360. */
  25361. distance: number;
  25362. /**
  25363. * The location of pick collision
  25364. */
  25365. pickedPoint: Nullable<Vector3>;
  25366. /**
  25367. * The mesh corresponding the the pick collision
  25368. */
  25369. pickedMesh: Nullable<AbstractMesh>;
  25370. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25371. bu: number;
  25372. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25373. bv: number;
  25374. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25375. faceId: number;
  25376. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25377. subMeshFaceId: number;
  25378. /** Id of the the submesh that was picked */
  25379. subMeshId: number;
  25380. /** If a sprite was picked, this will be the sprite the pick collided with */
  25381. pickedSprite: Nullable<Sprite>;
  25382. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  25383. thinInstanceIndex: number;
  25384. /**
  25385. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25386. */
  25387. originMesh: Nullable<AbstractMesh>;
  25388. /**
  25389. * The ray that was used to perform the picking.
  25390. */
  25391. ray: Nullable<Ray>;
  25392. /**
  25393. * Gets the normal correspodning to the face the pick collided with
  25394. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25395. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25396. * @returns The normal correspodning to the face the pick collided with
  25397. */
  25398. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25399. /**
  25400. * Gets the texture coordinates of where the pick occured
  25401. * @returns the vector containing the coordnates of the texture
  25402. */
  25403. getTextureCoordinates(): Nullable<Vector2>;
  25404. }
  25405. }
  25406. declare module "babylonjs/Events/pointerEvents" {
  25407. import { Nullable } from "babylonjs/types";
  25408. import { Vector2 } from "babylonjs/Maths/math.vector";
  25409. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25410. import { Ray } from "babylonjs/Culling/ray";
  25411. /**
  25412. * Gather the list of pointer event types as constants.
  25413. */
  25414. export class PointerEventTypes {
  25415. /**
  25416. * 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.
  25417. */
  25418. static readonly POINTERDOWN: number;
  25419. /**
  25420. * The pointerup event is fired when a pointer is no longer active.
  25421. */
  25422. static readonly POINTERUP: number;
  25423. /**
  25424. * The pointermove event is fired when a pointer changes coordinates.
  25425. */
  25426. static readonly POINTERMOVE: number;
  25427. /**
  25428. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25429. */
  25430. static readonly POINTERWHEEL: number;
  25431. /**
  25432. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25433. */
  25434. static readonly POINTERPICK: number;
  25435. /**
  25436. * The pointertap event is fired when a the object has been touched and released without drag.
  25437. */
  25438. static readonly POINTERTAP: number;
  25439. /**
  25440. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25441. */
  25442. static readonly POINTERDOUBLETAP: number;
  25443. }
  25444. /**
  25445. * Base class of pointer info types.
  25446. */
  25447. export class PointerInfoBase {
  25448. /**
  25449. * Defines the type of event (PointerEventTypes)
  25450. */
  25451. type: number;
  25452. /**
  25453. * Defines the related dom event
  25454. */
  25455. event: PointerEvent | MouseWheelEvent;
  25456. /**
  25457. * Instantiates the base class of pointers info.
  25458. * @param type Defines the type of event (PointerEventTypes)
  25459. * @param event Defines the related dom event
  25460. */
  25461. constructor(
  25462. /**
  25463. * Defines the type of event (PointerEventTypes)
  25464. */
  25465. type: number,
  25466. /**
  25467. * Defines the related dom event
  25468. */
  25469. event: PointerEvent | MouseWheelEvent);
  25470. }
  25471. /**
  25472. * This class is used to store pointer related info for the onPrePointerObservable event.
  25473. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25474. */
  25475. export class PointerInfoPre extends PointerInfoBase {
  25476. /**
  25477. * Ray from a pointer if availible (eg. 6dof controller)
  25478. */
  25479. ray: Nullable<Ray>;
  25480. /**
  25481. * Defines the local position of the pointer on the canvas.
  25482. */
  25483. localPosition: Vector2;
  25484. /**
  25485. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25486. */
  25487. skipOnPointerObservable: boolean;
  25488. /**
  25489. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25490. * @param type Defines the type of event (PointerEventTypes)
  25491. * @param event Defines the related dom event
  25492. * @param localX Defines the local x coordinates of the pointer when the event occured
  25493. * @param localY Defines the local y coordinates of the pointer when the event occured
  25494. */
  25495. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  25496. }
  25497. /**
  25498. * This type contains all the data related to a pointer event in Babylon.js.
  25499. * 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.
  25500. */
  25501. export class PointerInfo extends PointerInfoBase {
  25502. /**
  25503. * Defines the picking info associated to the info (if any)\
  25504. */
  25505. pickInfo: Nullable<PickingInfo>;
  25506. /**
  25507. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25508. * @param type Defines the type of event (PointerEventTypes)
  25509. * @param event Defines the related dom event
  25510. * @param pickInfo Defines the picking info associated to the info (if any)\
  25511. */
  25512. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  25513. /**
  25514. * Defines the picking info associated to the info (if any)\
  25515. */
  25516. pickInfo: Nullable<PickingInfo>);
  25517. }
  25518. /**
  25519. * Data relating to a touch event on the screen.
  25520. */
  25521. export interface PointerTouch {
  25522. /**
  25523. * X coordinate of touch.
  25524. */
  25525. x: number;
  25526. /**
  25527. * Y coordinate of touch.
  25528. */
  25529. y: number;
  25530. /**
  25531. * Id of touch. Unique for each finger.
  25532. */
  25533. pointerId: number;
  25534. /**
  25535. * Event type passed from DOM.
  25536. */
  25537. type: any;
  25538. }
  25539. }
  25540. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  25541. import { Observable } from "babylonjs/Misc/observable";
  25542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25543. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25544. /**
  25545. * Manage the mouse inputs to control the movement of a free camera.
  25546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25547. */
  25548. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25549. /**
  25550. * Define if touch is enabled in the mouse input
  25551. */
  25552. touchEnabled: boolean;
  25553. /**
  25554. * Defines the camera the input is attached to.
  25555. */
  25556. camera: FreeCamera;
  25557. /**
  25558. * Defines the buttons associated with the input to handle camera move.
  25559. */
  25560. buttons: number[];
  25561. /**
  25562. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25563. */
  25564. angularSensibility: number;
  25565. private _pointerInput;
  25566. private _onMouseMove;
  25567. private _observer;
  25568. private previousPosition;
  25569. /**
  25570. * Observable for when a pointer move event occurs containing the move offset
  25571. */
  25572. onPointerMovedObservable: Observable<{
  25573. offsetX: number;
  25574. offsetY: number;
  25575. }>;
  25576. /**
  25577. * @hidden
  25578. * If the camera should be rotated automatically based on pointer movement
  25579. */
  25580. _allowCameraRotation: boolean;
  25581. /**
  25582. * Manage the mouse inputs to control the movement of a free camera.
  25583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25584. * @param touchEnabled Defines if touch is enabled or not
  25585. */
  25586. constructor(
  25587. /**
  25588. * Define if touch is enabled in the mouse input
  25589. */
  25590. touchEnabled?: boolean);
  25591. /**
  25592. * Attach the input controls to a specific dom element to get the input from.
  25593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25594. */
  25595. attachControl(noPreventDefault?: boolean): void;
  25596. /**
  25597. * Called on JS contextmenu event.
  25598. * Override this method to provide functionality.
  25599. */
  25600. protected onContextMenu(evt: PointerEvent): void;
  25601. /**
  25602. * Detach the current controls from the specified dom element.
  25603. */
  25604. detachControl(): void;
  25605. /**
  25606. * Gets the class name of the current intput.
  25607. * @returns the class name
  25608. */
  25609. getClassName(): string;
  25610. /**
  25611. * Get the friendly name associated with the input class.
  25612. * @returns the input friendly name
  25613. */
  25614. getSimpleName(): string;
  25615. }
  25616. }
  25617. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  25618. import { Observable } from "babylonjs/Misc/observable";
  25619. import { Camera } from "babylonjs/Cameras/camera";
  25620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25621. /**
  25622. * Base class for mouse wheel input..
  25623. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25624. * for example usage.
  25625. */
  25626. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25627. /**
  25628. * Defines the camera the input is attached to.
  25629. */
  25630. abstract camera: Camera;
  25631. /**
  25632. * How fast is the camera moves in relation to X axis mouseWheel events.
  25633. * Use negative value to reverse direction.
  25634. */
  25635. wheelPrecisionX: number;
  25636. /**
  25637. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25638. * Use negative value to reverse direction.
  25639. */
  25640. wheelPrecisionY: number;
  25641. /**
  25642. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25643. * Use negative value to reverse direction.
  25644. */
  25645. wheelPrecisionZ: number;
  25646. /**
  25647. * Observable for when a mouse wheel move event occurs.
  25648. */
  25649. onChangedObservable: Observable<{
  25650. wheelDeltaX: number;
  25651. wheelDeltaY: number;
  25652. wheelDeltaZ: number;
  25653. }>;
  25654. private _wheel;
  25655. private _observer;
  25656. /**
  25657. * Attach the input controls to a specific dom element to get the input from.
  25658. * @param noPreventDefault Defines whether event caught by the controls
  25659. * should call preventdefault().
  25660. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25661. */
  25662. attachControl(noPreventDefault?: boolean): void;
  25663. /**
  25664. * Detach the current controls from the specified dom element.
  25665. */
  25666. detachControl(): void;
  25667. /**
  25668. * Called for each rendered frame.
  25669. */
  25670. checkInputs(): void;
  25671. /**
  25672. * Gets the class name of the current intput.
  25673. * @returns the class name
  25674. */
  25675. getClassName(): string;
  25676. /**
  25677. * Get the friendly name associated with the input class.
  25678. * @returns the input friendly name
  25679. */
  25680. getSimpleName(): string;
  25681. /**
  25682. * Incremental value of multiple mouse wheel movements of the X axis.
  25683. * Should be zero-ed when read.
  25684. */
  25685. protected _wheelDeltaX: number;
  25686. /**
  25687. * Incremental value of multiple mouse wheel movements of the Y axis.
  25688. * Should be zero-ed when read.
  25689. */
  25690. protected _wheelDeltaY: number;
  25691. /**
  25692. * Incremental value of multiple mouse wheel movements of the Z axis.
  25693. * Should be zero-ed when read.
  25694. */
  25695. protected _wheelDeltaZ: number;
  25696. /**
  25697. * Firefox uses a different scheme to report scroll distances to other
  25698. * browsers. Rather than use complicated methods to calculate the exact
  25699. * multiple we need to apply, let's just cheat and use a constant.
  25700. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25701. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25702. */
  25703. private readonly _ffMultiplier;
  25704. /**
  25705. * Different event attributes for wheel data fall into a few set ranges.
  25706. * Some relevant but dated date here:
  25707. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25708. */
  25709. private readonly _normalize;
  25710. }
  25711. }
  25712. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  25713. import { Nullable } from "babylonjs/types";
  25714. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25715. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  25716. import { Coordinate } from "babylonjs/Maths/math.axis";
  25717. /**
  25718. * Manage the mouse wheel inputs to control a free camera.
  25719. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25720. */
  25721. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25722. /**
  25723. * Defines the camera the input is attached to.
  25724. */
  25725. camera: FreeCamera;
  25726. /**
  25727. * Gets the class name of the current input.
  25728. * @returns the class name
  25729. */
  25730. getClassName(): string;
  25731. /**
  25732. * Set which movement axis (relative to camera's orientation) the mouse
  25733. * wheel's X axis controls.
  25734. * @param axis The axis to be moved. Set null to clear.
  25735. */
  25736. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25737. /**
  25738. * Get the configured movement axis (relative to camera's orientation) the
  25739. * mouse wheel's X axis controls.
  25740. * @returns The configured axis or null if none.
  25741. */
  25742. get wheelXMoveRelative(): Nullable<Coordinate>;
  25743. /**
  25744. * Set which movement axis (relative to camera's orientation) the mouse
  25745. * wheel's Y axis controls.
  25746. * @param axis The axis to be moved. Set null to clear.
  25747. */
  25748. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25749. /**
  25750. * Get the configured movement axis (relative to camera's orientation) the
  25751. * mouse wheel's Y axis controls.
  25752. * @returns The configured axis or null if none.
  25753. */
  25754. get wheelYMoveRelative(): Nullable<Coordinate>;
  25755. /**
  25756. * Set which movement axis (relative to camera's orientation) the mouse
  25757. * wheel's Z axis controls.
  25758. * @param axis The axis to be moved. Set null to clear.
  25759. */
  25760. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25761. /**
  25762. * Get the configured movement axis (relative to camera's orientation) the
  25763. * mouse wheel's Z axis controls.
  25764. * @returns The configured axis or null if none.
  25765. */
  25766. get wheelZMoveRelative(): Nullable<Coordinate>;
  25767. /**
  25768. * Set which rotation axis (relative to camera's orientation) the mouse
  25769. * wheel's X axis controls.
  25770. * @param axis The axis to be moved. Set null to clear.
  25771. */
  25772. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25773. /**
  25774. * Get the configured rotation axis (relative to camera's orientation) the
  25775. * mouse wheel's X axis controls.
  25776. * @returns The configured axis or null if none.
  25777. */
  25778. get wheelXRotateRelative(): Nullable<Coordinate>;
  25779. /**
  25780. * Set which rotation axis (relative to camera's orientation) the mouse
  25781. * wheel's Y axis controls.
  25782. * @param axis The axis to be moved. Set null to clear.
  25783. */
  25784. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25785. /**
  25786. * Get the configured rotation axis (relative to camera's orientation) the
  25787. * mouse wheel's Y axis controls.
  25788. * @returns The configured axis or null if none.
  25789. */
  25790. get wheelYRotateRelative(): Nullable<Coordinate>;
  25791. /**
  25792. * Set which rotation axis (relative to camera's orientation) the mouse
  25793. * wheel's Z axis controls.
  25794. * @param axis The axis to be moved. Set null to clear.
  25795. */
  25796. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25797. /**
  25798. * Get the configured rotation axis (relative to camera's orientation) the
  25799. * mouse wheel's Z axis controls.
  25800. * @returns The configured axis or null if none.
  25801. */
  25802. get wheelZRotateRelative(): Nullable<Coordinate>;
  25803. /**
  25804. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25805. * controls.
  25806. * @param axis The axis to be moved. Set null to clear.
  25807. */
  25808. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25809. /**
  25810. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25811. * X axis controls.
  25812. * @returns The configured axis or null if none.
  25813. */
  25814. get wheelXMoveScene(): Nullable<Coordinate>;
  25815. /**
  25816. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25817. * controls.
  25818. * @param axis The axis to be moved. Set null to clear.
  25819. */
  25820. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25821. /**
  25822. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25823. * Y axis controls.
  25824. * @returns The configured axis or null if none.
  25825. */
  25826. get wheelYMoveScene(): Nullable<Coordinate>;
  25827. /**
  25828. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25829. * controls.
  25830. * @param axis The axis to be moved. Set null to clear.
  25831. */
  25832. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25833. /**
  25834. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25835. * Z axis controls.
  25836. * @returns The configured axis or null if none.
  25837. */
  25838. get wheelZMoveScene(): Nullable<Coordinate>;
  25839. /**
  25840. * Called for each rendered frame.
  25841. */
  25842. checkInputs(): void;
  25843. private _moveRelative;
  25844. private _rotateRelative;
  25845. private _moveScene;
  25846. /**
  25847. * These are set to the desired default behaviour.
  25848. */
  25849. private _wheelXAction;
  25850. private _wheelXActionCoordinate;
  25851. private _wheelYAction;
  25852. private _wheelYActionCoordinate;
  25853. private _wheelZAction;
  25854. private _wheelZActionCoordinate;
  25855. /**
  25856. * Update the camera according to any configured properties for the 3
  25857. * mouse-wheel axis.
  25858. */
  25859. private _updateCamera;
  25860. /**
  25861. * Update one property of the camera.
  25862. */
  25863. private _updateCameraProperty;
  25864. }
  25865. }
  25866. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25867. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25868. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25869. /**
  25870. * Manage the touch inputs to control the movement of a free camera.
  25871. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25872. */
  25873. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25874. /**
  25875. * Define if mouse events can be treated as touch events
  25876. */
  25877. allowMouse: boolean;
  25878. /**
  25879. * Defines the camera the input is attached to.
  25880. */
  25881. camera: FreeCamera;
  25882. /**
  25883. * Defines the touch sensibility for rotation.
  25884. * The higher the faster.
  25885. */
  25886. touchAngularSensibility: number;
  25887. /**
  25888. * Defines the touch sensibility for move.
  25889. * The higher the faster.
  25890. */
  25891. touchMoveSensibility: number;
  25892. private _offsetX;
  25893. private _offsetY;
  25894. private _pointerPressed;
  25895. private _pointerInput?;
  25896. private _observer;
  25897. private _onLostFocus;
  25898. /**
  25899. * Manage the touch inputs to control the movement of a free camera.
  25900. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25901. * @param allowMouse Defines if mouse events can be treated as touch events
  25902. */
  25903. constructor(
  25904. /**
  25905. * Define if mouse events can be treated as touch events
  25906. */
  25907. allowMouse?: boolean);
  25908. /**
  25909. * Attach the input controls to a specific dom element to get the input from.
  25910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25911. */
  25912. attachControl(noPreventDefault?: boolean): void;
  25913. /**
  25914. * Detach the current controls from the specified dom element.
  25915. */
  25916. detachControl(): void;
  25917. /**
  25918. * Update the current camera state depending on the inputs that have been used this frame.
  25919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25920. */
  25921. checkInputs(): void;
  25922. /**
  25923. * Gets the class name of the current intput.
  25924. * @returns the class name
  25925. */
  25926. getClassName(): string;
  25927. /**
  25928. * Get the friendly name associated with the input class.
  25929. * @returns the input friendly name
  25930. */
  25931. getSimpleName(): string;
  25932. }
  25933. }
  25934. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25935. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25936. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25937. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25938. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25939. import { Nullable } from "babylonjs/types";
  25940. /**
  25941. * Default Inputs manager for the FreeCamera.
  25942. * It groups all the default supported inputs for ease of use.
  25943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25944. */
  25945. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25946. /**
  25947. * @hidden
  25948. */
  25949. _mouseInput: Nullable<FreeCameraMouseInput>;
  25950. /**
  25951. * @hidden
  25952. */
  25953. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25954. /**
  25955. * Instantiates a new FreeCameraInputsManager.
  25956. * @param camera Defines the camera the inputs belong to
  25957. */
  25958. constructor(camera: FreeCamera);
  25959. /**
  25960. * Add keyboard input support to the input manager.
  25961. * @returns the current input manager
  25962. */
  25963. addKeyboard(): FreeCameraInputsManager;
  25964. /**
  25965. * Add mouse input support to the input manager.
  25966. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25967. * @returns the current input manager
  25968. */
  25969. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25970. /**
  25971. * Removes the mouse input support from the manager
  25972. * @returns the current input manager
  25973. */
  25974. removeMouse(): FreeCameraInputsManager;
  25975. /**
  25976. * Add mouse wheel input support to the input manager.
  25977. * @returns the current input manager
  25978. */
  25979. addMouseWheel(): FreeCameraInputsManager;
  25980. /**
  25981. * Removes the mouse wheel input support from the manager
  25982. * @returns the current input manager
  25983. */
  25984. removeMouseWheel(): FreeCameraInputsManager;
  25985. /**
  25986. * Add touch input support to the input manager.
  25987. * @returns the current input manager
  25988. */
  25989. addTouch(): FreeCameraInputsManager;
  25990. /**
  25991. * Remove all attached input methods from a camera
  25992. */
  25993. clear(): void;
  25994. }
  25995. }
  25996. declare module "babylonjs/Cameras/freeCamera" {
  25997. import { Vector3 } from "babylonjs/Maths/math.vector";
  25998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25999. import { Scene } from "babylonjs/scene";
  26000. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  26001. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  26002. /**
  26003. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26004. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  26005. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26006. */
  26007. export class FreeCamera extends TargetCamera {
  26008. /**
  26009. * Define the collision ellipsoid of the camera.
  26010. * This is helpful to simulate a camera body like the player body around the camera
  26011. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  26012. */
  26013. ellipsoid: Vector3;
  26014. /**
  26015. * Define an offset for the position of the ellipsoid around the camera.
  26016. * This can be helpful to determine the center of the body near the gravity center of the body
  26017. * instead of its head.
  26018. */
  26019. ellipsoidOffset: Vector3;
  26020. /**
  26021. * Enable or disable collisions of the camera with the rest of the scene objects.
  26022. */
  26023. checkCollisions: boolean;
  26024. /**
  26025. * Enable or disable gravity on the camera.
  26026. */
  26027. applyGravity: boolean;
  26028. /**
  26029. * Define the input manager associated to the camera.
  26030. */
  26031. inputs: FreeCameraInputsManager;
  26032. /**
  26033. * Gets the input sensibility for a mouse input. (default is 2000.0)
  26034. * Higher values reduce sensitivity.
  26035. */
  26036. get angularSensibility(): number;
  26037. /**
  26038. * Sets the input sensibility for a mouse input. (default is 2000.0)
  26039. * Higher values reduce sensitivity.
  26040. */
  26041. set angularSensibility(value: number);
  26042. /**
  26043. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  26044. */
  26045. get keysUp(): number[];
  26046. set keysUp(value: number[]);
  26047. /**
  26048. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  26049. */
  26050. get keysUpward(): number[];
  26051. set keysUpward(value: number[]);
  26052. /**
  26053. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  26054. */
  26055. get keysDown(): number[];
  26056. set keysDown(value: number[]);
  26057. /**
  26058. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  26059. */
  26060. get keysDownward(): number[];
  26061. set keysDownward(value: number[]);
  26062. /**
  26063. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  26064. */
  26065. get keysLeft(): number[];
  26066. set keysLeft(value: number[]);
  26067. /**
  26068. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  26069. */
  26070. get keysRight(): number[];
  26071. set keysRight(value: number[]);
  26072. /**
  26073. * Event raised when the camera collide with a mesh in the scene.
  26074. */
  26075. onCollide: (collidedMesh: AbstractMesh) => void;
  26076. private _collider;
  26077. private _needMoveForGravity;
  26078. private _oldPosition;
  26079. private _diffPosition;
  26080. private _newPosition;
  26081. /** @hidden */
  26082. _localDirection: Vector3;
  26083. /** @hidden */
  26084. _transformedDirection: Vector3;
  26085. /**
  26086. * Instantiates a Free Camera.
  26087. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26088. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  26089. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26090. * @param name Define the name of the camera in the scene
  26091. * @param position Define the start position of the camera in the scene
  26092. * @param scene Define the scene the camera belongs to
  26093. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  26094. */
  26095. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26096. /**
  26097. * Attach the input controls to a specific dom element to get the input from.
  26098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26099. */
  26100. attachControl(noPreventDefault?: boolean): void;
  26101. /**
  26102. * Attach the input controls to a specific dom element to get the input from.
  26103. * @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
  26104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26105. * BACK COMPAT SIGNATURE ONLY.
  26106. */
  26107. attachControl(ignored: any, noPreventDefault?: boolean): void;
  26108. /**
  26109. * Detach the current controls from the specified dom element.
  26110. */
  26111. detachControl(): void;
  26112. /**
  26113. * Detach the current controls from the specified dom element.
  26114. * @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
  26115. */
  26116. detachControl(ignored: any): void;
  26117. private _collisionMask;
  26118. /**
  26119. * Define a collision mask to limit the list of object the camera can collide with
  26120. */
  26121. get collisionMask(): number;
  26122. set collisionMask(mask: number);
  26123. /** @hidden */
  26124. _collideWithWorld(displacement: Vector3): void;
  26125. private _onCollisionPositionChange;
  26126. /** @hidden */
  26127. _checkInputs(): void;
  26128. /** @hidden */
  26129. _decideIfNeedsToMove(): boolean;
  26130. /** @hidden */
  26131. _updatePosition(): void;
  26132. /**
  26133. * Destroy the camera and release the current resources hold by it.
  26134. */
  26135. dispose(): void;
  26136. /**
  26137. * Gets the current object class name.
  26138. * @return the class name
  26139. */
  26140. getClassName(): string;
  26141. }
  26142. }
  26143. declare module "babylonjs/Gamepads/gamepad" {
  26144. import { Observable } from "babylonjs/Misc/observable";
  26145. /**
  26146. * Represents a gamepad control stick position
  26147. */
  26148. export class StickValues {
  26149. /**
  26150. * The x component of the control stick
  26151. */
  26152. x: number;
  26153. /**
  26154. * The y component of the control stick
  26155. */
  26156. y: number;
  26157. /**
  26158. * Initializes the gamepad x and y control stick values
  26159. * @param x The x component of the gamepad control stick value
  26160. * @param y The y component of the gamepad control stick value
  26161. */
  26162. constructor(
  26163. /**
  26164. * The x component of the control stick
  26165. */
  26166. x: number,
  26167. /**
  26168. * The y component of the control stick
  26169. */
  26170. y: number);
  26171. }
  26172. /**
  26173. * An interface which manages callbacks for gamepad button changes
  26174. */
  26175. export interface GamepadButtonChanges {
  26176. /**
  26177. * Called when a gamepad has been changed
  26178. */
  26179. changed: boolean;
  26180. /**
  26181. * Called when a gamepad press event has been triggered
  26182. */
  26183. pressChanged: boolean;
  26184. /**
  26185. * Called when a touch event has been triggered
  26186. */
  26187. touchChanged: boolean;
  26188. /**
  26189. * Called when a value has changed
  26190. */
  26191. valueChanged: boolean;
  26192. }
  26193. /**
  26194. * Represents a gamepad
  26195. */
  26196. export class Gamepad {
  26197. /**
  26198. * The id of the gamepad
  26199. */
  26200. id: string;
  26201. /**
  26202. * The index of the gamepad
  26203. */
  26204. index: number;
  26205. /**
  26206. * The browser gamepad
  26207. */
  26208. browserGamepad: any;
  26209. /**
  26210. * Specifies what type of gamepad this represents
  26211. */
  26212. type: number;
  26213. private _leftStick;
  26214. private _rightStick;
  26215. /** @hidden */
  26216. _isConnected: boolean;
  26217. private _leftStickAxisX;
  26218. private _leftStickAxisY;
  26219. private _rightStickAxisX;
  26220. private _rightStickAxisY;
  26221. /**
  26222. * Triggered when the left control stick has been changed
  26223. */
  26224. private _onleftstickchanged;
  26225. /**
  26226. * Triggered when the right control stick has been changed
  26227. */
  26228. private _onrightstickchanged;
  26229. /**
  26230. * Represents a gamepad controller
  26231. */
  26232. static GAMEPAD: number;
  26233. /**
  26234. * Represents a generic controller
  26235. */
  26236. static GENERIC: number;
  26237. /**
  26238. * Represents an XBox controller
  26239. */
  26240. static XBOX: number;
  26241. /**
  26242. * Represents a pose-enabled controller
  26243. */
  26244. static POSE_ENABLED: number;
  26245. /**
  26246. * Represents an Dual Shock controller
  26247. */
  26248. static DUALSHOCK: number;
  26249. /**
  26250. * Specifies whether the left control stick should be Y-inverted
  26251. */
  26252. protected _invertLeftStickY: boolean;
  26253. /**
  26254. * Specifies if the gamepad has been connected
  26255. */
  26256. get isConnected(): boolean;
  26257. /**
  26258. * Initializes the gamepad
  26259. * @param id The id of the gamepad
  26260. * @param index The index of the gamepad
  26261. * @param browserGamepad The browser gamepad
  26262. * @param leftStickX The x component of the left joystick
  26263. * @param leftStickY The y component of the left joystick
  26264. * @param rightStickX The x component of the right joystick
  26265. * @param rightStickY The y component of the right joystick
  26266. */
  26267. constructor(
  26268. /**
  26269. * The id of the gamepad
  26270. */
  26271. id: string,
  26272. /**
  26273. * The index of the gamepad
  26274. */
  26275. index: number,
  26276. /**
  26277. * The browser gamepad
  26278. */
  26279. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  26280. /**
  26281. * Callback triggered when the left joystick has changed
  26282. * @param callback
  26283. */
  26284. onleftstickchanged(callback: (values: StickValues) => void): void;
  26285. /**
  26286. * Callback triggered when the right joystick has changed
  26287. * @param callback
  26288. */
  26289. onrightstickchanged(callback: (values: StickValues) => void): void;
  26290. /**
  26291. * Gets the left joystick
  26292. */
  26293. get leftStick(): StickValues;
  26294. /**
  26295. * Sets the left joystick values
  26296. */
  26297. set leftStick(newValues: StickValues);
  26298. /**
  26299. * Gets the right joystick
  26300. */
  26301. get rightStick(): StickValues;
  26302. /**
  26303. * Sets the right joystick value
  26304. */
  26305. set rightStick(newValues: StickValues);
  26306. /**
  26307. * Updates the gamepad joystick positions
  26308. */
  26309. update(): void;
  26310. /**
  26311. * Disposes the gamepad
  26312. */
  26313. dispose(): void;
  26314. }
  26315. /**
  26316. * Represents a generic gamepad
  26317. */
  26318. export class GenericPad extends Gamepad {
  26319. private _buttons;
  26320. private _onbuttondown;
  26321. private _onbuttonup;
  26322. /**
  26323. * Observable triggered when a button has been pressed
  26324. */
  26325. onButtonDownObservable: Observable<number>;
  26326. /**
  26327. * Observable triggered when a button has been released
  26328. */
  26329. onButtonUpObservable: Observable<number>;
  26330. /**
  26331. * Callback triggered when a button has been pressed
  26332. * @param callback Called when a button has been pressed
  26333. */
  26334. onbuttondown(callback: (buttonPressed: number) => void): void;
  26335. /**
  26336. * Callback triggered when a button has been released
  26337. * @param callback Called when a button has been released
  26338. */
  26339. onbuttonup(callback: (buttonReleased: number) => void): void;
  26340. /**
  26341. * Initializes the generic gamepad
  26342. * @param id The id of the generic gamepad
  26343. * @param index The index of the generic gamepad
  26344. * @param browserGamepad The browser gamepad
  26345. */
  26346. constructor(id: string, index: number, browserGamepad: any);
  26347. private _setButtonValue;
  26348. /**
  26349. * Updates the generic gamepad
  26350. */
  26351. update(): void;
  26352. /**
  26353. * Disposes the generic gamepad
  26354. */
  26355. dispose(): void;
  26356. }
  26357. }
  26358. declare module "babylonjs/Animations/runtimeAnimation" {
  26359. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  26360. import { Animatable } from "babylonjs/Animations/animatable";
  26361. import { Scene } from "babylonjs/scene";
  26362. /**
  26363. * Defines a runtime animation
  26364. */
  26365. export class RuntimeAnimation {
  26366. private _events;
  26367. /**
  26368. * The current frame of the runtime animation
  26369. */
  26370. private _currentFrame;
  26371. /**
  26372. * The animation used by the runtime animation
  26373. */
  26374. private _animation;
  26375. /**
  26376. * The target of the runtime animation
  26377. */
  26378. private _target;
  26379. /**
  26380. * The initiating animatable
  26381. */
  26382. private _host;
  26383. /**
  26384. * The original value of the runtime animation
  26385. */
  26386. private _originalValue;
  26387. /**
  26388. * The original blend value of the runtime animation
  26389. */
  26390. private _originalBlendValue;
  26391. /**
  26392. * The offsets cache of the runtime animation
  26393. */
  26394. private _offsetsCache;
  26395. /**
  26396. * The high limits cache of the runtime animation
  26397. */
  26398. private _highLimitsCache;
  26399. /**
  26400. * Specifies if the runtime animation has been stopped
  26401. */
  26402. private _stopped;
  26403. /**
  26404. * The blending factor of the runtime animation
  26405. */
  26406. private _blendingFactor;
  26407. /**
  26408. * The BabylonJS scene
  26409. */
  26410. private _scene;
  26411. /**
  26412. * The current value of the runtime animation
  26413. */
  26414. private _currentValue;
  26415. /** @hidden */
  26416. _animationState: _IAnimationState;
  26417. /**
  26418. * The active target of the runtime animation
  26419. */
  26420. private _activeTargets;
  26421. private _currentActiveTarget;
  26422. private _directTarget;
  26423. /**
  26424. * The target path of the runtime animation
  26425. */
  26426. private _targetPath;
  26427. /**
  26428. * The weight of the runtime animation
  26429. */
  26430. private _weight;
  26431. /**
  26432. * The ratio offset of the runtime animation
  26433. */
  26434. private _ratioOffset;
  26435. /**
  26436. * The previous delay of the runtime animation
  26437. */
  26438. private _previousDelay;
  26439. /**
  26440. * The previous ratio of the runtime animation
  26441. */
  26442. private _previousRatio;
  26443. private _enableBlending;
  26444. private _keys;
  26445. private _minFrame;
  26446. private _maxFrame;
  26447. private _minValue;
  26448. private _maxValue;
  26449. private _targetIsArray;
  26450. /**
  26451. * Gets the current frame of the runtime animation
  26452. */
  26453. get currentFrame(): number;
  26454. /**
  26455. * Gets the weight of the runtime animation
  26456. */
  26457. get weight(): number;
  26458. /**
  26459. * Gets the current value of the runtime animation
  26460. */
  26461. get currentValue(): any;
  26462. /**
  26463. * Gets the target path of the runtime animation
  26464. */
  26465. get targetPath(): string;
  26466. /**
  26467. * Gets the actual target of the runtime animation
  26468. */
  26469. get target(): any;
  26470. /**
  26471. * Gets the additive state of the runtime animation
  26472. */
  26473. get isAdditive(): boolean;
  26474. /** @hidden */
  26475. _onLoop: () => void;
  26476. /**
  26477. * Create a new RuntimeAnimation object
  26478. * @param target defines the target of the animation
  26479. * @param animation defines the source animation object
  26480. * @param scene defines the hosting scene
  26481. * @param host defines the initiating Animatable
  26482. */
  26483. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26484. private _preparePath;
  26485. /**
  26486. * Gets the animation from the runtime animation
  26487. */
  26488. get animation(): Animation;
  26489. /**
  26490. * Resets the runtime animation to the beginning
  26491. * @param restoreOriginal defines whether to restore the target property to the original value
  26492. */
  26493. reset(restoreOriginal?: boolean): void;
  26494. /**
  26495. * Specifies if the runtime animation is stopped
  26496. * @returns Boolean specifying if the runtime animation is stopped
  26497. */
  26498. isStopped(): boolean;
  26499. /**
  26500. * Disposes of the runtime animation
  26501. */
  26502. dispose(): void;
  26503. /**
  26504. * Apply the interpolated value to the target
  26505. * @param currentValue defines the value computed by the animation
  26506. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26507. */
  26508. setValue(currentValue: any, weight: number): void;
  26509. private _getOriginalValues;
  26510. private _setValue;
  26511. /**
  26512. * Gets the loop pmode of the runtime animation
  26513. * @returns Loop Mode
  26514. */
  26515. private _getCorrectLoopMode;
  26516. /**
  26517. * Move the current animation to a given frame
  26518. * @param frame defines the frame to move to
  26519. */
  26520. goToFrame(frame: number): void;
  26521. /**
  26522. * @hidden Internal use only
  26523. */
  26524. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26525. /**
  26526. * Execute the current animation
  26527. * @param delay defines the delay to add to the current frame
  26528. * @param from defines the lower bound of the animation range
  26529. * @param to defines the upper bound of the animation range
  26530. * @param loop defines if the current animation must loop
  26531. * @param speedRatio defines the current speed ratio
  26532. * @param weight defines the weight of the animation (default is -1 so no weight)
  26533. * @param onLoop optional callback called when animation loops
  26534. * @returns a boolean indicating if the animation is running
  26535. */
  26536. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26537. }
  26538. }
  26539. declare module "babylonjs/Animations/animatable" {
  26540. import { Animation } from "babylonjs/Animations/animation";
  26541. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26542. import { Nullable } from "babylonjs/types";
  26543. import { Observable } from "babylonjs/Misc/observable";
  26544. import { Scene } from "babylonjs/scene";
  26545. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  26546. import { Node } from "babylonjs/node";
  26547. /**
  26548. * Class used to store an actual running animation
  26549. */
  26550. export class Animatable {
  26551. /** defines the target object */
  26552. target: any;
  26553. /** defines the starting frame number (default is 0) */
  26554. fromFrame: number;
  26555. /** defines the ending frame number (default is 100) */
  26556. toFrame: number;
  26557. /** defines if the animation must loop (default is false) */
  26558. loopAnimation: boolean;
  26559. /** defines a callback to call when animation ends if it is not looping */
  26560. onAnimationEnd?: (() => void) | null | undefined;
  26561. /** defines a callback to call when animation loops */
  26562. onAnimationLoop?: (() => void) | null | undefined;
  26563. /** defines whether the animation should be evaluated additively */
  26564. isAdditive: boolean;
  26565. private _localDelayOffset;
  26566. private _pausedDelay;
  26567. private _runtimeAnimations;
  26568. private _paused;
  26569. private _scene;
  26570. private _speedRatio;
  26571. private _weight;
  26572. private _syncRoot;
  26573. /**
  26574. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26575. * This will only apply for non looping animation (default is true)
  26576. */
  26577. disposeOnEnd: boolean;
  26578. /**
  26579. * Gets a boolean indicating if the animation has started
  26580. */
  26581. animationStarted: boolean;
  26582. /**
  26583. * Observer raised when the animation ends
  26584. */
  26585. onAnimationEndObservable: Observable<Animatable>;
  26586. /**
  26587. * Observer raised when the animation loops
  26588. */
  26589. onAnimationLoopObservable: Observable<Animatable>;
  26590. /**
  26591. * Gets the root Animatable used to synchronize and normalize animations
  26592. */
  26593. get syncRoot(): Nullable<Animatable>;
  26594. /**
  26595. * Gets the current frame of the first RuntimeAnimation
  26596. * Used to synchronize Animatables
  26597. */
  26598. get masterFrame(): number;
  26599. /**
  26600. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26601. */
  26602. get weight(): number;
  26603. set weight(value: number);
  26604. /**
  26605. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26606. */
  26607. get speedRatio(): number;
  26608. set speedRatio(value: number);
  26609. /**
  26610. * Creates a new Animatable
  26611. * @param scene defines the hosting scene
  26612. * @param target defines the target object
  26613. * @param fromFrame defines the starting frame number (default is 0)
  26614. * @param toFrame defines the ending frame number (default is 100)
  26615. * @param loopAnimation defines if the animation must loop (default is false)
  26616. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26617. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26618. * @param animations defines a group of animation to add to the new Animatable
  26619. * @param onAnimationLoop defines a callback to call when animation loops
  26620. * @param isAdditive defines whether the animation should be evaluated additively
  26621. */
  26622. constructor(scene: Scene,
  26623. /** defines the target object */
  26624. target: any,
  26625. /** defines the starting frame number (default is 0) */
  26626. fromFrame?: number,
  26627. /** defines the ending frame number (default is 100) */
  26628. toFrame?: number,
  26629. /** defines if the animation must loop (default is false) */
  26630. loopAnimation?: boolean, speedRatio?: number,
  26631. /** defines a callback to call when animation ends if it is not looping */
  26632. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26633. /** defines a callback to call when animation loops */
  26634. onAnimationLoop?: (() => void) | null | undefined,
  26635. /** defines whether the animation should be evaluated additively */
  26636. isAdditive?: boolean);
  26637. /**
  26638. * Synchronize and normalize current Animatable with a source Animatable
  26639. * This is useful when using animation weights and when animations are not of the same length
  26640. * @param root defines the root Animatable to synchronize with
  26641. * @returns the current Animatable
  26642. */
  26643. syncWith(root: Animatable): Animatable;
  26644. /**
  26645. * Gets the list of runtime animations
  26646. * @returns an array of RuntimeAnimation
  26647. */
  26648. getAnimations(): RuntimeAnimation[];
  26649. /**
  26650. * Adds more animations to the current animatable
  26651. * @param target defines the target of the animations
  26652. * @param animations defines the new animations to add
  26653. */
  26654. appendAnimations(target: any, animations: Animation[]): void;
  26655. /**
  26656. * Gets the source animation for a specific property
  26657. * @param property defines the propertyu to look for
  26658. * @returns null or the source animation for the given property
  26659. */
  26660. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26661. /**
  26662. * Gets the runtime animation for a specific property
  26663. * @param property defines the propertyu to look for
  26664. * @returns null or the runtime animation for the given property
  26665. */
  26666. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26667. /**
  26668. * Resets the animatable to its original state
  26669. */
  26670. reset(): void;
  26671. /**
  26672. * Allows the animatable to blend with current running animations
  26673. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26674. * @param blendingSpeed defines the blending speed to use
  26675. */
  26676. enableBlending(blendingSpeed: number): void;
  26677. /**
  26678. * Disable animation blending
  26679. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26680. */
  26681. disableBlending(): void;
  26682. /**
  26683. * Jump directly to a given frame
  26684. * @param frame defines the frame to jump to
  26685. */
  26686. goToFrame(frame: number): void;
  26687. /**
  26688. * Pause the animation
  26689. */
  26690. pause(): void;
  26691. /**
  26692. * Restart the animation
  26693. */
  26694. restart(): void;
  26695. private _raiseOnAnimationEnd;
  26696. /**
  26697. * Stop and delete the current animation
  26698. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26699. * @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)
  26700. */
  26701. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26702. /**
  26703. * Wait asynchronously for the animation to end
  26704. * @returns a promise which will be fullfilled when the animation ends
  26705. */
  26706. waitAsync(): Promise<Animatable>;
  26707. /** @hidden */
  26708. _animate(delay: number): boolean;
  26709. }
  26710. module "babylonjs/scene" {
  26711. interface Scene {
  26712. /** @hidden */
  26713. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26714. /** @hidden */
  26715. _processLateAnimationBindingsForMatrices(holder: {
  26716. totalWeight: number;
  26717. totalAdditiveWeight: number;
  26718. animations: RuntimeAnimation[];
  26719. additiveAnimations: RuntimeAnimation[];
  26720. originalValue: Matrix;
  26721. }): any;
  26722. /** @hidden */
  26723. _processLateAnimationBindingsForQuaternions(holder: {
  26724. totalWeight: number;
  26725. totalAdditiveWeight: number;
  26726. animations: RuntimeAnimation[];
  26727. additiveAnimations: RuntimeAnimation[];
  26728. originalValue: Quaternion;
  26729. }, refQuaternion: Quaternion): Quaternion;
  26730. /** @hidden */
  26731. _processLateAnimationBindings(): void;
  26732. /**
  26733. * Will start the animation sequence of a given target
  26734. * @param target defines the target
  26735. * @param from defines from which frame should animation start
  26736. * @param to defines until which frame should animation run.
  26737. * @param weight defines the weight to apply to the animation (1.0 by default)
  26738. * @param loop defines if the animation loops
  26739. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26740. * @param onAnimationEnd defines the function to be executed when the animation ends
  26741. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26742. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26743. * @param onAnimationLoop defines the callback to call when an animation loops
  26744. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26745. * @returns the animatable object created for this animation
  26746. */
  26747. 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;
  26748. /**
  26749. * Will start the animation sequence of a given target
  26750. * @param target defines the target
  26751. * @param from defines from which frame should animation start
  26752. * @param to defines until which frame should animation run.
  26753. * @param loop defines if the animation loops
  26754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26755. * @param onAnimationEnd defines the function to be executed when the animation ends
  26756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26757. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26758. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26759. * @param onAnimationLoop defines the callback to call when an animation loops
  26760. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26761. * @returns the animatable object created for this animation
  26762. */
  26763. 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;
  26764. /**
  26765. * Will start the animation sequence of a given target and its hierarchy
  26766. * @param target defines the target
  26767. * @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.
  26768. * @param from defines from which frame should animation start
  26769. * @param to defines until which frame should animation run.
  26770. * @param loop defines if the animation loops
  26771. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26772. * @param onAnimationEnd defines the function to be executed when the animation ends
  26773. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26774. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26775. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26776. * @param onAnimationLoop defines the callback to call when an animation loops
  26777. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26778. * @returns the list of created animatables
  26779. */
  26780. 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[];
  26781. /**
  26782. * Begin a new animation on a given node
  26783. * @param target defines the target where the animation will take place
  26784. * @param animations defines the list of animations to start
  26785. * @param from defines the initial value
  26786. * @param to defines the final value
  26787. * @param loop defines if you want animation to loop (off by default)
  26788. * @param speedRatio defines the speed ratio to apply to all animations
  26789. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26790. * @param onAnimationLoop defines the callback to call when an animation loops
  26791. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26792. * @returns the list of created animatables
  26793. */
  26794. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26795. /**
  26796. * Begin a new animation on a given node and its hierarchy
  26797. * @param target defines the root node where the animation will take place
  26798. * @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.
  26799. * @param animations defines the list of animations to start
  26800. * @param from defines the initial value
  26801. * @param to defines the final value
  26802. * @param loop defines if you want animation to loop (off by default)
  26803. * @param speedRatio defines the speed ratio to apply to all animations
  26804. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26805. * @param onAnimationLoop defines the callback to call when an animation loops
  26806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26807. * @returns the list of animatables created for all nodes
  26808. */
  26809. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26810. /**
  26811. * Gets the animatable associated with a specific target
  26812. * @param target defines the target of the animatable
  26813. * @returns the required animatable if found
  26814. */
  26815. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26816. /**
  26817. * Gets all animatables associated with a given target
  26818. * @param target defines the target to look animatables for
  26819. * @returns an array of Animatables
  26820. */
  26821. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26822. /**
  26823. * Stops and removes all animations that have been applied to the scene
  26824. */
  26825. stopAllAnimations(): void;
  26826. /**
  26827. * Gets the current delta time used by animation engine
  26828. */
  26829. deltaTime: number;
  26830. }
  26831. }
  26832. module "babylonjs/Bones/bone" {
  26833. interface Bone {
  26834. /**
  26835. * Copy an animation range from another bone
  26836. * @param source defines the source bone
  26837. * @param rangeName defines the range name to copy
  26838. * @param frameOffset defines the frame offset
  26839. * @param rescaleAsRequired defines if rescaling must be applied if required
  26840. * @param skelDimensionsRatio defines the scaling ratio
  26841. * @returns true if operation was successful
  26842. */
  26843. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26844. }
  26845. }
  26846. }
  26847. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26848. /**
  26849. * Class used to override all child animations of a given target
  26850. */
  26851. export class AnimationPropertiesOverride {
  26852. /**
  26853. * Gets or sets a value indicating if animation blending must be used
  26854. */
  26855. enableBlending: boolean;
  26856. /**
  26857. * Gets or sets the blending speed to use when enableBlending is true
  26858. */
  26859. blendingSpeed: number;
  26860. /**
  26861. * Gets or sets the default loop mode to use
  26862. */
  26863. loopMode: number;
  26864. }
  26865. }
  26866. declare module "babylonjs/Bones/skeleton" {
  26867. import { Bone } from "babylonjs/Bones/bone";
  26868. import { Observable } from "babylonjs/Misc/observable";
  26869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26870. import { Scene } from "babylonjs/scene";
  26871. import { Nullable } from "babylonjs/types";
  26872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26873. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26874. import { Animatable } from "babylonjs/Animations/animatable";
  26875. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26876. import { Animation } from "babylonjs/Animations/animation";
  26877. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26878. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26879. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26880. /**
  26881. * Class used to handle skinning animations
  26882. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26883. */
  26884. export class Skeleton implements IAnimatable {
  26885. /** defines the skeleton name */
  26886. name: string;
  26887. /** defines the skeleton Id */
  26888. id: string;
  26889. /**
  26890. * Defines the list of child bones
  26891. */
  26892. bones: Bone[];
  26893. /**
  26894. * Defines an estimate of the dimension of the skeleton at rest
  26895. */
  26896. dimensionsAtRest: Vector3;
  26897. /**
  26898. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26899. */
  26900. needInitialSkinMatrix: boolean;
  26901. /**
  26902. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26903. */
  26904. overrideMesh: Nullable<AbstractMesh>;
  26905. /**
  26906. * Gets the list of animations attached to this skeleton
  26907. */
  26908. animations: Array<Animation>;
  26909. private _scene;
  26910. private _isDirty;
  26911. private _transformMatrices;
  26912. private _transformMatrixTexture;
  26913. private _meshesWithPoseMatrix;
  26914. private _animatables;
  26915. private _identity;
  26916. private _synchronizedWithMesh;
  26917. private _ranges;
  26918. private _lastAbsoluteTransformsUpdateId;
  26919. private _canUseTextureForBones;
  26920. private _uniqueId;
  26921. /** @hidden */
  26922. _numBonesWithLinkedTransformNode: number;
  26923. /** @hidden */
  26924. _hasWaitingData: Nullable<boolean>;
  26925. /** @hidden */
  26926. _waitingOverrideMeshId: Nullable<string>;
  26927. /**
  26928. * Specifies if the skeleton should be serialized
  26929. */
  26930. doNotSerialize: boolean;
  26931. private _useTextureToStoreBoneMatrices;
  26932. /**
  26933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26934. * Please note that this option is not available if the hardware does not support it
  26935. */
  26936. get useTextureToStoreBoneMatrices(): boolean;
  26937. set useTextureToStoreBoneMatrices(value: boolean);
  26938. private _animationPropertiesOverride;
  26939. /**
  26940. * Gets or sets the animation properties override
  26941. */
  26942. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26943. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26944. /**
  26945. * List of inspectable custom properties (used by the Inspector)
  26946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26947. */
  26948. inspectableCustomProperties: IInspectable[];
  26949. /**
  26950. * An observable triggered before computing the skeleton's matrices
  26951. */
  26952. onBeforeComputeObservable: Observable<Skeleton>;
  26953. /**
  26954. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26955. */
  26956. get isUsingTextureForMatrices(): boolean;
  26957. /**
  26958. * Gets the unique ID of this skeleton
  26959. */
  26960. get uniqueId(): number;
  26961. /**
  26962. * Creates a new skeleton
  26963. * @param name defines the skeleton name
  26964. * @param id defines the skeleton Id
  26965. * @param scene defines the hosting scene
  26966. */
  26967. constructor(
  26968. /** defines the skeleton name */
  26969. name: string,
  26970. /** defines the skeleton Id */
  26971. id: string, scene: Scene);
  26972. /**
  26973. * Gets the current object class name.
  26974. * @return the class name
  26975. */
  26976. getClassName(): string;
  26977. /**
  26978. * Returns an array containing the root bones
  26979. * @returns an array containing the root bones
  26980. */
  26981. getChildren(): Array<Bone>;
  26982. /**
  26983. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26984. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26985. * @returns a Float32Array containing matrices data
  26986. */
  26987. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26988. /**
  26989. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26990. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26991. * @returns a raw texture containing the data
  26992. */
  26993. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26994. /**
  26995. * Gets the current hosting scene
  26996. * @returns a scene object
  26997. */
  26998. getScene(): Scene;
  26999. /**
  27000. * Gets a string representing the current skeleton data
  27001. * @param fullDetails defines a boolean indicating if we want a verbose version
  27002. * @returns a string representing the current skeleton data
  27003. */
  27004. toString(fullDetails?: boolean): string;
  27005. /**
  27006. * Get bone's index searching by name
  27007. * @param name defines bone's name to search for
  27008. * @return the indice of the bone. Returns -1 if not found
  27009. */
  27010. getBoneIndexByName(name: string): number;
  27011. /**
  27012. * Creater a new animation range
  27013. * @param name defines the name of the range
  27014. * @param from defines the start key
  27015. * @param to defines the end key
  27016. */
  27017. createAnimationRange(name: string, from: number, to: number): void;
  27018. /**
  27019. * Delete a specific animation range
  27020. * @param name defines the name of the range
  27021. * @param deleteFrames defines if frames must be removed as well
  27022. */
  27023. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27024. /**
  27025. * Gets a specific animation range
  27026. * @param name defines the name of the range to look for
  27027. * @returns the requested animation range or null if not found
  27028. */
  27029. getAnimationRange(name: string): Nullable<AnimationRange>;
  27030. /**
  27031. * Gets the list of all animation ranges defined on this skeleton
  27032. * @returns an array
  27033. */
  27034. getAnimationRanges(): Nullable<AnimationRange>[];
  27035. /**
  27036. * Copy animation range from a source skeleton.
  27037. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  27038. * @param source defines the source skeleton
  27039. * @param name defines the name of the range to copy
  27040. * @param rescaleAsRequired defines if rescaling must be applied if required
  27041. * @returns true if operation was successful
  27042. */
  27043. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  27044. /**
  27045. * Forces the skeleton to go to rest pose
  27046. */
  27047. returnToRest(): void;
  27048. private _getHighestAnimationFrame;
  27049. /**
  27050. * Begin a specific animation range
  27051. * @param name defines the name of the range to start
  27052. * @param loop defines if looping must be turned on (false by default)
  27053. * @param speedRatio defines the speed ratio to apply (1 by default)
  27054. * @param onAnimationEnd defines a callback which will be called when animation will end
  27055. * @returns a new animatable
  27056. */
  27057. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27058. /**
  27059. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  27060. * @param skeleton defines the Skeleton containing the animation range to convert
  27061. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  27062. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  27063. * @returns the original skeleton
  27064. */
  27065. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  27066. /** @hidden */
  27067. _markAsDirty(): void;
  27068. /** @hidden */
  27069. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27070. /** @hidden */
  27071. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27072. private _computeTransformMatrices;
  27073. /**
  27074. * Build all resources required to render a skeleton
  27075. */
  27076. prepare(): void;
  27077. /**
  27078. * Gets the list of animatables currently running for this skeleton
  27079. * @returns an array of animatables
  27080. */
  27081. getAnimatables(): IAnimatable[];
  27082. /**
  27083. * Clone the current skeleton
  27084. * @param name defines the name of the new skeleton
  27085. * @param id defines the id of the new skeleton
  27086. * @returns the new skeleton
  27087. */
  27088. clone(name: string, id?: string): Skeleton;
  27089. /**
  27090. * Enable animation blending for this skeleton
  27091. * @param blendingSpeed defines the blending speed to apply
  27092. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  27093. */
  27094. enableBlending(blendingSpeed?: number): void;
  27095. /**
  27096. * Releases all resources associated with the current skeleton
  27097. */
  27098. dispose(): void;
  27099. /**
  27100. * Serialize the skeleton in a JSON object
  27101. * @returns a JSON object
  27102. */
  27103. serialize(): any;
  27104. /**
  27105. * Creates a new skeleton from serialized data
  27106. * @param parsedSkeleton defines the serialized data
  27107. * @param scene defines the hosting scene
  27108. * @returns a new skeleton
  27109. */
  27110. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  27111. /**
  27112. * Compute all node absolute transforms
  27113. * @param forceUpdate defines if computation must be done even if cache is up to date
  27114. */
  27115. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  27116. /**
  27117. * Gets the root pose matrix
  27118. * @returns a matrix
  27119. */
  27120. getPoseMatrix(): Nullable<Matrix>;
  27121. /**
  27122. * Sorts bones per internal index
  27123. */
  27124. sortBones(): void;
  27125. private _sortBones;
  27126. /**
  27127. * Set the current local matrix as the restPose for all bones in the skeleton.
  27128. */
  27129. setCurrentPoseAsRest(): void;
  27130. }
  27131. }
  27132. declare module "babylonjs/Bones/bone" {
  27133. import { Skeleton } from "babylonjs/Bones/skeleton";
  27134. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  27135. import { Nullable } from "babylonjs/types";
  27136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27138. import { Node } from "babylonjs/node";
  27139. import { Space } from "babylonjs/Maths/math.axis";
  27140. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27141. /**
  27142. * Class used to store bone information
  27143. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27144. */
  27145. export class Bone extends Node {
  27146. /**
  27147. * defines the bone name
  27148. */
  27149. name: string;
  27150. private static _tmpVecs;
  27151. private static _tmpQuat;
  27152. private static _tmpMats;
  27153. /**
  27154. * Gets the list of child bones
  27155. */
  27156. children: Bone[];
  27157. /** Gets the animations associated with this bone */
  27158. animations: import("babylonjs/Animations/animation").Animation[];
  27159. /**
  27160. * Gets or sets bone length
  27161. */
  27162. length: number;
  27163. /**
  27164. * @hidden Internal only
  27165. * Set this value to map this bone to a different index in the transform matrices
  27166. * Set this value to -1 to exclude the bone from the transform matrices
  27167. */
  27168. _index: Nullable<number>;
  27169. private _skeleton;
  27170. private _localMatrix;
  27171. private _restPose;
  27172. private _bindPose;
  27173. private _baseMatrix;
  27174. private _absoluteTransform;
  27175. private _invertedAbsoluteTransform;
  27176. private _parent;
  27177. private _scalingDeterminant;
  27178. private _worldTransform;
  27179. private _localScaling;
  27180. private _localRotation;
  27181. private _localPosition;
  27182. private _needToDecompose;
  27183. private _needToCompose;
  27184. /** @hidden */
  27185. _linkedTransformNode: Nullable<TransformNode>;
  27186. /** @hidden */
  27187. _waitingTransformNodeId: Nullable<string>;
  27188. /** @hidden */
  27189. get _matrix(): Matrix;
  27190. /** @hidden */
  27191. set _matrix(value: Matrix);
  27192. /**
  27193. * Create a new bone
  27194. * @param name defines the bone name
  27195. * @param skeleton defines the parent skeleton
  27196. * @param parentBone defines the parent (can be null if the bone is the root)
  27197. * @param localMatrix defines the local matrix
  27198. * @param restPose defines the rest pose matrix
  27199. * @param baseMatrix defines the base matrix
  27200. * @param index defines index of the bone in the hiearchy
  27201. */
  27202. constructor(
  27203. /**
  27204. * defines the bone name
  27205. */
  27206. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  27207. /**
  27208. * Gets the current object class name.
  27209. * @return the class name
  27210. */
  27211. getClassName(): string;
  27212. /**
  27213. * Gets the parent skeleton
  27214. * @returns a skeleton
  27215. */
  27216. getSkeleton(): Skeleton;
  27217. /**
  27218. * Gets parent bone
  27219. * @returns a bone or null if the bone is the root of the bone hierarchy
  27220. */
  27221. getParent(): Nullable<Bone>;
  27222. /**
  27223. * Returns an array containing the root bones
  27224. * @returns an array containing the root bones
  27225. */
  27226. getChildren(): Array<Bone>;
  27227. /**
  27228. * Gets the node index in matrix array generated for rendering
  27229. * @returns the node index
  27230. */
  27231. getIndex(): number;
  27232. /**
  27233. * Sets the parent bone
  27234. * @param parent defines the parent (can be null if the bone is the root)
  27235. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27236. */
  27237. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  27238. /**
  27239. * Gets the local matrix
  27240. * @returns a matrix
  27241. */
  27242. getLocalMatrix(): Matrix;
  27243. /**
  27244. * Gets the base matrix (initial matrix which remains unchanged)
  27245. * @returns a matrix
  27246. */
  27247. getBaseMatrix(): Matrix;
  27248. /**
  27249. * Gets the rest pose matrix
  27250. * @returns a matrix
  27251. */
  27252. getRestPose(): Matrix;
  27253. /**
  27254. * Sets the rest pose matrix
  27255. * @param matrix the local-space rest pose to set for this bone
  27256. */
  27257. setRestPose(matrix: Matrix): void;
  27258. /**
  27259. * Gets the bind pose matrix
  27260. * @returns the bind pose matrix
  27261. */
  27262. getBindPose(): Matrix;
  27263. /**
  27264. * Sets the bind pose matrix
  27265. * @param matrix the local-space bind pose to set for this bone
  27266. */
  27267. setBindPose(matrix: Matrix): void;
  27268. /**
  27269. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  27270. */
  27271. getWorldMatrix(): Matrix;
  27272. /**
  27273. * Sets the local matrix to rest pose matrix
  27274. */
  27275. returnToRest(): void;
  27276. /**
  27277. * Gets the inverse of the absolute transform matrix.
  27278. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  27279. * @returns a matrix
  27280. */
  27281. getInvertedAbsoluteTransform(): Matrix;
  27282. /**
  27283. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  27284. * @returns a matrix
  27285. */
  27286. getAbsoluteTransform(): Matrix;
  27287. /**
  27288. * Links with the given transform node.
  27289. * The local matrix of this bone is copied from the transform node every frame.
  27290. * @param transformNode defines the transform node to link to
  27291. */
  27292. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  27293. /**
  27294. * Gets the node used to drive the bone's transformation
  27295. * @returns a transform node or null
  27296. */
  27297. getTransformNode(): Nullable<TransformNode>;
  27298. /** Gets or sets current position (in local space) */
  27299. get position(): Vector3;
  27300. set position(newPosition: Vector3);
  27301. /** Gets or sets current rotation (in local space) */
  27302. get rotation(): Vector3;
  27303. set rotation(newRotation: Vector3);
  27304. /** Gets or sets current rotation quaternion (in local space) */
  27305. get rotationQuaternion(): Quaternion;
  27306. set rotationQuaternion(newRotation: Quaternion);
  27307. /** Gets or sets current scaling (in local space) */
  27308. get scaling(): Vector3;
  27309. set scaling(newScaling: Vector3);
  27310. /**
  27311. * Gets the animation properties override
  27312. */
  27313. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27314. private _decompose;
  27315. private _compose;
  27316. /**
  27317. * Update the base and local matrices
  27318. * @param matrix defines the new base or local matrix
  27319. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27320. * @param updateLocalMatrix defines if the local matrix should be updated
  27321. */
  27322. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  27323. /** @hidden */
  27324. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  27325. /**
  27326. * Flag the bone as dirty (Forcing it to update everything)
  27327. */
  27328. markAsDirty(): void;
  27329. /** @hidden */
  27330. _markAsDirtyAndCompose(): void;
  27331. private _markAsDirtyAndDecompose;
  27332. /**
  27333. * Translate the bone in local or world space
  27334. * @param vec The amount to translate the bone
  27335. * @param space The space that the translation is in
  27336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27337. */
  27338. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27339. /**
  27340. * Set the postion of the bone in local or world space
  27341. * @param position The position to set the bone
  27342. * @param space The space that the position is in
  27343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27344. */
  27345. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27346. /**
  27347. * Set the absolute position of the bone (world space)
  27348. * @param position The position to set the bone
  27349. * @param mesh The mesh that this bone is attached to
  27350. */
  27351. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  27352. /**
  27353. * Scale the bone on the x, y and z axes (in local space)
  27354. * @param x The amount to scale the bone on the x axis
  27355. * @param y The amount to scale the bone on the y axis
  27356. * @param z The amount to scale the bone on the z axis
  27357. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  27358. */
  27359. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  27360. /**
  27361. * Set the bone scaling in local space
  27362. * @param scale defines the scaling vector
  27363. */
  27364. setScale(scale: Vector3): void;
  27365. /**
  27366. * Gets the current scaling in local space
  27367. * @returns the current scaling vector
  27368. */
  27369. getScale(): Vector3;
  27370. /**
  27371. * Gets the current scaling in local space and stores it in a target vector
  27372. * @param result defines the target vector
  27373. */
  27374. getScaleToRef(result: Vector3): void;
  27375. /**
  27376. * Set the yaw, pitch, and roll of the bone in local or world space
  27377. * @param yaw The rotation of the bone on the y axis
  27378. * @param pitch The rotation of the bone on the x axis
  27379. * @param roll The rotation of the bone on the z axis
  27380. * @param space The space that the axes of rotation are in
  27381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27382. */
  27383. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  27384. /**
  27385. * Add a rotation to the bone on an axis in local or world space
  27386. * @param axis The axis to rotate the bone on
  27387. * @param amount The amount to rotate the bone
  27388. * @param space The space that the axis is in
  27389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27390. */
  27391. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  27392. /**
  27393. * Set the rotation of the bone to a particular axis angle in local or world space
  27394. * @param axis The axis to rotate the bone on
  27395. * @param angle The angle that the bone should be rotated to
  27396. * @param space The space that the axis is in
  27397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27398. */
  27399. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  27400. /**
  27401. * Set the euler rotation of the bone in local or world space
  27402. * @param rotation The euler rotation that the bone should be set to
  27403. * @param space The space that the rotation is in
  27404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27405. */
  27406. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27407. /**
  27408. * Set the quaternion rotation of the bone in local or world space
  27409. * @param quat The quaternion rotation that the bone should be set to
  27410. * @param space The space that the rotation is in
  27411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27412. */
  27413. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  27414. /**
  27415. * Set the rotation matrix of the bone in local or world space
  27416. * @param rotMat The rotation matrix that the bone should be set to
  27417. * @param space The space that the rotation is in
  27418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27419. */
  27420. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  27421. private _rotateWithMatrix;
  27422. private _getNegativeRotationToRef;
  27423. /**
  27424. * Get the position of the bone in local or world space
  27425. * @param space The space that the returned position is in
  27426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27427. * @returns The position of the bone
  27428. */
  27429. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27430. /**
  27431. * Copy the position of the bone to a vector3 in local or world space
  27432. * @param space The space that the returned position is in
  27433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27434. * @param result The vector3 to copy the position to
  27435. */
  27436. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  27437. /**
  27438. * Get the absolute position of the bone (world space)
  27439. * @param mesh The mesh that this bone is attached to
  27440. * @returns The absolute position of the bone
  27441. */
  27442. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  27443. /**
  27444. * Copy the absolute position of the bone (world space) to the result param
  27445. * @param mesh The mesh that this bone is attached to
  27446. * @param result The vector3 to copy the absolute position to
  27447. */
  27448. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27449. /**
  27450. * Compute the absolute transforms of this bone and its children
  27451. */
  27452. computeAbsoluteTransforms(): void;
  27453. /**
  27454. * Get the world direction from an axis that is in the local space of the bone
  27455. * @param localAxis The local direction that is used to compute the world direction
  27456. * @param mesh The mesh that this bone is attached to
  27457. * @returns The world direction
  27458. */
  27459. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27460. /**
  27461. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27462. * @param localAxis The local direction that is used to compute the world direction
  27463. * @param mesh The mesh that this bone is attached to
  27464. * @param result The vector3 that the world direction will be copied to
  27465. */
  27466. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27467. /**
  27468. * Get the euler rotation of the bone in local or world space
  27469. * @param space The space that the rotation should be in
  27470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27471. * @returns The euler rotation
  27472. */
  27473. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27474. /**
  27475. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27476. * @param space The space that the rotation should be in
  27477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27478. * @param result The vector3 that the rotation should be copied to
  27479. */
  27480. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27481. /**
  27482. * Get the quaternion rotation of the bone in either local or world space
  27483. * @param space The space that the rotation should be in
  27484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27485. * @returns The quaternion rotation
  27486. */
  27487. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27488. /**
  27489. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27490. * @param space The space that the rotation should be in
  27491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27492. * @param result The quaternion that the rotation should be copied to
  27493. */
  27494. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27495. /**
  27496. * Get the rotation matrix of the bone in local or world space
  27497. * @param space The space that the rotation should be in
  27498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27499. * @returns The rotation matrix
  27500. */
  27501. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27502. /**
  27503. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27504. * @param space The space that the rotation should be in
  27505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27506. * @param result The quaternion that the rotation should be copied to
  27507. */
  27508. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27509. /**
  27510. * Get the world position of a point that is in the local space of the bone
  27511. * @param position The local position
  27512. * @param mesh The mesh that this bone is attached to
  27513. * @returns The world position
  27514. */
  27515. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27516. /**
  27517. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27518. * @param position The local position
  27519. * @param mesh The mesh that this bone is attached to
  27520. * @param result The vector3 that the world position should be copied to
  27521. */
  27522. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27523. /**
  27524. * Get the local position of a point that is in world space
  27525. * @param position The world position
  27526. * @param mesh The mesh that this bone is attached to
  27527. * @returns The local position
  27528. */
  27529. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27530. /**
  27531. * Get the local position of a point that is in world space and copy it to the result param
  27532. * @param position The world position
  27533. * @param mesh The mesh that this bone is attached to
  27534. * @param result The vector3 that the local position should be copied to
  27535. */
  27536. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27537. /**
  27538. * Set the current local matrix as the restPose for this bone.
  27539. */
  27540. setCurrentPoseAsRest(): void;
  27541. }
  27542. }
  27543. declare module "babylonjs/Meshes/transformNode" {
  27544. import { DeepImmutable } from "babylonjs/types";
  27545. import { Observable } from "babylonjs/Misc/observable";
  27546. import { Nullable } from "babylonjs/types";
  27547. import { Camera } from "babylonjs/Cameras/camera";
  27548. import { Scene } from "babylonjs/scene";
  27549. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27550. import { Node } from "babylonjs/node";
  27551. import { Bone } from "babylonjs/Bones/bone";
  27552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27553. import { Space } from "babylonjs/Maths/math.axis";
  27554. /**
  27555. * 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.
  27556. * @see https://doc.babylonjs.com/how_to/transformnode
  27557. */
  27558. export class TransformNode extends Node {
  27559. /**
  27560. * Object will not rotate to face the camera
  27561. */
  27562. static BILLBOARDMODE_NONE: number;
  27563. /**
  27564. * Object will rotate to face the camera but only on the x axis
  27565. */
  27566. static BILLBOARDMODE_X: number;
  27567. /**
  27568. * Object will rotate to face the camera but only on the y axis
  27569. */
  27570. static BILLBOARDMODE_Y: number;
  27571. /**
  27572. * Object will rotate to face the camera but only on the z axis
  27573. */
  27574. static BILLBOARDMODE_Z: number;
  27575. /**
  27576. * Object will rotate to face the camera
  27577. */
  27578. static BILLBOARDMODE_ALL: number;
  27579. /**
  27580. * Object will rotate to face the camera's position instead of orientation
  27581. */
  27582. static BILLBOARDMODE_USE_POSITION: number;
  27583. private static _TmpRotation;
  27584. private static _TmpScaling;
  27585. private static _TmpTranslation;
  27586. private _forward;
  27587. private _forwardInverted;
  27588. private _up;
  27589. private _right;
  27590. private _rightInverted;
  27591. private _position;
  27592. private _rotation;
  27593. private _rotationQuaternion;
  27594. protected _scaling: Vector3;
  27595. protected _isDirty: boolean;
  27596. private _transformToBoneReferal;
  27597. private _isAbsoluteSynced;
  27598. private _billboardMode;
  27599. /**
  27600. * Gets or sets the billboard mode. Default is 0.
  27601. *
  27602. * | Value | Type | Description |
  27603. * | --- | --- | --- |
  27604. * | 0 | BILLBOARDMODE_NONE | |
  27605. * | 1 | BILLBOARDMODE_X | |
  27606. * | 2 | BILLBOARDMODE_Y | |
  27607. * | 4 | BILLBOARDMODE_Z | |
  27608. * | 7 | BILLBOARDMODE_ALL | |
  27609. *
  27610. */
  27611. get billboardMode(): number;
  27612. set billboardMode(value: number);
  27613. private _preserveParentRotationForBillboard;
  27614. /**
  27615. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27616. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27617. */
  27618. get preserveParentRotationForBillboard(): boolean;
  27619. set preserveParentRotationForBillboard(value: boolean);
  27620. /**
  27621. * 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
  27622. */
  27623. scalingDeterminant: number;
  27624. private _infiniteDistance;
  27625. /**
  27626. * Gets or sets the distance of the object to max, often used by skybox
  27627. */
  27628. get infiniteDistance(): boolean;
  27629. set infiniteDistance(value: boolean);
  27630. /**
  27631. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27632. * By default the system will update normals to compensate
  27633. */
  27634. ignoreNonUniformScaling: boolean;
  27635. /**
  27636. * 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
  27637. */
  27638. reIntegrateRotationIntoRotationQuaternion: boolean;
  27639. /** @hidden */
  27640. _poseMatrix: Nullable<Matrix>;
  27641. /** @hidden */
  27642. _localMatrix: Matrix;
  27643. private _usePivotMatrix;
  27644. private _absolutePosition;
  27645. private _absoluteScaling;
  27646. private _absoluteRotationQuaternion;
  27647. private _pivotMatrix;
  27648. private _pivotMatrixInverse;
  27649. /** @hidden */
  27650. _postMultiplyPivotMatrix: boolean;
  27651. protected _isWorldMatrixFrozen: boolean;
  27652. /** @hidden */
  27653. _indexInSceneTransformNodesArray: number;
  27654. /**
  27655. * An event triggered after the world matrix is updated
  27656. */
  27657. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27658. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27659. /**
  27660. * Gets a string identifying the name of the class
  27661. * @returns "TransformNode" string
  27662. */
  27663. getClassName(): string;
  27664. /**
  27665. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27666. */
  27667. get position(): Vector3;
  27668. set position(newPosition: Vector3);
  27669. /**
  27670. * 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)).
  27671. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27672. */
  27673. get rotation(): Vector3;
  27674. set rotation(newRotation: Vector3);
  27675. /**
  27676. * 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)).
  27677. */
  27678. get scaling(): Vector3;
  27679. set scaling(newScaling: Vector3);
  27680. /**
  27681. * 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).
  27682. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27683. */
  27684. get rotationQuaternion(): Nullable<Quaternion>;
  27685. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27686. /**
  27687. * The forward direction of that transform in world space.
  27688. */
  27689. get forward(): Vector3;
  27690. /**
  27691. * The up direction of that transform in world space.
  27692. */
  27693. get up(): Vector3;
  27694. /**
  27695. * The right direction of that transform in world space.
  27696. */
  27697. get right(): Vector3;
  27698. /**
  27699. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27700. * @param matrix the matrix to copy the pose from
  27701. * @returns this TransformNode.
  27702. */
  27703. updatePoseMatrix(matrix: Matrix): TransformNode;
  27704. /**
  27705. * Returns the mesh Pose matrix.
  27706. * @returns the pose matrix
  27707. */
  27708. getPoseMatrix(): Matrix;
  27709. /** @hidden */
  27710. _isSynchronized(): boolean;
  27711. /** @hidden */
  27712. _initCache(): void;
  27713. /**
  27714. * Flag the transform node as dirty (Forcing it to update everything)
  27715. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27716. * @returns this transform node
  27717. */
  27718. markAsDirty(property: string): TransformNode;
  27719. /**
  27720. * Returns the current mesh absolute position.
  27721. * Returns a Vector3.
  27722. */
  27723. get absolutePosition(): Vector3;
  27724. /**
  27725. * Returns the current mesh absolute scaling.
  27726. * Returns a Vector3.
  27727. */
  27728. get absoluteScaling(): Vector3;
  27729. /**
  27730. * Returns the current mesh absolute rotation.
  27731. * Returns a Quaternion.
  27732. */
  27733. get absoluteRotationQuaternion(): Quaternion;
  27734. /**
  27735. * Sets a new matrix to apply before all other transformation
  27736. * @param matrix defines the transform matrix
  27737. * @returns the current TransformNode
  27738. */
  27739. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27740. /**
  27741. * Sets a new pivot matrix to the current node
  27742. * @param matrix defines the new pivot matrix to use
  27743. * @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
  27744. * @returns the current TransformNode
  27745. */
  27746. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27747. /**
  27748. * Returns the mesh pivot matrix.
  27749. * Default : Identity.
  27750. * @returns the matrix
  27751. */
  27752. getPivotMatrix(): Matrix;
  27753. /**
  27754. * Instantiate (when possible) or clone that node with its hierarchy
  27755. * @param newParent defines the new parent to use for the instance (or clone)
  27756. * @param options defines options to configure how copy is done
  27757. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27758. * @returns an instance (or a clone) of the current node with its hiearchy
  27759. */
  27760. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27761. doNotInstantiate: boolean;
  27762. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27763. /**
  27764. * Prevents the World matrix to be computed any longer
  27765. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27766. * @returns the TransformNode.
  27767. */
  27768. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27769. /**
  27770. * Allows back the World matrix computation.
  27771. * @returns the TransformNode.
  27772. */
  27773. unfreezeWorldMatrix(): this;
  27774. /**
  27775. * True if the World matrix has been frozen.
  27776. */
  27777. get isWorldMatrixFrozen(): boolean;
  27778. /**
  27779. * Retuns the mesh absolute position in the World.
  27780. * @returns a Vector3.
  27781. */
  27782. getAbsolutePosition(): Vector3;
  27783. /**
  27784. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27785. * @param absolutePosition the absolute position to set
  27786. * @returns the TransformNode.
  27787. */
  27788. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27789. /**
  27790. * Sets the mesh position in its local space.
  27791. * @param vector3 the position to set in localspace
  27792. * @returns the TransformNode.
  27793. */
  27794. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27795. /**
  27796. * Returns the mesh position in the local space from the current World matrix values.
  27797. * @returns a new Vector3.
  27798. */
  27799. getPositionExpressedInLocalSpace(): Vector3;
  27800. /**
  27801. * Translates the mesh along the passed Vector3 in its local space.
  27802. * @param vector3 the distance to translate in localspace
  27803. * @returns the TransformNode.
  27804. */
  27805. locallyTranslate(vector3: Vector3): TransformNode;
  27806. private static _lookAtVectorCache;
  27807. /**
  27808. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27809. * @param targetPoint the position (must be in same space as current mesh) to look at
  27810. * @param yawCor optional yaw (y-axis) correction in radians
  27811. * @param pitchCor optional pitch (x-axis) correction in radians
  27812. * @param rollCor optional roll (z-axis) correction in radians
  27813. * @param space the choosen space of the target
  27814. * @returns the TransformNode.
  27815. */
  27816. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27817. /**
  27818. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27819. * This Vector3 is expressed in the World space.
  27820. * @param localAxis axis to rotate
  27821. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27822. */
  27823. getDirection(localAxis: Vector3): Vector3;
  27824. /**
  27825. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27826. * localAxis is expressed in the mesh local space.
  27827. * result is computed in the Wordl space from the mesh World matrix.
  27828. * @param localAxis axis to rotate
  27829. * @param result the resulting transformnode
  27830. * @returns this TransformNode.
  27831. */
  27832. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27833. /**
  27834. * Sets this transform node rotation to the given local axis.
  27835. * @param localAxis the axis in local space
  27836. * @param yawCor optional yaw (y-axis) correction in radians
  27837. * @param pitchCor optional pitch (x-axis) correction in radians
  27838. * @param rollCor optional roll (z-axis) correction in radians
  27839. * @returns this TransformNode
  27840. */
  27841. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27842. /**
  27843. * Sets a new pivot point to the current node
  27844. * @param point defines the new pivot point to use
  27845. * @param space defines if the point is in world or local space (local by default)
  27846. * @returns the current TransformNode
  27847. */
  27848. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27849. /**
  27850. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27851. * @returns the pivot point
  27852. */
  27853. getPivotPoint(): Vector3;
  27854. /**
  27855. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27856. * @param result the vector3 to store the result
  27857. * @returns this TransformNode.
  27858. */
  27859. getPivotPointToRef(result: Vector3): TransformNode;
  27860. /**
  27861. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27862. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27863. */
  27864. getAbsolutePivotPoint(): Vector3;
  27865. /**
  27866. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27867. * @param result vector3 to store the result
  27868. * @returns this TransformNode.
  27869. */
  27870. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27871. /**
  27872. * Defines the passed node as the parent of the current node.
  27873. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27874. * @see https://doc.babylonjs.com/how_to/parenting
  27875. * @param node the node ot set as the parent
  27876. * @returns this TransformNode.
  27877. */
  27878. setParent(node: Nullable<Node>): TransformNode;
  27879. private _nonUniformScaling;
  27880. /**
  27881. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27882. */
  27883. get nonUniformScaling(): boolean;
  27884. /** @hidden */
  27885. _updateNonUniformScalingState(value: boolean): boolean;
  27886. /**
  27887. * Attach the current TransformNode to another TransformNode associated with a bone
  27888. * @param bone Bone affecting the TransformNode
  27889. * @param affectedTransformNode TransformNode associated with the bone
  27890. * @returns this object
  27891. */
  27892. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27893. /**
  27894. * Detach the transform node if its associated with a bone
  27895. * @returns this object
  27896. */
  27897. detachFromBone(): TransformNode;
  27898. private static _rotationAxisCache;
  27899. /**
  27900. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27901. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27902. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27903. * The passed axis is also normalized.
  27904. * @param axis the axis to rotate around
  27905. * @param amount the amount to rotate in radians
  27906. * @param space Space to rotate in (Default: local)
  27907. * @returns the TransformNode.
  27908. */
  27909. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27910. /**
  27911. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27912. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27913. * The passed axis is also normalized. .
  27914. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27915. * @param point the point to rotate around
  27916. * @param axis the axis to rotate around
  27917. * @param amount the amount to rotate in radians
  27918. * @returns the TransformNode
  27919. */
  27920. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27921. /**
  27922. * Translates the mesh along the axis vector for the passed distance in the given space.
  27923. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27924. * @param axis the axis to translate in
  27925. * @param distance the distance to translate
  27926. * @param space Space to rotate in (Default: local)
  27927. * @returns the TransformNode.
  27928. */
  27929. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27930. /**
  27931. * Adds a rotation step to the mesh current rotation.
  27932. * x, y, z are Euler angles expressed in radians.
  27933. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27934. * This means this rotation is made in the mesh local space only.
  27935. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27936. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27937. * ```javascript
  27938. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27939. * ```
  27940. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27941. * 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.
  27942. * @param x Rotation to add
  27943. * @param y Rotation to add
  27944. * @param z Rotation to add
  27945. * @returns the TransformNode.
  27946. */
  27947. addRotation(x: number, y: number, z: number): TransformNode;
  27948. /**
  27949. * @hidden
  27950. */
  27951. protected _getEffectiveParent(): Nullable<Node>;
  27952. /**
  27953. * Computes the world matrix of the node
  27954. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27955. * @returns the world matrix
  27956. */
  27957. computeWorldMatrix(force?: boolean): Matrix;
  27958. /**
  27959. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27960. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27961. */
  27962. resetLocalMatrix(independentOfChildren?: boolean): void;
  27963. protected _afterComputeWorldMatrix(): void;
  27964. /**
  27965. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27966. * @param func callback function to add
  27967. *
  27968. * @returns the TransformNode.
  27969. */
  27970. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27971. /**
  27972. * Removes a registered callback function.
  27973. * @param func callback function to remove
  27974. * @returns the TransformNode.
  27975. */
  27976. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27977. /**
  27978. * Gets the position of the current mesh in camera space
  27979. * @param camera defines the camera to use
  27980. * @returns a position
  27981. */
  27982. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27983. /**
  27984. * Returns the distance from the mesh to the active camera
  27985. * @param camera defines the camera to use
  27986. * @returns the distance
  27987. */
  27988. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27989. /**
  27990. * Clone the current transform node
  27991. * @param name Name of the new clone
  27992. * @param newParent New parent for the clone
  27993. * @param doNotCloneChildren Do not clone children hierarchy
  27994. * @returns the new transform node
  27995. */
  27996. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27997. /**
  27998. * Serializes the objects information.
  27999. * @param currentSerializationObject defines the object to serialize in
  28000. * @returns the serialized object
  28001. */
  28002. serialize(currentSerializationObject?: any): any;
  28003. /**
  28004. * Returns a new TransformNode object parsed from the source provided.
  28005. * @param parsedTransformNode is the source.
  28006. * @param scene the scne the object belongs to
  28007. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28008. * @returns a new TransformNode object parsed from the source provided.
  28009. */
  28010. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28011. /**
  28012. * Get all child-transformNodes of this node
  28013. * @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
  28014. * @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
  28015. * @returns an array of TransformNode
  28016. */
  28017. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  28018. /**
  28019. * Releases resources associated with this transform node.
  28020. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28021. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28022. */
  28023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28024. /**
  28025. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28026. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28027. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28028. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28029. * @returns the current mesh
  28030. */
  28031. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  28032. private _syncAbsoluteScalingAndRotation;
  28033. }
  28034. }
  28035. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  28036. import { Observable } from "babylonjs/Misc/observable";
  28037. import { Nullable } from "babylonjs/types";
  28038. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28039. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28041. import { Ray } from "babylonjs/Culling/ray";
  28042. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  28043. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  28044. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  28045. /**
  28046. * Defines the types of pose enabled controllers that are supported
  28047. */
  28048. export enum PoseEnabledControllerType {
  28049. /**
  28050. * HTC Vive
  28051. */
  28052. VIVE = 0,
  28053. /**
  28054. * Oculus Rift
  28055. */
  28056. OCULUS = 1,
  28057. /**
  28058. * Windows mixed reality
  28059. */
  28060. WINDOWS = 2,
  28061. /**
  28062. * Samsung gear VR
  28063. */
  28064. GEAR_VR = 3,
  28065. /**
  28066. * Google Daydream
  28067. */
  28068. DAYDREAM = 4,
  28069. /**
  28070. * Generic
  28071. */
  28072. GENERIC = 5
  28073. }
  28074. /**
  28075. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28076. */
  28077. export interface MutableGamepadButton {
  28078. /**
  28079. * Value of the button/trigger
  28080. */
  28081. value: number;
  28082. /**
  28083. * If the button/trigger is currently touched
  28084. */
  28085. touched: boolean;
  28086. /**
  28087. * If the button/trigger is currently pressed
  28088. */
  28089. pressed: boolean;
  28090. }
  28091. /**
  28092. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28093. * @hidden
  28094. */
  28095. export interface ExtendedGamepadButton extends GamepadButton {
  28096. /**
  28097. * If the button/trigger is currently pressed
  28098. */
  28099. readonly pressed: boolean;
  28100. /**
  28101. * If the button/trigger is currently touched
  28102. */
  28103. readonly touched: boolean;
  28104. /**
  28105. * Value of the button/trigger
  28106. */
  28107. readonly value: number;
  28108. }
  28109. /** @hidden */
  28110. export interface _GamePadFactory {
  28111. /**
  28112. * Returns whether or not the current gamepad can be created for this type of controller.
  28113. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28114. * @returns true if it can be created, otherwise false
  28115. */
  28116. canCreate(gamepadInfo: any): boolean;
  28117. /**
  28118. * Creates a new instance of the Gamepad.
  28119. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28120. * @returns the new gamepad instance
  28121. */
  28122. create(gamepadInfo: any): Gamepad;
  28123. }
  28124. /**
  28125. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28126. */
  28127. export class PoseEnabledControllerHelper {
  28128. /** @hidden */
  28129. static _ControllerFactories: _GamePadFactory[];
  28130. /** @hidden */
  28131. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  28132. /**
  28133. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28134. * @param vrGamepad the gamepad to initialized
  28135. * @returns a vr controller of the type the gamepad identified as
  28136. */
  28137. static InitiateController(vrGamepad: any): Gamepad;
  28138. }
  28139. /**
  28140. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28141. */
  28142. export class PoseEnabledController extends Gamepad implements PoseControlled {
  28143. /**
  28144. * If the controller is used in a webXR session
  28145. */
  28146. isXR: boolean;
  28147. private _deviceRoomPosition;
  28148. private _deviceRoomRotationQuaternion;
  28149. /**
  28150. * The device position in babylon space
  28151. */
  28152. devicePosition: Vector3;
  28153. /**
  28154. * The device rotation in babylon space
  28155. */
  28156. deviceRotationQuaternion: Quaternion;
  28157. /**
  28158. * The scale factor of the device in babylon space
  28159. */
  28160. deviceScaleFactor: number;
  28161. /**
  28162. * (Likely devicePosition should be used instead) The device position in its room space
  28163. */
  28164. position: Vector3;
  28165. /**
  28166. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28167. */
  28168. rotationQuaternion: Quaternion;
  28169. /**
  28170. * The type of controller (Eg. Windows mixed reality)
  28171. */
  28172. controllerType: PoseEnabledControllerType;
  28173. protected _calculatedPosition: Vector3;
  28174. private _calculatedRotation;
  28175. /**
  28176. * The raw pose from the device
  28177. */
  28178. rawPose: DevicePose;
  28179. private _trackPosition;
  28180. private _maxRotationDistFromHeadset;
  28181. private _draggedRoomRotation;
  28182. /**
  28183. * @hidden
  28184. */
  28185. _disableTrackPosition(fixedPosition: Vector3): void;
  28186. /**
  28187. * Internal, the mesh attached to the controller
  28188. * @hidden
  28189. */
  28190. _mesh: Nullable<AbstractMesh>;
  28191. private _poseControlledCamera;
  28192. private _leftHandSystemQuaternion;
  28193. /**
  28194. * Internal, matrix used to convert room space to babylon space
  28195. * @hidden
  28196. */
  28197. _deviceToWorld: Matrix;
  28198. /**
  28199. * Node to be used when casting a ray from the controller
  28200. * @hidden
  28201. */
  28202. _pointingPoseNode: Nullable<TransformNode>;
  28203. /**
  28204. * Name of the child mesh that can be used to cast a ray from the controller
  28205. */
  28206. static readonly POINTING_POSE: string;
  28207. /**
  28208. * Creates a new PoseEnabledController from a gamepad
  28209. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28210. */
  28211. constructor(browserGamepad: any);
  28212. private _workingMatrix;
  28213. /**
  28214. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28215. */
  28216. update(): void;
  28217. /**
  28218. * Updates only the pose device and mesh without doing any button event checking
  28219. */
  28220. protected _updatePoseAndMesh(): void;
  28221. /**
  28222. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28223. * @param poseData raw pose fromthe device
  28224. */
  28225. updateFromDevice(poseData: DevicePose): void;
  28226. /**
  28227. * @hidden
  28228. */
  28229. _meshAttachedObservable: Observable<AbstractMesh>;
  28230. /**
  28231. * Attaches a mesh to the controller
  28232. * @param mesh the mesh to be attached
  28233. */
  28234. attachToMesh(mesh: AbstractMesh): void;
  28235. /**
  28236. * Attaches the controllers mesh to a camera
  28237. * @param camera the camera the mesh should be attached to
  28238. */
  28239. attachToPoseControlledCamera(camera: TargetCamera): void;
  28240. /**
  28241. * Disposes of the controller
  28242. */
  28243. dispose(): void;
  28244. /**
  28245. * The mesh that is attached to the controller
  28246. */
  28247. get mesh(): Nullable<AbstractMesh>;
  28248. /**
  28249. * Gets the ray of the controller in the direction the controller is pointing
  28250. * @param length the length the resulting ray should be
  28251. * @returns a ray in the direction the controller is pointing
  28252. */
  28253. getForwardRay(length?: number): Ray;
  28254. }
  28255. }
  28256. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  28257. import { Observable } from "babylonjs/Misc/observable";
  28258. import { Scene } from "babylonjs/scene";
  28259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28260. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  28261. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  28262. import { Nullable } from "babylonjs/types";
  28263. /**
  28264. * Defines the WebVRController object that represents controllers tracked in 3D space
  28265. */
  28266. export abstract class WebVRController extends PoseEnabledController {
  28267. /**
  28268. * Internal, the default controller model for the controller
  28269. */
  28270. protected _defaultModel: Nullable<AbstractMesh>;
  28271. /**
  28272. * Fired when the trigger state has changed
  28273. */
  28274. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28275. /**
  28276. * Fired when the main button state has changed
  28277. */
  28278. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28279. /**
  28280. * Fired when the secondary button state has changed
  28281. */
  28282. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28283. /**
  28284. * Fired when the pad state has changed
  28285. */
  28286. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  28287. /**
  28288. * Fired when controllers stick values have changed
  28289. */
  28290. onPadValuesChangedObservable: Observable<StickValues>;
  28291. /**
  28292. * Array of button availible on the controller
  28293. */
  28294. protected _buttons: Array<MutableGamepadButton>;
  28295. private _onButtonStateChange;
  28296. /**
  28297. * Fired when a controller button's state has changed
  28298. * @param callback the callback containing the button that was modified
  28299. */
  28300. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  28301. /**
  28302. * X and Y axis corresponding to the controllers joystick
  28303. */
  28304. pad: StickValues;
  28305. /**
  28306. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  28307. */
  28308. hand: string;
  28309. /**
  28310. * The default controller model for the controller
  28311. */
  28312. get defaultModel(): Nullable<AbstractMesh>;
  28313. /**
  28314. * Creates a new WebVRController from a gamepad
  28315. * @param vrGamepad the gamepad that the WebVRController should be created from
  28316. */
  28317. constructor(vrGamepad: any);
  28318. /**
  28319. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  28320. */
  28321. update(): void;
  28322. /**
  28323. * Function to be called when a button is modified
  28324. */
  28325. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28326. /**
  28327. * Loads a mesh and attaches it to the controller
  28328. * @param scene the scene the mesh should be added to
  28329. * @param meshLoaded callback for when the mesh has been loaded
  28330. */
  28331. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28332. private _setButtonValue;
  28333. private _changes;
  28334. private _checkChanges;
  28335. /**
  28336. * Disposes of th webVRCOntroller
  28337. */
  28338. dispose(): void;
  28339. }
  28340. }
  28341. declare module "babylonjs/Lights/hemisphericLight" {
  28342. import { Nullable } from "babylonjs/types";
  28343. import { Scene } from "babylonjs/scene";
  28344. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28345. import { Color3 } from "babylonjs/Maths/math.color";
  28346. import { Effect } from "babylonjs/Materials/effect";
  28347. import { Light } from "babylonjs/Lights/light";
  28348. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  28349. /**
  28350. * The HemisphericLight simulates the ambient environment light,
  28351. * so the passed direction is the light reflection direction, not the incoming direction.
  28352. */
  28353. export class HemisphericLight extends Light {
  28354. /**
  28355. * The groundColor is the light in the opposite direction to the one specified during creation.
  28356. * 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.
  28357. */
  28358. groundColor: Color3;
  28359. /**
  28360. * The light reflection direction, not the incoming direction.
  28361. */
  28362. direction: Vector3;
  28363. /**
  28364. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  28365. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  28366. * The HemisphericLight can't cast shadows.
  28367. * Documentation : https://doc.babylonjs.com/babylon101/lights
  28368. * @param name The friendly name of the light
  28369. * @param direction The direction of the light reflection
  28370. * @param scene The scene the light belongs to
  28371. */
  28372. constructor(name: string, direction: Vector3, scene: Scene);
  28373. protected _buildUniformLayout(): void;
  28374. /**
  28375. * Returns the string "HemisphericLight".
  28376. * @return The class name
  28377. */
  28378. getClassName(): string;
  28379. /**
  28380. * Sets the HemisphericLight direction towards the passed target (Vector3).
  28381. * Returns the updated direction.
  28382. * @param target The target the direction should point to
  28383. * @return The computed direction
  28384. */
  28385. setDirectionToTarget(target: Vector3): Vector3;
  28386. /**
  28387. * Returns the shadow generator associated to the light.
  28388. * @returns Always null for hemispheric lights because it does not support shadows.
  28389. */
  28390. getShadowGenerator(): Nullable<IShadowGenerator>;
  28391. /**
  28392. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  28393. * @param effect The effect to update
  28394. * @param lightIndex The index of the light in the effect to update
  28395. * @returns The hemispheric light
  28396. */
  28397. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  28398. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  28399. /**
  28400. * Computes the world matrix of the node
  28401. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28402. * @param useWasUpdatedFlag defines a reserved property
  28403. * @returns the world matrix
  28404. */
  28405. computeWorldMatrix(): Matrix;
  28406. /**
  28407. * Returns the integer 3.
  28408. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  28409. */
  28410. getTypeID(): number;
  28411. /**
  28412. * Prepares the list of defines specific to the light type.
  28413. * @param defines the list of defines
  28414. * @param lightIndex defines the index of the light for the effect
  28415. */
  28416. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  28417. }
  28418. }
  28419. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  28420. /** @hidden */
  28421. export var vrMultiviewToSingleviewPixelShader: {
  28422. name: string;
  28423. shader: string;
  28424. };
  28425. }
  28426. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  28427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28428. import { Scene } from "babylonjs/scene";
  28429. /**
  28430. * Renders to multiple views with a single draw call
  28431. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  28432. */
  28433. export class MultiviewRenderTarget extends RenderTargetTexture {
  28434. /**
  28435. * Creates a multiview render target
  28436. * @param scene scene used with the render target
  28437. * @param size the size of the render target (used for each view)
  28438. */
  28439. constructor(scene: Scene, size?: number | {
  28440. width: number;
  28441. height: number;
  28442. } | {
  28443. ratio: number;
  28444. });
  28445. /**
  28446. * @hidden
  28447. * @param faceIndex the face index, if its a cube texture
  28448. */
  28449. _bindFrameBuffer(faceIndex?: number): void;
  28450. /**
  28451. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28452. * @returns the view count
  28453. */
  28454. getViewCount(): number;
  28455. }
  28456. }
  28457. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  28458. import { Camera } from "babylonjs/Cameras/camera";
  28459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28460. import { Nullable } from "babylonjs/types";
  28461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28462. import { Matrix } from "babylonjs/Maths/math.vector";
  28463. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28464. module "babylonjs/Engines/engine" {
  28465. interface Engine {
  28466. /**
  28467. * Creates a new multiview render target
  28468. * @param width defines the width of the texture
  28469. * @param height defines the height of the texture
  28470. * @returns the created multiview texture
  28471. */
  28472. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28473. /**
  28474. * Binds a multiview framebuffer to be drawn to
  28475. * @param multiviewTexture texture to bind
  28476. */
  28477. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28478. }
  28479. }
  28480. module "babylonjs/Cameras/camera" {
  28481. interface Camera {
  28482. /**
  28483. * @hidden
  28484. * 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)
  28485. */
  28486. _useMultiviewToSingleView: boolean;
  28487. /**
  28488. * @hidden
  28489. * 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)
  28490. */
  28491. _multiviewTexture: Nullable<RenderTargetTexture>;
  28492. /**
  28493. * @hidden
  28494. * ensures the multiview texture of the camera exists and has the specified width/height
  28495. * @param width height to set on the multiview texture
  28496. * @param height width to set on the multiview texture
  28497. */
  28498. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28499. }
  28500. }
  28501. module "babylonjs/scene" {
  28502. interface Scene {
  28503. /** @hidden */
  28504. _transformMatrixR: Matrix;
  28505. /** @hidden */
  28506. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28507. /** @hidden */
  28508. _createMultiviewUbo(): void;
  28509. /** @hidden */
  28510. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28511. /** @hidden */
  28512. _renderMultiviewToSingleView(camera: Camera): void;
  28513. }
  28514. }
  28515. }
  28516. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  28517. import { Camera } from "babylonjs/Cameras/camera";
  28518. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28519. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  28520. import "babylonjs/Engines/Extensions/engine.multiview";
  28521. /**
  28522. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28523. * This will not be used for webXR as it supports displaying texture arrays directly
  28524. */
  28525. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28526. /**
  28527. * Gets a string identifying the name of the class
  28528. * @returns "VRMultiviewToSingleviewPostProcess" string
  28529. */
  28530. getClassName(): string;
  28531. /**
  28532. * Initializes a VRMultiviewToSingleview
  28533. * @param name name of the post process
  28534. * @param camera camera to be applied to
  28535. * @param scaleFactor scaling factor to the size of the output texture
  28536. */
  28537. constructor(name: string, camera: Camera, scaleFactor: number);
  28538. }
  28539. }
  28540. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  28541. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  28542. import { Nullable } from "babylonjs/types";
  28543. import { Size } from "babylonjs/Maths/math.size";
  28544. import { Observable } from "babylonjs/Misc/observable";
  28545. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  28546. /**
  28547. * Interface used to define additional presentation attributes
  28548. */
  28549. export interface IVRPresentationAttributes {
  28550. /**
  28551. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28552. */
  28553. highRefreshRate: boolean;
  28554. /**
  28555. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28556. */
  28557. foveationLevel: number;
  28558. }
  28559. module "babylonjs/Engines/engine" {
  28560. interface Engine {
  28561. /** @hidden */
  28562. _vrDisplay: any;
  28563. /** @hidden */
  28564. _vrSupported: boolean;
  28565. /** @hidden */
  28566. _oldSize: Size;
  28567. /** @hidden */
  28568. _oldHardwareScaleFactor: number;
  28569. /** @hidden */
  28570. _vrExclusivePointerMode: boolean;
  28571. /** @hidden */
  28572. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28573. /** @hidden */
  28574. _onVRDisplayPointerRestricted: () => void;
  28575. /** @hidden */
  28576. _onVRDisplayPointerUnrestricted: () => void;
  28577. /** @hidden */
  28578. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28579. /** @hidden */
  28580. _onVrDisplayDisconnect: Nullable<() => void>;
  28581. /** @hidden */
  28582. _onVrDisplayPresentChange: Nullable<() => void>;
  28583. /**
  28584. * Observable signaled when VR display mode changes
  28585. */
  28586. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28587. /**
  28588. * Observable signaled when VR request present is complete
  28589. */
  28590. onVRRequestPresentComplete: Observable<boolean>;
  28591. /**
  28592. * Observable signaled when VR request present starts
  28593. */
  28594. onVRRequestPresentStart: Observable<Engine>;
  28595. /**
  28596. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28597. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28598. */
  28599. isInVRExclusivePointerMode: boolean;
  28600. /**
  28601. * Gets a boolean indicating if a webVR device was detected
  28602. * @returns true if a webVR device was detected
  28603. */
  28604. isVRDevicePresent(): boolean;
  28605. /**
  28606. * Gets the current webVR device
  28607. * @returns the current webVR device (or null)
  28608. */
  28609. getVRDevice(): any;
  28610. /**
  28611. * Initializes a webVR display and starts listening to display change events
  28612. * The onVRDisplayChangedObservable will be notified upon these changes
  28613. * @returns A promise containing a VRDisplay and if vr is supported
  28614. */
  28615. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28616. /** @hidden */
  28617. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28618. /**
  28619. * Gets or sets the presentation attributes used to configure VR rendering
  28620. */
  28621. vrPresentationAttributes?: IVRPresentationAttributes;
  28622. /**
  28623. * Call this function to switch to webVR mode
  28624. * Will do nothing if webVR is not supported or if there is no webVR device
  28625. * @param options the webvr options provided to the camera. mainly used for multiview
  28626. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28627. */
  28628. enableVR(options: WebVROptions): void;
  28629. /** @hidden */
  28630. _onVRFullScreenTriggered(): void;
  28631. }
  28632. }
  28633. }
  28634. declare module "babylonjs/Cameras/VR/webVRCamera" {
  28635. import { Nullable } from "babylonjs/types";
  28636. import { Observable } from "babylonjs/Misc/observable";
  28637. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  28638. import { Scene } from "babylonjs/scene";
  28639. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28640. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  28641. import { Node } from "babylonjs/node";
  28642. import { Ray } from "babylonjs/Culling/ray";
  28643. import "babylonjs/Cameras/RigModes/webVRRigMode";
  28644. import "babylonjs/Engines/Extensions/engine.webVR";
  28645. /**
  28646. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28647. * IMPORTANT!! The data is right-hand data.
  28648. * @export
  28649. * @interface DevicePose
  28650. */
  28651. export interface DevicePose {
  28652. /**
  28653. * The position of the device, values in array are [x,y,z].
  28654. */
  28655. readonly position: Nullable<Float32Array>;
  28656. /**
  28657. * The linearVelocity of the device, values in array are [x,y,z].
  28658. */
  28659. readonly linearVelocity: Nullable<Float32Array>;
  28660. /**
  28661. * The linearAcceleration of the device, values in array are [x,y,z].
  28662. */
  28663. readonly linearAcceleration: Nullable<Float32Array>;
  28664. /**
  28665. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28666. */
  28667. readonly orientation: Nullable<Float32Array>;
  28668. /**
  28669. * The angularVelocity of the device, values in array are [x,y,z].
  28670. */
  28671. readonly angularVelocity: Nullable<Float32Array>;
  28672. /**
  28673. * The angularAcceleration of the device, values in array are [x,y,z].
  28674. */
  28675. readonly angularAcceleration: Nullable<Float32Array>;
  28676. }
  28677. /**
  28678. * Interface representing a pose controlled object in Babylon.
  28679. * A pose controlled object has both regular pose values as well as pose values
  28680. * from an external device such as a VR head mounted display
  28681. */
  28682. export interface PoseControlled {
  28683. /**
  28684. * The position of the object in babylon space.
  28685. */
  28686. position: Vector3;
  28687. /**
  28688. * The rotation quaternion of the object in babylon space.
  28689. */
  28690. rotationQuaternion: Quaternion;
  28691. /**
  28692. * The position of the device in babylon space.
  28693. */
  28694. devicePosition?: Vector3;
  28695. /**
  28696. * The rotation quaternion of the device in babylon space.
  28697. */
  28698. deviceRotationQuaternion: Quaternion;
  28699. /**
  28700. * The raw pose coming from the device.
  28701. */
  28702. rawPose: Nullable<DevicePose>;
  28703. /**
  28704. * The scale of the device to be used when translating from device space to babylon space.
  28705. */
  28706. deviceScaleFactor: number;
  28707. /**
  28708. * Updates the poseControlled values based on the input device pose.
  28709. * @param poseData the pose data to update the object with
  28710. */
  28711. updateFromDevice(poseData: DevicePose): void;
  28712. }
  28713. /**
  28714. * Set of options to customize the webVRCamera
  28715. */
  28716. export interface WebVROptions {
  28717. /**
  28718. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28719. */
  28720. trackPosition?: boolean;
  28721. /**
  28722. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28723. */
  28724. positionScale?: number;
  28725. /**
  28726. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28727. */
  28728. displayName?: string;
  28729. /**
  28730. * Should the native controller meshes be initialized. (default: true)
  28731. */
  28732. controllerMeshes?: boolean;
  28733. /**
  28734. * Creating a default HemiLight only on controllers. (default: true)
  28735. */
  28736. defaultLightingOnControllers?: boolean;
  28737. /**
  28738. * If you don't want to use the default VR button of the helper. (default: false)
  28739. */
  28740. useCustomVRButton?: boolean;
  28741. /**
  28742. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28743. */
  28744. customVRButton?: HTMLButtonElement;
  28745. /**
  28746. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28747. */
  28748. rayLength?: number;
  28749. /**
  28750. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28751. */
  28752. defaultHeight?: number;
  28753. /**
  28754. * If multiview should be used if availible (default: false)
  28755. */
  28756. useMultiview?: boolean;
  28757. }
  28758. /**
  28759. * This represents a WebVR camera.
  28760. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28761. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28762. */
  28763. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28764. private webVROptions;
  28765. /**
  28766. * @hidden
  28767. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28768. */
  28769. _vrDevice: any;
  28770. /**
  28771. * The rawPose of the vrDevice.
  28772. */
  28773. rawPose: Nullable<DevicePose>;
  28774. private _onVREnabled;
  28775. private _specsVersion;
  28776. private _attached;
  28777. private _frameData;
  28778. protected _descendants: Array<Node>;
  28779. private _deviceRoomPosition;
  28780. /** @hidden */
  28781. _deviceRoomRotationQuaternion: Quaternion;
  28782. private _standingMatrix;
  28783. /**
  28784. * Represents device position in babylon space.
  28785. */
  28786. devicePosition: Vector3;
  28787. /**
  28788. * Represents device rotation in babylon space.
  28789. */
  28790. deviceRotationQuaternion: Quaternion;
  28791. /**
  28792. * The scale of the device to be used when translating from device space to babylon space.
  28793. */
  28794. deviceScaleFactor: number;
  28795. private _deviceToWorld;
  28796. private _worldToDevice;
  28797. /**
  28798. * References to the webVR controllers for the vrDevice.
  28799. */
  28800. controllers: Array<WebVRController>;
  28801. /**
  28802. * Emits an event when a controller is attached.
  28803. */
  28804. onControllersAttachedObservable: Observable<WebVRController[]>;
  28805. /**
  28806. * Emits an event when a controller's mesh has been loaded;
  28807. */
  28808. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28809. /**
  28810. * Emits an event when the HMD's pose has been updated.
  28811. */
  28812. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28813. private _poseSet;
  28814. /**
  28815. * If the rig cameras be used as parent instead of this camera.
  28816. */
  28817. rigParenting: boolean;
  28818. private _lightOnControllers;
  28819. private _defaultHeight?;
  28820. /**
  28821. * Instantiates a WebVRFreeCamera.
  28822. * @param name The name of the WebVRFreeCamera
  28823. * @param position The starting anchor position for the camera
  28824. * @param scene The scene the camera belongs to
  28825. * @param webVROptions a set of customizable options for the webVRCamera
  28826. */
  28827. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28828. /**
  28829. * Gets the device distance from the ground in meters.
  28830. * @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.
  28831. */
  28832. deviceDistanceToRoomGround(): number;
  28833. /**
  28834. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28835. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28836. */
  28837. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28838. /**
  28839. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28840. * @returns A promise with a boolean set to if the standing matrix is supported.
  28841. */
  28842. useStandingMatrixAsync(): Promise<boolean>;
  28843. /**
  28844. * Disposes the camera
  28845. */
  28846. dispose(): void;
  28847. /**
  28848. * Gets a vrController by name.
  28849. * @param name The name of the controller to retreive
  28850. * @returns the controller matching the name specified or null if not found
  28851. */
  28852. getControllerByName(name: string): Nullable<WebVRController>;
  28853. private _leftController;
  28854. /**
  28855. * The controller corresponding to the users left hand.
  28856. */
  28857. get leftController(): Nullable<WebVRController>;
  28858. private _rightController;
  28859. /**
  28860. * The controller corresponding to the users right hand.
  28861. */
  28862. get rightController(): Nullable<WebVRController>;
  28863. /**
  28864. * Casts a ray forward from the vrCamera's gaze.
  28865. * @param length Length of the ray (default: 100)
  28866. * @returns the ray corresponding to the gaze
  28867. */
  28868. getForwardRay(length?: number): Ray;
  28869. /**
  28870. * @hidden
  28871. * Updates the camera based on device's frame data
  28872. */
  28873. _checkInputs(): void;
  28874. /**
  28875. * Updates the poseControlled values based on the input device pose.
  28876. * @param poseData Pose coming from the device
  28877. */
  28878. updateFromDevice(poseData: DevicePose): void;
  28879. private _detachIfAttached;
  28880. /**
  28881. * WebVR's attach control will start broadcasting frames to the device.
  28882. * Note that in certain browsers (chrome for example) this function must be called
  28883. * within a user-interaction callback. Example:
  28884. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28885. *
  28886. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28887. */
  28888. attachControl(noPreventDefault?: boolean): void;
  28889. /**
  28890. * Detach the current controls from the specified dom element.
  28891. */
  28892. detachControl(): void;
  28893. /**
  28894. * @returns the name of this class
  28895. */
  28896. getClassName(): string;
  28897. /**
  28898. * Calls resetPose on the vrDisplay
  28899. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28900. */
  28901. resetToCurrentRotation(): void;
  28902. /**
  28903. * @hidden
  28904. * Updates the rig cameras (left and right eye)
  28905. */
  28906. _updateRigCameras(): void;
  28907. private _workingVector;
  28908. private _oneVector;
  28909. private _workingMatrix;
  28910. private updateCacheCalled;
  28911. private _correctPositionIfNotTrackPosition;
  28912. /**
  28913. * @hidden
  28914. * Updates the cached values of the camera
  28915. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28916. */
  28917. _updateCache(ignoreParentClass?: boolean): void;
  28918. /**
  28919. * @hidden
  28920. * Get current device position in babylon world
  28921. */
  28922. _computeDevicePosition(): void;
  28923. /**
  28924. * Updates the current device position and rotation in the babylon world
  28925. */
  28926. update(): void;
  28927. /**
  28928. * @hidden
  28929. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28930. * @returns an identity matrix
  28931. */
  28932. _getViewMatrix(): Matrix;
  28933. private _tmpMatrix;
  28934. /**
  28935. * This function is called by the two RIG cameras.
  28936. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28937. * @hidden
  28938. */
  28939. _getWebVRViewMatrix(): Matrix;
  28940. /** @hidden */
  28941. _getWebVRProjectionMatrix(): Matrix;
  28942. private _onGamepadConnectedObserver;
  28943. private _onGamepadDisconnectedObserver;
  28944. private _updateCacheWhenTrackingDisabledObserver;
  28945. /**
  28946. * Initializes the controllers and their meshes
  28947. */
  28948. initControllers(): void;
  28949. }
  28950. }
  28951. declare module "babylonjs/Materials/materialHelper" {
  28952. import { Nullable } from "babylonjs/types";
  28953. import { Scene } from "babylonjs/scene";
  28954. import { Engine } from "babylonjs/Engines/engine";
  28955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28956. import { Light } from "babylonjs/Lights/light";
  28957. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28958. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28959. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28961. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28962. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28963. import { Vector4 } from "babylonjs/Maths/math.vector";
  28964. /**
  28965. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28966. *
  28967. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28968. *
  28969. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28970. */
  28971. export class MaterialHelper {
  28972. /**
  28973. * Bind the current view position to an effect.
  28974. * @param effect The effect to be bound
  28975. * @param scene The scene the eyes position is used from
  28976. * @param variableName name of the shader variable that will hold the eye position
  28977. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28978. * @return the computed eye position
  28979. */
  28980. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28981. /**
  28982. * Helps preparing the defines values about the UVs in used in the effect.
  28983. * UVs are shared as much as we can accross channels in the shaders.
  28984. * @param texture The texture we are preparing the UVs for
  28985. * @param defines The defines to update
  28986. * @param key The channel key "diffuse", "specular"... used in the shader
  28987. */
  28988. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28989. /**
  28990. * Binds a texture matrix value to its corrsponding uniform
  28991. * @param texture The texture to bind the matrix for
  28992. * @param uniformBuffer The uniform buffer receivin the data
  28993. * @param key The channel key "diffuse", "specular"... used in the shader
  28994. */
  28995. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28996. /**
  28997. * Gets the current status of the fog (should it be enabled?)
  28998. * @param mesh defines the mesh to evaluate for fog support
  28999. * @param scene defines the hosting scene
  29000. * @returns true if fog must be enabled
  29001. */
  29002. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  29003. /**
  29004. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  29005. * @param mesh defines the current mesh
  29006. * @param scene defines the current scene
  29007. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  29008. * @param pointsCloud defines if point cloud rendering has to be turned on
  29009. * @param fogEnabled defines if fog has to be turned on
  29010. * @param alphaTest defines if alpha testing has to be turned on
  29011. * @param defines defines the current list of defines
  29012. */
  29013. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  29014. /**
  29015. * Helper used to prepare the list of defines associated with frame values for shader compilation
  29016. * @param scene defines the current scene
  29017. * @param engine defines the current engine
  29018. * @param defines specifies the list of active defines
  29019. * @param useInstances defines if instances have to be turned on
  29020. * @param useClipPlane defines if clip plane have to be turned on
  29021. * @param useInstances defines if instances have to be turned on
  29022. * @param useThinInstances defines if thin instances have to be turned on
  29023. */
  29024. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  29025. /**
  29026. * Prepares the defines for bones
  29027. * @param mesh The mesh containing the geometry data we will draw
  29028. * @param defines The defines to update
  29029. */
  29030. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  29031. /**
  29032. * Prepares the defines for morph targets
  29033. * @param mesh The mesh containing the geometry data we will draw
  29034. * @param defines The defines to update
  29035. */
  29036. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  29037. /**
  29038. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  29039. * @param mesh The mesh containing the geometry data we will draw
  29040. * @param defines The defines to update
  29041. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  29042. * @param useBones Precise whether bones should be used or not (override mesh info)
  29043. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  29044. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  29045. * @returns false if defines are considered not dirty and have not been checked
  29046. */
  29047. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  29048. /**
  29049. * Prepares the defines related to multiview
  29050. * @param scene The scene we are intending to draw
  29051. * @param defines The defines to update
  29052. */
  29053. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  29054. /**
  29055. * Prepares the defines related to the prepass
  29056. * @param scene The scene we are intending to draw
  29057. * @param defines The defines to update
  29058. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  29059. */
  29060. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  29061. /**
  29062. * Prepares the defines related to the light information passed in parameter
  29063. * @param scene The scene we are intending to draw
  29064. * @param mesh The mesh the effect is compiling for
  29065. * @param light The light the effect is compiling for
  29066. * @param lightIndex The index of the light
  29067. * @param defines The defines to update
  29068. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29069. * @param state Defines the current state regarding what is needed (normals, etc...)
  29070. */
  29071. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  29072. needNormals: boolean;
  29073. needRebuild: boolean;
  29074. shadowEnabled: boolean;
  29075. specularEnabled: boolean;
  29076. lightmapMode: boolean;
  29077. }): void;
  29078. /**
  29079. * Prepares the defines related to the light information passed in parameter
  29080. * @param scene The scene we are intending to draw
  29081. * @param mesh The mesh the effect is compiling for
  29082. * @param defines The defines to update
  29083. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29084. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  29085. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  29086. * @returns true if normals will be required for the rest of the effect
  29087. */
  29088. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  29089. /**
  29090. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  29091. * @param lightIndex defines the light index
  29092. * @param uniformsList The uniform list
  29093. * @param samplersList The sampler list
  29094. * @param projectedLightTexture defines if projected texture must be used
  29095. * @param uniformBuffersList defines an optional list of uniform buffers
  29096. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  29097. */
  29098. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  29099. /**
  29100. * Prepares the uniforms and samplers list to be used in the effect
  29101. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  29102. * @param samplersList The sampler list
  29103. * @param defines The defines helping in the list generation
  29104. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  29105. */
  29106. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  29107. /**
  29108. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  29109. * @param defines The defines to update while falling back
  29110. * @param fallbacks The authorized effect fallbacks
  29111. * @param maxSimultaneousLights The maximum number of lights allowed
  29112. * @param rank the current rank of the Effect
  29113. * @returns The newly affected rank
  29114. */
  29115. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  29116. private static _TmpMorphInfluencers;
  29117. /**
  29118. * Prepares the list of attributes required for morph targets according to the effect defines.
  29119. * @param attribs The current list of supported attribs
  29120. * @param mesh The mesh to prepare the morph targets attributes for
  29121. * @param influencers The number of influencers
  29122. */
  29123. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  29124. /**
  29125. * Prepares the list of attributes required for morph targets according to the effect defines.
  29126. * @param attribs The current list of supported attribs
  29127. * @param mesh The mesh to prepare the morph targets attributes for
  29128. * @param defines The current Defines of the effect
  29129. */
  29130. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  29131. /**
  29132. * Prepares the list of attributes required for bones according to the effect defines.
  29133. * @param attribs The current list of supported attribs
  29134. * @param mesh The mesh to prepare the bones attributes for
  29135. * @param defines The current Defines of the effect
  29136. * @param fallbacks The current efffect fallback strategy
  29137. */
  29138. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  29139. /**
  29140. * Check and prepare the list of attributes required for instances according to the effect defines.
  29141. * @param attribs The current list of supported attribs
  29142. * @param defines The current MaterialDefines of the effect
  29143. */
  29144. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  29145. /**
  29146. * Add the list of attributes required for instances to the attribs array.
  29147. * @param attribs The current list of supported attribs
  29148. */
  29149. static PushAttributesForInstances(attribs: string[]): void;
  29150. /**
  29151. * Binds the light information to the effect.
  29152. * @param light The light containing the generator
  29153. * @param effect The effect we are binding the data to
  29154. * @param lightIndex The light index in the effect used to render
  29155. */
  29156. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  29157. /**
  29158. * Binds the lights information from the scene to the effect for the given mesh.
  29159. * @param light Light to bind
  29160. * @param lightIndex Light index
  29161. * @param scene The scene where the light belongs to
  29162. * @param effect The effect we are binding the data to
  29163. * @param useSpecular Defines if specular is supported
  29164. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29165. */
  29166. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  29167. /**
  29168. * Binds the lights information from the scene to the effect for the given mesh.
  29169. * @param scene The scene the lights belongs to
  29170. * @param mesh The mesh we are binding the information to render
  29171. * @param effect The effect we are binding the data to
  29172. * @param defines The generated defines for the effect
  29173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  29174. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29175. */
  29176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  29177. private static _tempFogColor;
  29178. /**
  29179. * Binds the fog information from the scene to the effect for the given mesh.
  29180. * @param scene The scene the lights belongs to
  29181. * @param mesh The mesh we are binding the information to render
  29182. * @param effect The effect we are binding the data to
  29183. * @param linearSpace Defines if the fog effect is applied in linear space
  29184. */
  29185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  29186. /**
  29187. * Binds the bones information from the mesh to the effect.
  29188. * @param mesh The mesh we are binding the information to render
  29189. * @param effect The effect we are binding the data to
  29190. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  29191. */
  29192. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  29193. private static _CopyBonesTransformationMatrices;
  29194. /**
  29195. * Binds the morph targets information from the mesh to the effect.
  29196. * @param abstractMesh The mesh we are binding the information to render
  29197. * @param effect The effect we are binding the data to
  29198. */
  29199. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  29200. /**
  29201. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  29202. * @param defines The generated defines used in the effect
  29203. * @param effect The effect we are binding the data to
  29204. * @param scene The scene we are willing to render with logarithmic scale for
  29205. */
  29206. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  29207. /**
  29208. * Binds the clip plane information from the scene to the effect.
  29209. * @param scene The scene the clip plane information are extracted from
  29210. * @param effect The effect we are binding the data to
  29211. */
  29212. static BindClipPlane(effect: Effect, scene: Scene): void;
  29213. }
  29214. }
  29215. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  29216. /** @hidden */
  29217. export var bayerDitherFunctions: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  29223. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29224. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  29225. /** @hidden */
  29226. export var shadowMapFragmentDeclaration: {
  29227. name: string;
  29228. shader: string;
  29229. };
  29230. }
  29231. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  29232. /** @hidden */
  29233. export var shadowMapFragment: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module "babylonjs/Shaders/shadowMap.fragment" {
  29239. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  29240. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29242. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  29243. /** @hidden */
  29244. export var shadowMapPixelShader: {
  29245. name: string;
  29246. shader: string;
  29247. };
  29248. }
  29249. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  29250. /** @hidden */
  29251. export var shadowMapVertexDeclaration: {
  29252. name: string;
  29253. shader: string;
  29254. };
  29255. }
  29256. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  29257. /** @hidden */
  29258. export var shadowMapVertexNormalBias: {
  29259. name: string;
  29260. shader: string;
  29261. };
  29262. }
  29263. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  29264. /** @hidden */
  29265. export var shadowMapVertexMetric: {
  29266. name: string;
  29267. shader: string;
  29268. };
  29269. }
  29270. declare module "babylonjs/Shaders/shadowMap.vertex" {
  29271. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29272. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  29273. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  29274. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  29276. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  29277. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  29279. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29280. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29281. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  29282. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  29283. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29284. /** @hidden */
  29285. export var shadowMapVertexShader: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  29291. /** @hidden */
  29292. export var depthBoxBlurPixelShader: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  29298. /** @hidden */
  29299. export var shadowMapFragmentSoftTransparentShadow: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module "babylonjs/Meshes/instancedMesh" {
  29305. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29306. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29307. import { Camera } from "babylonjs/Cameras/camera";
  29308. import { Node } from "babylonjs/node";
  29309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29310. import { Mesh } from "babylonjs/Meshes/mesh";
  29311. import { Material } from "babylonjs/Materials/material";
  29312. import { Skeleton } from "babylonjs/Bones/skeleton";
  29313. import { Light } from "babylonjs/Lights/light";
  29314. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29315. /**
  29316. * Creates an instance based on a source mesh.
  29317. */
  29318. export class InstancedMesh extends AbstractMesh {
  29319. private _sourceMesh;
  29320. private _currentLOD;
  29321. /** @hidden */
  29322. _indexInSourceMeshInstanceArray: number;
  29323. constructor(name: string, source: Mesh);
  29324. /**
  29325. * Returns the string "InstancedMesh".
  29326. */
  29327. getClassName(): string;
  29328. /** Gets the list of lights affecting that mesh */
  29329. get lightSources(): Light[];
  29330. _resyncLightSources(): void;
  29331. _resyncLightSource(light: Light): void;
  29332. _removeLightSource(light: Light, dispose: boolean): void;
  29333. /**
  29334. * If the source mesh receives shadows
  29335. */
  29336. get receiveShadows(): boolean;
  29337. /**
  29338. * The material of the source mesh
  29339. */
  29340. get material(): Nullable<Material>;
  29341. /**
  29342. * Visibility of the source mesh
  29343. */
  29344. get visibility(): number;
  29345. /**
  29346. * Skeleton of the source mesh
  29347. */
  29348. get skeleton(): Nullable<Skeleton>;
  29349. /**
  29350. * Rendering ground id of the source mesh
  29351. */
  29352. get renderingGroupId(): number;
  29353. set renderingGroupId(value: number);
  29354. /**
  29355. * Returns the total number of vertices (integer).
  29356. */
  29357. getTotalVertices(): number;
  29358. /**
  29359. * Returns a positive integer : the total number of indices in this mesh geometry.
  29360. * @returns the numner of indices or zero if the mesh has no geometry.
  29361. */
  29362. getTotalIndices(): number;
  29363. /**
  29364. * The source mesh of the instance
  29365. */
  29366. get sourceMesh(): Mesh;
  29367. /**
  29368. * Creates a new InstancedMesh object from the mesh model.
  29369. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29370. * @param name defines the name of the new instance
  29371. * @returns a new InstancedMesh
  29372. */
  29373. createInstance(name: string): InstancedMesh;
  29374. /**
  29375. * Is this node ready to be used/rendered
  29376. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29377. * @return {boolean} is it ready
  29378. */
  29379. isReady(completeCheck?: boolean): boolean;
  29380. /**
  29381. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29382. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  29383. * @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.
  29384. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  29385. */
  29386. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  29387. /**
  29388. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29389. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29390. * The `data` are either a numeric array either a Float32Array.
  29391. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  29392. * 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).
  29393. * Note that a new underlying VertexBuffer object is created each call.
  29394. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29395. *
  29396. * Possible `kind` values :
  29397. * - VertexBuffer.PositionKind
  29398. * - VertexBuffer.UVKind
  29399. * - VertexBuffer.UV2Kind
  29400. * - VertexBuffer.UV3Kind
  29401. * - VertexBuffer.UV4Kind
  29402. * - VertexBuffer.UV5Kind
  29403. * - VertexBuffer.UV6Kind
  29404. * - VertexBuffer.ColorKind
  29405. * - VertexBuffer.MatricesIndicesKind
  29406. * - VertexBuffer.MatricesIndicesExtraKind
  29407. * - VertexBuffer.MatricesWeightsKind
  29408. * - VertexBuffer.MatricesWeightsExtraKind
  29409. *
  29410. * Returns the Mesh.
  29411. */
  29412. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29413. /**
  29414. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29415. * If the mesh has no geometry, it is simply returned as it is.
  29416. * The `data` are either a numeric array either a Float32Array.
  29417. * No new underlying VertexBuffer object is created.
  29418. * 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.
  29419. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  29420. *
  29421. * Possible `kind` values :
  29422. * - VertexBuffer.PositionKind
  29423. * - VertexBuffer.UVKind
  29424. * - VertexBuffer.UV2Kind
  29425. * - VertexBuffer.UV3Kind
  29426. * - VertexBuffer.UV4Kind
  29427. * - VertexBuffer.UV5Kind
  29428. * - VertexBuffer.UV6Kind
  29429. * - VertexBuffer.ColorKind
  29430. * - VertexBuffer.MatricesIndicesKind
  29431. * - VertexBuffer.MatricesIndicesExtraKind
  29432. * - VertexBuffer.MatricesWeightsKind
  29433. * - VertexBuffer.MatricesWeightsExtraKind
  29434. *
  29435. * Returns the Mesh.
  29436. */
  29437. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  29438. /**
  29439. * Sets the mesh indices.
  29440. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  29441. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29442. * This method creates a new index buffer each call.
  29443. * Returns the Mesh.
  29444. */
  29445. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  29446. /**
  29447. * Boolean : True if the mesh owns the requested kind of data.
  29448. */
  29449. isVerticesDataPresent(kind: string): boolean;
  29450. /**
  29451. * Returns an array of indices (IndicesArray).
  29452. */
  29453. getIndices(): Nullable<IndicesArray>;
  29454. get _positions(): Nullable<Vector3[]>;
  29455. /**
  29456. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29457. * This means the mesh underlying bounding box and sphere are recomputed.
  29458. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29459. * @returns the current mesh
  29460. */
  29461. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  29462. /** @hidden */
  29463. _preActivate(): InstancedMesh;
  29464. /** @hidden */
  29465. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29466. /** @hidden */
  29467. _postActivate(): void;
  29468. getWorldMatrix(): Matrix;
  29469. get isAnInstance(): boolean;
  29470. /**
  29471. * Returns the current associated LOD AbstractMesh.
  29472. */
  29473. getLOD(camera: Camera): AbstractMesh;
  29474. /** @hidden */
  29475. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29476. /** @hidden */
  29477. _syncSubMeshes(): InstancedMesh;
  29478. /** @hidden */
  29479. _generatePointsArray(): boolean;
  29480. /** @hidden */
  29481. _updateBoundingInfo(): AbstractMesh;
  29482. /**
  29483. * Creates a new InstancedMesh from the current mesh.
  29484. * - name (string) : the cloned mesh name
  29485. * - newParent (optional Node) : the optional Node to parent the clone to.
  29486. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  29487. *
  29488. * Returns the clone.
  29489. */
  29490. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  29491. /**
  29492. * Disposes the InstancedMesh.
  29493. * Returns nothing.
  29494. */
  29495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29496. }
  29497. module "babylonjs/Meshes/mesh" {
  29498. interface Mesh {
  29499. /**
  29500. * Register a custom buffer that will be instanced
  29501. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29502. * @param kind defines the buffer kind
  29503. * @param stride defines the stride in floats
  29504. */
  29505. registerInstancedBuffer(kind: string, stride: number): void;
  29506. /**
  29507. * true to use the edge renderer for all instances of this mesh
  29508. */
  29509. edgesShareWithInstances: boolean;
  29510. /** @hidden */
  29511. _userInstancedBuffersStorage: {
  29512. data: {
  29513. [key: string]: Float32Array;
  29514. };
  29515. sizes: {
  29516. [key: string]: number;
  29517. };
  29518. vertexBuffers: {
  29519. [key: string]: Nullable<VertexBuffer>;
  29520. };
  29521. strides: {
  29522. [key: string]: number;
  29523. };
  29524. };
  29525. }
  29526. }
  29527. module "babylonjs/Meshes/abstractMesh" {
  29528. interface AbstractMesh {
  29529. /**
  29530. * Object used to store instanced buffers defined by user
  29531. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29532. */
  29533. instancedBuffers: {
  29534. [key: string]: any;
  29535. };
  29536. }
  29537. }
  29538. }
  29539. declare module "babylonjs/Materials/shaderMaterial" {
  29540. import { Nullable } from "babylonjs/types";
  29541. import { Scene } from "babylonjs/scene";
  29542. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29544. import { Mesh } from "babylonjs/Meshes/mesh";
  29545. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29547. import { Effect } from "babylonjs/Materials/effect";
  29548. import { Material } from "babylonjs/Materials/material";
  29549. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29550. /**
  29551. * Defines the options associated with the creation of a shader material.
  29552. */
  29553. export interface IShaderMaterialOptions {
  29554. /**
  29555. * Does the material work in alpha blend mode
  29556. */
  29557. needAlphaBlending: boolean;
  29558. /**
  29559. * Does the material work in alpha test mode
  29560. */
  29561. needAlphaTesting: boolean;
  29562. /**
  29563. * The list of attribute names used in the shader
  29564. */
  29565. attributes: string[];
  29566. /**
  29567. * The list of unifrom names used in the shader
  29568. */
  29569. uniforms: string[];
  29570. /**
  29571. * The list of UBO names used in the shader
  29572. */
  29573. uniformBuffers: string[];
  29574. /**
  29575. * The list of sampler names used in the shader
  29576. */
  29577. samplers: string[];
  29578. /**
  29579. * The list of defines used in the shader
  29580. */
  29581. defines: string[];
  29582. }
  29583. /**
  29584. * 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.
  29585. *
  29586. * This returned material effects how the mesh will look based on the code in the shaders.
  29587. *
  29588. * @see https://doc.babylonjs.com/how_to/shader_material
  29589. */
  29590. export class ShaderMaterial extends Material {
  29591. private _shaderPath;
  29592. private _options;
  29593. private _textures;
  29594. private _textureArrays;
  29595. private _floats;
  29596. private _ints;
  29597. private _floatsArrays;
  29598. private _colors3;
  29599. private _colors3Arrays;
  29600. private _colors4;
  29601. private _colors4Arrays;
  29602. private _vectors2;
  29603. private _vectors3;
  29604. private _vectors4;
  29605. private _matrices;
  29606. private _matrixArrays;
  29607. private _matrices3x3;
  29608. private _matrices2x2;
  29609. private _vectors2Arrays;
  29610. private _vectors3Arrays;
  29611. private _vectors4Arrays;
  29612. private _cachedWorldViewMatrix;
  29613. private _cachedWorldViewProjectionMatrix;
  29614. private _renderId;
  29615. private _multiview;
  29616. private _cachedDefines;
  29617. /** Define the Url to load snippets */
  29618. static SnippetUrl: string;
  29619. /** Snippet ID if the material was created from the snippet server */
  29620. snippetId: string;
  29621. /**
  29622. * Instantiate a new shader material.
  29623. * 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.
  29624. * This returned material effects how the mesh will look based on the code in the shaders.
  29625. * @see https://doc.babylonjs.com/how_to/shader_material
  29626. * @param name Define the name of the material in the scene
  29627. * @param scene Define the scene the material belongs to
  29628. * @param shaderPath Defines the route to the shader code in one of three ways:
  29629. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29630. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29631. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29632. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29633. * @param options Define the options used to create the shader
  29634. */
  29635. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29636. /**
  29637. * Gets the shader path used to define the shader code
  29638. * It can be modified to trigger a new compilation
  29639. */
  29640. get shaderPath(): any;
  29641. /**
  29642. * Sets the shader path used to define the shader code
  29643. * It can be modified to trigger a new compilation
  29644. */
  29645. set shaderPath(shaderPath: any);
  29646. /**
  29647. * Gets the options used to compile the shader.
  29648. * They can be modified to trigger a new compilation
  29649. */
  29650. get options(): IShaderMaterialOptions;
  29651. /**
  29652. * Gets the current class name of the material e.g. "ShaderMaterial"
  29653. * Mainly use in serialization.
  29654. * @returns the class name
  29655. */
  29656. getClassName(): string;
  29657. /**
  29658. * Specifies if the material will require alpha blending
  29659. * @returns a boolean specifying if alpha blending is needed
  29660. */
  29661. needAlphaBlending(): boolean;
  29662. /**
  29663. * Specifies if this material should be rendered in alpha test mode
  29664. * @returns a boolean specifying if an alpha test is needed.
  29665. */
  29666. needAlphaTesting(): boolean;
  29667. private _checkUniform;
  29668. /**
  29669. * Set a texture in the shader.
  29670. * @param name Define the name of the uniform samplers as defined in the shader
  29671. * @param texture Define the texture to bind to this sampler
  29672. * @return the material itself allowing "fluent" like uniform updates
  29673. */
  29674. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29675. /**
  29676. * Set a texture array in the shader.
  29677. * @param name Define the name of the uniform sampler array as defined in the shader
  29678. * @param textures Define the list of textures to bind to this sampler
  29679. * @return the material itself allowing "fluent" like uniform updates
  29680. */
  29681. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29682. /**
  29683. * Set a float in the shader.
  29684. * @param name Define the name of the uniform as defined in the shader
  29685. * @param value Define the value to give to the uniform
  29686. * @return the material itself allowing "fluent" like uniform updates
  29687. */
  29688. setFloat(name: string, value: number): ShaderMaterial;
  29689. /**
  29690. * Set a int in the shader.
  29691. * @param name Define the name of the uniform as defined in the shader
  29692. * @param value Define the value to give to the uniform
  29693. * @return the material itself allowing "fluent" like uniform updates
  29694. */
  29695. setInt(name: string, value: number): ShaderMaterial;
  29696. /**
  29697. * Set an array of floats in the shader.
  29698. * @param name Define the name of the uniform as defined in the shader
  29699. * @param value Define the value to give to the uniform
  29700. * @return the material itself allowing "fluent" like uniform updates
  29701. */
  29702. setFloats(name: string, value: number[]): ShaderMaterial;
  29703. /**
  29704. * Set a vec3 in the shader from a Color3.
  29705. * @param name Define the name of the uniform as defined in the shader
  29706. * @param value Define the value to give to the uniform
  29707. * @return the material itself allowing "fluent" like uniform updates
  29708. */
  29709. setColor3(name: string, value: Color3): ShaderMaterial;
  29710. /**
  29711. * Set a vec3 array in the shader from a Color3 array.
  29712. * @param name Define the name of the uniform as defined in the shader
  29713. * @param value Define the value to give to the uniform
  29714. * @return the material itself allowing "fluent" like uniform updates
  29715. */
  29716. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29717. /**
  29718. * Set a vec4 in the shader from a Color4.
  29719. * @param name Define the name of the uniform as defined in the shader
  29720. * @param value Define the value to give to the uniform
  29721. * @return the material itself allowing "fluent" like uniform updates
  29722. */
  29723. setColor4(name: string, value: Color4): ShaderMaterial;
  29724. /**
  29725. * Set a vec4 array in the shader from a Color4 array.
  29726. * @param name Define the name of the uniform as defined in the shader
  29727. * @param value Define the value to give to the uniform
  29728. * @return the material itself allowing "fluent" like uniform updates
  29729. */
  29730. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29731. /**
  29732. * Set a vec2 in the shader from a Vector2.
  29733. * @param name Define the name of the uniform as defined in the shader
  29734. * @param value Define the value to give to the uniform
  29735. * @return the material itself allowing "fluent" like uniform updates
  29736. */
  29737. setVector2(name: string, value: Vector2): ShaderMaterial;
  29738. /**
  29739. * Set a vec3 in the shader from a Vector3.
  29740. * @param name Define the name of the uniform as defined in the shader
  29741. * @param value Define the value to give to the uniform
  29742. * @return the material itself allowing "fluent" like uniform updates
  29743. */
  29744. setVector3(name: string, value: Vector3): ShaderMaterial;
  29745. /**
  29746. * Set a vec4 in the shader from a Vector4.
  29747. * @param name Define the name of the uniform as defined in the shader
  29748. * @param value Define the value to give to the uniform
  29749. * @return the material itself allowing "fluent" like uniform updates
  29750. */
  29751. setVector4(name: string, value: Vector4): ShaderMaterial;
  29752. /**
  29753. * Set a mat4 in the shader from a Matrix.
  29754. * @param name Define the name of the uniform as defined in the shader
  29755. * @param value Define the value to give to the uniform
  29756. * @return the material itself allowing "fluent" like uniform updates
  29757. */
  29758. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29759. /**
  29760. * Set a float32Array in the shader from a matrix array.
  29761. * @param name Define the name of the uniform as defined in the shader
  29762. * @param value Define the value to give to the uniform
  29763. * @return the material itself allowing "fluent" like uniform updates
  29764. */
  29765. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29766. /**
  29767. * Set a mat3 in the shader from a Float32Array.
  29768. * @param name Define the name of the uniform as defined in the shader
  29769. * @param value Define the value to give to the uniform
  29770. * @return the material itself allowing "fluent" like uniform updates
  29771. */
  29772. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29773. /**
  29774. * Set a mat2 in the shader from a Float32Array.
  29775. * @param name Define the name of the uniform as defined in the shader
  29776. * @param value Define the value to give to the uniform
  29777. * @return the material itself allowing "fluent" like uniform updates
  29778. */
  29779. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29780. /**
  29781. * Set a vec2 array in the shader from a number array.
  29782. * @param name Define the name of the uniform as defined in the shader
  29783. * @param value Define the value to give to the uniform
  29784. * @return the material itself allowing "fluent" like uniform updates
  29785. */
  29786. setArray2(name: string, value: number[]): ShaderMaterial;
  29787. /**
  29788. * Set a vec3 array in the shader from a number array.
  29789. * @param name Define the name of the uniform as defined in the shader
  29790. * @param value Define the value to give to the uniform
  29791. * @return the material itself allowing "fluent" like uniform updates
  29792. */
  29793. setArray3(name: string, value: number[]): ShaderMaterial;
  29794. /**
  29795. * Set a vec4 array in the shader from a number array.
  29796. * @param name Define the name of the uniform as defined in the shader
  29797. * @param value Define the value to give to the uniform
  29798. * @return the material itself allowing "fluent" like uniform updates
  29799. */
  29800. setArray4(name: string, value: number[]): ShaderMaterial;
  29801. private _checkCache;
  29802. /**
  29803. * Specifies that the submesh is ready to be used
  29804. * @param mesh defines the mesh to check
  29805. * @param subMesh defines which submesh to check
  29806. * @param useInstances specifies that instances should be used
  29807. * @returns a boolean indicating that the submesh is ready or not
  29808. */
  29809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29810. /**
  29811. * Checks if the material is ready to render the requested mesh
  29812. * @param mesh Define the mesh to render
  29813. * @param useInstances Define whether or not the material is used with instances
  29814. * @returns true if ready, otherwise false
  29815. */
  29816. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29817. /**
  29818. * Binds the world matrix to the material
  29819. * @param world defines the world transformation matrix
  29820. * @param effectOverride - If provided, use this effect instead of internal effect
  29821. */
  29822. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29823. /**
  29824. * Binds the submesh to this material by preparing the effect and shader to draw
  29825. * @param world defines the world transformation matrix
  29826. * @param mesh defines the mesh containing the submesh
  29827. * @param subMesh defines the submesh to bind the material to
  29828. */
  29829. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29830. /**
  29831. * Binds the material to the mesh
  29832. * @param world defines the world transformation matrix
  29833. * @param mesh defines the mesh to bind the material to
  29834. * @param effectOverride - If provided, use this effect instead of internal effect
  29835. */
  29836. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29837. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29838. /**
  29839. * Gets the active textures from the material
  29840. * @returns an array of textures
  29841. */
  29842. getActiveTextures(): BaseTexture[];
  29843. /**
  29844. * Specifies if the material uses a texture
  29845. * @param texture defines the texture to check against the material
  29846. * @returns a boolean specifying if the material uses the texture
  29847. */
  29848. hasTexture(texture: BaseTexture): boolean;
  29849. /**
  29850. * Makes a duplicate of the material, and gives it a new name
  29851. * @param name defines the new name for the duplicated material
  29852. * @returns the cloned material
  29853. */
  29854. clone(name: string): ShaderMaterial;
  29855. /**
  29856. * Disposes the material
  29857. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29858. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29859. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29860. */
  29861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29862. /**
  29863. * Serializes this material in a JSON representation
  29864. * @returns the serialized material object
  29865. */
  29866. serialize(): any;
  29867. /**
  29868. * Creates a shader material from parsed shader material data
  29869. * @param source defines the JSON represnetation of the material
  29870. * @param scene defines the hosting scene
  29871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29872. * @returns a new material
  29873. */
  29874. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29875. /**
  29876. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29877. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29878. * @param url defines the url to load from
  29879. * @param scene defines the hosting scene
  29880. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29881. * @returns a promise that will resolve to the new ShaderMaterial
  29882. */
  29883. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29884. /**
  29885. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29886. * @param snippetId defines the snippet to load
  29887. * @param scene defines the hosting scene
  29888. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29889. * @returns a promise that will resolve to the new ShaderMaterial
  29890. */
  29891. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29892. }
  29893. }
  29894. declare module "babylonjs/Shaders/color.fragment" {
  29895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29896. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29897. /** @hidden */
  29898. export var colorPixelShader: {
  29899. name: string;
  29900. shader: string;
  29901. };
  29902. }
  29903. declare module "babylonjs/Shaders/color.vertex" {
  29904. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29905. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29906. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29907. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29908. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29909. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29910. /** @hidden */
  29911. export var colorVertexShader: {
  29912. name: string;
  29913. shader: string;
  29914. };
  29915. }
  29916. declare module "babylonjs/Meshes/linesMesh" {
  29917. import { Nullable } from "babylonjs/types";
  29918. import { Scene } from "babylonjs/scene";
  29919. import { Color3 } from "babylonjs/Maths/math.color";
  29920. import { Node } from "babylonjs/node";
  29921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29922. import { Mesh } from "babylonjs/Meshes/mesh";
  29923. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29924. import { Effect } from "babylonjs/Materials/effect";
  29925. import { Material } from "babylonjs/Materials/material";
  29926. import "babylonjs/Shaders/color.fragment";
  29927. import "babylonjs/Shaders/color.vertex";
  29928. /**
  29929. * Line mesh
  29930. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29931. */
  29932. export class LinesMesh extends Mesh {
  29933. /**
  29934. * If vertex color should be applied to the mesh
  29935. */
  29936. readonly useVertexColor?: boolean | undefined;
  29937. /**
  29938. * If vertex alpha should be applied to the mesh
  29939. */
  29940. readonly useVertexAlpha?: boolean | undefined;
  29941. /**
  29942. * Color of the line (Default: White)
  29943. */
  29944. color: Color3;
  29945. /**
  29946. * Alpha of the line (Default: 1)
  29947. */
  29948. alpha: number;
  29949. /**
  29950. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29951. * This margin is expressed in world space coordinates, so its value may vary.
  29952. * Default value is 0.1
  29953. */
  29954. intersectionThreshold: number;
  29955. private _colorShader;
  29956. private color4;
  29957. /**
  29958. * Creates a new LinesMesh
  29959. * @param name defines the name
  29960. * @param scene defines the hosting scene
  29961. * @param parent defines the parent mesh if any
  29962. * @param source defines the optional source LinesMesh used to clone data from
  29963. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29964. * When false, achieved by calling a clone(), also passing False.
  29965. * This will make creation of children, recursive.
  29966. * @param useVertexColor defines if this LinesMesh supports vertex color
  29967. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29968. */
  29969. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29970. /**
  29971. * If vertex color should be applied to the mesh
  29972. */
  29973. useVertexColor?: boolean | undefined,
  29974. /**
  29975. * If vertex alpha should be applied to the mesh
  29976. */
  29977. useVertexAlpha?: boolean | undefined);
  29978. private _addClipPlaneDefine;
  29979. private _removeClipPlaneDefine;
  29980. isReady(): boolean;
  29981. /**
  29982. * Returns the string "LineMesh"
  29983. */
  29984. getClassName(): string;
  29985. /**
  29986. * @hidden
  29987. */
  29988. get material(): Material;
  29989. /**
  29990. * @hidden
  29991. */
  29992. set material(value: Material);
  29993. /**
  29994. * @hidden
  29995. */
  29996. get checkCollisions(): boolean;
  29997. set checkCollisions(value: boolean);
  29998. /** @hidden */
  29999. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  30000. /** @hidden */
  30001. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  30002. /**
  30003. * Disposes of the line mesh
  30004. * @param doNotRecurse If children should be disposed
  30005. */
  30006. dispose(doNotRecurse?: boolean): void;
  30007. /**
  30008. * Returns a new LineMesh object cloned from the current one.
  30009. */
  30010. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  30011. /**
  30012. * Creates a new InstancedLinesMesh object from the mesh model.
  30013. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30014. * @param name defines the name of the new instance
  30015. * @returns a new InstancedLinesMesh
  30016. */
  30017. createInstance(name: string): InstancedLinesMesh;
  30018. }
  30019. /**
  30020. * Creates an instance based on a source LinesMesh
  30021. */
  30022. export class InstancedLinesMesh extends InstancedMesh {
  30023. /**
  30024. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30025. * This margin is expressed in world space coordinates, so its value may vary.
  30026. * Initilized with the intersectionThreshold value of the source LinesMesh
  30027. */
  30028. intersectionThreshold: number;
  30029. constructor(name: string, source: LinesMesh);
  30030. /**
  30031. * Returns the string "InstancedLinesMesh".
  30032. */
  30033. getClassName(): string;
  30034. }
  30035. }
  30036. declare module "babylonjs/Shaders/line.fragment" {
  30037. /** @hidden */
  30038. export var linePixelShader: {
  30039. name: string;
  30040. shader: string;
  30041. };
  30042. }
  30043. declare module "babylonjs/Shaders/line.vertex" {
  30044. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30045. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30046. /** @hidden */
  30047. export var lineVertexShader: {
  30048. name: string;
  30049. shader: string;
  30050. };
  30051. }
  30052. declare module "babylonjs/Rendering/edgesRenderer" {
  30053. import { Immutable, Nullable } from "babylonjs/types";
  30054. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30056. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  30057. import { IDisposable } from "babylonjs/scene";
  30058. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  30059. import "babylonjs/Shaders/line.fragment";
  30060. import "babylonjs/Shaders/line.vertex";
  30061. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30062. import { SmartArray } from "babylonjs/Misc/smartArray";
  30063. module "babylonjs/scene" {
  30064. interface Scene {
  30065. /** @hidden */
  30066. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  30067. }
  30068. }
  30069. module "babylonjs/Meshes/abstractMesh" {
  30070. interface AbstractMesh {
  30071. /**
  30072. * Gets the edgesRenderer associated with the mesh
  30073. */
  30074. edgesRenderer: Nullable<EdgesRenderer>;
  30075. }
  30076. }
  30077. module "babylonjs/Meshes/linesMesh" {
  30078. interface LinesMesh {
  30079. /**
  30080. * Enables the edge rendering mode on the mesh.
  30081. * This mode makes the mesh edges visible
  30082. * @param epsilon defines the maximal distance between two angles to detect a face
  30083. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30084. * @returns the currentAbstractMesh
  30085. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30086. */
  30087. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30088. }
  30089. }
  30090. module "babylonjs/Meshes/linesMesh" {
  30091. interface InstancedLinesMesh {
  30092. /**
  30093. * Enables the edge rendering mode on the mesh.
  30094. * This mode makes the mesh edges visible
  30095. * @param epsilon defines the maximal distance between two angles to detect a face
  30096. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30097. * @returns the current InstancedLinesMesh
  30098. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30099. */
  30100. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  30101. }
  30102. }
  30103. /**
  30104. * Defines the minimum contract an Edges renderer should follow.
  30105. */
  30106. export interface IEdgesRenderer extends IDisposable {
  30107. /**
  30108. * Gets or sets a boolean indicating if the edgesRenderer is active
  30109. */
  30110. isEnabled: boolean;
  30111. /**
  30112. * Renders the edges of the attached mesh,
  30113. */
  30114. render(): void;
  30115. /**
  30116. * Checks wether or not the edges renderer is ready to render.
  30117. * @return true if ready, otherwise false.
  30118. */
  30119. isReady(): boolean;
  30120. /**
  30121. * List of instances to render in case the source mesh has instances
  30122. */
  30123. customInstances: SmartArray<Matrix>;
  30124. }
  30125. /**
  30126. * Defines the additional options of the edges renderer
  30127. */
  30128. export interface IEdgesRendererOptions {
  30129. /**
  30130. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  30131. * If not defined, the default value is true
  30132. */
  30133. useAlternateEdgeFinder?: boolean;
  30134. /**
  30135. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  30136. * If not defined, the default value is true.
  30137. * 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)
  30138. * This option is used only if useAlternateEdgeFinder = true
  30139. */
  30140. useFastVertexMerger?: boolean;
  30141. /**
  30142. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  30143. * The default value is 1e-6
  30144. * This option is used only if useAlternateEdgeFinder = true
  30145. */
  30146. epsilonVertexMerge?: number;
  30147. /**
  30148. * 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
  30149. * 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.
  30150. * This option is used only if useAlternateEdgeFinder = true
  30151. */
  30152. applyTessellation?: boolean;
  30153. /**
  30154. * 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
  30155. * The default value is 1e-6
  30156. * This option is used only if useAlternateEdgeFinder = true
  30157. */
  30158. epsilonVertexAligned?: number;
  30159. }
  30160. /**
  30161. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  30162. */
  30163. export class EdgesRenderer implements IEdgesRenderer {
  30164. /**
  30165. * Define the size of the edges with an orthographic camera
  30166. */
  30167. edgesWidthScalerForOrthographic: number;
  30168. /**
  30169. * Define the size of the edges with a perspective camera
  30170. */
  30171. edgesWidthScalerForPerspective: number;
  30172. protected _source: AbstractMesh;
  30173. protected _linesPositions: number[];
  30174. protected _linesNormals: number[];
  30175. protected _linesIndices: number[];
  30176. protected _epsilon: number;
  30177. protected _indicesCount: number;
  30178. protected _lineShader: ShaderMaterial;
  30179. protected _ib: DataBuffer;
  30180. protected _buffers: {
  30181. [key: string]: Nullable<VertexBuffer>;
  30182. };
  30183. protected _buffersForInstances: {
  30184. [key: string]: Nullable<VertexBuffer>;
  30185. };
  30186. protected _checkVerticesInsteadOfIndices: boolean;
  30187. protected _options: Nullable<IEdgesRendererOptions>;
  30188. private _meshRebuildObserver;
  30189. private _meshDisposeObserver;
  30190. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  30191. isEnabled: boolean;
  30192. /** Gets the vertices generated by the edge renderer */
  30193. get linesPositions(): Immutable<Array<number>>;
  30194. /** Gets the normals generated by the edge renderer */
  30195. get linesNormals(): Immutable<Array<number>>;
  30196. /** Gets the indices generated by the edge renderer */
  30197. get linesIndices(): Immutable<Array<number>>;
  30198. /**
  30199. * List of instances to render in case the source mesh has instances
  30200. */
  30201. customInstances: SmartArray<Matrix>;
  30202. private static GetShader;
  30203. /**
  30204. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  30205. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  30206. * @param source Mesh used to create edges
  30207. * @param epsilon sum of angles in adjacency to check for edge
  30208. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  30209. * @param generateEdgesLines - should generate Lines or only prepare resources.
  30210. * @param options The options to apply when generating the edges
  30211. */
  30212. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  30213. protected _prepareRessources(): void;
  30214. /** @hidden */
  30215. _rebuild(): void;
  30216. /**
  30217. * Releases the required resources for the edges renderer
  30218. */
  30219. dispose(): void;
  30220. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  30221. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  30222. /**
  30223. * Checks if the pair of p0 and p1 is en edge
  30224. * @param faceIndex
  30225. * @param edge
  30226. * @param faceNormals
  30227. * @param p0
  30228. * @param p1
  30229. * @private
  30230. */
  30231. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  30232. /**
  30233. * push line into the position, normal and index buffer
  30234. * @protected
  30235. */
  30236. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  30237. /**
  30238. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  30239. */
  30240. private _tessellateTriangle;
  30241. private _generateEdgesLinesAlternate;
  30242. /**
  30243. * Generates lines edges from adjacencjes
  30244. * @private
  30245. */
  30246. _generateEdgesLines(): void;
  30247. /**
  30248. * Checks wether or not the edges renderer is ready to render.
  30249. * @return true if ready, otherwise false.
  30250. */
  30251. isReady(): boolean;
  30252. /**
  30253. * Renders the edges of the attached mesh,
  30254. */
  30255. render(): void;
  30256. }
  30257. /**
  30258. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  30259. */
  30260. export class LineEdgesRenderer extends EdgesRenderer {
  30261. /**
  30262. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  30263. * @param source LineMesh used to generate edges
  30264. * @param epsilon not important (specified angle for edge detection)
  30265. * @param checkVerticesInsteadOfIndices not important for LineMesh
  30266. */
  30267. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  30268. /**
  30269. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  30270. */
  30271. _generateEdgesLines(): void;
  30272. }
  30273. }
  30274. declare module "babylonjs/Rendering/renderingGroup" {
  30275. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  30276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30278. import { Nullable } from "babylonjs/types";
  30279. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30280. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  30281. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30282. import { Material } from "babylonjs/Materials/material";
  30283. import { Scene } from "babylonjs/scene";
  30284. /**
  30285. * This represents the object necessary to create a rendering group.
  30286. * This is exclusively used and created by the rendering manager.
  30287. * To modify the behavior, you use the available helpers in your scene or meshes.
  30288. * @hidden
  30289. */
  30290. export class RenderingGroup {
  30291. index: number;
  30292. private static _zeroVector;
  30293. private _scene;
  30294. private _opaqueSubMeshes;
  30295. private _transparentSubMeshes;
  30296. private _alphaTestSubMeshes;
  30297. private _depthOnlySubMeshes;
  30298. private _particleSystems;
  30299. private _spriteManagers;
  30300. private _opaqueSortCompareFn;
  30301. private _alphaTestSortCompareFn;
  30302. private _transparentSortCompareFn;
  30303. private _renderOpaque;
  30304. private _renderAlphaTest;
  30305. private _renderTransparent;
  30306. /** @hidden */
  30307. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  30308. onBeforeTransparentRendering: () => void;
  30309. /**
  30310. * Set the opaque sort comparison function.
  30311. * If null the sub meshes will be render in the order they were created
  30312. */
  30313. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30314. /**
  30315. * Set the alpha test sort comparison function.
  30316. * If null the sub meshes will be render in the order they were created
  30317. */
  30318. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30319. /**
  30320. * Set the transparent sort comparison function.
  30321. * If null the sub meshes will be render in the order they were created
  30322. */
  30323. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30324. /**
  30325. * Creates a new rendering group.
  30326. * @param index The rendering group index
  30327. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  30328. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  30329. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  30330. */
  30331. 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>);
  30332. /**
  30333. * Render all the sub meshes contained in the group.
  30334. * @param customRenderFunction Used to override the default render behaviour of the group.
  30335. * @returns true if rendered some submeshes.
  30336. */
  30337. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  30338. /**
  30339. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  30340. * @param subMeshes The submeshes to render
  30341. */
  30342. private renderOpaqueSorted;
  30343. /**
  30344. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  30345. * @param subMeshes The submeshes to render
  30346. */
  30347. private renderAlphaTestSorted;
  30348. /**
  30349. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  30350. * @param subMeshes The submeshes to render
  30351. */
  30352. private renderTransparentSorted;
  30353. /**
  30354. * Renders the submeshes in a specified order.
  30355. * @param subMeshes The submeshes to sort before render
  30356. * @param sortCompareFn The comparison function use to sort
  30357. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  30358. * @param transparent Specifies to activate blending if true
  30359. */
  30360. private static renderSorted;
  30361. /**
  30362. * Renders the submeshes in the order they were dispatched (no sort applied).
  30363. * @param subMeshes The submeshes to render
  30364. */
  30365. private static renderUnsorted;
  30366. /**
  30367. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30368. * are rendered back to front if in the same alpha index.
  30369. *
  30370. * @param a The first submesh
  30371. * @param b The second submesh
  30372. * @returns The result of the comparison
  30373. */
  30374. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  30375. /**
  30376. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30377. * are rendered back to front.
  30378. *
  30379. * @param a The first submesh
  30380. * @param b The second submesh
  30381. * @returns The result of the comparison
  30382. */
  30383. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  30384. /**
  30385. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30386. * are rendered front to back (prevent overdraw).
  30387. *
  30388. * @param a The first submesh
  30389. * @param b The second submesh
  30390. * @returns The result of the comparison
  30391. */
  30392. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  30393. /**
  30394. * Resets the different lists of submeshes to prepare a new frame.
  30395. */
  30396. prepare(): void;
  30397. dispose(): void;
  30398. /**
  30399. * Inserts the submesh in its correct queue depending on its material.
  30400. * @param subMesh The submesh to dispatch
  30401. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30402. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30403. */
  30404. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30405. dispatchSprites(spriteManager: ISpriteManager): void;
  30406. dispatchParticles(particleSystem: IParticleSystem): void;
  30407. private _renderParticles;
  30408. private _renderSprites;
  30409. }
  30410. }
  30411. declare module "babylonjs/Rendering/renderingManager" {
  30412. import { Nullable } from "babylonjs/types";
  30413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30414. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30415. import { SmartArray } from "babylonjs/Misc/smartArray";
  30416. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30417. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30418. import { Material } from "babylonjs/Materials/material";
  30419. import { Scene } from "babylonjs/scene";
  30420. import { Camera } from "babylonjs/Cameras/camera";
  30421. /**
  30422. * Interface describing the different options available in the rendering manager
  30423. * regarding Auto Clear between groups.
  30424. */
  30425. export interface IRenderingManagerAutoClearSetup {
  30426. /**
  30427. * Defines whether or not autoclear is enable.
  30428. */
  30429. autoClear: boolean;
  30430. /**
  30431. * Defines whether or not to autoclear the depth buffer.
  30432. */
  30433. depth: boolean;
  30434. /**
  30435. * Defines whether or not to autoclear the stencil buffer.
  30436. */
  30437. stencil: boolean;
  30438. }
  30439. /**
  30440. * This class is used by the onRenderingGroupObservable
  30441. */
  30442. export class RenderingGroupInfo {
  30443. /**
  30444. * The Scene that being rendered
  30445. */
  30446. scene: Scene;
  30447. /**
  30448. * The camera currently used for the rendering pass
  30449. */
  30450. camera: Nullable<Camera>;
  30451. /**
  30452. * The ID of the renderingGroup being processed
  30453. */
  30454. renderingGroupId: number;
  30455. }
  30456. /**
  30457. * This is the manager responsible of all the rendering for meshes sprites and particles.
  30458. * It is enable to manage the different groups as well as the different necessary sort functions.
  30459. * This should not be used directly aside of the few static configurations
  30460. */
  30461. export class RenderingManager {
  30462. /**
  30463. * The max id used for rendering groups (not included)
  30464. */
  30465. static MAX_RENDERINGGROUPS: number;
  30466. /**
  30467. * The min id used for rendering groups (included)
  30468. */
  30469. static MIN_RENDERINGGROUPS: number;
  30470. /**
  30471. * Used to globally prevent autoclearing scenes.
  30472. */
  30473. static AUTOCLEAR: boolean;
  30474. /**
  30475. * @hidden
  30476. */
  30477. _useSceneAutoClearSetup: boolean;
  30478. private _scene;
  30479. private _renderingGroups;
  30480. private _depthStencilBufferAlreadyCleaned;
  30481. private _autoClearDepthStencil;
  30482. private _customOpaqueSortCompareFn;
  30483. private _customAlphaTestSortCompareFn;
  30484. private _customTransparentSortCompareFn;
  30485. private _renderingGroupInfo;
  30486. /**
  30487. * Instantiates a new rendering group for a particular scene
  30488. * @param scene Defines the scene the groups belongs to
  30489. */
  30490. constructor(scene: Scene);
  30491. private _clearDepthStencilBuffer;
  30492. /**
  30493. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  30494. * @hidden
  30495. */
  30496. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30497. /**
  30498. * Resets the different information of the group to prepare a new frame
  30499. * @hidden
  30500. */
  30501. reset(): void;
  30502. /**
  30503. * Dispose and release the group and its associated resources.
  30504. * @hidden
  30505. */
  30506. dispose(): void;
  30507. /**
  30508. * Clear the info related to rendering groups preventing retention points during dispose.
  30509. */
  30510. freeRenderingGroups(): void;
  30511. private _prepareRenderingGroup;
  30512. /**
  30513. * Add a sprite manager to the rendering manager in order to render it this frame.
  30514. * @param spriteManager Define the sprite manager to render
  30515. */
  30516. dispatchSprites(spriteManager: ISpriteManager): void;
  30517. /**
  30518. * Add a particle system to the rendering manager in order to render it this frame.
  30519. * @param particleSystem Define the particle system to render
  30520. */
  30521. dispatchParticles(particleSystem: IParticleSystem): void;
  30522. /**
  30523. * Add a submesh to the manager in order to render it this frame
  30524. * @param subMesh The submesh to dispatch
  30525. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30526. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30527. */
  30528. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30529. /**
  30530. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30531. * This allowed control for front to back rendering or reversly depending of the special needs.
  30532. *
  30533. * @param renderingGroupId The rendering group id corresponding to its index
  30534. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30535. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30536. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30537. */
  30538. 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;
  30539. /**
  30540. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30541. *
  30542. * @param renderingGroupId The rendering group id corresponding to its index
  30543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30544. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30545. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30546. */
  30547. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30548. /**
  30549. * Gets the current auto clear configuration for one rendering group of the rendering
  30550. * manager.
  30551. * @param index the rendering group index to get the information for
  30552. * @returns The auto clear setup for the requested rendering group
  30553. */
  30554. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  30555. }
  30556. }
  30557. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  30558. import { SmartArray } from "babylonjs/Misc/smartArray";
  30559. import { Nullable } from "babylonjs/types";
  30560. import { Scene } from "babylonjs/scene";
  30561. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30564. import { Mesh } from "babylonjs/Meshes/mesh";
  30565. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  30566. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30567. import { Effect } from "babylonjs/Materials/effect";
  30568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30569. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30570. import "babylonjs/Shaders/shadowMap.fragment";
  30571. import "babylonjs/Shaders/shadowMap.vertex";
  30572. import "babylonjs/Shaders/depthBoxBlur.fragment";
  30573. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  30574. import { Observable } from "babylonjs/Misc/observable";
  30575. /**
  30576. * Defines the options associated with the creation of a custom shader for a shadow generator.
  30577. */
  30578. export interface ICustomShaderOptions {
  30579. /**
  30580. * Gets or sets the custom shader name to use
  30581. */
  30582. shaderName: string;
  30583. /**
  30584. * The list of attribute names used in the shader
  30585. */
  30586. attributes?: string[];
  30587. /**
  30588. * The list of unifrom names used in the shader
  30589. */
  30590. uniforms?: string[];
  30591. /**
  30592. * The list of sampler names used in the shader
  30593. */
  30594. samplers?: string[];
  30595. /**
  30596. * The list of defines used in the shader
  30597. */
  30598. defines?: string[];
  30599. }
  30600. /**
  30601. * Interface to implement to create a shadow generator compatible with BJS.
  30602. */
  30603. export interface IShadowGenerator {
  30604. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30605. id: string;
  30606. /**
  30607. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30608. * @returns The render target texture if present otherwise, null
  30609. */
  30610. getShadowMap(): Nullable<RenderTargetTexture>;
  30611. /**
  30612. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30613. * @param subMesh The submesh we want to render in the shadow map
  30614. * @param useInstances Defines wether will draw in the map using instances
  30615. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30616. * @returns true if ready otherwise, false
  30617. */
  30618. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30619. /**
  30620. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30621. * @param defines Defines of the material we want to update
  30622. * @param lightIndex Index of the light in the enabled light list of the material
  30623. */
  30624. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30625. /**
  30626. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30627. * defined in the generator but impacting the effect).
  30628. * It implies the unifroms available on the materials are the standard BJS ones.
  30629. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30630. * @param effect The effect we are binfing the information for
  30631. */
  30632. bindShadowLight(lightIndex: string, effect: Effect): void;
  30633. /**
  30634. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30635. * (eq to shadow prjection matrix * light transform matrix)
  30636. * @returns The transform matrix used to create the shadow map
  30637. */
  30638. getTransformMatrix(): Matrix;
  30639. /**
  30640. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30641. * Cube and 2D textures for instance.
  30642. */
  30643. recreateShadowMap(): void;
  30644. /**
  30645. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30646. * @param onCompiled Callback triggered at the and of the effects compilation
  30647. * @param options Sets of optional options forcing the compilation with different modes
  30648. */
  30649. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30650. useInstances: boolean;
  30651. }>): void;
  30652. /**
  30653. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30654. * @param options Sets of optional options forcing the compilation with different modes
  30655. * @returns A promise that resolves when the compilation completes
  30656. */
  30657. forceCompilationAsync(options?: Partial<{
  30658. useInstances: boolean;
  30659. }>): Promise<void>;
  30660. /**
  30661. * Serializes the shadow generator setup to a json object.
  30662. * @returns The serialized JSON object
  30663. */
  30664. serialize(): any;
  30665. /**
  30666. * Disposes the Shadow map and related Textures and effects.
  30667. */
  30668. dispose(): void;
  30669. }
  30670. /**
  30671. * Default implementation IShadowGenerator.
  30672. * This is the main object responsible of generating shadows in the framework.
  30673. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30674. */
  30675. export class ShadowGenerator implements IShadowGenerator {
  30676. private static _Counter;
  30677. /**
  30678. * Name of the shadow generator class
  30679. */
  30680. static CLASSNAME: string;
  30681. /**
  30682. * Shadow generator mode None: no filtering applied.
  30683. */
  30684. static readonly FILTER_NONE: number;
  30685. /**
  30686. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30687. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30688. */
  30689. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30690. /**
  30691. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30692. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30693. */
  30694. static readonly FILTER_POISSONSAMPLING: number;
  30695. /**
  30696. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30697. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30698. */
  30699. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30700. /**
  30701. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30702. * edge artifacts on steep falloff.
  30703. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30704. */
  30705. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30706. /**
  30707. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30708. * edge artifacts on steep falloff.
  30709. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30710. */
  30711. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30712. /**
  30713. * Shadow generator mode PCF: Percentage Closer Filtering
  30714. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30715. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30716. */
  30717. static readonly FILTER_PCF: number;
  30718. /**
  30719. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30720. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30721. * Contact Hardening
  30722. */
  30723. static readonly FILTER_PCSS: number;
  30724. /**
  30725. * Reserved for PCF and PCSS
  30726. * Highest Quality.
  30727. *
  30728. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30729. *
  30730. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30731. */
  30732. static readonly QUALITY_HIGH: number;
  30733. /**
  30734. * Reserved for PCF and PCSS
  30735. * Good tradeoff for quality/perf cross devices
  30736. *
  30737. * Execute PCF on a 3*3 kernel.
  30738. *
  30739. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30740. */
  30741. static readonly QUALITY_MEDIUM: number;
  30742. /**
  30743. * Reserved for PCF and PCSS
  30744. * The lowest quality but the fastest.
  30745. *
  30746. * Execute PCF on a 1*1 kernel.
  30747. *
  30748. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30749. */
  30750. static readonly QUALITY_LOW: number;
  30751. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30752. id: string;
  30753. /** Gets or sets the custom shader name to use */
  30754. customShaderOptions: ICustomShaderOptions;
  30755. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30756. customAllowRendering: (subMesh: SubMesh) => boolean;
  30757. /**
  30758. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30759. */
  30760. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30761. /**
  30762. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30763. */
  30764. onAfterShadowMapRenderObservable: Observable<Effect>;
  30765. /**
  30766. * Observable triggered before a mesh is rendered in the shadow map.
  30767. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30768. */
  30769. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30770. /**
  30771. * Observable triggered after a mesh is rendered in the shadow map.
  30772. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30773. */
  30774. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30775. protected _bias: number;
  30776. /**
  30777. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30778. */
  30779. get bias(): number;
  30780. /**
  30781. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30782. */
  30783. set bias(bias: number);
  30784. protected _normalBias: number;
  30785. /**
  30786. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30787. */
  30788. get normalBias(): number;
  30789. /**
  30790. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30791. */
  30792. set normalBias(normalBias: number);
  30793. protected _blurBoxOffset: number;
  30794. /**
  30795. * Gets the blur box offset: offset applied during the blur pass.
  30796. * Only useful if useKernelBlur = false
  30797. */
  30798. get blurBoxOffset(): number;
  30799. /**
  30800. * Sets the blur box offset: offset applied during the blur pass.
  30801. * Only useful if useKernelBlur = false
  30802. */
  30803. set blurBoxOffset(value: number);
  30804. protected _blurScale: number;
  30805. /**
  30806. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30807. * 2 means half of the size.
  30808. */
  30809. get blurScale(): number;
  30810. /**
  30811. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30812. * 2 means half of the size.
  30813. */
  30814. set blurScale(value: number);
  30815. protected _blurKernel: number;
  30816. /**
  30817. * Gets the blur kernel: kernel size of the blur pass.
  30818. * Only useful if useKernelBlur = true
  30819. */
  30820. get blurKernel(): number;
  30821. /**
  30822. * Sets the blur kernel: kernel size of the blur pass.
  30823. * Only useful if useKernelBlur = true
  30824. */
  30825. set blurKernel(value: number);
  30826. protected _useKernelBlur: boolean;
  30827. /**
  30828. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30829. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30830. */
  30831. get useKernelBlur(): boolean;
  30832. /**
  30833. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30835. */
  30836. set useKernelBlur(value: boolean);
  30837. protected _depthScale: number;
  30838. /**
  30839. * Gets the depth scale used in ESM mode.
  30840. */
  30841. get depthScale(): number;
  30842. /**
  30843. * Sets the depth scale used in ESM mode.
  30844. * This can override the scale stored on the light.
  30845. */
  30846. set depthScale(value: number);
  30847. protected _validateFilter(filter: number): number;
  30848. protected _filter: number;
  30849. /**
  30850. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30851. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30852. */
  30853. get filter(): number;
  30854. /**
  30855. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30856. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30857. */
  30858. set filter(value: number);
  30859. /**
  30860. * Gets if the current filter is set to Poisson Sampling.
  30861. */
  30862. get usePoissonSampling(): boolean;
  30863. /**
  30864. * Sets the current filter to Poisson Sampling.
  30865. */
  30866. set usePoissonSampling(value: boolean);
  30867. /**
  30868. * Gets if the current filter is set to ESM.
  30869. */
  30870. get useExponentialShadowMap(): boolean;
  30871. /**
  30872. * Sets the current filter is to ESM.
  30873. */
  30874. set useExponentialShadowMap(value: boolean);
  30875. /**
  30876. * Gets if the current filter is set to filtered ESM.
  30877. */
  30878. get useBlurExponentialShadowMap(): boolean;
  30879. /**
  30880. * Gets if the current filter is set to filtered ESM.
  30881. */
  30882. set useBlurExponentialShadowMap(value: boolean);
  30883. /**
  30884. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30885. * exponential to prevent steep falloff artifacts).
  30886. */
  30887. get useCloseExponentialShadowMap(): boolean;
  30888. /**
  30889. * Sets the current filter to "close ESM" (using the inverse of the
  30890. * exponential to prevent steep falloff artifacts).
  30891. */
  30892. set useCloseExponentialShadowMap(value: boolean);
  30893. /**
  30894. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30895. * exponential to prevent steep falloff artifacts).
  30896. */
  30897. get useBlurCloseExponentialShadowMap(): boolean;
  30898. /**
  30899. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30900. * exponential to prevent steep falloff artifacts).
  30901. */
  30902. set useBlurCloseExponentialShadowMap(value: boolean);
  30903. /**
  30904. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30905. */
  30906. get usePercentageCloserFiltering(): boolean;
  30907. /**
  30908. * Sets the current filter to "PCF" (percentage closer filtering).
  30909. */
  30910. set usePercentageCloserFiltering(value: boolean);
  30911. protected _filteringQuality: number;
  30912. /**
  30913. * Gets the PCF or PCSS Quality.
  30914. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30915. */
  30916. get filteringQuality(): number;
  30917. /**
  30918. * Sets the PCF or PCSS Quality.
  30919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30920. */
  30921. set filteringQuality(filteringQuality: number);
  30922. /**
  30923. * Gets if the current filter is set to "PCSS" (contact hardening).
  30924. */
  30925. get useContactHardeningShadow(): boolean;
  30926. /**
  30927. * Sets the current filter to "PCSS" (contact hardening).
  30928. */
  30929. set useContactHardeningShadow(value: boolean);
  30930. protected _contactHardeningLightSizeUVRatio: number;
  30931. /**
  30932. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30933. * Using a ratio helps keeping shape stability independently of the map size.
  30934. *
  30935. * It does not account for the light projection as it was having too much
  30936. * instability during the light setup or during light position changes.
  30937. *
  30938. * Only valid if useContactHardeningShadow is true.
  30939. */
  30940. get contactHardeningLightSizeUVRatio(): number;
  30941. /**
  30942. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30943. * Using a ratio helps keeping shape stability independently of the map size.
  30944. *
  30945. * It does not account for the light projection as it was having too much
  30946. * instability during the light setup or during light position changes.
  30947. *
  30948. * Only valid if useContactHardeningShadow is true.
  30949. */
  30950. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30951. protected _darkness: number;
  30952. /** Gets or sets the actual darkness of a shadow */
  30953. get darkness(): number;
  30954. set darkness(value: number);
  30955. /**
  30956. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30957. * 0 means strongest and 1 would means no shadow.
  30958. * @returns the darkness.
  30959. */
  30960. getDarkness(): number;
  30961. /**
  30962. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30963. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30964. * @returns the shadow generator allowing fluent coding.
  30965. */
  30966. setDarkness(darkness: number): ShadowGenerator;
  30967. protected _transparencyShadow: boolean;
  30968. /** Gets or sets the ability to have transparent shadow */
  30969. get transparencyShadow(): boolean;
  30970. set transparencyShadow(value: boolean);
  30971. /**
  30972. * Sets the ability to have transparent shadow (boolean).
  30973. * @param transparent True if transparent else False
  30974. * @returns the shadow generator allowing fluent coding
  30975. */
  30976. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30977. /**
  30978. * Enables or disables shadows with varying strength based on the transparency
  30979. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30980. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30981. * mesh.visibility * alphaTexture.a
  30982. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30983. */
  30984. enableSoftTransparentShadow: boolean;
  30985. protected _shadowMap: Nullable<RenderTargetTexture>;
  30986. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30987. /**
  30988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30989. * @returns The render target texture if present otherwise, null
  30990. */
  30991. getShadowMap(): Nullable<RenderTargetTexture>;
  30992. /**
  30993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30994. * @returns The render target texture if the shadow map is present otherwise, null
  30995. */
  30996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30997. /**
  30998. * Gets the class name of that object
  30999. * @returns "ShadowGenerator"
  31000. */
  31001. getClassName(): string;
  31002. /**
  31003. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31004. * @param mesh Mesh to add
  31005. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31006. * @returns the Shadow Generator itself
  31007. */
  31008. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31009. /**
  31010. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31011. * @param mesh Mesh to remove
  31012. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31013. * @returns the Shadow Generator itself
  31014. */
  31015. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31016. /**
  31017. * Controls the extent to which the shadows fade out at the edge of the frustum
  31018. */
  31019. frustumEdgeFalloff: number;
  31020. protected _light: IShadowLight;
  31021. /**
  31022. * Returns the associated light object.
  31023. * @returns the light generating the shadow
  31024. */
  31025. getLight(): IShadowLight;
  31026. /**
  31027. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31028. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31029. * It might on the other hand introduce peter panning.
  31030. */
  31031. forceBackFacesOnly: boolean;
  31032. protected _scene: Scene;
  31033. protected _lightDirection: Vector3;
  31034. protected _viewMatrix: Matrix;
  31035. protected _projectionMatrix: Matrix;
  31036. protected _transformMatrix: Matrix;
  31037. protected _cachedPosition: Vector3;
  31038. protected _cachedDirection: Vector3;
  31039. protected _cachedDefines: string;
  31040. protected _currentRenderID: number;
  31041. protected _boxBlurPostprocess: Nullable<PostProcess>;
  31042. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  31043. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  31044. protected _blurPostProcesses: PostProcess[];
  31045. protected _mapSize: number;
  31046. protected _currentFaceIndex: number;
  31047. protected _currentFaceIndexCache: number;
  31048. protected _textureType: number;
  31049. protected _defaultTextureMatrix: Matrix;
  31050. protected _storedUniqueId: Nullable<number>;
  31051. protected _nameForCustomEffect: string;
  31052. /** @hidden */
  31053. static _SceneComponentInitialization: (scene: Scene) => void;
  31054. /**
  31055. * Gets or sets the size of the texture what stores the shadows
  31056. */
  31057. get mapSize(): number;
  31058. set mapSize(size: number);
  31059. /**
  31060. * Creates a ShadowGenerator object.
  31061. * A ShadowGenerator is the required tool to use the shadows.
  31062. * Each light casting shadows needs to use its own ShadowGenerator.
  31063. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  31064. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31065. * @param light The light object generating the shadows.
  31066. * @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.
  31067. */
  31068. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  31069. protected _initializeGenerator(): void;
  31070. protected _createTargetRenderTexture(): void;
  31071. protected _initializeShadowMap(): void;
  31072. protected _initializeBlurRTTAndPostProcesses(): void;
  31073. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  31074. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  31075. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  31076. protected _applyFilterValues(): void;
  31077. /**
  31078. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31079. * @param onCompiled Callback triggered at the and of the effects compilation
  31080. * @param options Sets of optional options forcing the compilation with different modes
  31081. */
  31082. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  31083. useInstances: boolean;
  31084. }>): void;
  31085. /**
  31086. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31087. * @param options Sets of optional options forcing the compilation with different modes
  31088. * @returns A promise that resolves when the compilation completes
  31089. */
  31090. forceCompilationAsync(options?: Partial<{
  31091. useInstances: boolean;
  31092. }>): Promise<void>;
  31093. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  31094. private _prepareShadowDefines;
  31095. /**
  31096. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31097. * @param subMesh The submesh we want to render in the shadow map
  31098. * @param useInstances Defines wether will draw in the map using instances
  31099. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  31100. * @returns true if ready otherwise, false
  31101. */
  31102. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  31103. /**
  31104. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31105. * @param defines Defines of the material we want to update
  31106. * @param lightIndex Index of the light in the enabled light list of the material
  31107. */
  31108. prepareDefines(defines: any, lightIndex: number): void;
  31109. /**
  31110. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31111. * defined in the generator but impacting the effect).
  31112. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31113. * @param effect The effect we are binfing the information for
  31114. */
  31115. bindShadowLight(lightIndex: string, effect: Effect): void;
  31116. /**
  31117. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31118. * (eq to shadow prjection matrix * light transform matrix)
  31119. * @returns The transform matrix used to create the shadow map
  31120. */
  31121. getTransformMatrix(): Matrix;
  31122. /**
  31123. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31124. * Cube and 2D textures for instance.
  31125. */
  31126. recreateShadowMap(): void;
  31127. protected _disposeBlurPostProcesses(): void;
  31128. protected _disposeRTTandPostProcesses(): void;
  31129. /**
  31130. * Disposes the ShadowGenerator.
  31131. * Returns nothing.
  31132. */
  31133. dispose(): void;
  31134. /**
  31135. * Serializes the shadow generator setup to a json object.
  31136. * @returns The serialized JSON object
  31137. */
  31138. serialize(): any;
  31139. /**
  31140. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31141. * @param parsedShadowGenerator The JSON object to parse
  31142. * @param scene The scene to create the shadow map for
  31143. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  31144. * @returns The parsed shadow generator
  31145. */
  31146. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  31147. }
  31148. }
  31149. declare module "babylonjs/Materials/shadowDepthWrapper" {
  31150. import { Nullable } from "babylonjs/types";
  31151. import { Scene } from "babylonjs/scene";
  31152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31153. import { Material } from "babylonjs/Materials/material";
  31154. import { Effect } from "babylonjs/Materials/effect";
  31155. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  31156. /**
  31157. * Options to be used when creating a shadow depth material
  31158. */
  31159. export interface IIOptionShadowDepthMaterial {
  31160. /** Variables in the vertex shader code that need to have their names remapped.
  31161. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  31162. * "var_name" should be either: worldPos or vNormalW
  31163. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  31164. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  31165. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  31166. */
  31167. remappedVariables?: string[];
  31168. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  31169. standalone?: boolean;
  31170. }
  31171. /**
  31172. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  31173. */
  31174. export class ShadowDepthWrapper {
  31175. private _scene;
  31176. private _options?;
  31177. private _baseMaterial;
  31178. private _onEffectCreatedObserver;
  31179. private _subMeshToEffect;
  31180. private _subMeshToDepthEffect;
  31181. private _meshes;
  31182. /** @hidden */
  31183. _matriceNames: any;
  31184. /** Gets the standalone status of the wrapper */
  31185. get standalone(): boolean;
  31186. /** Gets the base material the wrapper is built upon */
  31187. get baseMaterial(): Material;
  31188. /**
  31189. * Instantiate a new shadow depth wrapper.
  31190. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  31191. * generate the shadow depth map. For more information, please refer to the documentation:
  31192. * https://doc.babylonjs.com/babylon101/shadows
  31193. * @param baseMaterial Material to wrap
  31194. * @param scene Define the scene the material belongs to
  31195. * @param options Options used to create the wrapper
  31196. */
  31197. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  31198. /**
  31199. * Gets the effect to use to generate the depth map
  31200. * @param subMesh subMesh to get the effect for
  31201. * @param shadowGenerator shadow generator to get the effect for
  31202. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  31203. */
  31204. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  31205. /**
  31206. * Specifies that the submesh is ready to be used for depth rendering
  31207. * @param subMesh submesh to check
  31208. * @param defines the list of defines to take into account when checking the effect
  31209. * @param shadowGenerator combined with subMesh, it defines the effect to check
  31210. * @param useInstances specifies that instances should be used
  31211. * @returns a boolean indicating that the submesh is ready or not
  31212. */
  31213. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  31214. /**
  31215. * Disposes the resources
  31216. */
  31217. dispose(): void;
  31218. private _makeEffect;
  31219. }
  31220. }
  31221. declare module "babylonjs/Materials/material" {
  31222. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31223. import { SmartArray } from "babylonjs/Misc/smartArray";
  31224. import { Observable } from "babylonjs/Misc/observable";
  31225. import { Nullable } from "babylonjs/types";
  31226. import { Matrix } from "babylonjs/Maths/math.vector";
  31227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31229. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31230. import { Effect } from "babylonjs/Materials/effect";
  31231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31233. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  31235. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  31236. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  31237. import { Mesh } from "babylonjs/Meshes/mesh";
  31238. import { Animation } from "babylonjs/Animations/animation";
  31239. import { Scene } from "babylonjs/scene";
  31240. /**
  31241. * Options for compiling materials.
  31242. */
  31243. export interface IMaterialCompilationOptions {
  31244. /**
  31245. * Defines whether clip planes are enabled.
  31246. */
  31247. clipPlane: boolean;
  31248. /**
  31249. * Defines whether instances are enabled.
  31250. */
  31251. useInstances: boolean;
  31252. }
  31253. /**
  31254. * Options passed when calling customShaderNameResolve
  31255. */
  31256. export interface ICustomShaderNameResolveOptions {
  31257. /**
  31258. * 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
  31259. */
  31260. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  31261. }
  31262. /**
  31263. * Base class for the main features of a material in Babylon.js
  31264. */
  31265. export class Material implements IAnimatable {
  31266. /**
  31267. * Returns the triangle fill mode
  31268. */
  31269. static readonly TriangleFillMode: number;
  31270. /**
  31271. * Returns the wireframe mode
  31272. */
  31273. static readonly WireFrameFillMode: number;
  31274. /**
  31275. * Returns the point fill mode
  31276. */
  31277. static readonly PointFillMode: number;
  31278. /**
  31279. * Returns the point list draw mode
  31280. */
  31281. static readonly PointListDrawMode: number;
  31282. /**
  31283. * Returns the line list draw mode
  31284. */
  31285. static readonly LineListDrawMode: number;
  31286. /**
  31287. * Returns the line loop draw mode
  31288. */
  31289. static readonly LineLoopDrawMode: number;
  31290. /**
  31291. * Returns the line strip draw mode
  31292. */
  31293. static readonly LineStripDrawMode: number;
  31294. /**
  31295. * Returns the triangle strip draw mode
  31296. */
  31297. static readonly TriangleStripDrawMode: number;
  31298. /**
  31299. * Returns the triangle fan draw mode
  31300. */
  31301. static readonly TriangleFanDrawMode: number;
  31302. /**
  31303. * Stores the clock-wise side orientation
  31304. */
  31305. static readonly ClockWiseSideOrientation: number;
  31306. /**
  31307. * Stores the counter clock-wise side orientation
  31308. */
  31309. static readonly CounterClockWiseSideOrientation: number;
  31310. /**
  31311. * The dirty texture flag value
  31312. */
  31313. static readonly TextureDirtyFlag: number;
  31314. /**
  31315. * The dirty light flag value
  31316. */
  31317. static readonly LightDirtyFlag: number;
  31318. /**
  31319. * The dirty fresnel flag value
  31320. */
  31321. static readonly FresnelDirtyFlag: number;
  31322. /**
  31323. * The dirty attribute flag value
  31324. */
  31325. static readonly AttributesDirtyFlag: number;
  31326. /**
  31327. * The dirty misc flag value
  31328. */
  31329. static readonly MiscDirtyFlag: number;
  31330. /**
  31331. * The dirty prepass flag value
  31332. */
  31333. static readonly PrePassDirtyFlag: number;
  31334. /**
  31335. * The all dirty flag value
  31336. */
  31337. static readonly AllDirtyFlag: number;
  31338. /**
  31339. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31340. */
  31341. static readonly MATERIAL_OPAQUE: number;
  31342. /**
  31343. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31344. */
  31345. static readonly MATERIAL_ALPHATEST: number;
  31346. /**
  31347. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31348. */
  31349. static readonly MATERIAL_ALPHABLEND: number;
  31350. /**
  31351. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31352. * They are also discarded below the alpha cutoff threshold to improve performances.
  31353. */
  31354. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  31355. /**
  31356. * The Whiteout method is used to blend normals.
  31357. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31358. */
  31359. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  31360. /**
  31361. * The Reoriented Normal Mapping method is used to blend normals.
  31362. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31363. */
  31364. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  31365. /**
  31366. * Custom callback helping to override the default shader used in the material.
  31367. */
  31368. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  31369. /**
  31370. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  31371. */
  31372. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  31373. /**
  31374. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  31375. * This means that the material can keep using a previous shader while a new one is being compiled.
  31376. * This is mostly used when shader parallel compilation is supported (true by default)
  31377. */
  31378. allowShaderHotSwapping: boolean;
  31379. /**
  31380. * The ID of the material
  31381. */
  31382. id: string;
  31383. /**
  31384. * Gets or sets the unique id of the material
  31385. */
  31386. uniqueId: number;
  31387. /**
  31388. * The name of the material
  31389. */
  31390. name: string;
  31391. /**
  31392. * Gets or sets user defined metadata
  31393. */
  31394. metadata: any;
  31395. /**
  31396. * For internal use only. Please do not use.
  31397. */
  31398. reservedDataStore: any;
  31399. /**
  31400. * Specifies if the ready state should be checked on each call
  31401. */
  31402. checkReadyOnEveryCall: boolean;
  31403. /**
  31404. * Specifies if the ready state should be checked once
  31405. */
  31406. checkReadyOnlyOnce: boolean;
  31407. /**
  31408. * The state of the material
  31409. */
  31410. state: string;
  31411. /**
  31412. * If the material can be rendered to several textures with MRT extension
  31413. */
  31414. get canRenderToMRT(): boolean;
  31415. /**
  31416. * The alpha value of the material
  31417. */
  31418. protected _alpha: number;
  31419. /**
  31420. * List of inspectable custom properties (used by the Inspector)
  31421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31422. */
  31423. inspectableCustomProperties: IInspectable[];
  31424. /**
  31425. * Sets the alpha value of the material
  31426. */
  31427. set alpha(value: number);
  31428. /**
  31429. * Gets the alpha value of the material
  31430. */
  31431. get alpha(): number;
  31432. /**
  31433. * Specifies if back face culling is enabled
  31434. */
  31435. protected _backFaceCulling: boolean;
  31436. /**
  31437. * Sets the back-face culling state
  31438. */
  31439. set backFaceCulling(value: boolean);
  31440. /**
  31441. * Gets the back-face culling state
  31442. */
  31443. get backFaceCulling(): boolean;
  31444. /**
  31445. * Stores the value for side orientation
  31446. */
  31447. sideOrientation: number;
  31448. /**
  31449. * Callback triggered when the material is compiled
  31450. */
  31451. onCompiled: Nullable<(effect: Effect) => void>;
  31452. /**
  31453. * Callback triggered when an error occurs
  31454. */
  31455. onError: Nullable<(effect: Effect, errors: string) => void>;
  31456. /**
  31457. * Callback triggered to get the render target textures
  31458. */
  31459. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  31460. /**
  31461. * Gets a boolean indicating that current material needs to register RTT
  31462. */
  31463. get hasRenderTargetTextures(): boolean;
  31464. /**
  31465. * Specifies if the material should be serialized
  31466. */
  31467. doNotSerialize: boolean;
  31468. /**
  31469. * @hidden
  31470. */
  31471. _storeEffectOnSubMeshes: boolean;
  31472. /**
  31473. * Stores the animations for the material
  31474. */
  31475. animations: Nullable<Array<Animation>>;
  31476. /**
  31477. * An event triggered when the material is disposed
  31478. */
  31479. onDisposeObservable: Observable<Material>;
  31480. /**
  31481. * An observer which watches for dispose events
  31482. */
  31483. private _onDisposeObserver;
  31484. private _onUnBindObservable;
  31485. /**
  31486. * Called during a dispose event
  31487. */
  31488. set onDispose(callback: () => void);
  31489. private _onBindObservable;
  31490. /**
  31491. * An event triggered when the material is bound
  31492. */
  31493. get onBindObservable(): Observable<AbstractMesh>;
  31494. /**
  31495. * An observer which watches for bind events
  31496. */
  31497. private _onBindObserver;
  31498. /**
  31499. * Called during a bind event
  31500. */
  31501. set onBind(callback: (Mesh: AbstractMesh) => void);
  31502. /**
  31503. * An event triggered when the material is unbound
  31504. */
  31505. get onUnBindObservable(): Observable<Material>;
  31506. protected _onEffectCreatedObservable: Nullable<Observable<{
  31507. effect: Effect;
  31508. subMesh: Nullable<SubMesh>;
  31509. }>>;
  31510. /**
  31511. * An event triggered when the effect is (re)created
  31512. */
  31513. get onEffectCreatedObservable(): Observable<{
  31514. effect: Effect;
  31515. subMesh: Nullable<SubMesh>;
  31516. }>;
  31517. /**
  31518. * Stores the value of the alpha mode
  31519. */
  31520. private _alphaMode;
  31521. /**
  31522. * Sets the value of the alpha mode.
  31523. *
  31524. * | Value | Type | Description |
  31525. * | --- | --- | --- |
  31526. * | 0 | ALPHA_DISABLE | |
  31527. * | 1 | ALPHA_ADD | |
  31528. * | 2 | ALPHA_COMBINE | |
  31529. * | 3 | ALPHA_SUBTRACT | |
  31530. * | 4 | ALPHA_MULTIPLY | |
  31531. * | 5 | ALPHA_MAXIMIZED | |
  31532. * | 6 | ALPHA_ONEONE | |
  31533. * | 7 | ALPHA_PREMULTIPLIED | |
  31534. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  31535. * | 9 | ALPHA_INTERPOLATE | |
  31536. * | 10 | ALPHA_SCREENMODE | |
  31537. *
  31538. */
  31539. set alphaMode(value: number);
  31540. /**
  31541. * Gets the value of the alpha mode
  31542. */
  31543. get alphaMode(): number;
  31544. /**
  31545. * Stores the state of the need depth pre-pass value
  31546. */
  31547. private _needDepthPrePass;
  31548. /**
  31549. * Sets the need depth pre-pass value
  31550. */
  31551. set needDepthPrePass(value: boolean);
  31552. /**
  31553. * Gets the depth pre-pass value
  31554. */
  31555. get needDepthPrePass(): boolean;
  31556. /**
  31557. * Specifies if depth writing should be disabled
  31558. */
  31559. disableDepthWrite: boolean;
  31560. /**
  31561. * Specifies if color writing should be disabled
  31562. */
  31563. disableColorWrite: boolean;
  31564. /**
  31565. * Specifies if depth writing should be forced
  31566. */
  31567. forceDepthWrite: boolean;
  31568. /**
  31569. * Specifies the depth function that should be used. 0 means the default engine function
  31570. */
  31571. depthFunction: number;
  31572. /**
  31573. * Specifies if there should be a separate pass for culling
  31574. */
  31575. separateCullingPass: boolean;
  31576. /**
  31577. * Stores the state specifing if fog should be enabled
  31578. */
  31579. private _fogEnabled;
  31580. /**
  31581. * Sets the state for enabling fog
  31582. */
  31583. set fogEnabled(value: boolean);
  31584. /**
  31585. * Gets the value of the fog enabled state
  31586. */
  31587. get fogEnabled(): boolean;
  31588. /**
  31589. * Stores the size of points
  31590. */
  31591. pointSize: number;
  31592. /**
  31593. * Stores the z offset value
  31594. */
  31595. zOffset: number;
  31596. get wireframe(): boolean;
  31597. /**
  31598. * Sets the state of wireframe mode
  31599. */
  31600. set wireframe(value: boolean);
  31601. /**
  31602. * Gets the value specifying if point clouds are enabled
  31603. */
  31604. get pointsCloud(): boolean;
  31605. /**
  31606. * Sets the state of point cloud mode
  31607. */
  31608. set pointsCloud(value: boolean);
  31609. /**
  31610. * Gets the material fill mode
  31611. */
  31612. get fillMode(): number;
  31613. /**
  31614. * Sets the material fill mode
  31615. */
  31616. set fillMode(value: number);
  31617. /**
  31618. * @hidden
  31619. * Stores the effects for the material
  31620. */
  31621. _effect: Nullable<Effect>;
  31622. /**
  31623. * Specifies if uniform buffers should be used
  31624. */
  31625. private _useUBO;
  31626. /**
  31627. * Stores a reference to the scene
  31628. */
  31629. private _scene;
  31630. private _needToBindSceneUbo;
  31631. /**
  31632. * Stores the fill mode state
  31633. */
  31634. private _fillMode;
  31635. /**
  31636. * Specifies if the depth write state should be cached
  31637. */
  31638. private _cachedDepthWriteState;
  31639. /**
  31640. * Specifies if the color write state should be cached
  31641. */
  31642. private _cachedColorWriteState;
  31643. /**
  31644. * Specifies if the depth function state should be cached
  31645. */
  31646. private _cachedDepthFunctionState;
  31647. /**
  31648. * Stores the uniform buffer
  31649. */
  31650. protected _uniformBuffer: UniformBuffer;
  31651. /** @hidden */
  31652. _indexInSceneMaterialArray: number;
  31653. /** @hidden */
  31654. meshMap: Nullable<{
  31655. [id: string]: AbstractMesh | undefined;
  31656. }>;
  31657. /**
  31658. * Creates a material instance
  31659. * @param name defines the name of the material
  31660. * @param scene defines the scene to reference
  31661. * @param doNotAdd specifies if the material should be added to the scene
  31662. */
  31663. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31664. /**
  31665. * Returns a string representation of the current material
  31666. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31667. * @returns a string with material information
  31668. */
  31669. toString(fullDetails?: boolean): string;
  31670. /**
  31671. * Gets the class name of the material
  31672. * @returns a string with the class name of the material
  31673. */
  31674. getClassName(): string;
  31675. /**
  31676. * Specifies if updates for the material been locked
  31677. */
  31678. get isFrozen(): boolean;
  31679. /**
  31680. * Locks updates for the material
  31681. */
  31682. freeze(): void;
  31683. /**
  31684. * Unlocks updates for the material
  31685. */
  31686. unfreeze(): void;
  31687. /**
  31688. * Specifies if the material is ready to be used
  31689. * @param mesh defines the mesh to check
  31690. * @param useInstances specifies if instances should be used
  31691. * @returns a boolean indicating if the material is ready to be used
  31692. */
  31693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31694. /**
  31695. * Specifies that the submesh is ready to be used
  31696. * @param mesh defines the mesh to check
  31697. * @param subMesh defines which submesh to check
  31698. * @param useInstances specifies that instances should be used
  31699. * @returns a boolean indicating that the submesh is ready or not
  31700. */
  31701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31702. /**
  31703. * Returns the material effect
  31704. * @returns the effect associated with the material
  31705. */
  31706. getEffect(): Nullable<Effect>;
  31707. /**
  31708. * Returns the current scene
  31709. * @returns a Scene
  31710. */
  31711. getScene(): Scene;
  31712. /**
  31713. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31714. */
  31715. protected _forceAlphaTest: boolean;
  31716. /**
  31717. * The transparency mode of the material.
  31718. */
  31719. protected _transparencyMode: Nullable<number>;
  31720. /**
  31721. * Gets the current transparency mode.
  31722. */
  31723. get transparencyMode(): Nullable<number>;
  31724. /**
  31725. * Sets the transparency mode of the material.
  31726. *
  31727. * | Value | Type | Description |
  31728. * | ----- | ----------------------------------- | ----------- |
  31729. * | 0 | OPAQUE | |
  31730. * | 1 | ALPHATEST | |
  31731. * | 2 | ALPHABLEND | |
  31732. * | 3 | ALPHATESTANDBLEND | |
  31733. *
  31734. */
  31735. set transparencyMode(value: Nullable<number>);
  31736. /**
  31737. * Returns true if alpha blending should be disabled.
  31738. */
  31739. protected get _disableAlphaBlending(): boolean;
  31740. /**
  31741. * Specifies whether or not this material should be rendered in alpha blend mode.
  31742. * @returns a boolean specifying if alpha blending is needed
  31743. */
  31744. needAlphaBlending(): boolean;
  31745. /**
  31746. * Specifies if the mesh will require alpha blending
  31747. * @param mesh defines the mesh to check
  31748. * @returns a boolean specifying if alpha blending is needed for the mesh
  31749. */
  31750. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31751. /**
  31752. * Specifies whether or not this material should be rendered in alpha test mode.
  31753. * @returns a boolean specifying if an alpha test is needed.
  31754. */
  31755. needAlphaTesting(): boolean;
  31756. /**
  31757. * Specifies if material alpha testing should be turned on for the mesh
  31758. * @param mesh defines the mesh to check
  31759. */
  31760. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31761. /**
  31762. * Gets the texture used for the alpha test
  31763. * @returns the texture to use for alpha testing
  31764. */
  31765. getAlphaTestTexture(): Nullable<BaseTexture>;
  31766. /**
  31767. * Marks the material to indicate that it needs to be re-calculated
  31768. */
  31769. markDirty(): void;
  31770. /** @hidden */
  31771. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31772. /**
  31773. * Binds the material to the mesh
  31774. * @param world defines the world transformation matrix
  31775. * @param mesh defines the mesh to bind the material to
  31776. */
  31777. bind(world: Matrix, mesh?: Mesh): void;
  31778. /**
  31779. * Binds the submesh to the material
  31780. * @param world defines the world transformation matrix
  31781. * @param mesh defines the mesh containing the submesh
  31782. * @param subMesh defines the submesh to bind the material to
  31783. */
  31784. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31785. /**
  31786. * Binds the world matrix to the material
  31787. * @param world defines the world transformation matrix
  31788. */
  31789. bindOnlyWorldMatrix(world: Matrix): void;
  31790. /**
  31791. * Update the scene ubo before it can be used in rendering processing
  31792. * @param scene the scene to retrieve the ubo from
  31793. * @returns the scene UniformBuffer
  31794. */
  31795. finalizeSceneUbo(scene: Scene): UniformBuffer;
  31796. /**
  31797. * Binds the scene's uniform buffer to the effect.
  31798. * @param effect defines the effect to bind to the scene uniform buffer
  31799. * @param sceneUbo defines the uniform buffer storing scene data
  31800. */
  31801. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31802. /**
  31803. * Binds the view matrix to the effect
  31804. * @param effect defines the effect to bind the view matrix to
  31805. */
  31806. bindView(effect: Effect): void;
  31807. /**
  31808. * Binds the view projection and projection matrices to the effect
  31809. * @param effect defines the effect to bind the view projection and projection matrices to
  31810. */
  31811. bindViewProjection(effect: Effect): void;
  31812. /**
  31813. * Binds the view matrix to the effect
  31814. * @param effect defines the effect to bind the view matrix to
  31815. * @param variableName name of the shader variable that will hold the eye position
  31816. */
  31817. bindEyePosition(effect: Effect, variableName?: string): void;
  31818. /**
  31819. * Processes to execute after binding the material to a mesh
  31820. * @param mesh defines the rendered mesh
  31821. */
  31822. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31823. /**
  31824. * Unbinds the material from the mesh
  31825. */
  31826. unbind(): void;
  31827. /**
  31828. * Gets the active textures from the material
  31829. * @returns an array of textures
  31830. */
  31831. getActiveTextures(): BaseTexture[];
  31832. /**
  31833. * Specifies if the material uses a texture
  31834. * @param texture defines the texture to check against the material
  31835. * @returns a boolean specifying if the material uses the texture
  31836. */
  31837. hasTexture(texture: BaseTexture): boolean;
  31838. /**
  31839. * Makes a duplicate of the material, and gives it a new name
  31840. * @param name defines the new name for the duplicated material
  31841. * @returns the cloned material
  31842. */
  31843. clone(name: string): Nullable<Material>;
  31844. /**
  31845. * Gets the meshes bound to the material
  31846. * @returns an array of meshes bound to the material
  31847. */
  31848. getBindedMeshes(): AbstractMesh[];
  31849. /**
  31850. * Force shader compilation
  31851. * @param mesh defines the mesh associated with this material
  31852. * @param onCompiled defines a function to execute once the material is compiled
  31853. * @param options defines the options to configure the compilation
  31854. * @param onError defines a function to execute if the material fails compiling
  31855. */
  31856. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31857. /**
  31858. * Force shader compilation
  31859. * @param mesh defines the mesh that will use this material
  31860. * @param options defines additional options for compiling the shaders
  31861. * @returns a promise that resolves when the compilation completes
  31862. */
  31863. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31864. private static readonly _AllDirtyCallBack;
  31865. private static readonly _ImageProcessingDirtyCallBack;
  31866. private static readonly _TextureDirtyCallBack;
  31867. private static readonly _FresnelDirtyCallBack;
  31868. private static readonly _MiscDirtyCallBack;
  31869. private static readonly _PrePassDirtyCallBack;
  31870. private static readonly _LightsDirtyCallBack;
  31871. private static readonly _AttributeDirtyCallBack;
  31872. private static _FresnelAndMiscDirtyCallBack;
  31873. private static _TextureAndMiscDirtyCallBack;
  31874. private static readonly _DirtyCallbackArray;
  31875. private static readonly _RunDirtyCallBacks;
  31876. /**
  31877. * Marks a define in the material to indicate that it needs to be re-computed
  31878. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31879. */
  31880. markAsDirty(flag: number): void;
  31881. /**
  31882. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31883. * @param func defines a function which checks material defines against the submeshes
  31884. */
  31885. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31886. /**
  31887. * Indicates that the scene should check if the rendering now needs a prepass
  31888. */
  31889. protected _markScenePrePassDirty(): void;
  31890. /**
  31891. * Indicates that we need to re-calculated for all submeshes
  31892. */
  31893. protected _markAllSubMeshesAsAllDirty(): void;
  31894. /**
  31895. * Indicates that image processing needs to be re-calculated for all submeshes
  31896. */
  31897. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31898. /**
  31899. * Indicates that textures need to be re-calculated for all submeshes
  31900. */
  31901. protected _markAllSubMeshesAsTexturesDirty(): void;
  31902. /**
  31903. * Indicates that fresnel needs to be re-calculated for all submeshes
  31904. */
  31905. protected _markAllSubMeshesAsFresnelDirty(): void;
  31906. /**
  31907. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31908. */
  31909. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31910. /**
  31911. * Indicates that lights need to be re-calculated for all submeshes
  31912. */
  31913. protected _markAllSubMeshesAsLightsDirty(): void;
  31914. /**
  31915. * Indicates that attributes need to be re-calculated for all submeshes
  31916. */
  31917. protected _markAllSubMeshesAsAttributesDirty(): void;
  31918. /**
  31919. * Indicates that misc needs to be re-calculated for all submeshes
  31920. */
  31921. protected _markAllSubMeshesAsMiscDirty(): void;
  31922. /**
  31923. * Indicates that prepass needs to be re-calculated for all submeshes
  31924. */
  31925. protected _markAllSubMeshesAsPrePassDirty(): void;
  31926. /**
  31927. * Indicates that textures and misc need to be re-calculated for all submeshes
  31928. */
  31929. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31930. /**
  31931. * Sets the required values to the prepass renderer.
  31932. * @param prePassRenderer defines the prepass renderer to setup.
  31933. * @returns true if the pre pass is needed.
  31934. */
  31935. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31936. /**
  31937. * Disposes the material
  31938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31940. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31941. */
  31942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31943. /** @hidden */
  31944. private releaseVertexArrayObject;
  31945. /**
  31946. * Serializes this material
  31947. * @returns the serialized material object
  31948. */
  31949. serialize(): any;
  31950. /**
  31951. * Creates a material from parsed material data
  31952. * @param parsedMaterial defines parsed material data
  31953. * @param scene defines the hosting scene
  31954. * @param rootUrl defines the root URL to use to load textures
  31955. * @returns a new material
  31956. */
  31957. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31958. }
  31959. }
  31960. declare module "babylonjs/Materials/multiMaterial" {
  31961. import { Nullable } from "babylonjs/types";
  31962. import { Scene } from "babylonjs/scene";
  31963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31966. import { Material } from "babylonjs/Materials/material";
  31967. /**
  31968. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31969. * separate meshes. This can be use to improve performances.
  31970. * @see https://doc.babylonjs.com/how_to/multi_materials
  31971. */
  31972. export class MultiMaterial extends Material {
  31973. private _subMaterials;
  31974. /**
  31975. * Gets or Sets the list of Materials used within the multi material.
  31976. * They need to be ordered according to the submeshes order in the associated mesh
  31977. */
  31978. get subMaterials(): Nullable<Material>[];
  31979. set subMaterials(value: Nullable<Material>[]);
  31980. /**
  31981. * Function used to align with Node.getChildren()
  31982. * @returns the list of Materials used within the multi material
  31983. */
  31984. getChildren(): Nullable<Material>[];
  31985. /**
  31986. * Instantiates a new Multi Material
  31987. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31988. * separate meshes. This can be use to improve performances.
  31989. * @see https://doc.babylonjs.com/how_to/multi_materials
  31990. * @param name Define the name in the scene
  31991. * @param scene Define the scene the material belongs to
  31992. */
  31993. constructor(name: string, scene: Scene);
  31994. private _hookArray;
  31995. /**
  31996. * Get one of the submaterial by its index in the submaterials array
  31997. * @param index The index to look the sub material at
  31998. * @returns The Material if the index has been defined
  31999. */
  32000. getSubMaterial(index: number): Nullable<Material>;
  32001. /**
  32002. * Get the list of active textures for the whole sub materials list.
  32003. * @returns All the textures that will be used during the rendering
  32004. */
  32005. getActiveTextures(): BaseTexture[];
  32006. /**
  32007. * Specifies if any sub-materials of this multi-material use a given texture.
  32008. * @param texture Defines the texture to check against this multi-material's sub-materials.
  32009. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  32010. */
  32011. hasTexture(texture: BaseTexture): boolean;
  32012. /**
  32013. * Gets the current class name of the material e.g. "MultiMaterial"
  32014. * Mainly use in serialization.
  32015. * @returns the class name
  32016. */
  32017. getClassName(): string;
  32018. /**
  32019. * Checks if the material is ready to render the requested sub mesh
  32020. * @param mesh Define the mesh the submesh belongs to
  32021. * @param subMesh Define the sub mesh to look readyness for
  32022. * @param useInstances Define whether or not the material is used with instances
  32023. * @returns true if ready, otherwise false
  32024. */
  32025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32026. /**
  32027. * Clones the current material and its related sub materials
  32028. * @param name Define the name of the newly cloned material
  32029. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  32030. * @returns the cloned material
  32031. */
  32032. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  32033. /**
  32034. * Serializes the materials into a JSON representation.
  32035. * @returns the JSON representation
  32036. */
  32037. serialize(): any;
  32038. /**
  32039. * Dispose the material and release its associated resources
  32040. * @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)
  32041. * @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)
  32042. * @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)
  32043. */
  32044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  32045. /**
  32046. * Creates a MultiMaterial from parsed MultiMaterial data.
  32047. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  32048. * @param scene defines the hosting scene
  32049. * @returns a new MultiMaterial
  32050. */
  32051. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  32052. }
  32053. }
  32054. declare module "babylonjs/Meshes/subMesh" {
  32055. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  32056. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32057. import { Engine } from "babylonjs/Engines/engine";
  32058. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  32059. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32060. import { Effect } from "babylonjs/Materials/effect";
  32061. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32062. import { Plane } from "babylonjs/Maths/math.plane";
  32063. import { Collider } from "babylonjs/Collisions/collider";
  32064. import { Material } from "babylonjs/Materials/material";
  32065. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  32066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32067. import { Mesh } from "babylonjs/Meshes/mesh";
  32068. import { Ray } from "babylonjs/Culling/ray";
  32069. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32070. /** @hidden */
  32071. export interface ICustomEffect {
  32072. effect: Effect;
  32073. defines: string;
  32074. }
  32075. /**
  32076. * Defines a subdivision inside a mesh
  32077. */
  32078. export class SubMesh implements ICullable {
  32079. /** the material index to use */
  32080. materialIndex: number;
  32081. /** vertex index start */
  32082. verticesStart: number;
  32083. /** vertices count */
  32084. verticesCount: number;
  32085. /** index start */
  32086. indexStart: number;
  32087. /** indices count */
  32088. indexCount: number;
  32089. /** @hidden */
  32090. _materialDefines: Nullable<MaterialDefines>;
  32091. /** @hidden */
  32092. _materialEffect: Nullable<Effect>;
  32093. /** @hidden */
  32094. _effectOverride: Nullable<Effect>;
  32095. private _customEffects;
  32096. /**
  32097. * Gets material defines used by the effect associated to the sub mesh
  32098. */
  32099. get materialDefines(): Nullable<MaterialDefines>;
  32100. /**
  32101. * Sets material defines used by the effect associated to the sub mesh
  32102. */
  32103. set materialDefines(defines: Nullable<MaterialDefines>);
  32104. /** @hidden */
  32105. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  32106. /** @hidden */
  32107. _removeCustomEffect(name: string): void;
  32108. /**
  32109. * Gets associated effect
  32110. */
  32111. get effect(): Nullable<Effect>;
  32112. /**
  32113. * Sets associated effect (effect used to render this submesh)
  32114. * @param effect defines the effect to associate with
  32115. * @param defines defines the set of defines used to compile this effect
  32116. */
  32117. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  32118. /** @hidden */
  32119. _linesIndexCount: number;
  32120. private _mesh;
  32121. private _renderingMesh;
  32122. private _boundingInfo;
  32123. private _linesIndexBuffer;
  32124. /** @hidden */
  32125. _lastColliderWorldVertices: Nullable<Vector3[]>;
  32126. /** @hidden */
  32127. _trianglePlanes: Plane[];
  32128. /** @hidden */
  32129. _lastColliderTransformMatrix: Nullable<Matrix>;
  32130. /** @hidden */
  32131. _renderId: number;
  32132. /** @hidden */
  32133. _alphaIndex: number;
  32134. /** @hidden */
  32135. _distanceToCamera: number;
  32136. /** @hidden */
  32137. _id: number;
  32138. private _currentMaterial;
  32139. /**
  32140. * Add a new submesh to a mesh
  32141. * @param materialIndex defines the material index to use
  32142. * @param verticesStart defines vertex index start
  32143. * @param verticesCount defines vertices count
  32144. * @param indexStart defines index start
  32145. * @param indexCount defines indices count
  32146. * @param mesh defines the parent mesh
  32147. * @param renderingMesh defines an optional rendering mesh
  32148. * @param createBoundingBox defines if bounding box should be created for this submesh
  32149. * @returns the new submesh
  32150. */
  32151. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  32152. /**
  32153. * Creates a new submesh
  32154. * @param materialIndex defines the material index to use
  32155. * @param verticesStart defines vertex index start
  32156. * @param verticesCount defines vertices count
  32157. * @param indexStart defines index start
  32158. * @param indexCount defines indices count
  32159. * @param mesh defines the parent mesh
  32160. * @param renderingMesh defines an optional rendering mesh
  32161. * @param createBoundingBox defines if bounding box should be created for this submesh
  32162. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  32163. */
  32164. constructor(
  32165. /** the material index to use */
  32166. materialIndex: number,
  32167. /** vertex index start */
  32168. verticesStart: number,
  32169. /** vertices count */
  32170. verticesCount: number,
  32171. /** index start */
  32172. indexStart: number,
  32173. /** indices count */
  32174. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  32175. /**
  32176. * Returns true if this submesh covers the entire parent mesh
  32177. * @ignorenaming
  32178. */
  32179. get IsGlobal(): boolean;
  32180. /**
  32181. * Returns the submesh BoudingInfo object
  32182. * @returns current bounding info (or mesh's one if the submesh is global)
  32183. */
  32184. getBoundingInfo(): BoundingInfo;
  32185. /**
  32186. * Sets the submesh BoundingInfo
  32187. * @param boundingInfo defines the new bounding info to use
  32188. * @returns the SubMesh
  32189. */
  32190. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  32191. /**
  32192. * Returns the mesh of the current submesh
  32193. * @return the parent mesh
  32194. */
  32195. getMesh(): AbstractMesh;
  32196. /**
  32197. * Returns the rendering mesh of the submesh
  32198. * @returns the rendering mesh (could be different from parent mesh)
  32199. */
  32200. getRenderingMesh(): Mesh;
  32201. /**
  32202. * Returns the replacement mesh of the submesh
  32203. * @returns the replacement mesh (could be different from parent mesh)
  32204. */
  32205. getReplacementMesh(): Nullable<AbstractMesh>;
  32206. /**
  32207. * Returns the effective mesh of the submesh
  32208. * @returns the effective mesh (could be different from parent mesh)
  32209. */
  32210. getEffectiveMesh(): AbstractMesh;
  32211. /**
  32212. * Returns the submesh material
  32213. * @returns null or the current material
  32214. */
  32215. getMaterial(): Nullable<Material>;
  32216. private _IsMultiMaterial;
  32217. /**
  32218. * Sets a new updated BoundingInfo object to the submesh
  32219. * @param data defines an optional position array to use to determine the bounding info
  32220. * @returns the SubMesh
  32221. */
  32222. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  32223. /** @hidden */
  32224. _checkCollision(collider: Collider): boolean;
  32225. /**
  32226. * Updates the submesh BoundingInfo
  32227. * @param world defines the world matrix to use to update the bounding info
  32228. * @returns the submesh
  32229. */
  32230. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  32231. /**
  32232. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  32233. * @param frustumPlanes defines the frustum planes
  32234. * @returns true if the submesh is intersecting with the frustum
  32235. */
  32236. isInFrustum(frustumPlanes: Plane[]): boolean;
  32237. /**
  32238. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  32239. * @param frustumPlanes defines the frustum planes
  32240. * @returns true if the submesh is inside the frustum
  32241. */
  32242. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32243. /**
  32244. * Renders the submesh
  32245. * @param enableAlphaMode defines if alpha needs to be used
  32246. * @returns the submesh
  32247. */
  32248. render(enableAlphaMode: boolean): SubMesh;
  32249. /**
  32250. * @hidden
  32251. */
  32252. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  32253. /**
  32254. * Checks if the submesh intersects with a ray
  32255. * @param ray defines the ray to test
  32256. * @returns true is the passed ray intersects the submesh bounding box
  32257. */
  32258. canIntersects(ray: Ray): boolean;
  32259. /**
  32260. * Intersects current submesh with a ray
  32261. * @param ray defines the ray to test
  32262. * @param positions defines mesh's positions array
  32263. * @param indices defines mesh's indices array
  32264. * @param fastCheck defines if the first intersection will be used (and not the closest)
  32265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32266. * @returns intersection info or null if no intersection
  32267. */
  32268. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  32269. /** @hidden */
  32270. private _intersectLines;
  32271. /** @hidden */
  32272. private _intersectUnIndexedLines;
  32273. /** @hidden */
  32274. private _intersectTriangles;
  32275. /** @hidden */
  32276. private _intersectUnIndexedTriangles;
  32277. /** @hidden */
  32278. _rebuild(): void;
  32279. /**
  32280. * Creates a new submesh from the passed mesh
  32281. * @param newMesh defines the new hosting mesh
  32282. * @param newRenderingMesh defines an optional rendering mesh
  32283. * @returns the new submesh
  32284. */
  32285. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  32286. /**
  32287. * Release associated resources
  32288. */
  32289. dispose(): void;
  32290. /**
  32291. * Gets the class name
  32292. * @returns the string "SubMesh".
  32293. */
  32294. getClassName(): string;
  32295. /**
  32296. * Creates a new submesh from indices data
  32297. * @param materialIndex the index of the main mesh material
  32298. * @param startIndex the index where to start the copy in the mesh indices array
  32299. * @param indexCount the number of indices to copy then from the startIndex
  32300. * @param mesh the main mesh to create the submesh from
  32301. * @param renderingMesh the optional rendering mesh
  32302. * @returns a new submesh
  32303. */
  32304. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  32305. }
  32306. }
  32307. declare module "babylonjs/Loading/sceneLoaderFlags" {
  32308. /**
  32309. * Class used to represent data loading progression
  32310. */
  32311. export class SceneLoaderFlags {
  32312. private static _ForceFullSceneLoadingForIncremental;
  32313. private static _ShowLoadingScreen;
  32314. private static _CleanBoneMatrixWeights;
  32315. private static _loggingLevel;
  32316. /**
  32317. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  32318. */
  32319. static get ForceFullSceneLoadingForIncremental(): boolean;
  32320. static set ForceFullSceneLoadingForIncremental(value: boolean);
  32321. /**
  32322. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  32323. */
  32324. static get ShowLoadingScreen(): boolean;
  32325. static set ShowLoadingScreen(value: boolean);
  32326. /**
  32327. * Defines the current logging level (while loading the scene)
  32328. * @ignorenaming
  32329. */
  32330. static get loggingLevel(): number;
  32331. static set loggingLevel(value: number);
  32332. /**
  32333. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  32334. */
  32335. static get CleanBoneMatrixWeights(): boolean;
  32336. static set CleanBoneMatrixWeights(value: boolean);
  32337. }
  32338. }
  32339. declare module "babylonjs/Meshes/geometry" {
  32340. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  32341. import { Scene } from "babylonjs/scene";
  32342. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32343. import { Engine } from "babylonjs/Engines/engine";
  32344. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  32345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32346. import { Effect } from "babylonjs/Materials/effect";
  32347. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32348. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32349. import { Mesh } from "babylonjs/Meshes/mesh";
  32350. /**
  32351. * Class used to store geometry data (vertex buffers + index buffer)
  32352. */
  32353. export class Geometry implements IGetSetVerticesData {
  32354. /**
  32355. * Gets or sets the ID of the geometry
  32356. */
  32357. id: string;
  32358. /**
  32359. * Gets or sets the unique ID of the geometry
  32360. */
  32361. uniqueId: number;
  32362. /**
  32363. * Gets the delay loading state of the geometry (none by default which means not delayed)
  32364. */
  32365. delayLoadState: number;
  32366. /**
  32367. * Gets the file containing the data to load when running in delay load state
  32368. */
  32369. delayLoadingFile: Nullable<string>;
  32370. /**
  32371. * Callback called when the geometry is updated
  32372. */
  32373. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  32374. private _scene;
  32375. private _engine;
  32376. private _meshes;
  32377. private _totalVertices;
  32378. /** @hidden */
  32379. _indices: IndicesArray;
  32380. /** @hidden */
  32381. _vertexBuffers: {
  32382. [key: string]: VertexBuffer;
  32383. };
  32384. private _isDisposed;
  32385. private _extend;
  32386. private _boundingBias;
  32387. /** @hidden */
  32388. _delayInfo: Array<string>;
  32389. private _indexBuffer;
  32390. private _indexBufferIsUpdatable;
  32391. /** @hidden */
  32392. _boundingInfo: Nullable<BoundingInfo>;
  32393. /** @hidden */
  32394. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  32395. /** @hidden */
  32396. _softwareSkinningFrameId: number;
  32397. private _vertexArrayObjects;
  32398. private _updatable;
  32399. /** @hidden */
  32400. _positions: Nullable<Vector3[]>;
  32401. private _positionsCache;
  32402. /**
  32403. * 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
  32404. */
  32405. get boundingBias(): Vector2;
  32406. /**
  32407. * 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
  32408. */
  32409. set boundingBias(value: Vector2);
  32410. /**
  32411. * Static function used to attach a new empty geometry to a mesh
  32412. * @param mesh defines the mesh to attach the geometry to
  32413. * @returns the new Geometry
  32414. */
  32415. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  32416. /** Get the list of meshes using this geometry */
  32417. get meshes(): Mesh[];
  32418. /**
  32419. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  32420. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  32421. */
  32422. useBoundingInfoFromGeometry: boolean;
  32423. /**
  32424. * Creates a new geometry
  32425. * @param id defines the unique ID
  32426. * @param scene defines the hosting scene
  32427. * @param vertexData defines the VertexData used to get geometry data
  32428. * @param updatable defines if geometry must be updatable (false by default)
  32429. * @param mesh defines the mesh that will be associated with the geometry
  32430. */
  32431. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  32432. /**
  32433. * Gets the current extend of the geometry
  32434. */
  32435. get extend(): {
  32436. minimum: Vector3;
  32437. maximum: Vector3;
  32438. };
  32439. /**
  32440. * Gets the hosting scene
  32441. * @returns the hosting Scene
  32442. */
  32443. getScene(): Scene;
  32444. /**
  32445. * Gets the hosting engine
  32446. * @returns the hosting Engine
  32447. */
  32448. getEngine(): Engine;
  32449. /**
  32450. * Defines if the geometry is ready to use
  32451. * @returns true if the geometry is ready to be used
  32452. */
  32453. isReady(): boolean;
  32454. /**
  32455. * Gets a value indicating that the geometry should not be serialized
  32456. */
  32457. get doNotSerialize(): boolean;
  32458. /** @hidden */
  32459. _rebuild(): void;
  32460. /**
  32461. * Affects all geometry data in one call
  32462. * @param vertexData defines the geometry data
  32463. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  32464. */
  32465. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  32466. /**
  32467. * Set specific vertex data
  32468. * @param kind defines the data kind (Position, normal, etc...)
  32469. * @param data defines the vertex data to use
  32470. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  32471. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  32472. */
  32473. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  32474. /**
  32475. * Removes a specific vertex data
  32476. * @param kind defines the data kind (Position, normal, etc...)
  32477. */
  32478. removeVerticesData(kind: string): void;
  32479. /**
  32480. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  32481. * @param buffer defines the vertex buffer to use
  32482. * @param totalVertices defines the total number of vertices for position kind (could be null)
  32483. */
  32484. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  32485. /**
  32486. * Update a specific vertex buffer
  32487. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  32488. * It will do nothing if the buffer is not updatable
  32489. * @param kind defines the data kind (Position, normal, etc...)
  32490. * @param data defines the data to use
  32491. * @param offset defines the offset in the target buffer where to store the data
  32492. * @param useBytes set to true if the offset is in bytes
  32493. */
  32494. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  32495. /**
  32496. * Update a specific vertex buffer
  32497. * This function will create a new buffer if the current one is not updatable
  32498. * @param kind defines the data kind (Position, normal, etc...)
  32499. * @param data defines the data to use
  32500. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  32501. */
  32502. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  32503. private _updateBoundingInfo;
  32504. /** @hidden */
  32505. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  32506. /**
  32507. * Gets total number of vertices
  32508. * @returns the total number of vertices
  32509. */
  32510. getTotalVertices(): number;
  32511. /**
  32512. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  32513. * @param kind defines the data kind (Position, normal, etc...)
  32514. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32515. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32516. * @returns a float array containing vertex data
  32517. */
  32518. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32519. /**
  32520. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  32521. * @param kind defines the data kind (Position, normal, etc...)
  32522. * @returns true if the vertex buffer with the specified kind is updatable
  32523. */
  32524. isVertexBufferUpdatable(kind: string): boolean;
  32525. /**
  32526. * Gets a specific vertex buffer
  32527. * @param kind defines the data kind (Position, normal, etc...)
  32528. * @returns a VertexBuffer
  32529. */
  32530. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32531. /**
  32532. * Returns all vertex buffers
  32533. * @return an object holding all vertex buffers indexed by kind
  32534. */
  32535. getVertexBuffers(): Nullable<{
  32536. [key: string]: VertexBuffer;
  32537. }>;
  32538. /**
  32539. * Gets a boolean indicating if specific vertex buffer is present
  32540. * @param kind defines the data kind (Position, normal, etc...)
  32541. * @returns true if data is present
  32542. */
  32543. isVerticesDataPresent(kind: string): boolean;
  32544. /**
  32545. * Gets a list of all attached data kinds (Position, normal, etc...)
  32546. * @returns a list of string containing all kinds
  32547. */
  32548. getVerticesDataKinds(): string[];
  32549. /**
  32550. * Update index buffer
  32551. * @param indices defines the indices to store in the index buffer
  32552. * @param offset defines the offset in the target buffer where to store the data
  32553. * @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)
  32554. */
  32555. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  32556. /**
  32557. * Creates a new index buffer
  32558. * @param indices defines the indices to store in the index buffer
  32559. * @param totalVertices defines the total number of vertices (could be null)
  32560. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  32561. */
  32562. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  32563. /**
  32564. * Return the total number of indices
  32565. * @returns the total number of indices
  32566. */
  32567. getTotalIndices(): number;
  32568. /**
  32569. * Gets the index buffer array
  32570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32572. * @returns the index buffer array
  32573. */
  32574. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32575. /**
  32576. * Gets the index buffer
  32577. * @return the index buffer
  32578. */
  32579. getIndexBuffer(): Nullable<DataBuffer>;
  32580. /** @hidden */
  32581. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  32582. /**
  32583. * Release the associated resources for a specific mesh
  32584. * @param mesh defines the source mesh
  32585. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  32586. */
  32587. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  32588. /**
  32589. * Apply current geometry to a given mesh
  32590. * @param mesh defines the mesh to apply geometry to
  32591. */
  32592. applyToMesh(mesh: Mesh): void;
  32593. private _updateExtend;
  32594. private _applyToMesh;
  32595. private notifyUpdate;
  32596. /**
  32597. * Load the geometry if it was flagged as delay loaded
  32598. * @param scene defines the hosting scene
  32599. * @param onLoaded defines a callback called when the geometry is loaded
  32600. */
  32601. load(scene: Scene, onLoaded?: () => void): void;
  32602. private _queueLoad;
  32603. /**
  32604. * Invert the geometry to move from a right handed system to a left handed one.
  32605. */
  32606. toLeftHanded(): void;
  32607. /** @hidden */
  32608. _resetPointsArrayCache(): void;
  32609. /** @hidden */
  32610. _generatePointsArray(): boolean;
  32611. /**
  32612. * Gets a value indicating if the geometry is disposed
  32613. * @returns true if the geometry was disposed
  32614. */
  32615. isDisposed(): boolean;
  32616. private _disposeVertexArrayObjects;
  32617. /**
  32618. * Free all associated resources
  32619. */
  32620. dispose(): void;
  32621. /**
  32622. * Clone the current geometry into a new geometry
  32623. * @param id defines the unique ID of the new geometry
  32624. * @returns a new geometry object
  32625. */
  32626. copy(id: string): Geometry;
  32627. /**
  32628. * Serialize the current geometry info (and not the vertices data) into a JSON object
  32629. * @return a JSON representation of the current geometry data (without the vertices data)
  32630. */
  32631. serialize(): any;
  32632. private toNumberArray;
  32633. /**
  32634. * Serialize all vertices data into a JSON oject
  32635. * @returns a JSON representation of the current geometry data
  32636. */
  32637. serializeVerticeData(): any;
  32638. /**
  32639. * Extracts a clone of a mesh geometry
  32640. * @param mesh defines the source mesh
  32641. * @param id defines the unique ID of the new geometry object
  32642. * @returns the new geometry object
  32643. */
  32644. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  32645. /**
  32646. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  32647. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32648. * Be aware Math.random() could cause collisions, but:
  32649. * "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"
  32650. * @returns a string containing a new GUID
  32651. */
  32652. static RandomId(): string;
  32653. /** @hidden */
  32654. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  32655. private static _CleanMatricesWeights;
  32656. /**
  32657. * Create a new geometry from persisted data (Using .babylon file format)
  32658. * @param parsedVertexData defines the persisted data
  32659. * @param scene defines the hosting scene
  32660. * @param rootUrl defines the root url to use to load assets (like delayed data)
  32661. * @returns the new geometry object
  32662. */
  32663. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  32664. }
  32665. }
  32666. declare module "babylonjs/Morph/morphTarget" {
  32667. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32668. import { Observable } from "babylonjs/Misc/observable";
  32669. import { Nullable, FloatArray } from "babylonjs/types";
  32670. import { Scene } from "babylonjs/scene";
  32671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32672. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32673. /**
  32674. * Defines a target to use with MorphTargetManager
  32675. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32676. */
  32677. export class MorphTarget implements IAnimatable {
  32678. /** defines the name of the target */
  32679. name: string;
  32680. /**
  32681. * Gets or sets the list of animations
  32682. */
  32683. animations: import("babylonjs/Animations/animation").Animation[];
  32684. private _scene;
  32685. private _positions;
  32686. private _normals;
  32687. private _tangents;
  32688. private _uvs;
  32689. private _influence;
  32690. private _uniqueId;
  32691. /**
  32692. * Observable raised when the influence changes
  32693. */
  32694. onInfluenceChanged: Observable<boolean>;
  32695. /** @hidden */
  32696. _onDataLayoutChanged: Observable<void>;
  32697. /**
  32698. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32699. */
  32700. get influence(): number;
  32701. set influence(influence: number);
  32702. /**
  32703. * Gets or sets the id of the morph Target
  32704. */
  32705. id: string;
  32706. private _animationPropertiesOverride;
  32707. /**
  32708. * Gets or sets the animation properties override
  32709. */
  32710. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32711. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32712. /**
  32713. * Creates a new MorphTarget
  32714. * @param name defines the name of the target
  32715. * @param influence defines the influence to use
  32716. * @param scene defines the scene the morphtarget belongs to
  32717. */
  32718. constructor(
  32719. /** defines the name of the target */
  32720. name: string, influence?: number, scene?: Nullable<Scene>);
  32721. /**
  32722. * Gets the unique ID of this manager
  32723. */
  32724. get uniqueId(): number;
  32725. /**
  32726. * Gets a boolean defining if the target contains position data
  32727. */
  32728. get hasPositions(): boolean;
  32729. /**
  32730. * Gets a boolean defining if the target contains normal data
  32731. */
  32732. get hasNormals(): boolean;
  32733. /**
  32734. * Gets a boolean defining if the target contains tangent data
  32735. */
  32736. get hasTangents(): boolean;
  32737. /**
  32738. * Gets a boolean defining if the target contains texture coordinates data
  32739. */
  32740. get hasUVs(): boolean;
  32741. /**
  32742. * Affects position data to this target
  32743. * @param data defines the position data to use
  32744. */
  32745. setPositions(data: Nullable<FloatArray>): void;
  32746. /**
  32747. * Gets the position data stored in this target
  32748. * @returns a FloatArray containing the position data (or null if not present)
  32749. */
  32750. getPositions(): Nullable<FloatArray>;
  32751. /**
  32752. * Affects normal data to this target
  32753. * @param data defines the normal data to use
  32754. */
  32755. setNormals(data: Nullable<FloatArray>): void;
  32756. /**
  32757. * Gets the normal data stored in this target
  32758. * @returns a FloatArray containing the normal data (or null if not present)
  32759. */
  32760. getNormals(): Nullable<FloatArray>;
  32761. /**
  32762. * Affects tangent data to this target
  32763. * @param data defines the tangent data to use
  32764. */
  32765. setTangents(data: Nullable<FloatArray>): void;
  32766. /**
  32767. * Gets the tangent data stored in this target
  32768. * @returns a FloatArray containing the tangent data (or null if not present)
  32769. */
  32770. getTangents(): Nullable<FloatArray>;
  32771. /**
  32772. * Affects texture coordinates data to this target
  32773. * @param data defines the texture coordinates data to use
  32774. */
  32775. setUVs(data: Nullable<FloatArray>): void;
  32776. /**
  32777. * Gets the texture coordinates data stored in this target
  32778. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32779. */
  32780. getUVs(): Nullable<FloatArray>;
  32781. /**
  32782. * Clone the current target
  32783. * @returns a new MorphTarget
  32784. */
  32785. clone(): MorphTarget;
  32786. /**
  32787. * Serializes the current target into a Serialization object
  32788. * @returns the serialized object
  32789. */
  32790. serialize(): any;
  32791. /**
  32792. * Returns the string "MorphTarget"
  32793. * @returns "MorphTarget"
  32794. */
  32795. getClassName(): string;
  32796. /**
  32797. * Creates a new target from serialized data
  32798. * @param serializationObject defines the serialized data to use
  32799. * @returns a new MorphTarget
  32800. */
  32801. static Parse(serializationObject: any): MorphTarget;
  32802. /**
  32803. * Creates a MorphTarget from mesh data
  32804. * @param mesh defines the source mesh
  32805. * @param name defines the name to use for the new target
  32806. * @param influence defines the influence to attach to the target
  32807. * @returns a new MorphTarget
  32808. */
  32809. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32810. }
  32811. }
  32812. declare module "babylonjs/Morph/morphTargetManager" {
  32813. import { Nullable } from "babylonjs/types";
  32814. import { Scene } from "babylonjs/scene";
  32815. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32816. /**
  32817. * This class is used to deform meshes using morphing between different targets
  32818. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32819. */
  32820. export class MorphTargetManager {
  32821. private _targets;
  32822. private _targetInfluenceChangedObservers;
  32823. private _targetDataLayoutChangedObservers;
  32824. private _activeTargets;
  32825. private _scene;
  32826. private _influences;
  32827. private _supportsNormals;
  32828. private _supportsTangents;
  32829. private _supportsUVs;
  32830. private _vertexCount;
  32831. private _uniqueId;
  32832. private _tempInfluences;
  32833. /**
  32834. * Gets or sets a boolean indicating if normals must be morphed
  32835. */
  32836. enableNormalMorphing: boolean;
  32837. /**
  32838. * Gets or sets a boolean indicating if tangents must be morphed
  32839. */
  32840. enableTangentMorphing: boolean;
  32841. /**
  32842. * Gets or sets a boolean indicating if UV must be morphed
  32843. */
  32844. enableUVMorphing: boolean;
  32845. /**
  32846. * Creates a new MorphTargetManager
  32847. * @param scene defines the current scene
  32848. */
  32849. constructor(scene?: Nullable<Scene>);
  32850. /**
  32851. * Gets the unique ID of this manager
  32852. */
  32853. get uniqueId(): number;
  32854. /**
  32855. * Gets the number of vertices handled by this manager
  32856. */
  32857. get vertexCount(): number;
  32858. /**
  32859. * Gets a boolean indicating if this manager supports morphing of normals
  32860. */
  32861. get supportsNormals(): boolean;
  32862. /**
  32863. * Gets a boolean indicating if this manager supports morphing of tangents
  32864. */
  32865. get supportsTangents(): boolean;
  32866. /**
  32867. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32868. */
  32869. get supportsUVs(): boolean;
  32870. /**
  32871. * Gets the number of targets stored in this manager
  32872. */
  32873. get numTargets(): number;
  32874. /**
  32875. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32876. */
  32877. get numInfluencers(): number;
  32878. /**
  32879. * Gets the list of influences (one per target)
  32880. */
  32881. get influences(): Float32Array;
  32882. /**
  32883. * Gets the active target at specified index. An active target is a target with an influence > 0
  32884. * @param index defines the index to check
  32885. * @returns the requested target
  32886. */
  32887. getActiveTarget(index: number): MorphTarget;
  32888. /**
  32889. * Gets the target at specified index
  32890. * @param index defines the index to check
  32891. * @returns the requested target
  32892. */
  32893. getTarget(index: number): MorphTarget;
  32894. /**
  32895. * Add a new target to this manager
  32896. * @param target defines the target to add
  32897. */
  32898. addTarget(target: MorphTarget): void;
  32899. /**
  32900. * Removes a target from the manager
  32901. * @param target defines the target to remove
  32902. */
  32903. removeTarget(target: MorphTarget): void;
  32904. /**
  32905. * Clone the current manager
  32906. * @returns a new MorphTargetManager
  32907. */
  32908. clone(): MorphTargetManager;
  32909. /**
  32910. * Serializes the current manager into a Serialization object
  32911. * @returns the serialized object
  32912. */
  32913. serialize(): any;
  32914. private _syncActiveTargets;
  32915. /**
  32916. * Syncrhonize the targets with all the meshes using this morph target manager
  32917. */
  32918. synchronize(): void;
  32919. /**
  32920. * Creates a new MorphTargetManager from serialized data
  32921. * @param serializationObject defines the serialized data
  32922. * @param scene defines the hosting scene
  32923. * @returns the new MorphTargetManager
  32924. */
  32925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32926. }
  32927. }
  32928. declare module "babylonjs/Meshes/meshLODLevel" {
  32929. import { Mesh } from "babylonjs/Meshes/mesh";
  32930. import { Nullable } from "babylonjs/types";
  32931. /**
  32932. * Class used to represent a specific level of detail of a mesh
  32933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32934. */
  32935. export class MeshLODLevel {
  32936. /** Defines the distance where this level should start being displayed */
  32937. distance: number;
  32938. /** Defines the mesh to use to render this level */
  32939. mesh: Nullable<Mesh>;
  32940. /**
  32941. * Creates a new LOD level
  32942. * @param distance defines the distance where this level should star being displayed
  32943. * @param mesh defines the mesh to use to render this level
  32944. */
  32945. constructor(
  32946. /** Defines the distance where this level should start being displayed */
  32947. distance: number,
  32948. /** Defines the mesh to use to render this level */
  32949. mesh: Nullable<Mesh>);
  32950. }
  32951. }
  32952. declare module "babylonjs/Misc/canvasGenerator" {
  32953. /**
  32954. * Helper class used to generate a canvas to manipulate images
  32955. */
  32956. export class CanvasGenerator {
  32957. /**
  32958. * Create a new canvas (or offscreen canvas depending on the context)
  32959. * @param width defines the expected width
  32960. * @param height defines the expected height
  32961. * @return a new canvas or offscreen canvas
  32962. */
  32963. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32964. }
  32965. }
  32966. declare module "babylonjs/Meshes/groundMesh" {
  32967. import { Scene } from "babylonjs/scene";
  32968. import { Vector3 } from "babylonjs/Maths/math.vector";
  32969. import { Mesh } from "babylonjs/Meshes/mesh";
  32970. /**
  32971. * Mesh representing the gorund
  32972. */
  32973. export class GroundMesh extends Mesh {
  32974. /** If octree should be generated */
  32975. generateOctree: boolean;
  32976. private _heightQuads;
  32977. /** @hidden */
  32978. _subdivisionsX: number;
  32979. /** @hidden */
  32980. _subdivisionsY: number;
  32981. /** @hidden */
  32982. _width: number;
  32983. /** @hidden */
  32984. _height: number;
  32985. /** @hidden */
  32986. _minX: number;
  32987. /** @hidden */
  32988. _maxX: number;
  32989. /** @hidden */
  32990. _minZ: number;
  32991. /** @hidden */
  32992. _maxZ: number;
  32993. constructor(name: string, scene: Scene);
  32994. /**
  32995. * "GroundMesh"
  32996. * @returns "GroundMesh"
  32997. */
  32998. getClassName(): string;
  32999. /**
  33000. * The minimum of x and y subdivisions
  33001. */
  33002. get subdivisions(): number;
  33003. /**
  33004. * X subdivisions
  33005. */
  33006. get subdivisionsX(): number;
  33007. /**
  33008. * Y subdivisions
  33009. */
  33010. get subdivisionsY(): number;
  33011. /**
  33012. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  33013. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  33014. * @param chunksCount the number of subdivisions for x and y
  33015. * @param octreeBlocksSize (Default: 32)
  33016. */
  33017. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  33018. /**
  33019. * Returns a height (y) value in the Worl system :
  33020. * the ground altitude at the coordinates (x, z) expressed in the World system.
  33021. * @param x x coordinate
  33022. * @param z z coordinate
  33023. * @returns the ground y position if (x, z) are outside the ground surface.
  33024. */
  33025. getHeightAtCoordinates(x: number, z: number): number;
  33026. /**
  33027. * Returns a normalized vector (Vector3) orthogonal to the ground
  33028. * at the ground coordinates (x, z) expressed in the World system.
  33029. * @param x x coordinate
  33030. * @param z z coordinate
  33031. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  33032. */
  33033. getNormalAtCoordinates(x: number, z: number): Vector3;
  33034. /**
  33035. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  33036. * at the ground coordinates (x, z) expressed in the World system.
  33037. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  33038. * @param x x coordinate
  33039. * @param z z coordinate
  33040. * @param ref vector to store the result
  33041. * @returns the GroundMesh.
  33042. */
  33043. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  33044. /**
  33045. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  33046. * if the ground has been updated.
  33047. * This can be used in the render loop.
  33048. * @returns the GroundMesh.
  33049. */
  33050. updateCoordinateHeights(): GroundMesh;
  33051. private _getFacetAt;
  33052. private _initHeightQuads;
  33053. private _computeHeightQuads;
  33054. /**
  33055. * Serializes this ground mesh
  33056. * @param serializationObject object to write serialization to
  33057. */
  33058. serialize(serializationObject: any): void;
  33059. /**
  33060. * Parses a serialized ground mesh
  33061. * @param parsedMesh the serialized mesh
  33062. * @param scene the scene to create the ground mesh in
  33063. * @returns the created ground mesh
  33064. */
  33065. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  33066. }
  33067. }
  33068. declare module "babylonjs/Physics/physicsJoint" {
  33069. import { Vector3 } from "babylonjs/Maths/math.vector";
  33070. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  33071. /**
  33072. * Interface for Physics-Joint data
  33073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33074. */
  33075. export interface PhysicsJointData {
  33076. /**
  33077. * The main pivot of the joint
  33078. */
  33079. mainPivot?: Vector3;
  33080. /**
  33081. * The connected pivot of the joint
  33082. */
  33083. connectedPivot?: Vector3;
  33084. /**
  33085. * The main axis of the joint
  33086. */
  33087. mainAxis?: Vector3;
  33088. /**
  33089. * The connected axis of the joint
  33090. */
  33091. connectedAxis?: Vector3;
  33092. /**
  33093. * The collision of the joint
  33094. */
  33095. collision?: boolean;
  33096. /**
  33097. * Native Oimo/Cannon/Energy data
  33098. */
  33099. nativeParams?: any;
  33100. }
  33101. /**
  33102. * This is a holder class for the physics joint created by the physics plugin
  33103. * It holds a set of functions to control the underlying joint
  33104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33105. */
  33106. export class PhysicsJoint {
  33107. /**
  33108. * The type of the physics joint
  33109. */
  33110. type: number;
  33111. /**
  33112. * The data for the physics joint
  33113. */
  33114. jointData: PhysicsJointData;
  33115. private _physicsJoint;
  33116. protected _physicsPlugin: IPhysicsEnginePlugin;
  33117. /**
  33118. * Initializes the physics joint
  33119. * @param type The type of the physics joint
  33120. * @param jointData The data for the physics joint
  33121. */
  33122. constructor(
  33123. /**
  33124. * The type of the physics joint
  33125. */
  33126. type: number,
  33127. /**
  33128. * The data for the physics joint
  33129. */
  33130. jointData: PhysicsJointData);
  33131. /**
  33132. * Gets the physics joint
  33133. */
  33134. get physicsJoint(): any;
  33135. /**
  33136. * Sets the physics joint
  33137. */
  33138. set physicsJoint(newJoint: any);
  33139. /**
  33140. * Sets the physics plugin
  33141. */
  33142. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  33143. /**
  33144. * Execute a function that is physics-plugin specific.
  33145. * @param {Function} func the function that will be executed.
  33146. * It accepts two parameters: the physics world and the physics joint
  33147. */
  33148. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33149. /**
  33150. * Distance-Joint type
  33151. */
  33152. static DistanceJoint: number;
  33153. /**
  33154. * Hinge-Joint type
  33155. */
  33156. static HingeJoint: number;
  33157. /**
  33158. * Ball-and-Socket joint type
  33159. */
  33160. static BallAndSocketJoint: number;
  33161. /**
  33162. * Wheel-Joint type
  33163. */
  33164. static WheelJoint: number;
  33165. /**
  33166. * Slider-Joint type
  33167. */
  33168. static SliderJoint: number;
  33169. /**
  33170. * Prismatic-Joint type
  33171. */
  33172. static PrismaticJoint: number;
  33173. /**
  33174. * Universal-Joint type
  33175. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33176. */
  33177. static UniversalJoint: number;
  33178. /**
  33179. * Hinge-Joint 2 type
  33180. */
  33181. static Hinge2Joint: number;
  33182. /**
  33183. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33184. */
  33185. static PointToPointJoint: number;
  33186. /**
  33187. * Spring-Joint type
  33188. */
  33189. static SpringJoint: number;
  33190. /**
  33191. * Lock-Joint type
  33192. */
  33193. static LockJoint: number;
  33194. }
  33195. /**
  33196. * A class representing a physics distance joint
  33197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33198. */
  33199. export class DistanceJoint extends PhysicsJoint {
  33200. /**
  33201. *
  33202. * @param jointData The data for the Distance-Joint
  33203. */
  33204. constructor(jointData: DistanceJointData);
  33205. /**
  33206. * Update the predefined distance.
  33207. * @param maxDistance The maximum preferred distance
  33208. * @param minDistance The minimum preferred distance
  33209. */
  33210. updateDistance(maxDistance: number, minDistance?: number): void;
  33211. }
  33212. /**
  33213. * Represents a Motor-Enabled Joint
  33214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33215. */
  33216. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33217. /**
  33218. * Initializes the Motor-Enabled Joint
  33219. * @param type The type of the joint
  33220. * @param jointData The physica joint data for the joint
  33221. */
  33222. constructor(type: number, jointData: PhysicsJointData);
  33223. /**
  33224. * Set the motor values.
  33225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33226. * @param force the force to apply
  33227. * @param maxForce max force for this motor.
  33228. */
  33229. setMotor(force?: number, maxForce?: number): void;
  33230. /**
  33231. * Set the motor's limits.
  33232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33233. * @param upperLimit The upper limit of the motor
  33234. * @param lowerLimit The lower limit of the motor
  33235. */
  33236. setLimit(upperLimit: number, lowerLimit?: number): void;
  33237. }
  33238. /**
  33239. * This class represents a single physics Hinge-Joint
  33240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33241. */
  33242. export class HingeJoint extends MotorEnabledJoint {
  33243. /**
  33244. * Initializes the Hinge-Joint
  33245. * @param jointData The joint data for the Hinge-Joint
  33246. */
  33247. constructor(jointData: PhysicsJointData);
  33248. /**
  33249. * Set the motor values.
  33250. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33251. * @param {number} force the force to apply
  33252. * @param {number} maxForce max force for this motor.
  33253. */
  33254. setMotor(force?: number, maxForce?: number): void;
  33255. /**
  33256. * Set the motor's limits.
  33257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33258. * @param upperLimit The upper limit of the motor
  33259. * @param lowerLimit The lower limit of the motor
  33260. */
  33261. setLimit(upperLimit: number, lowerLimit?: number): void;
  33262. }
  33263. /**
  33264. * This class represents a dual hinge physics joint (same as wheel joint)
  33265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33266. */
  33267. export class Hinge2Joint extends MotorEnabledJoint {
  33268. /**
  33269. * Initializes the Hinge2-Joint
  33270. * @param jointData The joint data for the Hinge2-Joint
  33271. */
  33272. constructor(jointData: PhysicsJointData);
  33273. /**
  33274. * Set the motor values.
  33275. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33276. * @param {number} targetSpeed the speed the motor is to reach
  33277. * @param {number} maxForce max force for this motor.
  33278. * @param {motorIndex} the motor's index, 0 or 1.
  33279. */
  33280. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  33281. /**
  33282. * Set the motor limits.
  33283. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33284. * @param {number} upperLimit the upper limit
  33285. * @param {number} lowerLimit lower limit
  33286. * @param {motorIndex} the motor's index, 0 or 1.
  33287. */
  33288. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33289. }
  33290. /**
  33291. * Interface for a motor enabled joint
  33292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33293. */
  33294. export interface IMotorEnabledJoint {
  33295. /**
  33296. * Physics joint
  33297. */
  33298. physicsJoint: any;
  33299. /**
  33300. * Sets the motor of the motor-enabled joint
  33301. * @param force The force of the motor
  33302. * @param maxForce The maximum force of the motor
  33303. * @param motorIndex The index of the motor
  33304. */
  33305. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33306. /**
  33307. * Sets the limit of the motor
  33308. * @param upperLimit The upper limit of the motor
  33309. * @param lowerLimit The lower limit of the motor
  33310. * @param motorIndex The index of the motor
  33311. */
  33312. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33313. }
  33314. /**
  33315. * Joint data for a Distance-Joint
  33316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33317. */
  33318. export interface DistanceJointData extends PhysicsJointData {
  33319. /**
  33320. * Max distance the 2 joint objects can be apart
  33321. */
  33322. maxDistance: number;
  33323. }
  33324. /**
  33325. * Joint data from a spring joint
  33326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33327. */
  33328. export interface SpringJointData extends PhysicsJointData {
  33329. /**
  33330. * Length of the spring
  33331. */
  33332. length: number;
  33333. /**
  33334. * Stiffness of the spring
  33335. */
  33336. stiffness: number;
  33337. /**
  33338. * Damping of the spring
  33339. */
  33340. damping: number;
  33341. /** this callback will be called when applying the force to the impostors. */
  33342. forceApplicationCallback: () => void;
  33343. }
  33344. }
  33345. declare module "babylonjs/Physics/physicsRaycastResult" {
  33346. import { Vector3 } from "babylonjs/Maths/math.vector";
  33347. /**
  33348. * Holds the data for the raycast result
  33349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33350. */
  33351. export class PhysicsRaycastResult {
  33352. private _hasHit;
  33353. private _hitDistance;
  33354. private _hitNormalWorld;
  33355. private _hitPointWorld;
  33356. private _rayFromWorld;
  33357. private _rayToWorld;
  33358. /**
  33359. * Gets if there was a hit
  33360. */
  33361. get hasHit(): boolean;
  33362. /**
  33363. * Gets the distance from the hit
  33364. */
  33365. get hitDistance(): number;
  33366. /**
  33367. * Gets the hit normal/direction in the world
  33368. */
  33369. get hitNormalWorld(): Vector3;
  33370. /**
  33371. * Gets the hit point in the world
  33372. */
  33373. get hitPointWorld(): Vector3;
  33374. /**
  33375. * Gets the ray "start point" of the ray in the world
  33376. */
  33377. get rayFromWorld(): Vector3;
  33378. /**
  33379. * Gets the ray "end point" of the ray in the world
  33380. */
  33381. get rayToWorld(): Vector3;
  33382. /**
  33383. * Sets the hit data (normal & point in world space)
  33384. * @param hitNormalWorld defines the normal in world space
  33385. * @param hitPointWorld defines the point in world space
  33386. */
  33387. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33388. /**
  33389. * Sets the distance from the start point to the hit point
  33390. * @param distance
  33391. */
  33392. setHitDistance(distance: number): void;
  33393. /**
  33394. * Calculates the distance manually
  33395. */
  33396. calculateHitDistance(): void;
  33397. /**
  33398. * Resets all the values to default
  33399. * @param from The from point on world space
  33400. * @param to The to point on world space
  33401. */
  33402. reset(from?: Vector3, to?: Vector3): void;
  33403. }
  33404. /**
  33405. * Interface for the size containing width and height
  33406. */
  33407. interface IXYZ {
  33408. /**
  33409. * X
  33410. */
  33411. x: number;
  33412. /**
  33413. * Y
  33414. */
  33415. y: number;
  33416. /**
  33417. * Z
  33418. */
  33419. z: number;
  33420. }
  33421. }
  33422. declare module "babylonjs/Physics/IPhysicsEngine" {
  33423. import { Nullable } from "babylonjs/types";
  33424. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33426. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33427. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33428. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33429. /**
  33430. * Interface used to describe a physics joint
  33431. */
  33432. export interface PhysicsImpostorJoint {
  33433. /** Defines the main impostor to which the joint is linked */
  33434. mainImpostor: PhysicsImpostor;
  33435. /** Defines the impostor that is connected to the main impostor using this joint */
  33436. connectedImpostor: PhysicsImpostor;
  33437. /** Defines the joint itself */
  33438. joint: PhysicsJoint;
  33439. }
  33440. /** @hidden */
  33441. export interface IPhysicsEnginePlugin {
  33442. world: any;
  33443. name: string;
  33444. setGravity(gravity: Vector3): void;
  33445. setTimeStep(timeStep: number): void;
  33446. getTimeStep(): number;
  33447. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33448. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33449. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33450. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33451. removePhysicsBody(impostor: PhysicsImpostor): void;
  33452. generateJoint(joint: PhysicsImpostorJoint): void;
  33453. removeJoint(joint: PhysicsImpostorJoint): void;
  33454. isSupported(): boolean;
  33455. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33456. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33457. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33458. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33459. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33460. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33461. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33462. getBodyMass(impostor: PhysicsImpostor): number;
  33463. getBodyFriction(impostor: PhysicsImpostor): number;
  33464. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33465. getBodyRestitution(impostor: PhysicsImpostor): number;
  33466. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33467. getBodyPressure?(impostor: PhysicsImpostor): number;
  33468. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33469. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33470. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33471. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33472. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33473. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33474. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33475. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33476. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33477. sleepBody(impostor: PhysicsImpostor): void;
  33478. wakeUpBody(impostor: PhysicsImpostor): void;
  33479. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33481. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33482. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33483. getRadius(impostor: PhysicsImpostor): number;
  33484. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33485. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33486. dispose(): void;
  33487. }
  33488. /**
  33489. * Interface used to define a physics engine
  33490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33491. */
  33492. export interface IPhysicsEngine {
  33493. /**
  33494. * Gets the gravity vector used by the simulation
  33495. */
  33496. gravity: Vector3;
  33497. /**
  33498. * Sets the gravity vector used by the simulation
  33499. * @param gravity defines the gravity vector to use
  33500. */
  33501. setGravity(gravity: Vector3): void;
  33502. /**
  33503. * Set the time step of the physics engine.
  33504. * Default is 1/60.
  33505. * To slow it down, enter 1/600 for example.
  33506. * To speed it up, 1/30
  33507. * @param newTimeStep the new timestep to apply to this world.
  33508. */
  33509. setTimeStep(newTimeStep: number): void;
  33510. /**
  33511. * Get the time step of the physics engine.
  33512. * @returns the current time step
  33513. */
  33514. getTimeStep(): number;
  33515. /**
  33516. * Set the sub time step of the physics engine.
  33517. * Default is 0 meaning there is no sub steps
  33518. * To increase physics resolution precision, set a small value (like 1 ms)
  33519. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33520. */
  33521. setSubTimeStep(subTimeStep: number): void;
  33522. /**
  33523. * Get the sub time step of the physics engine.
  33524. * @returns the current sub time step
  33525. */
  33526. getSubTimeStep(): number;
  33527. /**
  33528. * Release all resources
  33529. */
  33530. dispose(): void;
  33531. /**
  33532. * Gets the name of the current physics plugin
  33533. * @returns the name of the plugin
  33534. */
  33535. getPhysicsPluginName(): string;
  33536. /**
  33537. * Adding a new impostor for the impostor tracking.
  33538. * This will be done by the impostor itself.
  33539. * @param impostor the impostor to add
  33540. */
  33541. addImpostor(impostor: PhysicsImpostor): void;
  33542. /**
  33543. * Remove an impostor from the engine.
  33544. * This impostor and its mesh will not longer be updated by the physics engine.
  33545. * @param impostor the impostor to remove
  33546. */
  33547. removeImpostor(impostor: PhysicsImpostor): void;
  33548. /**
  33549. * Add a joint to the physics engine
  33550. * @param mainImpostor defines the main impostor to which the joint is added.
  33551. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33552. * @param joint defines the joint that will connect both impostors.
  33553. */
  33554. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33555. /**
  33556. * Removes a joint from the simulation
  33557. * @param mainImpostor defines the impostor used with the joint
  33558. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33559. * @param joint defines the joint to remove
  33560. */
  33561. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33562. /**
  33563. * Gets the current plugin used to run the simulation
  33564. * @returns current plugin
  33565. */
  33566. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33567. /**
  33568. * Gets the list of physic impostors
  33569. * @returns an array of PhysicsImpostor
  33570. */
  33571. getImpostors(): Array<PhysicsImpostor>;
  33572. /**
  33573. * Gets the impostor for a physics enabled object
  33574. * @param object defines the object impersonated by the impostor
  33575. * @returns the PhysicsImpostor or null if not found
  33576. */
  33577. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33578. /**
  33579. * Gets the impostor for a physics body object
  33580. * @param body defines physics body used by the impostor
  33581. * @returns the PhysicsImpostor or null if not found
  33582. */
  33583. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33584. /**
  33585. * Does a raycast in the physics world
  33586. * @param from when should the ray start?
  33587. * @param to when should the ray end?
  33588. * @returns PhysicsRaycastResult
  33589. */
  33590. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33591. /**
  33592. * Called by the scene. No need to call it.
  33593. * @param delta defines the timespam between frames
  33594. */
  33595. _step(delta: number): void;
  33596. }
  33597. }
  33598. declare module "babylonjs/Physics/physicsImpostor" {
  33599. import { Nullable, IndicesArray } from "babylonjs/types";
  33600. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33603. import { Scene } from "babylonjs/scene";
  33604. import { Bone } from "babylonjs/Bones/bone";
  33605. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33606. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33607. import { Space } from "babylonjs/Maths/math.axis";
  33608. /**
  33609. * The interface for the physics imposter parameters
  33610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33611. */
  33612. export interface PhysicsImpostorParameters {
  33613. /**
  33614. * The mass of the physics imposter
  33615. */
  33616. mass: number;
  33617. /**
  33618. * The friction of the physics imposter
  33619. */
  33620. friction?: number;
  33621. /**
  33622. * The coefficient of restitution of the physics imposter
  33623. */
  33624. restitution?: number;
  33625. /**
  33626. * The native options of the physics imposter
  33627. */
  33628. nativeOptions?: any;
  33629. /**
  33630. * Specifies if the parent should be ignored
  33631. */
  33632. ignoreParent?: boolean;
  33633. /**
  33634. * Specifies if bi-directional transformations should be disabled
  33635. */
  33636. disableBidirectionalTransformation?: boolean;
  33637. /**
  33638. * The pressure inside the physics imposter, soft object only
  33639. */
  33640. pressure?: number;
  33641. /**
  33642. * The stiffness the physics imposter, soft object only
  33643. */
  33644. stiffness?: number;
  33645. /**
  33646. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33647. */
  33648. velocityIterations?: number;
  33649. /**
  33650. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33651. */
  33652. positionIterations?: number;
  33653. /**
  33654. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33655. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33656. * Add to fix multiple points
  33657. */
  33658. fixedPoints?: number;
  33659. /**
  33660. * The collision margin around a soft object
  33661. */
  33662. margin?: number;
  33663. /**
  33664. * The collision margin around a soft object
  33665. */
  33666. damping?: number;
  33667. /**
  33668. * The path for a rope based on an extrusion
  33669. */
  33670. path?: any;
  33671. /**
  33672. * The shape of an extrusion used for a rope based on an extrusion
  33673. */
  33674. shape?: any;
  33675. }
  33676. /**
  33677. * Interface for a physics-enabled object
  33678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33679. */
  33680. export interface IPhysicsEnabledObject {
  33681. /**
  33682. * The position of the physics-enabled object
  33683. */
  33684. position: Vector3;
  33685. /**
  33686. * The rotation of the physics-enabled object
  33687. */
  33688. rotationQuaternion: Nullable<Quaternion>;
  33689. /**
  33690. * The scale of the physics-enabled object
  33691. */
  33692. scaling: Vector3;
  33693. /**
  33694. * The rotation of the physics-enabled object
  33695. */
  33696. rotation?: Vector3;
  33697. /**
  33698. * The parent of the physics-enabled object
  33699. */
  33700. parent?: any;
  33701. /**
  33702. * The bounding info of the physics-enabled object
  33703. * @returns The bounding info of the physics-enabled object
  33704. */
  33705. getBoundingInfo(): BoundingInfo;
  33706. /**
  33707. * Computes the world matrix
  33708. * @param force Specifies if the world matrix should be computed by force
  33709. * @returns A world matrix
  33710. */
  33711. computeWorldMatrix(force: boolean): Matrix;
  33712. /**
  33713. * Gets the world matrix
  33714. * @returns A world matrix
  33715. */
  33716. getWorldMatrix?(): Matrix;
  33717. /**
  33718. * Gets the child meshes
  33719. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33720. * @returns An array of abstract meshes
  33721. */
  33722. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33723. /**
  33724. * Gets the vertex data
  33725. * @param kind The type of vertex data
  33726. * @returns A nullable array of numbers, or a float32 array
  33727. */
  33728. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33729. /**
  33730. * Gets the indices from the mesh
  33731. * @returns A nullable array of index arrays
  33732. */
  33733. getIndices?(): Nullable<IndicesArray>;
  33734. /**
  33735. * Gets the scene from the mesh
  33736. * @returns the indices array or null
  33737. */
  33738. getScene?(): Scene;
  33739. /**
  33740. * Gets the absolute position from the mesh
  33741. * @returns the absolute position
  33742. */
  33743. getAbsolutePosition(): Vector3;
  33744. /**
  33745. * Gets the absolute pivot point from the mesh
  33746. * @returns the absolute pivot point
  33747. */
  33748. getAbsolutePivotPoint(): Vector3;
  33749. /**
  33750. * Rotates the mesh
  33751. * @param axis The axis of rotation
  33752. * @param amount The amount of rotation
  33753. * @param space The space of the rotation
  33754. * @returns The rotation transform node
  33755. */
  33756. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33757. /**
  33758. * Translates the mesh
  33759. * @param axis The axis of translation
  33760. * @param distance The distance of translation
  33761. * @param space The space of the translation
  33762. * @returns The transform node
  33763. */
  33764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33765. /**
  33766. * Sets the absolute position of the mesh
  33767. * @param absolutePosition The absolute position of the mesh
  33768. * @returns The transform node
  33769. */
  33770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33771. /**
  33772. * Gets the class name of the mesh
  33773. * @returns The class name
  33774. */
  33775. getClassName(): string;
  33776. }
  33777. /**
  33778. * Represents a physics imposter
  33779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33780. */
  33781. export class PhysicsImpostor {
  33782. /**
  33783. * The physics-enabled object used as the physics imposter
  33784. */
  33785. object: IPhysicsEnabledObject;
  33786. /**
  33787. * The type of the physics imposter
  33788. */
  33789. type: number;
  33790. private _options;
  33791. private _scene?;
  33792. /**
  33793. * The default object size of the imposter
  33794. */
  33795. static DEFAULT_OBJECT_SIZE: Vector3;
  33796. /**
  33797. * The identity quaternion of the imposter
  33798. */
  33799. static IDENTITY_QUATERNION: Quaternion;
  33800. /** @hidden */
  33801. _pluginData: any;
  33802. private _physicsEngine;
  33803. private _physicsBody;
  33804. private _bodyUpdateRequired;
  33805. private _onBeforePhysicsStepCallbacks;
  33806. private _onAfterPhysicsStepCallbacks;
  33807. /** @hidden */
  33808. _onPhysicsCollideCallbacks: Array<{
  33809. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33810. otherImpostors: Array<PhysicsImpostor>;
  33811. }>;
  33812. private _deltaPosition;
  33813. private _deltaRotation;
  33814. private _deltaRotationConjugated;
  33815. /** @hidden */
  33816. _isFromLine: boolean;
  33817. private _parent;
  33818. private _isDisposed;
  33819. private static _tmpVecs;
  33820. private static _tmpQuat;
  33821. /**
  33822. * Specifies if the physics imposter is disposed
  33823. */
  33824. get isDisposed(): boolean;
  33825. /**
  33826. * Gets the mass of the physics imposter
  33827. */
  33828. get mass(): number;
  33829. set mass(value: number);
  33830. /**
  33831. * Gets the coefficient of friction
  33832. */
  33833. get friction(): number;
  33834. /**
  33835. * Sets the coefficient of friction
  33836. */
  33837. set friction(value: number);
  33838. /**
  33839. * Gets the coefficient of restitution
  33840. */
  33841. get restitution(): number;
  33842. /**
  33843. * Sets the coefficient of restitution
  33844. */
  33845. set restitution(value: number);
  33846. /**
  33847. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33848. */
  33849. get pressure(): number;
  33850. /**
  33851. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33852. */
  33853. set pressure(value: number);
  33854. /**
  33855. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33856. */
  33857. get stiffness(): number;
  33858. /**
  33859. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33860. */
  33861. set stiffness(value: number);
  33862. /**
  33863. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33864. */
  33865. get velocityIterations(): number;
  33866. /**
  33867. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33868. */
  33869. set velocityIterations(value: number);
  33870. /**
  33871. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33872. */
  33873. get positionIterations(): number;
  33874. /**
  33875. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33876. */
  33877. set positionIterations(value: number);
  33878. /**
  33879. * The unique id of the physics imposter
  33880. * set by the physics engine when adding this impostor to the array
  33881. */
  33882. uniqueId: number;
  33883. /**
  33884. * @hidden
  33885. */
  33886. soft: boolean;
  33887. /**
  33888. * @hidden
  33889. */
  33890. segments: number;
  33891. private _joints;
  33892. /**
  33893. * Initializes the physics imposter
  33894. * @param object The physics-enabled object used as the physics imposter
  33895. * @param type The type of the physics imposter
  33896. * @param _options The options for the physics imposter
  33897. * @param _scene The Babylon scene
  33898. */
  33899. constructor(
  33900. /**
  33901. * The physics-enabled object used as the physics imposter
  33902. */
  33903. object: IPhysicsEnabledObject,
  33904. /**
  33905. * The type of the physics imposter
  33906. */
  33907. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33908. /**
  33909. * This function will completly initialize this impostor.
  33910. * It will create a new body - but only if this mesh has no parent.
  33911. * If it has, this impostor will not be used other than to define the impostor
  33912. * of the child mesh.
  33913. * @hidden
  33914. */
  33915. _init(): void;
  33916. private _getPhysicsParent;
  33917. /**
  33918. * Should a new body be generated.
  33919. * @returns boolean specifying if body initialization is required
  33920. */
  33921. isBodyInitRequired(): boolean;
  33922. /**
  33923. * Sets the updated scaling
  33924. * @param updated Specifies if the scaling is updated
  33925. */
  33926. setScalingUpdated(): void;
  33927. /**
  33928. * Force a regeneration of this or the parent's impostor's body.
  33929. * Use under cautious - This will remove all joints already implemented.
  33930. */
  33931. forceUpdate(): void;
  33932. /**
  33933. * Gets the body that holds this impostor. Either its own, or its parent.
  33934. */
  33935. get physicsBody(): any;
  33936. /**
  33937. * Get the parent of the physics imposter
  33938. * @returns Physics imposter or null
  33939. */
  33940. get parent(): Nullable<PhysicsImpostor>;
  33941. /**
  33942. * Sets the parent of the physics imposter
  33943. */
  33944. set parent(value: Nullable<PhysicsImpostor>);
  33945. /**
  33946. * Set the physics body. Used mainly by the physics engine/plugin
  33947. */
  33948. set physicsBody(physicsBody: any);
  33949. /**
  33950. * Resets the update flags
  33951. */
  33952. resetUpdateFlags(): void;
  33953. /**
  33954. * Gets the object extend size
  33955. * @returns the object extend size
  33956. */
  33957. getObjectExtendSize(): Vector3;
  33958. /**
  33959. * Gets the object center
  33960. * @returns The object center
  33961. */
  33962. getObjectCenter(): Vector3;
  33963. /**
  33964. * Get a specific parameter from the options parameters
  33965. * @param paramName The object parameter name
  33966. * @returns The object parameter
  33967. */
  33968. getParam(paramName: string): any;
  33969. /**
  33970. * Sets a specific parameter in the options given to the physics plugin
  33971. * @param paramName The parameter name
  33972. * @param value The value of the parameter
  33973. */
  33974. setParam(paramName: string, value: number): void;
  33975. /**
  33976. * Specifically change the body's mass option. Won't recreate the physics body object
  33977. * @param mass The mass of the physics imposter
  33978. */
  33979. setMass(mass: number): void;
  33980. /**
  33981. * Gets the linear velocity
  33982. * @returns linear velocity or null
  33983. */
  33984. getLinearVelocity(): Nullable<Vector3>;
  33985. /**
  33986. * Sets the linear velocity
  33987. * @param velocity linear velocity or null
  33988. */
  33989. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33990. /**
  33991. * Gets the angular velocity
  33992. * @returns angular velocity or null
  33993. */
  33994. getAngularVelocity(): Nullable<Vector3>;
  33995. /**
  33996. * Sets the angular velocity
  33997. * @param velocity The velocity or null
  33998. */
  33999. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34000. /**
  34001. * Execute a function with the physics plugin native code
  34002. * Provide a function the will have two variables - the world object and the physics body object
  34003. * @param func The function to execute with the physics plugin native code
  34004. */
  34005. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34006. /**
  34007. * Register a function that will be executed before the physics world is stepping forward
  34008. * @param func The function to execute before the physics world is stepped forward
  34009. */
  34010. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34011. /**
  34012. * Unregister a function that will be executed before the physics world is stepping forward
  34013. * @param func The function to execute before the physics world is stepped forward
  34014. */
  34015. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34016. /**
  34017. * Register a function that will be executed after the physics step
  34018. * @param func The function to execute after physics step
  34019. */
  34020. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34021. /**
  34022. * Unregisters a function that will be executed after the physics step
  34023. * @param func The function to execute after physics step
  34024. */
  34025. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34026. /**
  34027. * register a function that will be executed when this impostor collides against a different body
  34028. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34029. * @param func Callback that is executed on collision
  34030. */
  34031. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34032. /**
  34033. * Unregisters the physics imposter on contact
  34034. * @param collideAgainst The physics object to collide against
  34035. * @param func Callback to execute on collision
  34036. */
  34037. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34038. private _tmpQuat;
  34039. private _tmpQuat2;
  34040. /**
  34041. * Get the parent rotation
  34042. * @returns The parent rotation
  34043. */
  34044. getParentsRotation(): Quaternion;
  34045. /**
  34046. * this function is executed by the physics engine.
  34047. */
  34048. beforeStep: () => void;
  34049. /**
  34050. * this function is executed by the physics engine
  34051. */
  34052. afterStep: () => void;
  34053. /**
  34054. * Legacy collision detection event support
  34055. */
  34056. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34057. /**
  34058. * event and body object due to cannon's event-based architecture.
  34059. */
  34060. onCollide: (e: {
  34061. body: any;
  34062. point: Nullable<Vector3>;
  34063. }) => void;
  34064. /**
  34065. * Apply a force
  34066. * @param force The force to apply
  34067. * @param contactPoint The contact point for the force
  34068. * @returns The physics imposter
  34069. */
  34070. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34071. /**
  34072. * Apply an impulse
  34073. * @param force The impulse force
  34074. * @param contactPoint The contact point for the impulse force
  34075. * @returns The physics imposter
  34076. */
  34077. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34078. /**
  34079. * A help function to create a joint
  34080. * @param otherImpostor A physics imposter used to create a joint
  34081. * @param jointType The type of joint
  34082. * @param jointData The data for the joint
  34083. * @returns The physics imposter
  34084. */
  34085. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34086. /**
  34087. * Add a joint to this impostor with a different impostor
  34088. * @param otherImpostor A physics imposter used to add a joint
  34089. * @param joint The joint to add
  34090. * @returns The physics imposter
  34091. */
  34092. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34093. /**
  34094. * Add an anchor to a cloth impostor
  34095. * @param otherImpostor rigid impostor to anchor to
  34096. * @param width ratio across width from 0 to 1
  34097. * @param height ratio up height from 0 to 1
  34098. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  34099. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  34100. * @returns impostor the soft imposter
  34101. */
  34102. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34103. /**
  34104. * Add a hook to a rope impostor
  34105. * @param otherImpostor rigid impostor to anchor to
  34106. * @param length ratio across rope from 0 to 1
  34107. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  34108. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  34109. * @returns impostor the rope imposter
  34110. */
  34111. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34112. /**
  34113. * Will keep this body still, in a sleep mode.
  34114. * @returns the physics imposter
  34115. */
  34116. sleep(): PhysicsImpostor;
  34117. /**
  34118. * Wake the body up.
  34119. * @returns The physics imposter
  34120. */
  34121. wakeUp(): PhysicsImpostor;
  34122. /**
  34123. * Clones the physics imposter
  34124. * @param newObject The physics imposter clones to this physics-enabled object
  34125. * @returns A nullable physics imposter
  34126. */
  34127. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34128. /**
  34129. * Disposes the physics imposter
  34130. */
  34131. dispose(): void;
  34132. /**
  34133. * Sets the delta position
  34134. * @param position The delta position amount
  34135. */
  34136. setDeltaPosition(position: Vector3): void;
  34137. /**
  34138. * Sets the delta rotation
  34139. * @param rotation The delta rotation amount
  34140. */
  34141. setDeltaRotation(rotation: Quaternion): void;
  34142. /**
  34143. * Gets the box size of the physics imposter and stores the result in the input parameter
  34144. * @param result Stores the box size
  34145. * @returns The physics imposter
  34146. */
  34147. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34148. /**
  34149. * Gets the radius of the physics imposter
  34150. * @returns Radius of the physics imposter
  34151. */
  34152. getRadius(): number;
  34153. /**
  34154. * Sync a bone with this impostor
  34155. * @param bone The bone to sync to the impostor.
  34156. * @param boneMesh The mesh that the bone is influencing.
  34157. * @param jointPivot The pivot of the joint / bone in local space.
  34158. * @param distToJoint Optional distance from the impostor to the joint.
  34159. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34160. */
  34161. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34162. /**
  34163. * Sync impostor to a bone
  34164. * @param bone The bone that the impostor will be synced to.
  34165. * @param boneMesh The mesh that the bone is influencing.
  34166. * @param jointPivot The pivot of the joint / bone in local space.
  34167. * @param distToJoint Optional distance from the impostor to the joint.
  34168. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34169. * @param boneAxis Optional vector3 axis the bone is aligned with
  34170. */
  34171. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34172. /**
  34173. * No-Imposter type
  34174. */
  34175. static NoImpostor: number;
  34176. /**
  34177. * Sphere-Imposter type
  34178. */
  34179. static SphereImpostor: number;
  34180. /**
  34181. * Box-Imposter type
  34182. */
  34183. static BoxImpostor: number;
  34184. /**
  34185. * Plane-Imposter type
  34186. */
  34187. static PlaneImpostor: number;
  34188. /**
  34189. * Mesh-imposter type
  34190. */
  34191. static MeshImpostor: number;
  34192. /**
  34193. * Capsule-Impostor type (Ammo.js plugin only)
  34194. */
  34195. static CapsuleImpostor: number;
  34196. /**
  34197. * Cylinder-Imposter type
  34198. */
  34199. static CylinderImpostor: number;
  34200. /**
  34201. * Particle-Imposter type
  34202. */
  34203. static ParticleImpostor: number;
  34204. /**
  34205. * Heightmap-Imposter type
  34206. */
  34207. static HeightmapImpostor: number;
  34208. /**
  34209. * ConvexHull-Impostor type (Ammo.js plugin only)
  34210. */
  34211. static ConvexHullImpostor: number;
  34212. /**
  34213. * Custom-Imposter type (Ammo.js plugin only)
  34214. */
  34215. static CustomImpostor: number;
  34216. /**
  34217. * Rope-Imposter type
  34218. */
  34219. static RopeImpostor: number;
  34220. /**
  34221. * Cloth-Imposter type
  34222. */
  34223. static ClothImpostor: number;
  34224. /**
  34225. * Softbody-Imposter type
  34226. */
  34227. static SoftbodyImpostor: number;
  34228. }
  34229. }
  34230. declare module "babylonjs/Meshes/mesh" {
  34231. import { Observable } from "babylonjs/Misc/observable";
  34232. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34233. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34234. import { Camera } from "babylonjs/Cameras/camera";
  34235. import { Scene } from "babylonjs/scene";
  34236. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34237. import { Color4 } from "babylonjs/Maths/math.color";
  34238. import { Engine } from "babylonjs/Engines/engine";
  34239. import { Node } from "babylonjs/node";
  34240. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  34241. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  34242. import { Buffer } from "babylonjs/Meshes/buffer";
  34243. import { Geometry } from "babylonjs/Meshes/geometry";
  34244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34246. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  34247. import { Effect } from "babylonjs/Materials/effect";
  34248. import { Material } from "babylonjs/Materials/material";
  34249. import { Skeleton } from "babylonjs/Bones/skeleton";
  34250. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34251. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  34252. import { Path3D } from "babylonjs/Maths/math.path";
  34253. import { Plane } from "babylonjs/Maths/math.plane";
  34254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34255. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34256. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  34257. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  34258. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  34259. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  34260. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  34261. /**
  34262. * @hidden
  34263. **/
  34264. export class _CreationDataStorage {
  34265. closePath?: boolean;
  34266. closeArray?: boolean;
  34267. idx: number[];
  34268. dashSize: number;
  34269. gapSize: number;
  34270. path3D: Path3D;
  34271. pathArray: Vector3[][];
  34272. arc: number;
  34273. radius: number;
  34274. cap: number;
  34275. tessellation: number;
  34276. }
  34277. /**
  34278. * @hidden
  34279. **/
  34280. class _InstanceDataStorage {
  34281. visibleInstances: any;
  34282. batchCache: _InstancesBatch;
  34283. instancesBufferSize: number;
  34284. instancesBuffer: Nullable<Buffer>;
  34285. instancesData: Float32Array;
  34286. overridenInstanceCount: number;
  34287. isFrozen: boolean;
  34288. previousBatch: Nullable<_InstancesBatch>;
  34289. hardwareInstancedRendering: boolean;
  34290. sideOrientation: number;
  34291. manualUpdate: boolean;
  34292. previousRenderId: number;
  34293. }
  34294. /**
  34295. * @hidden
  34296. **/
  34297. export class _InstancesBatch {
  34298. mustReturn: boolean;
  34299. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34300. renderSelf: boolean[];
  34301. hardwareInstancedRendering: boolean[];
  34302. }
  34303. /**
  34304. * @hidden
  34305. **/
  34306. class _ThinInstanceDataStorage {
  34307. instancesCount: number;
  34308. matrixBuffer: Nullable<Buffer>;
  34309. matrixBufferSize: number;
  34310. matrixData: Nullable<Float32Array>;
  34311. boundingVectors: Array<Vector3>;
  34312. worldMatrices: Nullable<Matrix[]>;
  34313. }
  34314. /**
  34315. * Class used to represent renderable models
  34316. */
  34317. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34318. /**
  34319. * Mesh side orientation : usually the external or front surface
  34320. */
  34321. static readonly FRONTSIDE: number;
  34322. /**
  34323. * Mesh side orientation : usually the internal or back surface
  34324. */
  34325. static readonly BACKSIDE: number;
  34326. /**
  34327. * Mesh side orientation : both internal and external or front and back surfaces
  34328. */
  34329. static readonly DOUBLESIDE: number;
  34330. /**
  34331. * Mesh side orientation : by default, `FRONTSIDE`
  34332. */
  34333. static readonly DEFAULTSIDE: number;
  34334. /**
  34335. * Mesh cap setting : no cap
  34336. */
  34337. static readonly NO_CAP: number;
  34338. /**
  34339. * Mesh cap setting : one cap at the beginning of the mesh
  34340. */
  34341. static readonly CAP_START: number;
  34342. /**
  34343. * Mesh cap setting : one cap at the end of the mesh
  34344. */
  34345. static readonly CAP_END: number;
  34346. /**
  34347. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34348. */
  34349. static readonly CAP_ALL: number;
  34350. /**
  34351. * Mesh pattern setting : no flip or rotate
  34352. */
  34353. static readonly NO_FLIP: number;
  34354. /**
  34355. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34356. */
  34357. static readonly FLIP_TILE: number;
  34358. /**
  34359. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34360. */
  34361. static readonly ROTATE_TILE: number;
  34362. /**
  34363. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34364. */
  34365. static readonly FLIP_ROW: number;
  34366. /**
  34367. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34368. */
  34369. static readonly ROTATE_ROW: number;
  34370. /**
  34371. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34372. */
  34373. static readonly FLIP_N_ROTATE_TILE: number;
  34374. /**
  34375. * Mesh pattern setting : rotate pattern and rotate
  34376. */
  34377. static readonly FLIP_N_ROTATE_ROW: number;
  34378. /**
  34379. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34380. */
  34381. static readonly CENTER: number;
  34382. /**
  34383. * Mesh tile positioning : part tiles on left
  34384. */
  34385. static readonly LEFT: number;
  34386. /**
  34387. * Mesh tile positioning : part tiles on right
  34388. */
  34389. static readonly RIGHT: number;
  34390. /**
  34391. * Mesh tile positioning : part tiles on top
  34392. */
  34393. static readonly TOP: number;
  34394. /**
  34395. * Mesh tile positioning : part tiles on bottom
  34396. */
  34397. static readonly BOTTOM: number;
  34398. /**
  34399. * Gets the default side orientation.
  34400. * @param orientation the orientation to value to attempt to get
  34401. * @returns the default orientation
  34402. * @hidden
  34403. */
  34404. static _GetDefaultSideOrientation(orientation?: number): number;
  34405. private _internalMeshDataInfo;
  34406. get computeBonesUsingShaders(): boolean;
  34407. set computeBonesUsingShaders(value: boolean);
  34408. /**
  34409. * An event triggered before rendering the mesh
  34410. */
  34411. get onBeforeRenderObservable(): Observable<Mesh>;
  34412. /**
  34413. * An event triggered before binding the mesh
  34414. */
  34415. get onBeforeBindObservable(): Observable<Mesh>;
  34416. /**
  34417. * An event triggered after rendering the mesh
  34418. */
  34419. get onAfterRenderObservable(): Observable<Mesh>;
  34420. /**
  34421. * An event triggered before drawing the mesh
  34422. */
  34423. get onBeforeDrawObservable(): Observable<Mesh>;
  34424. private _onBeforeDrawObserver;
  34425. /**
  34426. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34427. */
  34428. set onBeforeDraw(callback: () => void);
  34429. get hasInstances(): boolean;
  34430. get hasThinInstances(): boolean;
  34431. /**
  34432. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34433. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34434. */
  34435. delayLoadState: number;
  34436. /**
  34437. * Gets the list of instances created from this mesh
  34438. * it is not supposed to be modified manually.
  34439. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34440. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34441. */
  34442. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34443. /**
  34444. * Gets the file containing delay loading data for this mesh
  34445. */
  34446. delayLoadingFile: string;
  34447. /** @hidden */
  34448. _binaryInfo: any;
  34449. /**
  34450. * User defined function used to change how LOD level selection is done
  34451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34452. */
  34453. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34454. /**
  34455. * Gets or sets the morph target manager
  34456. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34457. */
  34458. get morphTargetManager(): Nullable<MorphTargetManager>;
  34459. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34460. /** @hidden */
  34461. _creationDataStorage: Nullable<_CreationDataStorage>;
  34462. /** @hidden */
  34463. _geometry: Nullable<Geometry>;
  34464. /** @hidden */
  34465. _delayInfo: Array<string>;
  34466. /** @hidden */
  34467. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34468. /** @hidden */
  34469. _instanceDataStorage: _InstanceDataStorage;
  34470. /** @hidden */
  34471. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34472. private _effectiveMaterial;
  34473. /** @hidden */
  34474. _shouldGenerateFlatShading: boolean;
  34475. /** @hidden */
  34476. _originalBuilderSideOrientation: number;
  34477. /**
  34478. * Use this property to change the original side orientation defined at construction time
  34479. */
  34480. overrideMaterialSideOrientation: Nullable<number>;
  34481. /**
  34482. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  34483. * Note this will reduce performance when set to true.
  34484. */
  34485. ignoreCameraMaxZ: boolean;
  34486. /**
  34487. * Gets the source mesh (the one used to clone this one from)
  34488. */
  34489. get source(): Nullable<Mesh>;
  34490. /**
  34491. * Gets the list of clones of this mesh
  34492. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34493. * Note that useClonedMeshMap=true is the default setting
  34494. */
  34495. get cloneMeshMap(): Nullable<{
  34496. [id: string]: Mesh | undefined;
  34497. }>;
  34498. /**
  34499. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34500. */
  34501. get isUnIndexed(): boolean;
  34502. set isUnIndexed(value: boolean);
  34503. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34504. get worldMatrixInstancedBuffer(): Float32Array;
  34505. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34506. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34507. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34508. /**
  34509. * @constructor
  34510. * @param name The value used by scene.getMeshByName() to do a lookup.
  34511. * @param scene The scene to add this mesh to.
  34512. * @param parent The parent of this mesh, if it has one
  34513. * @param source An optional Mesh from which geometry is shared, cloned.
  34514. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34515. * When false, achieved by calling a clone(), also passing False.
  34516. * This will make creation of children, recursive.
  34517. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34518. */
  34519. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34520. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34521. doNotInstantiate: boolean;
  34522. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34523. /**
  34524. * Gets the class name
  34525. * @returns the string "Mesh".
  34526. */
  34527. getClassName(): string;
  34528. /** @hidden */
  34529. get _isMesh(): boolean;
  34530. /**
  34531. * Returns a description of this mesh
  34532. * @param fullDetails define if full details about this mesh must be used
  34533. * @returns a descriptive string representing this mesh
  34534. */
  34535. toString(fullDetails?: boolean): string;
  34536. /** @hidden */
  34537. _unBindEffect(): void;
  34538. /**
  34539. * Gets a boolean indicating if this mesh has LOD
  34540. */
  34541. get hasLODLevels(): boolean;
  34542. /**
  34543. * Gets the list of MeshLODLevel associated with the current mesh
  34544. * @returns an array of MeshLODLevel
  34545. */
  34546. getLODLevels(): MeshLODLevel[];
  34547. private _sortLODLevels;
  34548. /**
  34549. * Add a mesh as LOD level triggered at the given distance.
  34550. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34551. * @param distance The distance from the center of the object to show this level
  34552. * @param mesh The mesh to be added as LOD level (can be null)
  34553. * @return This mesh (for chaining)
  34554. */
  34555. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34556. /**
  34557. * Returns the LOD level mesh at the passed distance or null if not found.
  34558. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34559. * @param distance The distance from the center of the object to show this level
  34560. * @returns a Mesh or `null`
  34561. */
  34562. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34563. /**
  34564. * Remove a mesh from the LOD array
  34565. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34566. * @param mesh defines the mesh to be removed
  34567. * @return This mesh (for chaining)
  34568. */
  34569. removeLODLevel(mesh: Mesh): Mesh;
  34570. /**
  34571. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34572. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34573. * @param camera defines the camera to use to compute distance
  34574. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34575. * @return This mesh (for chaining)
  34576. */
  34577. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34578. /**
  34579. * Gets the mesh internal Geometry object
  34580. */
  34581. get geometry(): Nullable<Geometry>;
  34582. /**
  34583. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34584. * @returns the total number of vertices
  34585. */
  34586. getTotalVertices(): number;
  34587. /**
  34588. * Returns the content of an associated vertex buffer
  34589. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34590. * - VertexBuffer.PositionKind
  34591. * - VertexBuffer.UVKind
  34592. * - VertexBuffer.UV2Kind
  34593. * - VertexBuffer.UV3Kind
  34594. * - VertexBuffer.UV4Kind
  34595. * - VertexBuffer.UV5Kind
  34596. * - VertexBuffer.UV6Kind
  34597. * - VertexBuffer.ColorKind
  34598. * - VertexBuffer.MatricesIndicesKind
  34599. * - VertexBuffer.MatricesIndicesExtraKind
  34600. * - VertexBuffer.MatricesWeightsKind
  34601. * - VertexBuffer.MatricesWeightsExtraKind
  34602. * @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
  34603. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34604. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34605. */
  34606. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34607. /**
  34608. * Returns the mesh VertexBuffer object from the requested `kind`
  34609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34610. * - VertexBuffer.PositionKind
  34611. * - VertexBuffer.NormalKind
  34612. * - VertexBuffer.UVKind
  34613. * - VertexBuffer.UV2Kind
  34614. * - VertexBuffer.UV3Kind
  34615. * - VertexBuffer.UV4Kind
  34616. * - VertexBuffer.UV5Kind
  34617. * - VertexBuffer.UV6Kind
  34618. * - VertexBuffer.ColorKind
  34619. * - VertexBuffer.MatricesIndicesKind
  34620. * - VertexBuffer.MatricesIndicesExtraKind
  34621. * - VertexBuffer.MatricesWeightsKind
  34622. * - VertexBuffer.MatricesWeightsExtraKind
  34623. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34624. */
  34625. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34626. /**
  34627. * Tests if a specific vertex buffer is associated with this mesh
  34628. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34629. * - VertexBuffer.PositionKind
  34630. * - VertexBuffer.NormalKind
  34631. * - VertexBuffer.UVKind
  34632. * - VertexBuffer.UV2Kind
  34633. * - VertexBuffer.UV3Kind
  34634. * - VertexBuffer.UV4Kind
  34635. * - VertexBuffer.UV5Kind
  34636. * - VertexBuffer.UV6Kind
  34637. * - VertexBuffer.ColorKind
  34638. * - VertexBuffer.MatricesIndicesKind
  34639. * - VertexBuffer.MatricesIndicesExtraKind
  34640. * - VertexBuffer.MatricesWeightsKind
  34641. * - VertexBuffer.MatricesWeightsExtraKind
  34642. * @returns a boolean
  34643. */
  34644. isVerticesDataPresent(kind: string): boolean;
  34645. /**
  34646. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34647. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34648. * - VertexBuffer.PositionKind
  34649. * - VertexBuffer.UVKind
  34650. * - VertexBuffer.UV2Kind
  34651. * - VertexBuffer.UV3Kind
  34652. * - VertexBuffer.UV4Kind
  34653. * - VertexBuffer.UV5Kind
  34654. * - VertexBuffer.UV6Kind
  34655. * - VertexBuffer.ColorKind
  34656. * - VertexBuffer.MatricesIndicesKind
  34657. * - VertexBuffer.MatricesIndicesExtraKind
  34658. * - VertexBuffer.MatricesWeightsKind
  34659. * - VertexBuffer.MatricesWeightsExtraKind
  34660. * @returns a boolean
  34661. */
  34662. isVertexBufferUpdatable(kind: string): boolean;
  34663. /**
  34664. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34665. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34666. * - VertexBuffer.PositionKind
  34667. * - VertexBuffer.NormalKind
  34668. * - VertexBuffer.UVKind
  34669. * - VertexBuffer.UV2Kind
  34670. * - VertexBuffer.UV3Kind
  34671. * - VertexBuffer.UV4Kind
  34672. * - VertexBuffer.UV5Kind
  34673. * - VertexBuffer.UV6Kind
  34674. * - VertexBuffer.ColorKind
  34675. * - VertexBuffer.MatricesIndicesKind
  34676. * - VertexBuffer.MatricesIndicesExtraKind
  34677. * - VertexBuffer.MatricesWeightsKind
  34678. * - VertexBuffer.MatricesWeightsExtraKind
  34679. * @returns an array of strings
  34680. */
  34681. getVerticesDataKinds(): string[];
  34682. /**
  34683. * Returns a positive integer : the total number of indices in this mesh geometry.
  34684. * @returns the numner of indices or zero if the mesh has no geometry.
  34685. */
  34686. getTotalIndices(): number;
  34687. /**
  34688. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34689. * @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.
  34690. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34691. * @returns the indices array or an empty array if the mesh has no geometry
  34692. */
  34693. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34694. get isBlocked(): boolean;
  34695. /**
  34696. * Determine if the current mesh is ready to be rendered
  34697. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34698. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34699. * @returns true if all associated assets are ready (material, textures, shaders)
  34700. */
  34701. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34702. /**
  34703. * 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.
  34704. */
  34705. get areNormalsFrozen(): boolean;
  34706. /**
  34707. * 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.
  34708. * @returns the current mesh
  34709. */
  34710. freezeNormals(): Mesh;
  34711. /**
  34712. * 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
  34713. * @returns the current mesh
  34714. */
  34715. unfreezeNormals(): Mesh;
  34716. /**
  34717. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34718. */
  34719. set overridenInstanceCount(count: number);
  34720. /** @hidden */
  34721. _preActivate(): Mesh;
  34722. /** @hidden */
  34723. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34724. /** @hidden */
  34725. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34726. protected _afterComputeWorldMatrix(): void;
  34727. /** @hidden */
  34728. _postActivate(): void;
  34729. /**
  34730. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34731. * This means the mesh underlying bounding box and sphere are recomputed.
  34732. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34733. * @returns the current mesh
  34734. */
  34735. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34736. /** @hidden */
  34737. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34738. /**
  34739. * This function will subdivide the mesh into multiple submeshes
  34740. * @param count defines the expected number of submeshes
  34741. */
  34742. subdivide(count: number): void;
  34743. /**
  34744. * Copy a FloatArray into a specific associated vertex buffer
  34745. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34746. * - VertexBuffer.PositionKind
  34747. * - VertexBuffer.UVKind
  34748. * - VertexBuffer.UV2Kind
  34749. * - VertexBuffer.UV3Kind
  34750. * - VertexBuffer.UV4Kind
  34751. * - VertexBuffer.UV5Kind
  34752. * - VertexBuffer.UV6Kind
  34753. * - VertexBuffer.ColorKind
  34754. * - VertexBuffer.MatricesIndicesKind
  34755. * - VertexBuffer.MatricesIndicesExtraKind
  34756. * - VertexBuffer.MatricesWeightsKind
  34757. * - VertexBuffer.MatricesWeightsExtraKind
  34758. * @param data defines the data source
  34759. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34760. * @param stride defines the data stride size (can be null)
  34761. * @returns the current mesh
  34762. */
  34763. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34764. /**
  34765. * Delete a vertex buffer associated with this mesh
  34766. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34767. * - VertexBuffer.PositionKind
  34768. * - VertexBuffer.UVKind
  34769. * - VertexBuffer.UV2Kind
  34770. * - VertexBuffer.UV3Kind
  34771. * - VertexBuffer.UV4Kind
  34772. * - VertexBuffer.UV5Kind
  34773. * - VertexBuffer.UV6Kind
  34774. * - VertexBuffer.ColorKind
  34775. * - VertexBuffer.MatricesIndicesKind
  34776. * - VertexBuffer.MatricesIndicesExtraKind
  34777. * - VertexBuffer.MatricesWeightsKind
  34778. * - VertexBuffer.MatricesWeightsExtraKind
  34779. */
  34780. removeVerticesData(kind: string): void;
  34781. /**
  34782. * Flags an associated vertex buffer as updatable
  34783. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34784. * - VertexBuffer.PositionKind
  34785. * - VertexBuffer.UVKind
  34786. * - VertexBuffer.UV2Kind
  34787. * - VertexBuffer.UV3Kind
  34788. * - VertexBuffer.UV4Kind
  34789. * - VertexBuffer.UV5Kind
  34790. * - VertexBuffer.UV6Kind
  34791. * - VertexBuffer.ColorKind
  34792. * - VertexBuffer.MatricesIndicesKind
  34793. * - VertexBuffer.MatricesIndicesExtraKind
  34794. * - VertexBuffer.MatricesWeightsKind
  34795. * - VertexBuffer.MatricesWeightsExtraKind
  34796. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34797. */
  34798. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34799. /**
  34800. * Sets the mesh global Vertex Buffer
  34801. * @param buffer defines the buffer to use
  34802. * @returns the current mesh
  34803. */
  34804. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34805. /**
  34806. * Update a specific associated vertex buffer
  34807. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34808. * - VertexBuffer.PositionKind
  34809. * - VertexBuffer.UVKind
  34810. * - VertexBuffer.UV2Kind
  34811. * - VertexBuffer.UV3Kind
  34812. * - VertexBuffer.UV4Kind
  34813. * - VertexBuffer.UV5Kind
  34814. * - VertexBuffer.UV6Kind
  34815. * - VertexBuffer.ColorKind
  34816. * - VertexBuffer.MatricesIndicesKind
  34817. * - VertexBuffer.MatricesIndicesExtraKind
  34818. * - VertexBuffer.MatricesWeightsKind
  34819. * - VertexBuffer.MatricesWeightsExtraKind
  34820. * @param data defines the data source
  34821. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34822. * @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)
  34823. * @returns the current mesh
  34824. */
  34825. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34826. /**
  34827. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34828. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34829. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34830. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34831. * @returns the current mesh
  34832. */
  34833. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34834. /**
  34835. * Creates a un-shared specific occurence of the geometry for the mesh.
  34836. * @returns the current mesh
  34837. */
  34838. makeGeometryUnique(): Mesh;
  34839. /**
  34840. * Set the index buffer of this mesh
  34841. * @param indices defines the source data
  34842. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34843. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34844. * @returns the current mesh
  34845. */
  34846. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34847. /**
  34848. * Update the current index buffer
  34849. * @param indices defines the source data
  34850. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34851. * @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)
  34852. * @returns the current mesh
  34853. */
  34854. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34855. /**
  34856. * Invert the geometry to move from a right handed system to a left handed one.
  34857. * @returns the current mesh
  34858. */
  34859. toLeftHanded(): Mesh;
  34860. /** @hidden */
  34861. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34862. /** @hidden */
  34863. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34864. /**
  34865. * Registers for this mesh a javascript function called just before the rendering process
  34866. * @param func defines the function to call before rendering this mesh
  34867. * @returns the current mesh
  34868. */
  34869. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34870. /**
  34871. * Disposes a previously registered javascript function called before the rendering
  34872. * @param func defines the function to remove
  34873. * @returns the current mesh
  34874. */
  34875. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34876. /**
  34877. * Registers for this mesh a javascript function called just after the rendering is complete
  34878. * @param func defines the function to call after rendering this mesh
  34879. * @returns the current mesh
  34880. */
  34881. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34882. /**
  34883. * Disposes a previously registered javascript function called after the rendering.
  34884. * @param func defines the function to remove
  34885. * @returns the current mesh
  34886. */
  34887. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34888. /** @hidden */
  34889. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34890. /** @hidden */
  34891. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34892. /** @hidden */
  34893. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34894. /** @hidden */
  34895. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34896. /** @hidden */
  34897. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34898. /** @hidden */
  34899. _rebuild(): void;
  34900. /** @hidden */
  34901. _freeze(): void;
  34902. /** @hidden */
  34903. _unFreeze(): void;
  34904. /**
  34905. * 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
  34906. * @param subMesh defines the subMesh to render
  34907. * @param enableAlphaMode defines if alpha mode can be changed
  34908. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34909. * @returns the current mesh
  34910. */
  34911. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34912. private _onBeforeDraw;
  34913. /**
  34914. * Renormalize the mesh and patch it up if there are no weights
  34915. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34916. * However in the case of zero weights then we set just a single influence to 1.
  34917. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34918. */
  34919. cleanMatrixWeights(): void;
  34920. private normalizeSkinFourWeights;
  34921. private normalizeSkinWeightsAndExtra;
  34922. /**
  34923. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34924. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34925. * the user know there was an issue with importing the mesh
  34926. * @returns a validation object with skinned, valid and report string
  34927. */
  34928. validateSkinning(): {
  34929. skinned: boolean;
  34930. valid: boolean;
  34931. report: string;
  34932. };
  34933. /** @hidden */
  34934. _checkDelayState(): Mesh;
  34935. private _queueLoad;
  34936. /**
  34937. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34938. * A mesh is in the frustum if its bounding box intersects the frustum
  34939. * @param frustumPlanes defines the frustum to test
  34940. * @returns true if the mesh is in the frustum planes
  34941. */
  34942. isInFrustum(frustumPlanes: Plane[]): boolean;
  34943. /**
  34944. * Sets the mesh material by the material or multiMaterial `id` property
  34945. * @param id is a string identifying the material or the multiMaterial
  34946. * @returns the current mesh
  34947. */
  34948. setMaterialByID(id: string): Mesh;
  34949. /**
  34950. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34951. * @returns an array of IAnimatable
  34952. */
  34953. getAnimatables(): IAnimatable[];
  34954. /**
  34955. * Modifies the mesh geometry according to the passed transformation matrix.
  34956. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34957. * The mesh normals are modified using the same transformation.
  34958. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34959. * @param transform defines the transform matrix to use
  34960. * @see https://doc.babylonjs.com/resources/baking_transformations
  34961. * @returns the current mesh
  34962. */
  34963. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34964. /**
  34965. * Modifies the mesh geometry according to its own current World Matrix.
  34966. * The mesh World Matrix is then reset.
  34967. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34968. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34969. * @see https://doc.babylonjs.com/resources/baking_transformations
  34970. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34971. * @returns the current mesh
  34972. */
  34973. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34974. /** @hidden */
  34975. get _positions(): Nullable<Vector3[]>;
  34976. /** @hidden */
  34977. _resetPointsArrayCache(): Mesh;
  34978. /** @hidden */
  34979. _generatePointsArray(): boolean;
  34980. /**
  34981. * Returns a new Mesh object generated from the current mesh properties.
  34982. * This method must not get confused with createInstance()
  34983. * @param name is a string, the name given to the new mesh
  34984. * @param newParent can be any Node object (default `null`)
  34985. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34986. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34987. * @returns a new mesh
  34988. */
  34989. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34990. /**
  34991. * Releases resources associated with this mesh.
  34992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34994. */
  34995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34996. /** @hidden */
  34997. _disposeInstanceSpecificData(): void;
  34998. /** @hidden */
  34999. _disposeThinInstanceSpecificData(): void;
  35000. /**
  35001. * Modifies the mesh geometry according to a displacement map.
  35002. * 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.
  35003. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35004. * @param url is a string, the URL from the image file is to be downloaded.
  35005. * @param minHeight is the lower limit of the displacement.
  35006. * @param maxHeight is the upper limit of the displacement.
  35007. * @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.
  35008. * @param uvOffset is an optional vector2 used to offset UV.
  35009. * @param uvScale is an optional vector2 used to scale UV.
  35010. * @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.
  35011. * @returns the Mesh.
  35012. */
  35013. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35014. /**
  35015. * Modifies the mesh geometry according to a displacementMap buffer.
  35016. * 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.
  35017. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35018. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  35019. * @param heightMapWidth is the width of the buffer image.
  35020. * @param heightMapHeight is the height of the buffer image.
  35021. * @param minHeight is the lower limit of the displacement.
  35022. * @param maxHeight is the upper limit of the displacement.
  35023. * @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.
  35024. * @param uvOffset is an optional vector2 used to offset UV.
  35025. * @param uvScale is an optional vector2 used to scale UV.
  35026. * @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.
  35027. * @returns the Mesh.
  35028. */
  35029. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35030. /**
  35031. * Modify the mesh to get a flat shading rendering.
  35032. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  35033. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  35034. * @returns current mesh
  35035. */
  35036. convertToFlatShadedMesh(): Mesh;
  35037. /**
  35038. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  35039. * In other words, more vertices, no more indices and a single bigger VBO.
  35040. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  35041. * @returns current mesh
  35042. */
  35043. convertToUnIndexedMesh(): Mesh;
  35044. /**
  35045. * Inverses facet orientations.
  35046. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35047. * @param flipNormals will also inverts the normals
  35048. * @returns current mesh
  35049. */
  35050. flipFaces(flipNormals?: boolean): Mesh;
  35051. /**
  35052. * Increase the number of facets and hence vertices in a mesh
  35053. * Vertex normals are interpolated from existing vertex normals
  35054. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35055. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  35056. */
  35057. increaseVertices(numberPerEdge: number): void;
  35058. /**
  35059. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  35060. * This will undo any application of covertToFlatShadedMesh
  35061. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35062. */
  35063. forceSharedVertices(): void;
  35064. /** @hidden */
  35065. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  35066. /** @hidden */
  35067. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  35068. /**
  35069. * Creates a new InstancedMesh object from the mesh model.
  35070. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  35071. * @param name defines the name of the new instance
  35072. * @returns a new InstancedMesh
  35073. */
  35074. createInstance(name: string): InstancedMesh;
  35075. /**
  35076. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  35077. * After this call, all the mesh instances have the same submeshes than the current mesh.
  35078. * @returns the current mesh
  35079. */
  35080. synchronizeInstances(): Mesh;
  35081. /**
  35082. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  35083. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  35084. * This should be used together with the simplification to avoid disappearing triangles.
  35085. * @param successCallback an optional success callback to be called after the optimization finished.
  35086. * @returns the current mesh
  35087. */
  35088. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  35089. /**
  35090. * Serialize current mesh
  35091. * @param serializationObject defines the object which will receive the serialization data
  35092. */
  35093. serialize(serializationObject: any): void;
  35094. /** @hidden */
  35095. _syncGeometryWithMorphTargetManager(): void;
  35096. /** @hidden */
  35097. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  35098. /**
  35099. * Returns a new Mesh object parsed from the source provided.
  35100. * @param parsedMesh is the source
  35101. * @param scene defines the hosting scene
  35102. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  35103. * @returns a new Mesh
  35104. */
  35105. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  35106. /**
  35107. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  35108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35109. * @param name defines the name of the mesh to create
  35110. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  35111. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  35112. * @param closePath creates a seam between the first and the last points of each path of the path array
  35113. * @param offset is taken in account only if the `pathArray` is containing a single path
  35114. * @param scene defines the hosting scene
  35115. * @param updatable defines if the mesh must be flagged as updatable
  35116. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35117. * @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)
  35118. * @returns a new Mesh
  35119. */
  35120. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35121. /**
  35122. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  35123. * @param name defines the name of the mesh to create
  35124. * @param radius sets the radius size (float) of the polygon (default 0.5)
  35125. * @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
  35126. * @param scene defines the hosting scene
  35127. * @param updatable defines if the mesh must be flagged as updatable
  35128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35129. * @returns a new Mesh
  35130. */
  35131. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35132. /**
  35133. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  35134. * @param name defines the name of the mesh to create
  35135. * @param size sets the size (float) of each box side (default 1)
  35136. * @param scene defines the hosting scene
  35137. * @param updatable defines if the mesh must be flagged as updatable
  35138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35139. * @returns a new Mesh
  35140. */
  35141. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35142. /**
  35143. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  35144. * @param name defines the name of the mesh to create
  35145. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35146. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35147. * @param scene defines the hosting scene
  35148. * @param updatable defines if the mesh must be flagged as updatable
  35149. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35150. * @returns a new Mesh
  35151. */
  35152. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35153. /**
  35154. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  35155. * @param name defines the name of the mesh to create
  35156. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35157. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35158. * @param scene defines the hosting scene
  35159. * @returns a new Mesh
  35160. */
  35161. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  35162. /**
  35163. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  35164. * @param name defines the name of the mesh to create
  35165. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  35166. * @param diameterTop set the top cap diameter (floats, default 1)
  35167. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  35168. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  35169. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  35170. * @param scene defines the hosting scene
  35171. * @param updatable defines if the mesh must be flagged as updatable
  35172. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35173. * @returns a new Mesh
  35174. */
  35175. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  35176. /**
  35177. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  35178. * @param name defines the name of the mesh to create
  35179. * @param diameter sets the diameter size (float) of the torus (default 1)
  35180. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  35181. * @param tessellation sets the number of torus sides (postive integer, default 16)
  35182. * @param scene defines the hosting scene
  35183. * @param updatable defines if the mesh must be flagged as updatable
  35184. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35185. * @returns a new Mesh
  35186. */
  35187. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35188. /**
  35189. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  35190. * @param name defines the name of the mesh to create
  35191. * @param radius sets the global radius size (float) of the torus knot (default 2)
  35192. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  35193. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  35194. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  35195. * @param p the number of windings on X axis (positive integers, default 2)
  35196. * @param q the number of windings on Y axis (positive integers, default 3)
  35197. * @param scene defines the hosting scene
  35198. * @param updatable defines if the mesh must be flagged as updatable
  35199. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35200. * @returns a new Mesh
  35201. */
  35202. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35203. /**
  35204. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  35205. * @param name defines the name of the mesh to create
  35206. * @param points is an array successive Vector3
  35207. * @param scene defines the hosting scene
  35208. * @param updatable defines if the mesh must be flagged as updatable
  35209. * @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).
  35210. * @returns a new Mesh
  35211. */
  35212. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  35213. /**
  35214. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  35215. * @param name defines the name of the mesh to create
  35216. * @param points is an array successive Vector3
  35217. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  35218. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  35219. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  35220. * @param scene defines the hosting scene
  35221. * @param updatable defines if the mesh must be flagged as updatable
  35222. * @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)
  35223. * @returns a new Mesh
  35224. */
  35225. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  35226. /**
  35227. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  35228. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  35229. * 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.
  35230. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35231. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  35232. * Remember you can only change the shape positions, not their number when updating a polygon.
  35233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  35234. * @param name defines the name of the mesh to create
  35235. * @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
  35236. * @param scene defines the hosting scene
  35237. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35238. * @param updatable defines if the mesh must be flagged as updatable
  35239. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35240. * @param earcutInjection can be used to inject your own earcut reference
  35241. * @returns a new Mesh
  35242. */
  35243. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35244. /**
  35245. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  35246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  35247. * @param name defines the name of the mesh to create
  35248. * @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
  35249. * @param depth defines the height of extrusion
  35250. * @param scene defines the hosting scene
  35251. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35252. * @param updatable defines if the mesh must be flagged as updatable
  35253. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35254. * @param earcutInjection can be used to inject your own earcut reference
  35255. * @returns a new Mesh
  35256. */
  35257. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35258. /**
  35259. * Creates an extruded shape mesh.
  35260. * 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
  35261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35263. * @param name defines the name of the mesh to create
  35264. * @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
  35265. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35266. * @param scale is the value to scale the shape
  35267. * @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
  35268. * @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
  35269. * @param scene defines the hosting scene
  35270. * @param updatable defines if the mesh must be flagged as updatable
  35271. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35272. * @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)
  35273. * @returns a new Mesh
  35274. */
  35275. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35276. /**
  35277. * Creates an custom extruded shape mesh.
  35278. * The custom extrusion is a parametric shape.
  35279. * It has no predefined shape. Its final shape will depend on the input parameters.
  35280. * Please consider using the same method from the MeshBuilder class instead
  35281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35282. * @param name defines the name of the mesh to create
  35283. * @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
  35284. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35285. * @param scaleFunction is a custom Javascript function called on each path point
  35286. * @param rotationFunction is a custom Javascript function called on each path point
  35287. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  35288. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  35289. * @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
  35290. * @param scene defines the hosting scene
  35291. * @param updatable defines if the mesh must be flagged as updatable
  35292. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35293. * @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)
  35294. * @returns a new Mesh
  35295. */
  35296. 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;
  35297. /**
  35298. * Creates lathe mesh.
  35299. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35300. * Please consider using the same method from the MeshBuilder class instead
  35301. * @param name defines the name of the mesh to create
  35302. * @param 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
  35303. * @param radius is the radius value of the lathe
  35304. * @param tessellation is the side number of the lathe.
  35305. * @param scene defines the hosting scene
  35306. * @param updatable defines if the mesh must be flagged as updatable
  35307. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35308. * @returns a new Mesh
  35309. */
  35310. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35311. /**
  35312. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35313. * @param name defines the name of the mesh to create
  35314. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35315. * @param scene defines the hosting scene
  35316. * @param updatable defines if the mesh must be flagged as updatable
  35317. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35318. * @returns a new Mesh
  35319. */
  35320. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35321. /**
  35322. * Creates a ground mesh.
  35323. * Please consider using the same method from the MeshBuilder class instead
  35324. * @param name defines the name of the mesh to create
  35325. * @param width set the width of the ground
  35326. * @param height set the height of the ground
  35327. * @param subdivisions sets the number of subdivisions per side
  35328. * @param scene defines the hosting scene
  35329. * @param updatable defines if the mesh must be flagged as updatable
  35330. * @returns a new Mesh
  35331. */
  35332. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35333. /**
  35334. * Creates a tiled ground mesh.
  35335. * Please consider using the same method from the MeshBuilder class instead
  35336. * @param name defines the name of the mesh to create
  35337. * @param xmin set the ground minimum X coordinate
  35338. * @param zmin set the ground minimum Y coordinate
  35339. * @param xmax set the ground maximum X coordinate
  35340. * @param zmax set the ground maximum Z coordinate
  35341. * @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
  35342. * @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
  35343. * @param scene defines the hosting scene
  35344. * @param updatable defines if the mesh must be flagged as updatable
  35345. * @returns a new Mesh
  35346. */
  35347. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35348. w: number;
  35349. h: number;
  35350. }, precision: {
  35351. w: number;
  35352. h: number;
  35353. }, scene: Scene, updatable?: boolean): Mesh;
  35354. /**
  35355. * Creates a ground mesh from a height map.
  35356. * Please consider using the same method from the MeshBuilder class instead
  35357. * @see https://doc.babylonjs.com/babylon101/height_map
  35358. * @param name defines the name of the mesh to create
  35359. * @param url sets the URL of the height map image resource
  35360. * @param width set the ground width size
  35361. * @param height set the ground height size
  35362. * @param subdivisions sets the number of subdivision per side
  35363. * @param minHeight is the minimum altitude on the ground
  35364. * @param maxHeight is the maximum altitude on the ground
  35365. * @param scene defines the hosting scene
  35366. * @param updatable defines if the mesh must be flagged as updatable
  35367. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35368. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35369. * @returns a new Mesh
  35370. */
  35371. 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;
  35372. /**
  35373. * Creates a tube mesh.
  35374. * The tube is a parametric shape.
  35375. * It has no predefined shape. Its final shape will depend on the input parameters.
  35376. * Please consider using the same method from the MeshBuilder class instead
  35377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35378. * @param name defines the name of the mesh to create
  35379. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35380. * @param radius sets the tube radius size
  35381. * @param tessellation is the number of sides on the tubular surface
  35382. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  35383. * @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
  35384. * @param scene defines the hosting scene
  35385. * @param updatable defines if the mesh must be flagged as updatable
  35386. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35387. * @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)
  35388. * @returns a new Mesh
  35389. */
  35390. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35391. (i: number, distance: number): number;
  35392. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35393. /**
  35394. * Creates a polyhedron mesh.
  35395. * Please consider using the same method from the MeshBuilder class instead.
  35396. * * 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
  35397. * * The parameter `size` (positive float, default 1) sets the polygon size
  35398. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35399. * * 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`
  35400. * * 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
  35401. * * 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)`)
  35402. * * 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
  35403. * * 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
  35404. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35407. * @param name defines the name of the mesh to create
  35408. * @param options defines the options used to create the mesh
  35409. * @param scene defines the hosting scene
  35410. * @returns a new Mesh
  35411. */
  35412. static CreatePolyhedron(name: string, options: {
  35413. type?: number;
  35414. size?: number;
  35415. sizeX?: number;
  35416. sizeY?: number;
  35417. sizeZ?: number;
  35418. custom?: any;
  35419. faceUV?: Vector4[];
  35420. faceColors?: Color4[];
  35421. updatable?: boolean;
  35422. sideOrientation?: number;
  35423. }, scene: Scene): Mesh;
  35424. /**
  35425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35427. * * 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`)
  35428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35429. * * 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
  35430. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35433. * @param name defines the name of the mesh
  35434. * @param options defines the options used to create the mesh
  35435. * @param scene defines the hosting scene
  35436. * @returns a new Mesh
  35437. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35438. */
  35439. static CreateIcoSphere(name: string, options: {
  35440. radius?: number;
  35441. flat?: boolean;
  35442. subdivisions?: number;
  35443. sideOrientation?: number;
  35444. updatable?: boolean;
  35445. }, scene: Scene): Mesh;
  35446. /**
  35447. * Creates a decal mesh.
  35448. * Please consider using the same method from the MeshBuilder class instead.
  35449. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35450. * @param name defines the name of the mesh
  35451. * @param sourceMesh defines the mesh receiving the decal
  35452. * @param position sets the position of the decal in world coordinates
  35453. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35454. * @param size sets the decal scaling
  35455. * @param angle sets the angle to rotate the decal
  35456. * @returns a new Mesh
  35457. */
  35458. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35459. /** Creates a Capsule Mesh
  35460. * @param name defines the name of the mesh.
  35461. * @param options the constructors options used to shape the mesh.
  35462. * @param scene defines the scene the mesh is scoped to.
  35463. * @returns the capsule mesh
  35464. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35465. */
  35466. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35467. /**
  35468. * Prepare internal position array for software CPU skinning
  35469. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35470. */
  35471. setPositionsForCPUSkinning(): Float32Array;
  35472. /**
  35473. * Prepare internal normal array for software CPU skinning
  35474. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35475. */
  35476. setNormalsForCPUSkinning(): Float32Array;
  35477. /**
  35478. * Updates the vertex buffer by applying transformation from the bones
  35479. * @param skeleton defines the skeleton to apply to current mesh
  35480. * @returns the current mesh
  35481. */
  35482. applySkeleton(skeleton: Skeleton): Mesh;
  35483. /**
  35484. * 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
  35485. * @param meshes defines the list of meshes to scan
  35486. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35487. */
  35488. static MinMax(meshes: AbstractMesh[]): {
  35489. min: Vector3;
  35490. max: Vector3;
  35491. };
  35492. /**
  35493. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35494. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35495. * @returns a vector3
  35496. */
  35497. static Center(meshesOrMinMaxVector: {
  35498. min: Vector3;
  35499. max: Vector3;
  35500. } | AbstractMesh[]): Vector3;
  35501. /**
  35502. * Merge the array of meshes into a single mesh for performance reasons.
  35503. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35504. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35505. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35506. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35507. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35508. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35509. * @returns a new mesh
  35510. */
  35511. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35512. /** @hidden */
  35513. addInstance(instance: InstancedMesh): void;
  35514. /** @hidden */
  35515. removeInstance(instance: InstancedMesh): void;
  35516. }
  35517. }
  35518. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  35519. import { Vector3 } from "babylonjs/Maths/math.vector";
  35520. import { Mesh } from "babylonjs/Meshes/mesh";
  35521. /**
  35522. * The options Interface for creating a Capsule Mesh
  35523. */
  35524. export interface ICreateCapsuleOptions {
  35525. /** The Orientation of the capsule. Default : Vector3.Up() */
  35526. orientation?: Vector3;
  35527. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  35528. subdivisions: number;
  35529. /** Number of cylindrical segments on the capsule. */
  35530. tessellation: number;
  35531. /** Height or Length of the capsule. */
  35532. height: number;
  35533. /** Radius of the capsule. */
  35534. radius: number;
  35535. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  35536. capSubdivisions: number;
  35537. /** Overwrite for the top radius. */
  35538. radiusTop?: number;
  35539. /** Overwrite for the bottom radius. */
  35540. radiusBottom?: number;
  35541. /** Overwrite for the top capSubdivisions. */
  35542. topCapSubdivisions?: number;
  35543. /** Overwrite for the bottom capSubdivisions. */
  35544. bottomCapSubdivisions?: number;
  35545. }
  35546. /**
  35547. * Class containing static functions to help procedurally build meshes
  35548. */
  35549. export class CapsuleBuilder {
  35550. /**
  35551. * Creates a capsule or a pill mesh
  35552. * @param name defines the name of the mesh
  35553. * @param options The constructors options.
  35554. * @param scene The scene the mesh is scoped to.
  35555. * @returns Capsule Mesh
  35556. */
  35557. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  35558. }
  35559. }
  35560. declare module "babylonjs/Meshes/mesh.vertexData" {
  35561. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  35562. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  35563. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35564. import { Geometry } from "babylonjs/Meshes/geometry";
  35565. import { Mesh } from "babylonjs/Meshes/mesh";
  35566. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  35567. /**
  35568. * Define an interface for all classes that will get and set the data on vertices
  35569. */
  35570. export interface IGetSetVerticesData {
  35571. /**
  35572. * Gets a boolean indicating if specific vertex data is present
  35573. * @param kind defines the vertex data kind to use
  35574. * @returns true is data kind is present
  35575. */
  35576. isVerticesDataPresent(kind: string): boolean;
  35577. /**
  35578. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  35579. * @param kind defines the data kind (Position, normal, etc...)
  35580. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  35581. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35582. * @returns a float array containing vertex data
  35583. */
  35584. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  35585. /**
  35586. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35587. * @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.
  35588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35589. * @returns the indices array or an empty array if the mesh has no geometry
  35590. */
  35591. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35592. /**
  35593. * Set specific vertex data
  35594. * @param kind defines the data kind (Position, normal, etc...)
  35595. * @param data defines the vertex data to use
  35596. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  35597. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  35598. */
  35599. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  35600. /**
  35601. * Update a specific associated vertex buffer
  35602. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35603. * - VertexBuffer.PositionKind
  35604. * - VertexBuffer.UVKind
  35605. * - VertexBuffer.UV2Kind
  35606. * - VertexBuffer.UV3Kind
  35607. * - VertexBuffer.UV4Kind
  35608. * - VertexBuffer.UV5Kind
  35609. * - VertexBuffer.UV6Kind
  35610. * - VertexBuffer.ColorKind
  35611. * - VertexBuffer.MatricesIndicesKind
  35612. * - VertexBuffer.MatricesIndicesExtraKind
  35613. * - VertexBuffer.MatricesWeightsKind
  35614. * - VertexBuffer.MatricesWeightsExtraKind
  35615. * @param data defines the data source
  35616. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  35617. * @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)
  35618. */
  35619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  35620. /**
  35621. * Creates a new index buffer
  35622. * @param indices defines the indices to store in the index buffer
  35623. * @param totalVertices defines the total number of vertices (could be null)
  35624. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  35625. */
  35626. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  35627. }
  35628. /**
  35629. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  35630. */
  35631. export class VertexData {
  35632. /**
  35633. * Mesh side orientation : usually the external or front surface
  35634. */
  35635. static readonly FRONTSIDE: number;
  35636. /**
  35637. * Mesh side orientation : usually the internal or back surface
  35638. */
  35639. static readonly BACKSIDE: number;
  35640. /**
  35641. * Mesh side orientation : both internal and external or front and back surfaces
  35642. */
  35643. static readonly DOUBLESIDE: number;
  35644. /**
  35645. * Mesh side orientation : by default, `FRONTSIDE`
  35646. */
  35647. static readonly DEFAULTSIDE: number;
  35648. /**
  35649. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  35650. */
  35651. positions: Nullable<FloatArray>;
  35652. /**
  35653. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  35654. */
  35655. normals: Nullable<FloatArray>;
  35656. /**
  35657. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  35658. */
  35659. tangents: Nullable<FloatArray>;
  35660. /**
  35661. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35662. */
  35663. uvs: Nullable<FloatArray>;
  35664. /**
  35665. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35666. */
  35667. uvs2: Nullable<FloatArray>;
  35668. /**
  35669. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35670. */
  35671. uvs3: Nullable<FloatArray>;
  35672. /**
  35673. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35674. */
  35675. uvs4: Nullable<FloatArray>;
  35676. /**
  35677. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35678. */
  35679. uvs5: Nullable<FloatArray>;
  35680. /**
  35681. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35682. */
  35683. uvs6: Nullable<FloatArray>;
  35684. /**
  35685. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35686. */
  35687. colors: Nullable<FloatArray>;
  35688. /**
  35689. * 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).
  35690. */
  35691. matricesIndices: Nullable<FloatArray>;
  35692. /**
  35693. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35694. */
  35695. matricesWeights: Nullable<FloatArray>;
  35696. /**
  35697. * An array extending the number of possible indices
  35698. */
  35699. matricesIndicesExtra: Nullable<FloatArray>;
  35700. /**
  35701. * An array extending the number of possible weights when the number of indices is extended
  35702. */
  35703. matricesWeightsExtra: Nullable<FloatArray>;
  35704. /**
  35705. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35706. */
  35707. indices: Nullable<IndicesArray>;
  35708. /**
  35709. * Uses the passed data array to set the set the values for the specified kind of data
  35710. * @param data a linear array of floating numbers
  35711. * @param kind the type of data that is being set, eg positions, colors etc
  35712. */
  35713. set(data: FloatArray, kind: string): void;
  35714. /**
  35715. * Associates the vertexData to the passed Mesh.
  35716. * Sets it as updatable or not (default `false`)
  35717. * @param mesh the mesh the vertexData is applied to
  35718. * @param updatable when used and having the value true allows new data to update the vertexData
  35719. * @returns the VertexData
  35720. */
  35721. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35722. /**
  35723. * Associates the vertexData to the passed Geometry.
  35724. * Sets it as updatable or not (default `false`)
  35725. * @param geometry the geometry the vertexData is applied to
  35726. * @param updatable when used and having the value true allows new data to update the vertexData
  35727. * @returns VertexData
  35728. */
  35729. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35730. /**
  35731. * Updates the associated mesh
  35732. * @param mesh the mesh to be updated
  35733. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35734. * @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
  35735. * @returns VertexData
  35736. */
  35737. updateMesh(mesh: Mesh): VertexData;
  35738. /**
  35739. * Updates the associated geometry
  35740. * @param geometry the geometry to be updated
  35741. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35742. * @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
  35743. * @returns VertexData.
  35744. */
  35745. updateGeometry(geometry: Geometry): VertexData;
  35746. private _applyTo;
  35747. private _update;
  35748. /**
  35749. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35750. * @param matrix the transforming matrix
  35751. * @returns the VertexData
  35752. */
  35753. transform(matrix: Matrix): VertexData;
  35754. /**
  35755. * Merges the passed VertexData into the current one
  35756. * @param other the VertexData to be merged into the current one
  35757. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35758. * @returns the modified VertexData
  35759. */
  35760. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35761. private _mergeElement;
  35762. private _validate;
  35763. /**
  35764. * Serializes the VertexData
  35765. * @returns a serialized object
  35766. */
  35767. serialize(): any;
  35768. /**
  35769. * Extracts the vertexData from a mesh
  35770. * @param mesh the mesh from which to extract the VertexData
  35771. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35772. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35773. * @returns the object VertexData associated to the passed mesh
  35774. */
  35775. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35776. /**
  35777. * Extracts the vertexData from the geometry
  35778. * @param geometry the geometry from which to extract the VertexData
  35779. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  35780. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35781. * @returns the object VertexData associated to the passed mesh
  35782. */
  35783. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35784. private static _ExtractFrom;
  35785. /**
  35786. * Creates the VertexData for a Ribbon
  35787. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35788. * * pathArray array of paths, each of which an array of successive Vector3
  35789. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35790. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35791. * * 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
  35792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35793. * * 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)
  35794. * * 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)
  35795. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35796. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35797. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35798. * @returns the VertexData of the ribbon
  35799. */
  35800. static CreateRibbon(options: {
  35801. pathArray: Vector3[][];
  35802. closeArray?: boolean;
  35803. closePath?: boolean;
  35804. offset?: number;
  35805. sideOrientation?: number;
  35806. frontUVs?: Vector4;
  35807. backUVs?: Vector4;
  35808. invertUV?: boolean;
  35809. uvs?: Vector2[];
  35810. colors?: Color4[];
  35811. }): VertexData;
  35812. /**
  35813. * Creates the VertexData for a box
  35814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35815. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35816. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35817. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35818. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35819. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35820. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35822. * * 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)
  35823. * * 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)
  35824. * @returns the VertexData of the box
  35825. */
  35826. static CreateBox(options: {
  35827. size?: number;
  35828. width?: number;
  35829. height?: number;
  35830. depth?: number;
  35831. faceUV?: Vector4[];
  35832. faceColors?: Color4[];
  35833. sideOrientation?: number;
  35834. frontUVs?: Vector4;
  35835. backUVs?: Vector4;
  35836. }): VertexData;
  35837. /**
  35838. * Creates the VertexData for a tiled box
  35839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35840. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35841. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35842. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35844. * @returns the VertexData of the box
  35845. */
  35846. static CreateTiledBox(options: {
  35847. pattern?: number;
  35848. width?: number;
  35849. height?: number;
  35850. depth?: number;
  35851. tileSize?: number;
  35852. tileWidth?: number;
  35853. tileHeight?: number;
  35854. alignHorizontal?: number;
  35855. alignVertical?: number;
  35856. faceUV?: Vector4[];
  35857. faceColors?: Color4[];
  35858. sideOrientation?: number;
  35859. }): VertexData;
  35860. /**
  35861. * Creates the VertexData for a tiled plane
  35862. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35863. * * pattern a limited pattern arrangement depending on the number
  35864. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35865. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35866. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35868. * * 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)
  35869. * * 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)
  35870. * @returns the VertexData of the tiled plane
  35871. */
  35872. static CreateTiledPlane(options: {
  35873. pattern?: number;
  35874. tileSize?: number;
  35875. tileWidth?: number;
  35876. tileHeight?: number;
  35877. size?: number;
  35878. width?: number;
  35879. height?: number;
  35880. alignHorizontal?: number;
  35881. alignVertical?: number;
  35882. sideOrientation?: number;
  35883. frontUVs?: Vector4;
  35884. backUVs?: Vector4;
  35885. }): VertexData;
  35886. /**
  35887. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35888. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35889. * * segments sets the number of horizontal strips optional, default 32
  35890. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35891. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35892. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35893. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35894. * * 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
  35895. * * 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
  35896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35897. * * 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)
  35898. * * 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)
  35899. * @returns the VertexData of the ellipsoid
  35900. */
  35901. static CreateSphere(options: {
  35902. segments?: number;
  35903. diameter?: number;
  35904. diameterX?: number;
  35905. diameterY?: number;
  35906. diameterZ?: number;
  35907. arc?: number;
  35908. slice?: number;
  35909. sideOrientation?: number;
  35910. frontUVs?: Vector4;
  35911. backUVs?: Vector4;
  35912. }): VertexData;
  35913. /**
  35914. * Creates the VertexData for a cylinder, cone or prism
  35915. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35916. * * height sets the height (y direction) of the cylinder, optional, default 2
  35917. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35918. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35919. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35920. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35921. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35922. * * 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
  35923. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35924. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35925. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35926. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35928. * * 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)
  35929. * * 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)
  35930. * @returns the VertexData of the cylinder, cone or prism
  35931. */
  35932. static CreateCylinder(options: {
  35933. height?: number;
  35934. diameterTop?: number;
  35935. diameterBottom?: number;
  35936. diameter?: number;
  35937. tessellation?: number;
  35938. subdivisions?: number;
  35939. arc?: number;
  35940. faceColors?: Color4[];
  35941. faceUV?: Vector4[];
  35942. hasRings?: boolean;
  35943. enclose?: boolean;
  35944. sideOrientation?: number;
  35945. frontUVs?: Vector4;
  35946. backUVs?: Vector4;
  35947. }): VertexData;
  35948. /**
  35949. * Creates the VertexData for a torus
  35950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35951. * * diameter the diameter of the torus, optional default 1
  35952. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35953. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35955. * * 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)
  35956. * * 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)
  35957. * @returns the VertexData of the torus
  35958. */
  35959. static CreateTorus(options: {
  35960. diameter?: number;
  35961. thickness?: number;
  35962. tessellation?: number;
  35963. sideOrientation?: number;
  35964. frontUVs?: Vector4;
  35965. backUVs?: Vector4;
  35966. }): VertexData;
  35967. /**
  35968. * Creates the VertexData of the LineSystem
  35969. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35970. * - lines an array of lines, each line being an array of successive Vector3
  35971. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35972. * @returns the VertexData of the LineSystem
  35973. */
  35974. static CreateLineSystem(options: {
  35975. lines: Vector3[][];
  35976. colors?: Nullable<Color4[][]>;
  35977. }): VertexData;
  35978. /**
  35979. * Create the VertexData for a DashedLines
  35980. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35981. * - points an array successive Vector3
  35982. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35983. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35984. * - dashNb the intended total number of dashes, optional, default 200
  35985. * @returns the VertexData for the DashedLines
  35986. */
  35987. static CreateDashedLines(options: {
  35988. points: Vector3[];
  35989. dashSize?: number;
  35990. gapSize?: number;
  35991. dashNb?: number;
  35992. }): VertexData;
  35993. /**
  35994. * Creates the VertexData for a Ground
  35995. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35996. * - width the width (x direction) of the ground, optional, default 1
  35997. * - height the height (z direction) of the ground, optional, default 1
  35998. * - subdivisions the number of subdivisions per side, optional, default 1
  35999. * @returns the VertexData of the Ground
  36000. */
  36001. static CreateGround(options: {
  36002. width?: number;
  36003. height?: number;
  36004. subdivisions?: number;
  36005. subdivisionsX?: number;
  36006. subdivisionsY?: number;
  36007. }): VertexData;
  36008. /**
  36009. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  36010. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  36011. * * xmin the ground minimum X coordinate, optional, default -1
  36012. * * zmin the ground minimum Z coordinate, optional, default -1
  36013. * * xmax the ground maximum X coordinate, optional, default 1
  36014. * * zmax the ground maximum Z coordinate, optional, default 1
  36015. * * 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}
  36016. * * 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}
  36017. * @returns the VertexData of the TiledGround
  36018. */
  36019. static CreateTiledGround(options: {
  36020. xmin: number;
  36021. zmin: number;
  36022. xmax: number;
  36023. zmax: number;
  36024. subdivisions?: {
  36025. w: number;
  36026. h: number;
  36027. };
  36028. precision?: {
  36029. w: number;
  36030. h: number;
  36031. };
  36032. }): VertexData;
  36033. /**
  36034. * Creates the VertexData of the Ground designed from a heightmap
  36035. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  36036. * * width the width (x direction) of the ground
  36037. * * height the height (z direction) of the ground
  36038. * * subdivisions the number of subdivisions per side
  36039. * * minHeight the minimum altitude on the ground, optional, default 0
  36040. * * maxHeight the maximum altitude on the ground, optional default 1
  36041. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  36042. * * buffer the array holding the image color data
  36043. * * bufferWidth the width of image
  36044. * * bufferHeight the height of image
  36045. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  36046. * @returns the VertexData of the Ground designed from a heightmap
  36047. */
  36048. static CreateGroundFromHeightMap(options: {
  36049. width: number;
  36050. height: number;
  36051. subdivisions: number;
  36052. minHeight: number;
  36053. maxHeight: number;
  36054. colorFilter: Color3;
  36055. buffer: Uint8Array;
  36056. bufferWidth: number;
  36057. bufferHeight: number;
  36058. alphaFilter: number;
  36059. }): VertexData;
  36060. /**
  36061. * Creates the VertexData for a Plane
  36062. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  36063. * * size sets the width and height of the plane to the value of size, optional default 1
  36064. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  36065. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  36066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36067. * * 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)
  36068. * * 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)
  36069. * @returns the VertexData of the box
  36070. */
  36071. static CreatePlane(options: {
  36072. size?: number;
  36073. width?: number;
  36074. height?: number;
  36075. sideOrientation?: number;
  36076. frontUVs?: Vector4;
  36077. backUVs?: Vector4;
  36078. }): VertexData;
  36079. /**
  36080. * Creates the VertexData of the Disc or regular Polygon
  36081. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  36082. * * radius the radius of the disc, optional default 0.5
  36083. * * tessellation the number of polygon sides, optional, default 64
  36084. * * 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
  36085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36086. * * 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)
  36087. * * 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)
  36088. * @returns the VertexData of the box
  36089. */
  36090. static CreateDisc(options: {
  36091. radius?: number;
  36092. tessellation?: number;
  36093. arc?: number;
  36094. sideOrientation?: number;
  36095. frontUVs?: Vector4;
  36096. backUVs?: Vector4;
  36097. }): VertexData;
  36098. /**
  36099. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  36100. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  36101. * @param polygon a mesh built from polygonTriangulation.build()
  36102. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36103. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36104. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36105. * @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)
  36106. * @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)
  36107. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  36108. * @returns the VertexData of the Polygon
  36109. */
  36110. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  36111. /**
  36112. * Creates the VertexData of the IcoSphere
  36113. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  36114. * * radius the radius of the IcoSphere, optional default 1
  36115. * * radiusX allows stretching in the x direction, optional, default radius
  36116. * * radiusY allows stretching in the y direction, optional, default radius
  36117. * * radiusZ allows stretching in the z direction, optional, default radius
  36118. * * flat when true creates a flat shaded mesh, optional, default true
  36119. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36121. * * 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)
  36122. * * 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)
  36123. * @returns the VertexData of the IcoSphere
  36124. */
  36125. static CreateIcoSphere(options: {
  36126. radius?: number;
  36127. radiusX?: number;
  36128. radiusY?: number;
  36129. radiusZ?: number;
  36130. flat?: boolean;
  36131. subdivisions?: number;
  36132. sideOrientation?: number;
  36133. frontUVs?: Vector4;
  36134. backUVs?: Vector4;
  36135. }): VertexData;
  36136. /**
  36137. * Creates the VertexData for a Polyhedron
  36138. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  36139. * * type provided types are:
  36140. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  36141. * * 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)
  36142. * * size the size of the IcoSphere, optional default 1
  36143. * * sizeX allows stretching in the x direction, optional, default size
  36144. * * sizeY allows stretching in the y direction, optional, default size
  36145. * * sizeZ allows stretching in the z direction, optional, default size
  36146. * * 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
  36147. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36148. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36149. * * flat when true creates a flat shaded mesh, optional, default true
  36150. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36152. * * 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)
  36153. * * 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)
  36154. * @returns the VertexData of the Polyhedron
  36155. */
  36156. static CreatePolyhedron(options: {
  36157. type?: number;
  36158. size?: number;
  36159. sizeX?: number;
  36160. sizeY?: number;
  36161. sizeZ?: number;
  36162. custom?: any;
  36163. faceUV?: Vector4[];
  36164. faceColors?: Color4[];
  36165. flat?: boolean;
  36166. sideOrientation?: number;
  36167. frontUVs?: Vector4;
  36168. backUVs?: Vector4;
  36169. }): VertexData;
  36170. /**
  36171. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  36172. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  36173. * @returns the VertexData of the Capsule
  36174. */
  36175. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  36176. /**
  36177. * Creates the VertexData for a TorusKnot
  36178. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  36179. * * radius the radius of the torus knot, optional, default 2
  36180. * * tube the thickness of the tube, optional, default 0.5
  36181. * * radialSegments the number of sides on each tube segments, optional, default 32
  36182. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  36183. * * p the number of windings around the z axis, optional, default 2
  36184. * * q the number of windings around the x axis, optional, default 3
  36185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36186. * * 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)
  36187. * * 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)
  36188. * @returns the VertexData of the Torus Knot
  36189. */
  36190. static CreateTorusKnot(options: {
  36191. radius?: number;
  36192. tube?: number;
  36193. radialSegments?: number;
  36194. tubularSegments?: number;
  36195. p?: number;
  36196. q?: number;
  36197. sideOrientation?: number;
  36198. frontUVs?: Vector4;
  36199. backUVs?: Vector4;
  36200. }): VertexData;
  36201. /**
  36202. * Compute normals for given positions and indices
  36203. * @param positions an array of vertex positions, [...., x, y, z, ......]
  36204. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  36205. * @param normals an array of vertex normals, [...., x, y, z, ......]
  36206. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  36207. * * facetNormals : optional array of facet normals (vector3)
  36208. * * facetPositions : optional array of facet positions (vector3)
  36209. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  36210. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  36211. * * bInfo : optional bounding info, required for facetPartitioning computation
  36212. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  36213. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  36214. * * useRightHandedSystem: optional boolean to for right handed system computation
  36215. * * depthSort : optional boolean to enable the facet depth sort computation
  36216. * * distanceTo : optional Vector3 to compute the facet depth from this location
  36217. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  36218. */
  36219. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  36220. facetNormals?: any;
  36221. facetPositions?: any;
  36222. facetPartitioning?: any;
  36223. ratio?: number;
  36224. bInfo?: any;
  36225. bbSize?: Vector3;
  36226. subDiv?: any;
  36227. useRightHandedSystem?: boolean;
  36228. depthSort?: boolean;
  36229. distanceTo?: Vector3;
  36230. depthSortedFacets?: any;
  36231. }): void;
  36232. /** @hidden */
  36233. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  36234. /**
  36235. * Applies VertexData created from the imported parameters to the geometry
  36236. * @param parsedVertexData the parsed data from an imported file
  36237. * @param geometry the geometry to apply the VertexData to
  36238. */
  36239. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  36240. }
  36241. }
  36242. declare module "babylonjs/Meshes/Builders/discBuilder" {
  36243. import { Nullable } from "babylonjs/types";
  36244. import { Scene } from "babylonjs/scene";
  36245. import { Vector4 } from "babylonjs/Maths/math.vector";
  36246. import { Mesh } from "babylonjs/Meshes/mesh";
  36247. /**
  36248. * Class containing static functions to help procedurally build meshes
  36249. */
  36250. export class DiscBuilder {
  36251. /**
  36252. * Creates a plane polygonal mesh. By default, this is a disc
  36253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  36254. * * 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
  36255. * * 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
  36256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36259. * @param name defines the name of the mesh
  36260. * @param options defines the options used to create the mesh
  36261. * @param scene defines the hosting scene
  36262. * @returns the plane polygonal mesh
  36263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  36264. */
  36265. static CreateDisc(name: string, options: {
  36266. radius?: number;
  36267. tessellation?: number;
  36268. arc?: number;
  36269. updatable?: boolean;
  36270. sideOrientation?: number;
  36271. frontUVs?: Vector4;
  36272. backUVs?: Vector4;
  36273. }, scene?: Nullable<Scene>): Mesh;
  36274. }
  36275. }
  36276. declare module "babylonjs/Particles/solidParticleSystem" {
  36277. import { Nullable } from "babylonjs/types";
  36278. import { Mesh } from "babylonjs/Meshes/mesh";
  36279. import { Scene, IDisposable } from "babylonjs/scene";
  36280. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  36281. import { Material } from "babylonjs/Materials/material";
  36282. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36283. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36284. /**
  36285. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  36286. *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.
  36287. * The SPS is also a particle system. It provides some methods to manage the particles.
  36288. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  36289. *
  36290. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  36291. */
  36292. export class SolidParticleSystem implements IDisposable {
  36293. /**
  36294. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  36295. * Example : var p = SPS.particles[i];
  36296. */
  36297. particles: SolidParticle[];
  36298. /**
  36299. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  36300. */
  36301. nbParticles: number;
  36302. /**
  36303. * If the particles must ever face the camera (default false). Useful for planar particles.
  36304. */
  36305. billboard: boolean;
  36306. /**
  36307. * Recompute normals when adding a shape
  36308. */
  36309. recomputeNormals: boolean;
  36310. /**
  36311. * This a counter ofr your own usage. It's not set by any SPS functions.
  36312. */
  36313. counter: number;
  36314. /**
  36315. * The SPS name. This name is also given to the underlying mesh.
  36316. */
  36317. name: string;
  36318. /**
  36319. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  36320. */
  36321. mesh: Mesh;
  36322. /**
  36323. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  36324. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  36325. */
  36326. vars: any;
  36327. /**
  36328. * This array is populated when the SPS is set as 'pickable'.
  36329. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  36330. * Each element of this array is an object `{idx: int, faceId: int}`.
  36331. * `idx` is the picked particle index in the `SPS.particles` array
  36332. * `faceId` is the picked face index counted within this particle.
  36333. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  36334. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  36335. * Use the method SPS.pickedParticle(pickingInfo) instead.
  36336. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36337. */
  36338. pickedParticles: {
  36339. idx: number;
  36340. faceId: number;
  36341. }[];
  36342. /**
  36343. * This array is populated when the SPS is set as 'pickable'
  36344. * Each key of this array is a submesh index.
  36345. * Each element of this array is a second array defined like this :
  36346. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  36347. * Each element of this second array is an object `{idx: int, faceId: int}`.
  36348. * `idx` is the picked particle index in the `SPS.particles` array
  36349. * `faceId` is the picked face index counted within this particle.
  36350. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  36351. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36352. */
  36353. pickedBySubMesh: {
  36354. idx: number;
  36355. faceId: number;
  36356. }[][];
  36357. /**
  36358. * This array is populated when `enableDepthSort` is set to true.
  36359. * Each element of this array is an instance of the class DepthSortedParticle.
  36360. */
  36361. depthSortedParticles: DepthSortedParticle[];
  36362. /**
  36363. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  36364. * @hidden
  36365. */
  36366. _bSphereOnly: boolean;
  36367. /**
  36368. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  36369. * @hidden
  36370. */
  36371. _bSphereRadiusFactor: number;
  36372. private _scene;
  36373. private _positions;
  36374. private _indices;
  36375. private _normals;
  36376. private _colors;
  36377. private _uvs;
  36378. private _indices32;
  36379. private _positions32;
  36380. private _normals32;
  36381. private _fixedNormal32;
  36382. private _colors32;
  36383. private _uvs32;
  36384. private _index;
  36385. private _updatable;
  36386. private _pickable;
  36387. private _isVisibilityBoxLocked;
  36388. private _alwaysVisible;
  36389. private _depthSort;
  36390. private _expandable;
  36391. private _shapeCounter;
  36392. private _copy;
  36393. private _color;
  36394. private _computeParticleColor;
  36395. private _computeParticleTexture;
  36396. private _computeParticleRotation;
  36397. private _computeParticleVertex;
  36398. private _computeBoundingBox;
  36399. private _depthSortParticles;
  36400. private _camera;
  36401. private _mustUnrotateFixedNormals;
  36402. private _particlesIntersect;
  36403. private _needs32Bits;
  36404. private _isNotBuilt;
  36405. private _lastParticleId;
  36406. private _idxOfId;
  36407. private _multimaterialEnabled;
  36408. private _useModelMaterial;
  36409. private _indicesByMaterial;
  36410. private _materialIndexes;
  36411. private _depthSortFunction;
  36412. private _materialSortFunction;
  36413. private _materials;
  36414. private _multimaterial;
  36415. private _materialIndexesById;
  36416. private _defaultMaterial;
  36417. private _autoUpdateSubMeshes;
  36418. private _tmpVertex;
  36419. /**
  36420. * Creates a SPS (Solid Particle System) object.
  36421. * @param name (String) is the SPS name, this will be the underlying mesh name.
  36422. * @param scene (Scene) is the scene in which the SPS is added.
  36423. * @param options defines the options of the sps e.g.
  36424. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  36425. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  36426. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  36427. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  36428. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  36429. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  36430. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  36431. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  36432. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  36433. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  36434. */
  36435. constructor(name: string, scene: Scene, options?: {
  36436. updatable?: boolean;
  36437. isPickable?: boolean;
  36438. enableDepthSort?: boolean;
  36439. particleIntersection?: boolean;
  36440. boundingSphereOnly?: boolean;
  36441. bSphereRadiusFactor?: number;
  36442. expandable?: boolean;
  36443. useModelMaterial?: boolean;
  36444. enableMultiMaterial?: boolean;
  36445. });
  36446. /**
  36447. * Builds the SPS underlying mesh. Returns a standard Mesh.
  36448. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  36449. * @returns the created mesh
  36450. */
  36451. buildMesh(): Mesh;
  36452. /**
  36453. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  36454. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  36455. * Thus the particles generated from `digest()` have their property `position` set yet.
  36456. * @param mesh ( Mesh ) is the mesh to be digested
  36457. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  36458. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  36459. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  36460. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36461. * @returns the current SPS
  36462. */
  36463. digest(mesh: Mesh, options?: {
  36464. facetNb?: number;
  36465. number?: number;
  36466. delta?: number;
  36467. storage?: [];
  36468. }): SolidParticleSystem;
  36469. /**
  36470. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  36471. * @hidden
  36472. */
  36473. private _unrotateFixedNormals;
  36474. /**
  36475. * Resets the temporary working copy particle
  36476. * @hidden
  36477. */
  36478. private _resetCopy;
  36479. /**
  36480. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36481. * @param p the current index in the positions array to be updated
  36482. * @param ind the current index in the indices array
  36483. * @param shape a Vector3 array, the shape geometry
  36484. * @param positions the positions array to be updated
  36485. * @param meshInd the shape indices array
  36486. * @param indices the indices array to be updated
  36487. * @param meshUV the shape uv array
  36488. * @param uvs the uv array to be updated
  36489. * @param meshCol the shape color array
  36490. * @param colors the color array to be updated
  36491. * @param meshNor the shape normals array
  36492. * @param normals the normals array to be updated
  36493. * @param idx the particle index
  36494. * @param idxInShape the particle index in its shape
  36495. * @param options the addShape() method passed options
  36496. * @model the particle model
  36497. * @hidden
  36498. */
  36499. private _meshBuilder;
  36500. /**
  36501. * Returns a shape Vector3 array from positions float array
  36502. * @param positions float array
  36503. * @returns a vector3 array
  36504. * @hidden
  36505. */
  36506. private _posToShape;
  36507. /**
  36508. * Returns a shapeUV array from a float uvs (array deep copy)
  36509. * @param uvs as a float array
  36510. * @returns a shapeUV array
  36511. * @hidden
  36512. */
  36513. private _uvsToShapeUV;
  36514. /**
  36515. * Adds a new particle object in the particles array
  36516. * @param idx particle index in particles array
  36517. * @param id particle id
  36518. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36519. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36520. * @param model particle ModelShape object
  36521. * @param shapeId model shape identifier
  36522. * @param idxInShape index of the particle in the current model
  36523. * @param bInfo model bounding info object
  36524. * @param storage target storage array, if any
  36525. * @hidden
  36526. */
  36527. private _addParticle;
  36528. /**
  36529. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36530. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36531. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36532. * @param nb (positive integer) the number of particles to be created from this model
  36533. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36534. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36535. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36536. * @returns the number of shapes in the system
  36537. */
  36538. addShape(mesh: Mesh, nb: number, options?: {
  36539. positionFunction?: any;
  36540. vertexFunction?: any;
  36541. storage?: [];
  36542. }): number;
  36543. /**
  36544. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36545. * @hidden
  36546. */
  36547. private _rebuildParticle;
  36548. /**
  36549. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36550. * @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.
  36551. * @returns the SPS.
  36552. */
  36553. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36554. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36555. * Returns an array with the removed particles.
  36556. * 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.
  36557. * The SPS can't be empty so at least one particle needs to remain in place.
  36558. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36559. * @param start index of the first particle to remove
  36560. * @param end index of the last particle to remove (included)
  36561. * @returns an array populated with the removed particles
  36562. */
  36563. removeParticles(start: number, end: number): SolidParticle[];
  36564. /**
  36565. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36566. * @param solidParticleArray an array populated with Solid Particles objects
  36567. * @returns the SPS
  36568. */
  36569. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36570. /**
  36571. * Creates a new particle and modifies the SPS mesh geometry :
  36572. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36573. * - calls _addParticle() to populate the particle array
  36574. * factorized code from addShape() and insertParticlesFromArray()
  36575. * @param idx particle index in the particles array
  36576. * @param i particle index in its shape
  36577. * @param modelShape particle ModelShape object
  36578. * @param shape shape vertex array
  36579. * @param meshInd shape indices array
  36580. * @param meshUV shape uv array
  36581. * @param meshCol shape color array
  36582. * @param meshNor shape normals array
  36583. * @param bbInfo shape bounding info
  36584. * @param storage target particle storage
  36585. * @options addShape() passed options
  36586. * @hidden
  36587. */
  36588. private _insertNewParticle;
  36589. /**
  36590. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36591. * This method calls `updateParticle()` for each particle of the SPS.
  36592. * For an animated SPS, it is usually called within the render loop.
  36593. * 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.
  36594. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36595. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36596. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36597. * @returns the SPS.
  36598. */
  36599. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36600. /**
  36601. * Disposes the SPS.
  36602. */
  36603. dispose(): void;
  36604. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36605. * idx is the particle index in the SPS
  36606. * faceId is the picked face index counted within this particle.
  36607. * Returns null if the pickInfo can't identify a picked particle.
  36608. * @param pickingInfo (PickingInfo object)
  36609. * @returns {idx: number, faceId: number} or null
  36610. */
  36611. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36612. idx: number;
  36613. faceId: number;
  36614. }>;
  36615. /**
  36616. * Returns a SolidParticle object from its identifier : particle.id
  36617. * @param id (integer) the particle Id
  36618. * @returns the searched particle or null if not found in the SPS.
  36619. */
  36620. getParticleById(id: number): Nullable<SolidParticle>;
  36621. /**
  36622. * Returns a new array populated with the particles having the passed shapeId.
  36623. * @param shapeId (integer) the shape identifier
  36624. * @returns a new solid particle array
  36625. */
  36626. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36627. /**
  36628. * Populates the passed array "ref" with the particles having the passed shapeId.
  36629. * @param shapeId the shape identifier
  36630. * @returns the SPS
  36631. * @param ref
  36632. */
  36633. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36634. /**
  36635. * Computes the required SubMeshes according the materials assigned to the particles.
  36636. * @returns the solid particle system.
  36637. * Does nothing if called before the SPS mesh is built.
  36638. */
  36639. computeSubMeshes(): SolidParticleSystem;
  36640. /**
  36641. * Sorts the solid particles by material when MultiMaterial is enabled.
  36642. * Updates the indices32 array.
  36643. * Updates the indicesByMaterial array.
  36644. * Updates the mesh indices array.
  36645. * @returns the SPS
  36646. * @hidden
  36647. */
  36648. private _sortParticlesByMaterial;
  36649. /**
  36650. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36651. * @hidden
  36652. */
  36653. private _setMaterialIndexesById;
  36654. /**
  36655. * Returns an array with unique values of Materials from the passed array
  36656. * @param array the material array to be checked and filtered
  36657. * @hidden
  36658. */
  36659. private _filterUniqueMaterialId;
  36660. /**
  36661. * Sets a new Standard Material as _defaultMaterial if not already set.
  36662. * @hidden
  36663. */
  36664. private _setDefaultMaterial;
  36665. /**
  36666. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36667. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36668. * @returns the SPS.
  36669. */
  36670. refreshVisibleSize(): SolidParticleSystem;
  36671. /**
  36672. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36673. * @param size the size (float) of the visibility box
  36674. * note : this doesn't lock the SPS mesh bounding box.
  36675. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36676. */
  36677. setVisibilityBox(size: number): void;
  36678. /**
  36679. * Gets whether the SPS as always visible or not
  36680. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36681. */
  36682. get isAlwaysVisible(): boolean;
  36683. /**
  36684. * Sets the SPS as always visible or not
  36685. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36686. */
  36687. set isAlwaysVisible(val: boolean);
  36688. /**
  36689. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36690. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36691. */
  36692. set isVisibilityBoxLocked(val: boolean);
  36693. /**
  36694. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36695. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36696. */
  36697. get isVisibilityBoxLocked(): boolean;
  36698. /**
  36699. * Tells to `setParticles()` to compute the particle rotations or not.
  36700. * Default value : true. The SPS is faster when it's set to false.
  36701. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36702. */
  36703. set computeParticleRotation(val: boolean);
  36704. /**
  36705. * Tells to `setParticles()` to compute the particle colors or not.
  36706. * Default value : true. The SPS is faster when it's set to false.
  36707. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36708. */
  36709. set computeParticleColor(val: boolean);
  36710. set computeParticleTexture(val: boolean);
  36711. /**
  36712. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36713. * Default value : false. The SPS is faster when it's set to false.
  36714. * Note : the particle custom vertex positions aren't stored values.
  36715. */
  36716. set computeParticleVertex(val: boolean);
  36717. /**
  36718. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36719. */
  36720. set computeBoundingBox(val: boolean);
  36721. /**
  36722. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36723. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36724. * Default : `true`
  36725. */
  36726. set depthSortParticles(val: boolean);
  36727. /**
  36728. * Gets if `setParticles()` computes the particle rotations or not.
  36729. * Default value : true. The SPS is faster when it's set to false.
  36730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36731. */
  36732. get computeParticleRotation(): boolean;
  36733. /**
  36734. * Gets if `setParticles()` computes the particle colors or not.
  36735. * Default value : true. The SPS is faster when it's set to false.
  36736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36737. */
  36738. get computeParticleColor(): boolean;
  36739. /**
  36740. * Gets if `setParticles()` computes the particle textures or not.
  36741. * Default value : true. The SPS is faster when it's set to false.
  36742. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36743. */
  36744. get computeParticleTexture(): boolean;
  36745. /**
  36746. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36747. * Default value : false. The SPS is faster when it's set to false.
  36748. * Note : the particle custom vertex positions aren't stored values.
  36749. */
  36750. get computeParticleVertex(): boolean;
  36751. /**
  36752. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36753. */
  36754. get computeBoundingBox(): boolean;
  36755. /**
  36756. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36757. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36758. * Default : `true`
  36759. */
  36760. get depthSortParticles(): boolean;
  36761. /**
  36762. * Gets if the SPS is created as expandable at construction time.
  36763. * Default : `false`
  36764. */
  36765. get expandable(): boolean;
  36766. /**
  36767. * Gets if the SPS supports the Multi Materials
  36768. */
  36769. get multimaterialEnabled(): boolean;
  36770. /**
  36771. * Gets if the SPS uses the model materials for its own multimaterial.
  36772. */
  36773. get useModelMaterial(): boolean;
  36774. /**
  36775. * The SPS used material array.
  36776. */
  36777. get materials(): Material[];
  36778. /**
  36779. * Sets the SPS MultiMaterial from the passed materials.
  36780. * Note : the passed array is internally copied and not used then by reference.
  36781. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36782. */
  36783. setMultiMaterial(materials: Material[]): void;
  36784. /**
  36785. * The SPS computed multimaterial object
  36786. */
  36787. get multimaterial(): MultiMaterial;
  36788. set multimaterial(mm: MultiMaterial);
  36789. /**
  36790. * If the subMeshes must be updated on the next call to setParticles()
  36791. */
  36792. get autoUpdateSubMeshes(): boolean;
  36793. set autoUpdateSubMeshes(val: boolean);
  36794. /**
  36795. * This function does nothing. It may be overwritten to set all the particle first values.
  36796. * The SPS doesn't call this function, you may have to call it by your own.
  36797. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36798. */
  36799. initParticles(): void;
  36800. /**
  36801. * This function does nothing. It may be overwritten to recycle a particle.
  36802. * The SPS doesn't call this function, you may have to call it by your own.
  36803. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36804. * @param particle The particle to recycle
  36805. * @returns the recycled particle
  36806. */
  36807. recycleParticle(particle: SolidParticle): SolidParticle;
  36808. /**
  36809. * Updates a particle : this function should be overwritten by the user.
  36810. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36811. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36812. * @example : just set a particle position or velocity and recycle conditions
  36813. * @param particle The particle to update
  36814. * @returns the updated particle
  36815. */
  36816. updateParticle(particle: SolidParticle): SolidParticle;
  36817. /**
  36818. * Updates a vertex of a particle : it can be overwritten by the user.
  36819. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36820. * @param particle the current particle
  36821. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36822. * @param pt the index of the current vertex in the particle shape
  36823. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36824. * @example : just set a vertex particle position or color
  36825. * @returns the sps
  36826. */
  36827. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36828. /**
  36829. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36830. * This does nothing and may be overwritten by the user.
  36831. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36832. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36833. * @param update the boolean update value actually passed to setParticles()
  36834. */
  36835. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36836. /**
  36837. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36838. * This will be passed three parameters.
  36839. * This does nothing and may be overwritten by the user.
  36840. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36841. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36842. * @param update the boolean update value actually passed to setParticles()
  36843. */
  36844. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36845. }
  36846. }
  36847. declare module "babylonjs/Particles/solidParticle" {
  36848. import { Nullable } from "babylonjs/types";
  36849. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36850. import { Color4 } from "babylonjs/Maths/math.color";
  36851. import { Mesh } from "babylonjs/Meshes/mesh";
  36852. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36853. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36854. import { Plane } from "babylonjs/Maths/math.plane";
  36855. import { Material } from "babylonjs/Materials/material";
  36856. /**
  36857. * Represents one particle of a solid particle system.
  36858. */
  36859. export class SolidParticle {
  36860. /**
  36861. * particle global index
  36862. */
  36863. idx: number;
  36864. /**
  36865. * particle identifier
  36866. */
  36867. id: number;
  36868. /**
  36869. * The color of the particle
  36870. */
  36871. color: Nullable<Color4>;
  36872. /**
  36873. * The world space position of the particle.
  36874. */
  36875. position: Vector3;
  36876. /**
  36877. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36878. */
  36879. rotation: Vector3;
  36880. /**
  36881. * The world space rotation quaternion of the particle.
  36882. */
  36883. rotationQuaternion: Nullable<Quaternion>;
  36884. /**
  36885. * The scaling of the particle.
  36886. */
  36887. scaling: Vector3;
  36888. /**
  36889. * The uvs of the particle.
  36890. */
  36891. uvs: Vector4;
  36892. /**
  36893. * The current speed of the particle.
  36894. */
  36895. velocity: Vector3;
  36896. /**
  36897. * The pivot point in the particle local space.
  36898. */
  36899. pivot: Vector3;
  36900. /**
  36901. * Must the particle be translated from its pivot point in its local space ?
  36902. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36903. * Default : false
  36904. */
  36905. translateFromPivot: boolean;
  36906. /**
  36907. * Is the particle active or not ?
  36908. */
  36909. alive: boolean;
  36910. /**
  36911. * Is the particle visible or not ?
  36912. */
  36913. isVisible: boolean;
  36914. /**
  36915. * Index of this particle in the global "positions" array (Internal use)
  36916. * @hidden
  36917. */
  36918. _pos: number;
  36919. /**
  36920. * @hidden Index of this particle in the global "indices" array (Internal use)
  36921. */
  36922. _ind: number;
  36923. /**
  36924. * @hidden ModelShape of this particle (Internal use)
  36925. */
  36926. _model: ModelShape;
  36927. /**
  36928. * ModelShape id of this particle
  36929. */
  36930. shapeId: number;
  36931. /**
  36932. * Index of the particle in its shape id
  36933. */
  36934. idxInShape: number;
  36935. /**
  36936. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36937. */
  36938. _modelBoundingInfo: BoundingInfo;
  36939. /**
  36940. * @hidden Particle BoundingInfo object (Internal use)
  36941. */
  36942. _boundingInfo: BoundingInfo;
  36943. /**
  36944. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36945. */
  36946. _sps: SolidParticleSystem;
  36947. /**
  36948. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36949. */
  36950. _stillInvisible: boolean;
  36951. /**
  36952. * @hidden Last computed particle rotation matrix
  36953. */
  36954. _rotationMatrix: number[];
  36955. /**
  36956. * Parent particle Id, if any.
  36957. * Default null.
  36958. */
  36959. parentId: Nullable<number>;
  36960. /**
  36961. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36962. */
  36963. materialIndex: Nullable<number>;
  36964. /**
  36965. * Custom object or properties.
  36966. */
  36967. props: Nullable<any>;
  36968. /**
  36969. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36970. * The possible values are :
  36971. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36972. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36973. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36975. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36976. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36977. * */
  36978. cullingStrategy: number;
  36979. /**
  36980. * @hidden Internal global position in the SPS.
  36981. */
  36982. _globalPosition: Vector3;
  36983. /**
  36984. * Creates a Solid Particle object.
  36985. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36986. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36987. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36988. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36989. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36990. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36991. * @param shapeId (integer) is the model shape identifier in the SPS.
  36992. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36993. * @param sps defines the sps it is associated to
  36994. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36995. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36996. */
  36997. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36998. /**
  36999. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  37000. * @param target the particle target
  37001. * @returns the current particle
  37002. */
  37003. copyToRef(target: SolidParticle): SolidParticle;
  37004. /**
  37005. * Legacy support, changed scale to scaling
  37006. */
  37007. get scale(): Vector3;
  37008. /**
  37009. * Legacy support, changed scale to scaling
  37010. */
  37011. set scale(scale: Vector3);
  37012. /**
  37013. * Legacy support, changed quaternion to rotationQuaternion
  37014. */
  37015. get quaternion(): Nullable<Quaternion>;
  37016. /**
  37017. * Legacy support, changed quaternion to rotationQuaternion
  37018. */
  37019. set quaternion(q: Nullable<Quaternion>);
  37020. /**
  37021. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  37022. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  37023. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  37024. * @returns true if it intersects
  37025. */
  37026. intersectsMesh(target: Mesh | SolidParticle): boolean;
  37027. /**
  37028. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  37029. * A particle is in the frustum if its bounding box intersects the frustum
  37030. * @param frustumPlanes defines the frustum to test
  37031. * @returns true if the particle is in the frustum planes
  37032. */
  37033. isInFrustum(frustumPlanes: Plane[]): boolean;
  37034. /**
  37035. * get the rotation matrix of the particle
  37036. * @hidden
  37037. */
  37038. getRotationMatrix(m: Matrix): void;
  37039. }
  37040. /**
  37041. * Represents the shape of the model used by one particle of a solid particle system.
  37042. * SPS internal tool, don't use it manually.
  37043. */
  37044. export class ModelShape {
  37045. /**
  37046. * The shape id
  37047. * @hidden
  37048. */
  37049. shapeID: number;
  37050. /**
  37051. * flat array of model positions (internal use)
  37052. * @hidden
  37053. */
  37054. _shape: Vector3[];
  37055. /**
  37056. * flat array of model UVs (internal use)
  37057. * @hidden
  37058. */
  37059. _shapeUV: number[];
  37060. /**
  37061. * color array of the model
  37062. * @hidden
  37063. */
  37064. _shapeColors: number[];
  37065. /**
  37066. * indices array of the model
  37067. * @hidden
  37068. */
  37069. _indices: number[];
  37070. /**
  37071. * normals array of the model
  37072. * @hidden
  37073. */
  37074. _normals: number[];
  37075. /**
  37076. * length of the shape in the model indices array (internal use)
  37077. * @hidden
  37078. */
  37079. _indicesLength: number;
  37080. /**
  37081. * Custom position function (internal use)
  37082. * @hidden
  37083. */
  37084. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  37085. /**
  37086. * Custom vertex function (internal use)
  37087. * @hidden
  37088. */
  37089. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  37090. /**
  37091. * Model material (internal use)
  37092. * @hidden
  37093. */
  37094. _material: Nullable<Material>;
  37095. /**
  37096. * 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.
  37097. * SPS internal tool, don't use it manually.
  37098. * @hidden
  37099. */
  37100. 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>);
  37101. }
  37102. /**
  37103. * Represents a Depth Sorted Particle in the solid particle system.
  37104. * @hidden
  37105. */
  37106. export class DepthSortedParticle {
  37107. /**
  37108. * Particle index
  37109. */
  37110. idx: number;
  37111. /**
  37112. * Index of the particle in the "indices" array
  37113. */
  37114. ind: number;
  37115. /**
  37116. * Length of the particle shape in the "indices" array
  37117. */
  37118. indicesLength: number;
  37119. /**
  37120. * Squared distance from the particle to the camera
  37121. */
  37122. sqDistance: number;
  37123. /**
  37124. * Material index when used with MultiMaterials
  37125. */
  37126. materialIndex: number;
  37127. /**
  37128. * Creates a new sorted particle
  37129. * @param materialIndex
  37130. */
  37131. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  37132. }
  37133. /**
  37134. * Represents a solid particle vertex
  37135. */
  37136. export class SolidParticleVertex {
  37137. /**
  37138. * Vertex position
  37139. */
  37140. position: Vector3;
  37141. /**
  37142. * Vertex color
  37143. */
  37144. color: Color4;
  37145. /**
  37146. * Vertex UV
  37147. */
  37148. uv: Vector2;
  37149. /**
  37150. * Creates a new solid particle vertex
  37151. */
  37152. constructor();
  37153. /** Vertex x coordinate */
  37154. get x(): number;
  37155. set x(val: number);
  37156. /** Vertex y coordinate */
  37157. get y(): number;
  37158. set y(val: number);
  37159. /** Vertex z coordinate */
  37160. get z(): number;
  37161. set z(val: number);
  37162. }
  37163. }
  37164. declare module "babylonjs/Collisions/meshCollisionData" {
  37165. import { Collider } from "babylonjs/Collisions/collider";
  37166. import { Vector3 } from "babylonjs/Maths/math.vector";
  37167. import { Nullable } from "babylonjs/types";
  37168. import { Observer } from "babylonjs/Misc/observable";
  37169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37170. /**
  37171. * @hidden
  37172. */
  37173. export class _MeshCollisionData {
  37174. _checkCollisions: boolean;
  37175. _collisionMask: number;
  37176. _collisionGroup: number;
  37177. _surroundingMeshes: Nullable<AbstractMesh[]>;
  37178. _collider: Nullable<Collider>;
  37179. _oldPositionForCollisions: Vector3;
  37180. _diffPositionForCollisions: Vector3;
  37181. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  37182. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  37183. _collisionResponse: boolean;
  37184. }
  37185. }
  37186. declare module "babylonjs/Meshes/abstractMesh" {
  37187. import { Observable } from "babylonjs/Misc/observable";
  37188. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  37189. import { Camera } from "babylonjs/Cameras/camera";
  37190. import { Scene, IDisposable } from "babylonjs/scene";
  37191. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37192. import { Node } from "babylonjs/node";
  37193. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  37194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37195. import { SubMesh } from "babylonjs/Meshes/subMesh";
  37196. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  37197. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37198. import { Material } from "babylonjs/Materials/material";
  37199. import { Light } from "babylonjs/Lights/light";
  37200. import { Skeleton } from "babylonjs/Bones/skeleton";
  37201. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  37202. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  37203. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37204. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  37205. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  37206. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37207. import { Plane } from "babylonjs/Maths/math.plane";
  37208. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37209. import { Ray } from "babylonjs/Culling/ray";
  37210. import { Collider } from "babylonjs/Collisions/collider";
  37211. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  37212. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  37213. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  37214. /** @hidden */
  37215. class _FacetDataStorage {
  37216. facetPositions: Vector3[];
  37217. facetNormals: Vector3[];
  37218. facetPartitioning: number[][];
  37219. facetNb: number;
  37220. partitioningSubdivisions: number;
  37221. partitioningBBoxRatio: number;
  37222. facetDataEnabled: boolean;
  37223. facetParameters: any;
  37224. bbSize: Vector3;
  37225. subDiv: {
  37226. max: number;
  37227. X: number;
  37228. Y: number;
  37229. Z: number;
  37230. };
  37231. facetDepthSort: boolean;
  37232. facetDepthSortEnabled: boolean;
  37233. depthSortedIndices: IndicesArray;
  37234. depthSortedFacets: {
  37235. ind: number;
  37236. sqDistance: number;
  37237. }[];
  37238. facetDepthSortFunction: (f1: {
  37239. ind: number;
  37240. sqDistance: number;
  37241. }, f2: {
  37242. ind: number;
  37243. sqDistance: number;
  37244. }) => number;
  37245. facetDepthSortFrom: Vector3;
  37246. facetDepthSortOrigin: Vector3;
  37247. invertedMatrix: Matrix;
  37248. }
  37249. /**
  37250. * @hidden
  37251. **/
  37252. class _InternalAbstractMeshDataInfo {
  37253. _hasVertexAlpha: boolean;
  37254. _useVertexColors: boolean;
  37255. _numBoneInfluencers: number;
  37256. _applyFog: boolean;
  37257. _receiveShadows: boolean;
  37258. _facetData: _FacetDataStorage;
  37259. _visibility: number;
  37260. _skeleton: Nullable<Skeleton>;
  37261. _layerMask: number;
  37262. _computeBonesUsingShaders: boolean;
  37263. _isActive: boolean;
  37264. _onlyForInstances: boolean;
  37265. _isActiveIntermediate: boolean;
  37266. _onlyForInstancesIntermediate: boolean;
  37267. _actAsRegularMesh: boolean;
  37268. _currentLOD: Nullable<AbstractMesh>;
  37269. _currentLODIsUpToDate: boolean;
  37270. }
  37271. /**
  37272. * Class used to store all common mesh properties
  37273. */
  37274. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  37275. /** No occlusion */
  37276. static OCCLUSION_TYPE_NONE: number;
  37277. /** Occlusion set to optimisitic */
  37278. static OCCLUSION_TYPE_OPTIMISTIC: number;
  37279. /** Occlusion set to strict */
  37280. static OCCLUSION_TYPE_STRICT: number;
  37281. /** Use an accurante occlusion algorithm */
  37282. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  37283. /** Use a conservative occlusion algorithm */
  37284. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  37285. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  37286. * Test order :
  37287. * Is the bounding sphere outside the frustum ?
  37288. * If not, are the bounding box vertices outside the frustum ?
  37289. * It not, then the cullable object is in the frustum.
  37290. */
  37291. static readonly CULLINGSTRATEGY_STANDARD: number;
  37292. /** Culling strategy : Bounding Sphere Only.
  37293. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  37294. * It's also less accurate than the standard because some not visible objects can still be selected.
  37295. * Test : is the bounding sphere outside the frustum ?
  37296. * If not, then the cullable object is in the frustum.
  37297. */
  37298. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  37299. /** Culling strategy : Optimistic Inclusion.
  37300. * This in an inclusion test first, then the standard exclusion test.
  37301. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  37302. * 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.
  37303. * Anyway, it's as accurate as the standard strategy.
  37304. * Test :
  37305. * Is the cullable object bounding sphere center in the frustum ?
  37306. * If not, apply the default culling strategy.
  37307. */
  37308. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  37309. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  37310. * This in an inclusion test first, then the bounding sphere only exclusion test.
  37311. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  37312. * 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.
  37313. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  37314. * Test :
  37315. * Is the cullable object bounding sphere center in the frustum ?
  37316. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  37317. */
  37318. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  37319. /**
  37320. * No billboard
  37321. */
  37322. static get BILLBOARDMODE_NONE(): number;
  37323. /** Billboard on X axis */
  37324. static get BILLBOARDMODE_X(): number;
  37325. /** Billboard on Y axis */
  37326. static get BILLBOARDMODE_Y(): number;
  37327. /** Billboard on Z axis */
  37328. static get BILLBOARDMODE_Z(): number;
  37329. /** Billboard on all axes */
  37330. static get BILLBOARDMODE_ALL(): number;
  37331. /** Billboard on using position instead of orientation */
  37332. static get BILLBOARDMODE_USE_POSITION(): number;
  37333. /** @hidden */
  37334. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  37335. /**
  37336. * The culling strategy to use to check whether the mesh must be rendered or not.
  37337. * This value can be changed at any time and will be used on the next render mesh selection.
  37338. * The possible values are :
  37339. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37340. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37341. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37342. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37343. * Please read each static variable documentation to get details about the culling process.
  37344. * */
  37345. cullingStrategy: number;
  37346. /**
  37347. * Gets the number of facets in the mesh
  37348. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37349. */
  37350. get facetNb(): number;
  37351. /**
  37352. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  37353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37354. */
  37355. get partitioningSubdivisions(): number;
  37356. set partitioningSubdivisions(nb: number);
  37357. /**
  37358. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  37359. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  37360. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37361. */
  37362. get partitioningBBoxRatio(): number;
  37363. set partitioningBBoxRatio(ratio: number);
  37364. /**
  37365. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  37366. * Works only for updatable meshes.
  37367. * Doesn't work with multi-materials
  37368. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37369. */
  37370. get mustDepthSortFacets(): boolean;
  37371. set mustDepthSortFacets(sort: boolean);
  37372. /**
  37373. * The location (Vector3) where the facet depth sort must be computed from.
  37374. * By default, the active camera position.
  37375. * Used only when facet depth sort is enabled
  37376. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37377. */
  37378. get facetDepthSortFrom(): Vector3;
  37379. set facetDepthSortFrom(location: Vector3);
  37380. /**
  37381. * gets a boolean indicating if facetData is enabled
  37382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37383. */
  37384. get isFacetDataEnabled(): boolean;
  37385. /** @hidden */
  37386. _updateNonUniformScalingState(value: boolean): boolean;
  37387. /**
  37388. * An event triggered when this mesh collides with another one
  37389. */
  37390. onCollideObservable: Observable<AbstractMesh>;
  37391. /** Set a function to call when this mesh collides with another one */
  37392. set onCollide(callback: () => void);
  37393. /**
  37394. * An event triggered when the collision's position changes
  37395. */
  37396. onCollisionPositionChangeObservable: Observable<Vector3>;
  37397. /** Set a function to call when the collision's position changes */
  37398. set onCollisionPositionChange(callback: () => void);
  37399. /**
  37400. * An event triggered when material is changed
  37401. */
  37402. onMaterialChangedObservable: Observable<AbstractMesh>;
  37403. /**
  37404. * Gets or sets the orientation for POV movement & rotation
  37405. */
  37406. definedFacingForward: boolean;
  37407. /** @hidden */
  37408. _occlusionQuery: Nullable<WebGLQuery>;
  37409. /** @hidden */
  37410. _renderingGroup: Nullable<RenderingGroup>;
  37411. /**
  37412. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37413. */
  37414. get visibility(): number;
  37415. /**
  37416. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37417. */
  37418. set visibility(value: number);
  37419. /** Gets or sets the alpha index used to sort transparent meshes
  37420. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  37421. */
  37422. alphaIndex: number;
  37423. /**
  37424. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  37425. */
  37426. isVisible: boolean;
  37427. /**
  37428. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37429. */
  37430. isPickable: boolean;
  37431. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  37432. showSubMeshesBoundingBox: boolean;
  37433. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  37434. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  37435. */
  37436. isBlocker: boolean;
  37437. /**
  37438. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  37439. */
  37440. enablePointerMoveEvents: boolean;
  37441. private _renderingGroupId;
  37442. /**
  37443. * Specifies the rendering group id for this mesh (0 by default)
  37444. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37445. */
  37446. get renderingGroupId(): number;
  37447. set renderingGroupId(value: number);
  37448. private _material;
  37449. /** Gets or sets current material */
  37450. get material(): Nullable<Material>;
  37451. set material(value: Nullable<Material>);
  37452. /**
  37453. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  37454. * @see https://doc.babylonjs.com/babylon101/shadows
  37455. */
  37456. get receiveShadows(): boolean;
  37457. set receiveShadows(value: boolean);
  37458. /** Defines color to use when rendering outline */
  37459. outlineColor: Color3;
  37460. /** Define width to use when rendering outline */
  37461. outlineWidth: number;
  37462. /** Defines color to use when rendering overlay */
  37463. overlayColor: Color3;
  37464. /** Defines alpha to use when rendering overlay */
  37465. overlayAlpha: number;
  37466. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  37467. get hasVertexAlpha(): boolean;
  37468. set hasVertexAlpha(value: boolean);
  37469. /** 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) */
  37470. get useVertexColors(): boolean;
  37471. set useVertexColors(value: boolean);
  37472. /**
  37473. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  37474. */
  37475. get computeBonesUsingShaders(): boolean;
  37476. set computeBonesUsingShaders(value: boolean);
  37477. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37478. get numBoneInfluencers(): number;
  37479. set numBoneInfluencers(value: number);
  37480. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37481. get applyFog(): boolean;
  37482. set applyFog(value: boolean);
  37483. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37484. useOctreeForRenderingSelection: boolean;
  37485. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37486. useOctreeForPicking: boolean;
  37487. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37488. useOctreeForCollisions: boolean;
  37489. /**
  37490. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37491. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37492. */
  37493. get layerMask(): number;
  37494. set layerMask(value: number);
  37495. /**
  37496. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37497. */
  37498. alwaysSelectAsActiveMesh: boolean;
  37499. /**
  37500. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37501. */
  37502. doNotSyncBoundingInfo: boolean;
  37503. /**
  37504. * Gets or sets the current action manager
  37505. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37506. */
  37507. actionManager: Nullable<AbstractActionManager>;
  37508. private _meshCollisionData;
  37509. /**
  37510. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37511. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37512. */
  37513. ellipsoid: Vector3;
  37514. /**
  37515. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37516. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37517. */
  37518. ellipsoidOffset: Vector3;
  37519. /**
  37520. * Gets or sets a collision mask used to mask collisions (default is -1).
  37521. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37522. */
  37523. get collisionMask(): number;
  37524. set collisionMask(mask: number);
  37525. /**
  37526. * Gets or sets a collision response flag (default is true).
  37527. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37528. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37529. * to respond to the collision.
  37530. */
  37531. get collisionResponse(): boolean;
  37532. set collisionResponse(response: boolean);
  37533. /**
  37534. * Gets or sets the current collision group mask (-1 by default).
  37535. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37536. */
  37537. get collisionGroup(): number;
  37538. set collisionGroup(mask: number);
  37539. /**
  37540. * Gets or sets current surrounding meshes (null by default).
  37541. *
  37542. * By default collision detection is tested against every mesh in the scene.
  37543. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37544. * meshes will be tested for the collision.
  37545. *
  37546. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37547. */
  37548. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37549. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37550. /**
  37551. * Defines edge width used when edgesRenderer is enabled
  37552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37553. */
  37554. edgesWidth: number;
  37555. /**
  37556. * Defines edge color used when edgesRenderer is enabled
  37557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37558. */
  37559. edgesColor: Color4;
  37560. /** @hidden */
  37561. _edgesRenderer: Nullable<IEdgesRenderer>;
  37562. /** @hidden */
  37563. _masterMesh: Nullable<AbstractMesh>;
  37564. /** @hidden */
  37565. _boundingInfo: Nullable<BoundingInfo>;
  37566. /** @hidden */
  37567. _renderId: number;
  37568. /**
  37569. * Gets or sets the list of subMeshes
  37570. * @see https://doc.babylonjs.com/how_to/multi_materials
  37571. */
  37572. subMeshes: SubMesh[];
  37573. /** @hidden */
  37574. _intersectionsInProgress: AbstractMesh[];
  37575. /** @hidden */
  37576. _unIndexed: boolean;
  37577. /** @hidden */
  37578. _lightSources: Light[];
  37579. /** Gets the list of lights affecting that mesh */
  37580. get lightSources(): Light[];
  37581. /** @hidden */
  37582. get _positions(): Nullable<Vector3[]>;
  37583. /** @hidden */
  37584. _waitingData: {
  37585. lods: Nullable<any>;
  37586. actions: Nullable<any>;
  37587. freezeWorldMatrix: Nullable<boolean>;
  37588. };
  37589. /** @hidden */
  37590. _bonesTransformMatrices: Nullable<Float32Array>;
  37591. /** @hidden */
  37592. _transformMatrixTexture: Nullable<RawTexture>;
  37593. /**
  37594. * Gets or sets a skeleton to apply skining transformations
  37595. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37596. */
  37597. set skeleton(value: Nullable<Skeleton>);
  37598. get skeleton(): Nullable<Skeleton>;
  37599. /**
  37600. * An event triggered when the mesh is rebuilt.
  37601. */
  37602. onRebuildObservable: Observable<AbstractMesh>;
  37603. /**
  37604. * The current mesh unifom buffer.
  37605. * @hidden Internal use only.
  37606. */
  37607. _uniformBuffer: UniformBuffer;
  37608. /**
  37609. * Creates a new AbstractMesh
  37610. * @param name defines the name of the mesh
  37611. * @param scene defines the hosting scene
  37612. */
  37613. constructor(name: string, scene?: Nullable<Scene>);
  37614. protected _buildUniformLayout(): void;
  37615. /**
  37616. * Transfer the mesh values to its UBO.
  37617. * @param world The world matrix associated with the mesh
  37618. */
  37619. transferToEffect(world: Matrix): void;
  37620. /**
  37621. * Gets the mesh uniform buffer.
  37622. * @return the uniform buffer of the mesh.
  37623. */
  37624. getMeshUniformBuffer(): UniformBuffer;
  37625. /**
  37626. * Returns the string "AbstractMesh"
  37627. * @returns "AbstractMesh"
  37628. */
  37629. getClassName(): string;
  37630. /**
  37631. * Gets a string representation of the current mesh
  37632. * @param fullDetails defines a boolean indicating if full details must be included
  37633. * @returns a string representation of the current mesh
  37634. */
  37635. toString(fullDetails?: boolean): string;
  37636. /**
  37637. * @hidden
  37638. */
  37639. protected _getEffectiveParent(): Nullable<Node>;
  37640. /** @hidden */
  37641. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37642. /** @hidden */
  37643. _rebuild(): void;
  37644. /** @hidden */
  37645. _resyncLightSources(): void;
  37646. /** @hidden */
  37647. _resyncLightSource(light: Light): void;
  37648. /** @hidden */
  37649. _unBindEffect(): void;
  37650. /** @hidden */
  37651. _removeLightSource(light: Light, dispose: boolean): void;
  37652. private _markSubMeshesAsDirty;
  37653. /** @hidden */
  37654. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37655. /** @hidden */
  37656. _markSubMeshesAsAttributesDirty(): void;
  37657. /** @hidden */
  37658. _markSubMeshesAsMiscDirty(): void;
  37659. /**
  37660. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37661. */
  37662. get scaling(): Vector3;
  37663. set scaling(newScaling: Vector3);
  37664. /**
  37665. * Returns true if the mesh is blocked. Implemented by child classes
  37666. */
  37667. get isBlocked(): boolean;
  37668. /**
  37669. * Returns the mesh itself by default. Implemented by child classes
  37670. * @param camera defines the camera to use to pick the right LOD level
  37671. * @returns the currentAbstractMesh
  37672. */
  37673. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37674. /**
  37675. * Returns 0 by default. Implemented by child classes
  37676. * @returns an integer
  37677. */
  37678. getTotalVertices(): number;
  37679. /**
  37680. * Returns a positive integer : the total number of indices in this mesh geometry.
  37681. * @returns the numner of indices or zero if the mesh has no geometry.
  37682. */
  37683. getTotalIndices(): number;
  37684. /**
  37685. * Returns null by default. Implemented by child classes
  37686. * @returns null
  37687. */
  37688. getIndices(): Nullable<IndicesArray>;
  37689. /**
  37690. * Returns the array of the requested vertex data kind. Implemented by child classes
  37691. * @param kind defines the vertex data kind to use
  37692. * @returns null
  37693. */
  37694. getVerticesData(kind: string): Nullable<FloatArray>;
  37695. /**
  37696. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37697. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37698. * Note that a new underlying VertexBuffer object is created each call.
  37699. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37700. * @param kind defines vertex data kind:
  37701. * * VertexBuffer.PositionKind
  37702. * * VertexBuffer.UVKind
  37703. * * VertexBuffer.UV2Kind
  37704. * * VertexBuffer.UV3Kind
  37705. * * VertexBuffer.UV4Kind
  37706. * * VertexBuffer.UV5Kind
  37707. * * VertexBuffer.UV6Kind
  37708. * * VertexBuffer.ColorKind
  37709. * * VertexBuffer.MatricesIndicesKind
  37710. * * VertexBuffer.MatricesIndicesExtraKind
  37711. * * VertexBuffer.MatricesWeightsKind
  37712. * * VertexBuffer.MatricesWeightsExtraKind
  37713. * @param data defines the data source
  37714. * @param updatable defines if the data must be flagged as updatable (or static)
  37715. * @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
  37716. * @returns the current mesh
  37717. */
  37718. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37719. /**
  37720. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37721. * If the mesh has no geometry, it is simply returned as it is.
  37722. * @param kind defines vertex data kind:
  37723. * * VertexBuffer.PositionKind
  37724. * * VertexBuffer.UVKind
  37725. * * VertexBuffer.UV2Kind
  37726. * * VertexBuffer.UV3Kind
  37727. * * VertexBuffer.UV4Kind
  37728. * * VertexBuffer.UV5Kind
  37729. * * VertexBuffer.UV6Kind
  37730. * * VertexBuffer.ColorKind
  37731. * * VertexBuffer.MatricesIndicesKind
  37732. * * VertexBuffer.MatricesIndicesExtraKind
  37733. * * VertexBuffer.MatricesWeightsKind
  37734. * * VertexBuffer.MatricesWeightsExtraKind
  37735. * @param data defines the data source
  37736. * @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
  37737. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37738. * @returns the current mesh
  37739. */
  37740. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37741. /**
  37742. * Sets the mesh indices,
  37743. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37744. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37745. * @param totalVertices Defines the total number of vertices
  37746. * @returns the current mesh
  37747. */
  37748. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37749. /**
  37750. * Gets a boolean indicating if specific vertex data is present
  37751. * @param kind defines the vertex data kind to use
  37752. * @returns true is data kind is present
  37753. */
  37754. isVerticesDataPresent(kind: string): boolean;
  37755. /**
  37756. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37757. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37758. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37759. * @returns a BoundingInfo
  37760. */
  37761. getBoundingInfo(): BoundingInfo;
  37762. /**
  37763. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37764. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37765. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37766. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37767. * @returns the current mesh
  37768. */
  37769. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37770. /**
  37771. * Overwrite the current bounding info
  37772. * @param boundingInfo defines the new bounding info
  37773. * @returns the current mesh
  37774. */
  37775. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37776. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37777. get useBones(): boolean;
  37778. /** @hidden */
  37779. _preActivate(): void;
  37780. /** @hidden */
  37781. _preActivateForIntermediateRendering(renderId: number): void;
  37782. /** @hidden */
  37783. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37784. /** @hidden */
  37785. _postActivate(): void;
  37786. /** @hidden */
  37787. _freeze(): void;
  37788. /** @hidden */
  37789. _unFreeze(): void;
  37790. /**
  37791. * Gets the current world matrix
  37792. * @returns a Matrix
  37793. */
  37794. getWorldMatrix(): Matrix;
  37795. /** @hidden */
  37796. _getWorldMatrixDeterminant(): number;
  37797. /**
  37798. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37799. */
  37800. get isAnInstance(): boolean;
  37801. /**
  37802. * Gets a boolean indicating if this mesh has instances
  37803. */
  37804. get hasInstances(): boolean;
  37805. /**
  37806. * Gets a boolean indicating if this mesh has thin instances
  37807. */
  37808. get hasThinInstances(): boolean;
  37809. /**
  37810. * Perform relative position change from the point of view of behind the front of the mesh.
  37811. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37812. * Supports definition of mesh facing forward or backward
  37813. * @param amountRight defines the distance on the right axis
  37814. * @param amountUp defines the distance on the up axis
  37815. * @param amountForward defines the distance on the forward axis
  37816. * @returns the current mesh
  37817. */
  37818. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37819. /**
  37820. * Calculate relative position change from the point of view of behind the front of the mesh.
  37821. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37822. * Supports definition of mesh facing forward or backward
  37823. * @param amountRight defines the distance on the right axis
  37824. * @param amountUp defines the distance on the up axis
  37825. * @param amountForward defines the distance on the forward axis
  37826. * @returns the new displacement vector
  37827. */
  37828. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37829. /**
  37830. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37831. * Supports definition of mesh facing forward or backward
  37832. * @param flipBack defines the flip
  37833. * @param twirlClockwise defines the twirl
  37834. * @param tiltRight defines the tilt
  37835. * @returns the current mesh
  37836. */
  37837. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37838. /**
  37839. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37840. * Supports definition of mesh facing forward or backward.
  37841. * @param flipBack defines the flip
  37842. * @param twirlClockwise defines the twirl
  37843. * @param tiltRight defines the tilt
  37844. * @returns the new rotation vector
  37845. */
  37846. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37847. /**
  37848. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37849. * This means the mesh underlying bounding box and sphere are recomputed.
  37850. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37851. * @returns the current mesh
  37852. */
  37853. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37854. /** @hidden */
  37855. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37856. /** @hidden */
  37857. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37858. /** @hidden */
  37859. _updateBoundingInfo(): AbstractMesh;
  37860. /** @hidden */
  37861. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37862. /** @hidden */
  37863. protected _afterComputeWorldMatrix(): void;
  37864. /** @hidden */
  37865. get _effectiveMesh(): AbstractMesh;
  37866. /**
  37867. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37868. * A mesh is in the frustum if its bounding box intersects the frustum
  37869. * @param frustumPlanes defines the frustum to test
  37870. * @returns true if the mesh is in the frustum planes
  37871. */
  37872. isInFrustum(frustumPlanes: Plane[]): boolean;
  37873. /**
  37874. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37875. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37876. * @param frustumPlanes defines the frustum to test
  37877. * @returns true if the mesh is completely in the frustum planes
  37878. */
  37879. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37880. /**
  37881. * True if the mesh intersects another mesh or a SolidParticle object
  37882. * @param mesh defines a target mesh or SolidParticle to test
  37883. * @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)
  37884. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37885. * @returns true if there is an intersection
  37886. */
  37887. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37888. /**
  37889. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37890. * @param point defines the point to test
  37891. * @returns true if there is an intersection
  37892. */
  37893. intersectsPoint(point: Vector3): boolean;
  37894. /**
  37895. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37896. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37897. */
  37898. get checkCollisions(): boolean;
  37899. set checkCollisions(collisionEnabled: boolean);
  37900. /**
  37901. * Gets Collider object used to compute collisions (not physics)
  37902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37903. */
  37904. get collider(): Nullable<Collider>;
  37905. /**
  37906. * Move the mesh using collision engine
  37907. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37908. * @param displacement defines the requested displacement vector
  37909. * @returns the current mesh
  37910. */
  37911. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37912. private _onCollisionPositionChange;
  37913. /** @hidden */
  37914. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37915. /** @hidden */
  37916. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37917. /** @hidden */
  37918. _checkCollision(collider: Collider): AbstractMesh;
  37919. /** @hidden */
  37920. _generatePointsArray(): boolean;
  37921. /**
  37922. * Checks if the passed Ray intersects with the mesh
  37923. * @param ray defines the ray to use
  37924. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37925. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37926. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37927. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37928. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37929. * @returns the picking info
  37930. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37931. */
  37932. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37933. /**
  37934. * Clones the current mesh
  37935. * @param name defines the mesh name
  37936. * @param newParent defines the new mesh parent
  37937. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37938. * @returns the new mesh
  37939. */
  37940. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37941. /**
  37942. * Disposes all the submeshes of the current meshnp
  37943. * @returns the current mesh
  37944. */
  37945. releaseSubMeshes(): AbstractMesh;
  37946. /**
  37947. * Releases resources associated with this abstract mesh.
  37948. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37949. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37950. */
  37951. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37952. /**
  37953. * Adds the passed mesh as a child to the current mesh
  37954. * @param mesh defines the child mesh
  37955. * @returns the current mesh
  37956. */
  37957. addChild(mesh: AbstractMesh): AbstractMesh;
  37958. /**
  37959. * Removes the passed mesh from the current mesh children list
  37960. * @param mesh defines the child mesh
  37961. * @returns the current mesh
  37962. */
  37963. removeChild(mesh: AbstractMesh): AbstractMesh;
  37964. /** @hidden */
  37965. private _initFacetData;
  37966. /**
  37967. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37968. * This method can be called within the render loop.
  37969. * 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
  37970. * @returns the current mesh
  37971. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37972. */
  37973. updateFacetData(): AbstractMesh;
  37974. /**
  37975. * Returns the facetLocalNormals array.
  37976. * The normals are expressed in the mesh local spac
  37977. * @returns an array of Vector3
  37978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37979. */
  37980. getFacetLocalNormals(): Vector3[];
  37981. /**
  37982. * Returns the facetLocalPositions array.
  37983. * The facet positions are expressed in the mesh local space
  37984. * @returns an array of Vector3
  37985. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37986. */
  37987. getFacetLocalPositions(): Vector3[];
  37988. /**
  37989. * Returns the facetLocalPartioning array
  37990. * @returns an array of array of numbers
  37991. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37992. */
  37993. getFacetLocalPartitioning(): number[][];
  37994. /**
  37995. * Returns the i-th facet position in the world system.
  37996. * This method allocates a new Vector3 per call
  37997. * @param i defines the facet index
  37998. * @returns a new Vector3
  37999. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38000. */
  38001. getFacetPosition(i: number): Vector3;
  38002. /**
  38003. * Sets the reference Vector3 with the i-th facet position in the world system
  38004. * @param i defines the facet index
  38005. * @param ref defines the target vector
  38006. * @returns the current mesh
  38007. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38008. */
  38009. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  38010. /**
  38011. * Returns the i-th facet normal in the world system.
  38012. * This method allocates a new Vector3 per call
  38013. * @param i defines the facet index
  38014. * @returns a new Vector3
  38015. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38016. */
  38017. getFacetNormal(i: number): Vector3;
  38018. /**
  38019. * Sets the reference Vector3 with the i-th facet normal in the world system
  38020. * @param i defines the facet index
  38021. * @param ref defines the target vector
  38022. * @returns the current mesh
  38023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38024. */
  38025. getFacetNormalToRef(i: number, ref: Vector3): this;
  38026. /**
  38027. * 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)
  38028. * @param x defines x coordinate
  38029. * @param y defines y coordinate
  38030. * @param z defines z coordinate
  38031. * @returns the array of facet indexes
  38032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38033. */
  38034. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  38035. /**
  38036. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  38037. * @param projected sets as the (x,y,z) world projection on the facet
  38038. * @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
  38039. * @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
  38040. * @param x defines x coordinate
  38041. * @param y defines y coordinate
  38042. * @param z defines z coordinate
  38043. * @returns the face index if found (or null instead)
  38044. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38045. */
  38046. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38047. /**
  38048. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  38049. * @param projected sets as the (x,y,z) local projection on the facet
  38050. * @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
  38051. * @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
  38052. * @param x defines x coordinate
  38053. * @param y defines y coordinate
  38054. * @param z defines z coordinate
  38055. * @returns the face index if found (or null instead)
  38056. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38057. */
  38058. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38059. /**
  38060. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  38061. * @returns the parameters
  38062. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38063. */
  38064. getFacetDataParameters(): any;
  38065. /**
  38066. * Disables the feature FacetData and frees the related memory
  38067. * @returns the current mesh
  38068. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38069. */
  38070. disableFacetData(): AbstractMesh;
  38071. /**
  38072. * Updates the AbstractMesh indices array
  38073. * @param indices defines the data source
  38074. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  38075. * @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)
  38076. * @returns the current mesh
  38077. */
  38078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  38079. /**
  38080. * Creates new normals data for the mesh
  38081. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  38082. * @returns the current mesh
  38083. */
  38084. createNormals(updatable: boolean): AbstractMesh;
  38085. /**
  38086. * Align the mesh with a normal
  38087. * @param normal defines the normal to use
  38088. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  38089. * @returns the current mesh
  38090. */
  38091. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  38092. /** @hidden */
  38093. _checkOcclusionQuery(): boolean;
  38094. /**
  38095. * Disables the mesh edge rendering mode
  38096. * @returns the currentAbstractMesh
  38097. */
  38098. disableEdgesRendering(): AbstractMesh;
  38099. /**
  38100. * Enables the edge rendering mode on the mesh.
  38101. * This mode makes the mesh edges visible
  38102. * @param epsilon defines the maximal distance between two angles to detect a face
  38103. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  38104. * @param options options to the edge renderer
  38105. * @returns the currentAbstractMesh
  38106. * @see https://www.babylonjs-playground.com/#19O9TU#0
  38107. */
  38108. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  38109. /**
  38110. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  38111. * @returns an array of particle systems in the scene that use the mesh as an emitter
  38112. */
  38113. getConnectedParticleSystems(): IParticleSystem[];
  38114. }
  38115. }
  38116. declare module "babylonjs/Actions/actionEvent" {
  38117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38118. import { Nullable } from "babylonjs/types";
  38119. import { Sprite } from "babylonjs/Sprites/sprite";
  38120. import { Scene } from "babylonjs/scene";
  38121. import { Vector2 } from "babylonjs/Maths/math.vector";
  38122. /**
  38123. * Interface used to define ActionEvent
  38124. */
  38125. export interface IActionEvent {
  38126. /** The mesh or sprite that triggered the action */
  38127. source: any;
  38128. /** The X mouse cursor position at the time of the event */
  38129. pointerX: number;
  38130. /** The Y mouse cursor position at the time of the event */
  38131. pointerY: number;
  38132. /** The mesh that is currently pointed at (can be null) */
  38133. meshUnderPointer: Nullable<AbstractMesh>;
  38134. /** the original (browser) event that triggered the ActionEvent */
  38135. sourceEvent?: any;
  38136. /** additional data for the event */
  38137. additionalData?: any;
  38138. }
  38139. /**
  38140. * ActionEvent is the event being sent when an action is triggered.
  38141. */
  38142. export class ActionEvent implements IActionEvent {
  38143. /** The mesh or sprite that triggered the action */
  38144. source: any;
  38145. /** The X mouse cursor position at the time of the event */
  38146. pointerX: number;
  38147. /** The Y mouse cursor position at the time of the event */
  38148. pointerY: number;
  38149. /** The mesh that is currently pointed at (can be null) */
  38150. meshUnderPointer: Nullable<AbstractMesh>;
  38151. /** the original (browser) event that triggered the ActionEvent */
  38152. sourceEvent?: any;
  38153. /** additional data for the event */
  38154. additionalData?: any;
  38155. /**
  38156. * Creates a new ActionEvent
  38157. * @param source The mesh or sprite that triggered the action
  38158. * @param pointerX The X mouse cursor position at the time of the event
  38159. * @param pointerY The Y mouse cursor position at the time of the event
  38160. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  38161. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  38162. * @param additionalData additional data for the event
  38163. */
  38164. constructor(
  38165. /** The mesh or sprite that triggered the action */
  38166. source: any,
  38167. /** The X mouse cursor position at the time of the event */
  38168. pointerX: number,
  38169. /** The Y mouse cursor position at the time of the event */
  38170. pointerY: number,
  38171. /** The mesh that is currently pointed at (can be null) */
  38172. meshUnderPointer: Nullable<AbstractMesh>,
  38173. /** the original (browser) event that triggered the ActionEvent */
  38174. sourceEvent?: any,
  38175. /** additional data for the event */
  38176. additionalData?: any);
  38177. /**
  38178. * Helper function to auto-create an ActionEvent from a source mesh.
  38179. * @param source The source mesh that triggered the event
  38180. * @param evt The original (browser) event
  38181. * @param additionalData additional data for the event
  38182. * @returns the new ActionEvent
  38183. */
  38184. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  38185. /**
  38186. * Helper function to auto-create an ActionEvent from a source sprite
  38187. * @param source The source sprite that triggered the event
  38188. * @param scene Scene associated with the sprite
  38189. * @param evt The original (browser) event
  38190. * @param additionalData additional data for the event
  38191. * @returns the new ActionEvent
  38192. */
  38193. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  38194. /**
  38195. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  38196. * @param scene the scene where the event occurred
  38197. * @param evt The original (browser) event
  38198. * @returns the new ActionEvent
  38199. */
  38200. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  38201. /**
  38202. * Helper function to auto-create an ActionEvent from a primitive
  38203. * @param prim defines the target primitive
  38204. * @param pointerPos defines the pointer position
  38205. * @param evt The original (browser) event
  38206. * @param additionalData additional data for the event
  38207. * @returns the new ActionEvent
  38208. */
  38209. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  38210. }
  38211. }
  38212. declare module "babylonjs/Actions/abstractActionManager" {
  38213. import { IDisposable } from "babylonjs/scene";
  38214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  38215. import { IAction } from "babylonjs/Actions/action";
  38216. import { Nullable } from "babylonjs/types";
  38217. /**
  38218. * Abstract class used to decouple action Manager from scene and meshes.
  38219. * Do not instantiate.
  38220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  38221. */
  38222. export abstract class AbstractActionManager implements IDisposable {
  38223. /** Gets the list of active triggers */
  38224. static Triggers: {
  38225. [key: string]: number;
  38226. };
  38227. /** Gets the cursor to use when hovering items */
  38228. hoverCursor: string;
  38229. /** Gets the list of actions */
  38230. actions: IAction[];
  38231. /**
  38232. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  38233. */
  38234. isRecursive: boolean;
  38235. /**
  38236. * Releases all associated resources
  38237. */
  38238. abstract dispose(): void;
  38239. /**
  38240. * Does this action manager has pointer triggers
  38241. */
  38242. abstract get hasPointerTriggers(): boolean;
  38243. /**
  38244. * Does this action manager has pick triggers
  38245. */
  38246. abstract get hasPickTriggers(): boolean;
  38247. /**
  38248. * Process a specific trigger
  38249. * @param trigger defines the trigger to process
  38250. * @param evt defines the event details to be processed
  38251. */
  38252. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  38253. /**
  38254. * Does this action manager handles actions of any of the given triggers
  38255. * @param triggers defines the triggers to be tested
  38256. * @return a boolean indicating whether one (or more) of the triggers is handled
  38257. */
  38258. abstract hasSpecificTriggers(triggers: number[]): boolean;
  38259. /**
  38260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  38261. * speed.
  38262. * @param triggerA defines the trigger to be tested
  38263. * @param triggerB defines the trigger to be tested
  38264. * @return a boolean indicating whether one (or more) of the triggers is handled
  38265. */
  38266. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  38267. /**
  38268. * Does this action manager handles actions of a given trigger
  38269. * @param trigger defines the trigger to be tested
  38270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  38271. * @return whether the trigger is handled
  38272. */
  38273. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  38274. /**
  38275. * Serialize this manager to a JSON object
  38276. * @param name defines the property name to store this manager
  38277. * @returns a JSON representation of this manager
  38278. */
  38279. abstract serialize(name: string): any;
  38280. /**
  38281. * Registers an action to this action manager
  38282. * @param action defines the action to be registered
  38283. * @return the action amended (prepared) after registration
  38284. */
  38285. abstract registerAction(action: IAction): Nullable<IAction>;
  38286. /**
  38287. * Unregisters an action to this action manager
  38288. * @param action defines the action to be unregistered
  38289. * @return a boolean indicating whether the action has been unregistered
  38290. */
  38291. abstract unregisterAction(action: IAction): Boolean;
  38292. /**
  38293. * Does exist one action manager with at least one trigger
  38294. **/
  38295. static get HasTriggers(): boolean;
  38296. /**
  38297. * Does exist one action manager with at least one pick trigger
  38298. **/
  38299. static get HasPickTriggers(): boolean;
  38300. /**
  38301. * Does exist one action manager that handles actions of a given trigger
  38302. * @param trigger defines the trigger to be tested
  38303. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  38304. **/
  38305. static HasSpecificTrigger(trigger: number): boolean;
  38306. }
  38307. }
  38308. declare module "babylonjs/node" {
  38309. import { Scene } from "babylonjs/scene";
  38310. import { Nullable } from "babylonjs/types";
  38311. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38312. import { Engine } from "babylonjs/Engines/engine";
  38313. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  38314. import { Observable } from "babylonjs/Misc/observable";
  38315. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38316. import { IInspectable } from "babylonjs/Misc/iInspectable";
  38317. import { Animatable } from "babylonjs/Animations/animatable";
  38318. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  38319. import { Animation } from "babylonjs/Animations/animation";
  38320. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38322. /**
  38323. * Defines how a node can be built from a string name.
  38324. */
  38325. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  38326. /**
  38327. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  38328. */
  38329. export class Node implements IBehaviorAware<Node> {
  38330. /** @hidden */
  38331. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  38332. private static _NodeConstructors;
  38333. /**
  38334. * Add a new node constructor
  38335. * @param type defines the type name of the node to construct
  38336. * @param constructorFunc defines the constructor function
  38337. */
  38338. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  38339. /**
  38340. * Returns a node constructor based on type name
  38341. * @param type defines the type name
  38342. * @param name defines the new node name
  38343. * @param scene defines the hosting scene
  38344. * @param options defines optional options to transmit to constructors
  38345. * @returns the new constructor or null
  38346. */
  38347. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  38348. /**
  38349. * Gets or sets the name of the node
  38350. */
  38351. name: string;
  38352. /**
  38353. * Gets or sets the id of the node
  38354. */
  38355. id: string;
  38356. /**
  38357. * Gets or sets the unique id of the node
  38358. */
  38359. uniqueId: number;
  38360. /**
  38361. * Gets or sets a string used to store user defined state for the node
  38362. */
  38363. state: string;
  38364. /**
  38365. * Gets or sets an object used to store user defined information for the node
  38366. */
  38367. metadata: any;
  38368. /**
  38369. * For internal use only. Please do not use.
  38370. */
  38371. reservedDataStore: any;
  38372. /**
  38373. * List of inspectable custom properties (used by the Inspector)
  38374. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  38375. */
  38376. inspectableCustomProperties: IInspectable[];
  38377. private _doNotSerialize;
  38378. /**
  38379. * Gets or sets a boolean used to define if the node must be serialized
  38380. */
  38381. get doNotSerialize(): boolean;
  38382. set doNotSerialize(value: boolean);
  38383. /** @hidden */
  38384. _isDisposed: boolean;
  38385. /**
  38386. * Gets a list of Animations associated with the node
  38387. */
  38388. animations: import("babylonjs/Animations/animation").Animation[];
  38389. protected _ranges: {
  38390. [name: string]: Nullable<AnimationRange>;
  38391. };
  38392. /**
  38393. * Callback raised when the node is ready to be used
  38394. */
  38395. onReady: Nullable<(node: Node) => void>;
  38396. private _isEnabled;
  38397. private _isParentEnabled;
  38398. private _isReady;
  38399. /** @hidden */
  38400. _currentRenderId: number;
  38401. private _parentUpdateId;
  38402. /** @hidden */
  38403. _childUpdateId: number;
  38404. /** @hidden */
  38405. _waitingParentId: Nullable<string>;
  38406. /** @hidden */
  38407. _scene: Scene;
  38408. /** @hidden */
  38409. _cache: any;
  38410. private _parentNode;
  38411. private _children;
  38412. /** @hidden */
  38413. _worldMatrix: Matrix;
  38414. /** @hidden */
  38415. _worldMatrixDeterminant: number;
  38416. /** @hidden */
  38417. _worldMatrixDeterminantIsDirty: boolean;
  38418. /** @hidden */
  38419. private _sceneRootNodesIndex;
  38420. /**
  38421. * Gets a boolean indicating if the node has been disposed
  38422. * @returns true if the node was disposed
  38423. */
  38424. isDisposed(): boolean;
  38425. /**
  38426. * Gets or sets the parent of the node (without keeping the current position in the scene)
  38427. * @see https://doc.babylonjs.com/how_to/parenting
  38428. */
  38429. set parent(parent: Nullable<Node>);
  38430. get parent(): Nullable<Node>;
  38431. /** @hidden */
  38432. _addToSceneRootNodes(): void;
  38433. /** @hidden */
  38434. _removeFromSceneRootNodes(): void;
  38435. private _animationPropertiesOverride;
  38436. /**
  38437. * Gets or sets the animation properties override
  38438. */
  38439. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38440. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38441. /**
  38442. * Gets a string identifying the name of the class
  38443. * @returns "Node" string
  38444. */
  38445. getClassName(): string;
  38446. /** @hidden */
  38447. readonly _isNode: boolean;
  38448. /**
  38449. * An event triggered when the mesh is disposed
  38450. */
  38451. onDisposeObservable: Observable<Node>;
  38452. private _onDisposeObserver;
  38453. /**
  38454. * Sets a callback that will be raised when the node will be disposed
  38455. */
  38456. set onDispose(callback: () => void);
  38457. /**
  38458. * Creates a new Node
  38459. * @param name the name and id to be given to this node
  38460. * @param scene the scene this node will be added to
  38461. */
  38462. constructor(name: string, scene?: Nullable<Scene>);
  38463. /**
  38464. * Gets the scene of the node
  38465. * @returns a scene
  38466. */
  38467. getScene(): Scene;
  38468. /**
  38469. * Gets the engine of the node
  38470. * @returns a Engine
  38471. */
  38472. getEngine(): Engine;
  38473. private _behaviors;
  38474. /**
  38475. * Attach a behavior to the node
  38476. * @see https://doc.babylonjs.com/features/behaviour
  38477. * @param behavior defines the behavior to attach
  38478. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  38479. * @returns the current Node
  38480. */
  38481. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  38482. /**
  38483. * Remove an attached behavior
  38484. * @see https://doc.babylonjs.com/features/behaviour
  38485. * @param behavior defines the behavior to attach
  38486. * @returns the current Node
  38487. */
  38488. removeBehavior(behavior: Behavior<Node>): Node;
  38489. /**
  38490. * Gets the list of attached behaviors
  38491. * @see https://doc.babylonjs.com/features/behaviour
  38492. */
  38493. get behaviors(): Behavior<Node>[];
  38494. /**
  38495. * Gets an attached behavior by name
  38496. * @param name defines the name of the behavior to look for
  38497. * @see https://doc.babylonjs.com/features/behaviour
  38498. * @returns null if behavior was not found else the requested behavior
  38499. */
  38500. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38501. /**
  38502. * Returns the latest update of the World matrix
  38503. * @returns a Matrix
  38504. */
  38505. getWorldMatrix(): Matrix;
  38506. /** @hidden */
  38507. _getWorldMatrixDeterminant(): number;
  38508. /**
  38509. * Returns directly the latest state of the mesh World matrix.
  38510. * A Matrix is returned.
  38511. */
  38512. get worldMatrixFromCache(): Matrix;
  38513. /** @hidden */
  38514. _initCache(): void;
  38515. /** @hidden */
  38516. updateCache(force?: boolean): void;
  38517. /** @hidden */
  38518. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38519. /** @hidden */
  38520. _updateCache(ignoreParentClass?: boolean): void;
  38521. /** @hidden */
  38522. _isSynchronized(): boolean;
  38523. /** @hidden */
  38524. _markSyncedWithParent(): void;
  38525. /** @hidden */
  38526. isSynchronizedWithParent(): boolean;
  38527. /** @hidden */
  38528. isSynchronized(): boolean;
  38529. /**
  38530. * Is this node ready to be used/rendered
  38531. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38532. * @return true if the node is ready
  38533. */
  38534. isReady(completeCheck?: boolean): boolean;
  38535. /**
  38536. * Is this node enabled?
  38537. * 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
  38538. * @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
  38539. * @return whether this node (and its parent) is enabled
  38540. */
  38541. isEnabled(checkAncestors?: boolean): boolean;
  38542. /** @hidden */
  38543. protected _syncParentEnabledState(): void;
  38544. /**
  38545. * Set the enabled state of this node
  38546. * @param value defines the new enabled state
  38547. */
  38548. setEnabled(value: boolean): void;
  38549. /**
  38550. * Is this node a descendant of the given node?
  38551. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38552. * @param ancestor defines the parent node to inspect
  38553. * @returns a boolean indicating if this node is a descendant of the given node
  38554. */
  38555. isDescendantOf(ancestor: Node): boolean;
  38556. /** @hidden */
  38557. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38558. /**
  38559. * Will return all nodes that have this node as ascendant
  38560. * @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
  38561. * @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
  38562. * @return all children nodes of all types
  38563. */
  38564. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38565. /**
  38566. * Get all child-meshes of this node
  38567. * @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)
  38568. * @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
  38569. * @returns an array of AbstractMesh
  38570. */
  38571. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38572. /**
  38573. * Get all direct children of this node
  38574. * @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
  38575. * @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)
  38576. * @returns an array of Node
  38577. */
  38578. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38579. /** @hidden */
  38580. _setReady(state: boolean): void;
  38581. /**
  38582. * Get an animation by name
  38583. * @param name defines the name of the animation to look for
  38584. * @returns null if not found else the requested animation
  38585. */
  38586. getAnimationByName(name: string): Nullable<Animation>;
  38587. /**
  38588. * Creates an animation range for this node
  38589. * @param name defines the name of the range
  38590. * @param from defines the starting key
  38591. * @param to defines the end key
  38592. */
  38593. createAnimationRange(name: string, from: number, to: number): void;
  38594. /**
  38595. * Delete a specific animation range
  38596. * @param name defines the name of the range to delete
  38597. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38598. */
  38599. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38600. /**
  38601. * Get an animation range by name
  38602. * @param name defines the name of the animation range to look for
  38603. * @returns null if not found else the requested animation range
  38604. */
  38605. getAnimationRange(name: string): Nullable<AnimationRange>;
  38606. /**
  38607. * Gets the list of all animation ranges defined on this node
  38608. * @returns an array
  38609. */
  38610. getAnimationRanges(): Nullable<AnimationRange>[];
  38611. /**
  38612. * Will start the animation sequence
  38613. * @param name defines the range frames for animation sequence
  38614. * @param loop defines if the animation should loop (false by default)
  38615. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38616. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38617. * @returns the object created for this animation. If range does not exist, it will return null
  38618. */
  38619. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38620. /**
  38621. * Serialize animation ranges into a JSON compatible object
  38622. * @returns serialization object
  38623. */
  38624. serializeAnimationRanges(): any;
  38625. /**
  38626. * Computes the world matrix of the node
  38627. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38628. * @returns the world matrix
  38629. */
  38630. computeWorldMatrix(force?: boolean): Matrix;
  38631. /**
  38632. * Releases resources associated with this node.
  38633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38635. */
  38636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38637. /**
  38638. * Parse animation range data from a serialization object and store them into a given node
  38639. * @param node defines where to store the animation ranges
  38640. * @param parsedNode defines the serialization object to read data from
  38641. * @param scene defines the hosting scene
  38642. */
  38643. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38644. /**
  38645. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38646. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38647. * @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
  38648. * @returns the new bounding vectors
  38649. */
  38650. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38651. min: Vector3;
  38652. max: Vector3;
  38653. };
  38654. }
  38655. }
  38656. declare module "babylonjs/Animations/animation" {
  38657. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38658. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38659. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38660. import { Nullable } from "babylonjs/types";
  38661. import { Scene } from "babylonjs/scene";
  38662. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38663. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38664. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38665. import { Node } from "babylonjs/node";
  38666. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38667. import { Size } from "babylonjs/Maths/math.size";
  38668. import { Animatable } from "babylonjs/Animations/animatable";
  38669. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38670. /**
  38671. * @hidden
  38672. */
  38673. export class _IAnimationState {
  38674. key: number;
  38675. repeatCount: number;
  38676. workValue?: any;
  38677. loopMode?: number;
  38678. offsetValue?: any;
  38679. highLimitValue?: any;
  38680. }
  38681. /**
  38682. * Class used to store any kind of animation
  38683. */
  38684. export class Animation {
  38685. /**Name of the animation */
  38686. name: string;
  38687. /**Property to animate */
  38688. targetProperty: string;
  38689. /**The frames per second of the animation */
  38690. framePerSecond: number;
  38691. /**The data type of the animation */
  38692. dataType: number;
  38693. /**The loop mode of the animation */
  38694. loopMode?: number | undefined;
  38695. /**Specifies if blending should be enabled */
  38696. enableBlending?: boolean | undefined;
  38697. /**
  38698. * Use matrix interpolation instead of using direct key value when animating matrices
  38699. */
  38700. static AllowMatricesInterpolation: boolean;
  38701. /**
  38702. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38703. */
  38704. static AllowMatrixDecomposeForInterpolation: boolean;
  38705. /** Define the Url to load snippets */
  38706. static SnippetUrl: string;
  38707. /** Snippet ID if the animation was created from the snippet server */
  38708. snippetId: string;
  38709. /**
  38710. * Stores the key frames of the animation
  38711. */
  38712. private _keys;
  38713. /**
  38714. * Stores the easing function of the animation
  38715. */
  38716. private _easingFunction;
  38717. /**
  38718. * @hidden Internal use only
  38719. */
  38720. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38721. /**
  38722. * The set of event that will be linked to this animation
  38723. */
  38724. private _events;
  38725. /**
  38726. * Stores an array of target property paths
  38727. */
  38728. targetPropertyPath: string[];
  38729. /**
  38730. * Stores the blending speed of the animation
  38731. */
  38732. blendingSpeed: number;
  38733. /**
  38734. * Stores the animation ranges for the animation
  38735. */
  38736. private _ranges;
  38737. /**
  38738. * @hidden Internal use
  38739. */
  38740. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38741. /**
  38742. * Sets up an animation
  38743. * @param property The property to animate
  38744. * @param animationType The animation type to apply
  38745. * @param framePerSecond The frames per second of the animation
  38746. * @param easingFunction The easing function used in the animation
  38747. * @returns The created animation
  38748. */
  38749. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38750. /**
  38751. * Create and start an animation on a node
  38752. * @param name defines the name of the global animation that will be run on all nodes
  38753. * @param node defines the root node where the animation will take place
  38754. * @param targetProperty defines property to animate
  38755. * @param framePerSecond defines the number of frame per second yo use
  38756. * @param totalFrame defines the number of frames in total
  38757. * @param from defines the initial value
  38758. * @param to defines the final value
  38759. * @param loopMode defines which loop mode you want to use (off by default)
  38760. * @param easingFunction defines the easing function to use (linear by default)
  38761. * @param onAnimationEnd defines the callback to call when animation end
  38762. * @returns the animatable created for this animation
  38763. */
  38764. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38765. /**
  38766. * Create and start an animation on a node and its descendants
  38767. * @param name defines the name of the global animation that will be run on all nodes
  38768. * @param node defines the root node where the animation will take place
  38769. * @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
  38770. * @param targetProperty defines property to animate
  38771. * @param framePerSecond defines the number of frame per second to use
  38772. * @param totalFrame defines the number of frames in total
  38773. * @param from defines the initial value
  38774. * @param to defines the final value
  38775. * @param loopMode defines which loop mode you want to use (off by default)
  38776. * @param easingFunction defines the easing function to use (linear by default)
  38777. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38778. * @returns the list of animatables created for all nodes
  38779. * @example https://www.babylonjs-playground.com/#MH0VLI
  38780. */
  38781. 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[]>;
  38782. /**
  38783. * Creates a new animation, merges it with the existing animations and starts it
  38784. * @param name Name of the animation
  38785. * @param node Node which contains the scene that begins the animations
  38786. * @param targetProperty Specifies which property to animate
  38787. * @param framePerSecond The frames per second of the animation
  38788. * @param totalFrame The total number of frames
  38789. * @param from The frame at the beginning of the animation
  38790. * @param to The frame at the end of the animation
  38791. * @param loopMode Specifies the loop mode of the animation
  38792. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38793. * @param onAnimationEnd Callback to run once the animation is complete
  38794. * @returns Nullable animation
  38795. */
  38796. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38797. /**
  38798. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38799. * @param sourceAnimation defines the Animation containing keyframes to convert
  38800. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38801. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38802. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38803. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38804. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38805. */
  38806. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38807. /**
  38808. * Transition property of an host to the target Value
  38809. * @param property The property to transition
  38810. * @param targetValue The target Value of the property
  38811. * @param host The object where the property to animate belongs
  38812. * @param scene Scene used to run the animation
  38813. * @param frameRate Framerate (in frame/s) to use
  38814. * @param transition The transition type we want to use
  38815. * @param duration The duration of the animation, in milliseconds
  38816. * @param onAnimationEnd Callback trigger at the end of the animation
  38817. * @returns Nullable animation
  38818. */
  38819. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38820. /**
  38821. * Return the array of runtime animations currently using this animation
  38822. */
  38823. get runtimeAnimations(): RuntimeAnimation[];
  38824. /**
  38825. * Specifies if any of the runtime animations are currently running
  38826. */
  38827. get hasRunningRuntimeAnimations(): boolean;
  38828. /**
  38829. * Initializes the animation
  38830. * @param name Name of the animation
  38831. * @param targetProperty Property to animate
  38832. * @param framePerSecond The frames per second of the animation
  38833. * @param dataType The data type of the animation
  38834. * @param loopMode The loop mode of the animation
  38835. * @param enableBlending Specifies if blending should be enabled
  38836. */
  38837. constructor(
  38838. /**Name of the animation */
  38839. name: string,
  38840. /**Property to animate */
  38841. targetProperty: string,
  38842. /**The frames per second of the animation */
  38843. framePerSecond: number,
  38844. /**The data type of the animation */
  38845. dataType: number,
  38846. /**The loop mode of the animation */
  38847. loopMode?: number | undefined,
  38848. /**Specifies if blending should be enabled */
  38849. enableBlending?: boolean | undefined);
  38850. /**
  38851. * Converts the animation to a string
  38852. * @param fullDetails support for multiple levels of logging within scene loading
  38853. * @returns String form of the animation
  38854. */
  38855. toString(fullDetails?: boolean): string;
  38856. /**
  38857. * Add an event to this animation
  38858. * @param event Event to add
  38859. */
  38860. addEvent(event: AnimationEvent): void;
  38861. /**
  38862. * Remove all events found at the given frame
  38863. * @param frame The frame to remove events from
  38864. */
  38865. removeEvents(frame: number): void;
  38866. /**
  38867. * Retrieves all the events from the animation
  38868. * @returns Events from the animation
  38869. */
  38870. getEvents(): AnimationEvent[];
  38871. /**
  38872. * Creates an animation range
  38873. * @param name Name of the animation range
  38874. * @param from Starting frame of the animation range
  38875. * @param to Ending frame of the animation
  38876. */
  38877. createRange(name: string, from: number, to: number): void;
  38878. /**
  38879. * Deletes an animation range by name
  38880. * @param name Name of the animation range to delete
  38881. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38882. */
  38883. deleteRange(name: string, deleteFrames?: boolean): void;
  38884. /**
  38885. * Gets the animation range by name, or null if not defined
  38886. * @param name Name of the animation range
  38887. * @returns Nullable animation range
  38888. */
  38889. getRange(name: string): Nullable<AnimationRange>;
  38890. /**
  38891. * Gets the key frames from the animation
  38892. * @returns The key frames of the animation
  38893. */
  38894. getKeys(): Array<IAnimationKey>;
  38895. /**
  38896. * Gets the highest frame rate of the animation
  38897. * @returns Highest frame rate of the animation
  38898. */
  38899. getHighestFrame(): number;
  38900. /**
  38901. * Gets the easing function of the animation
  38902. * @returns Easing function of the animation
  38903. */
  38904. getEasingFunction(): IEasingFunction;
  38905. /**
  38906. * Sets the easing function of the animation
  38907. * @param easingFunction A custom mathematical formula for animation
  38908. */
  38909. setEasingFunction(easingFunction: EasingFunction): void;
  38910. /**
  38911. * Interpolates a scalar linearly
  38912. * @param startValue Start value of the animation curve
  38913. * @param endValue End value of the animation curve
  38914. * @param gradient Scalar amount to interpolate
  38915. * @returns Interpolated scalar value
  38916. */
  38917. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38918. /**
  38919. * Interpolates a scalar cubically
  38920. * @param startValue Start value of the animation curve
  38921. * @param outTangent End tangent of the animation
  38922. * @param endValue End value of the animation curve
  38923. * @param inTangent Start tangent of the animation curve
  38924. * @param gradient Scalar amount to interpolate
  38925. * @returns Interpolated scalar value
  38926. */
  38927. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38928. /**
  38929. * Interpolates a quaternion using a spherical linear interpolation
  38930. * @param startValue Start value of the animation curve
  38931. * @param endValue End value of the animation curve
  38932. * @param gradient Scalar amount to interpolate
  38933. * @returns Interpolated quaternion value
  38934. */
  38935. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38936. /**
  38937. * Interpolates a quaternion cubically
  38938. * @param startValue Start value of the animation curve
  38939. * @param outTangent End tangent of the animation curve
  38940. * @param endValue End value of the animation curve
  38941. * @param inTangent Start tangent of the animation curve
  38942. * @param gradient Scalar amount to interpolate
  38943. * @returns Interpolated quaternion value
  38944. */
  38945. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38946. /**
  38947. * Interpolates a Vector3 linearl
  38948. * @param startValue Start value of the animation curve
  38949. * @param endValue End value of the animation curve
  38950. * @param gradient Scalar amount to interpolate
  38951. * @returns Interpolated scalar value
  38952. */
  38953. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38954. /**
  38955. * Interpolates a Vector3 cubically
  38956. * @param startValue Start value of the animation curve
  38957. * @param outTangent End tangent of the animation
  38958. * @param endValue End value of the animation curve
  38959. * @param inTangent Start tangent of the animation curve
  38960. * @param gradient Scalar amount to interpolate
  38961. * @returns InterpolatedVector3 value
  38962. */
  38963. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38964. /**
  38965. * Interpolates a Vector2 linearly
  38966. * @param startValue Start value of the animation curve
  38967. * @param endValue End value of the animation curve
  38968. * @param gradient Scalar amount to interpolate
  38969. * @returns Interpolated Vector2 value
  38970. */
  38971. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38972. /**
  38973. * Interpolates a Vector2 cubically
  38974. * @param startValue Start value of the animation curve
  38975. * @param outTangent End tangent of the animation
  38976. * @param endValue End value of the animation curve
  38977. * @param inTangent Start tangent of the animation curve
  38978. * @param gradient Scalar amount to interpolate
  38979. * @returns Interpolated Vector2 value
  38980. */
  38981. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38982. /**
  38983. * Interpolates a size linearly
  38984. * @param startValue Start value of the animation curve
  38985. * @param endValue End value of the animation curve
  38986. * @param gradient Scalar amount to interpolate
  38987. * @returns Interpolated Size value
  38988. */
  38989. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38990. /**
  38991. * Interpolates a Color3 linearly
  38992. * @param startValue Start value of the animation curve
  38993. * @param endValue End value of the animation curve
  38994. * @param gradient Scalar amount to interpolate
  38995. * @returns Interpolated Color3 value
  38996. */
  38997. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38998. /**
  38999. * Interpolates a Color4 linearly
  39000. * @param startValue Start value of the animation curve
  39001. * @param endValue End value of the animation curve
  39002. * @param gradient Scalar amount to interpolate
  39003. * @returns Interpolated Color3 value
  39004. */
  39005. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  39006. /**
  39007. * @hidden Internal use only
  39008. */
  39009. _getKeyValue(value: any): any;
  39010. /**
  39011. * @hidden Internal use only
  39012. */
  39013. _interpolate(currentFrame: number, state: _IAnimationState): any;
  39014. /**
  39015. * Defines the function to use to interpolate matrices
  39016. * @param startValue defines the start matrix
  39017. * @param endValue defines the end matrix
  39018. * @param gradient defines the gradient between both matrices
  39019. * @param result defines an optional target matrix where to store the interpolation
  39020. * @returns the interpolated matrix
  39021. */
  39022. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  39023. /**
  39024. * Makes a copy of the animation
  39025. * @returns Cloned animation
  39026. */
  39027. clone(): Animation;
  39028. /**
  39029. * Sets the key frames of the animation
  39030. * @param values The animation key frames to set
  39031. */
  39032. setKeys(values: Array<IAnimationKey>): void;
  39033. /**
  39034. * Serializes the animation to an object
  39035. * @returns Serialized object
  39036. */
  39037. serialize(): any;
  39038. /**
  39039. * Float animation type
  39040. */
  39041. static readonly ANIMATIONTYPE_FLOAT: number;
  39042. /**
  39043. * Vector3 animation type
  39044. */
  39045. static readonly ANIMATIONTYPE_VECTOR3: number;
  39046. /**
  39047. * Quaternion animation type
  39048. */
  39049. static readonly ANIMATIONTYPE_QUATERNION: number;
  39050. /**
  39051. * Matrix animation type
  39052. */
  39053. static readonly ANIMATIONTYPE_MATRIX: number;
  39054. /**
  39055. * Color3 animation type
  39056. */
  39057. static readonly ANIMATIONTYPE_COLOR3: number;
  39058. /**
  39059. * Color3 animation type
  39060. */
  39061. static readonly ANIMATIONTYPE_COLOR4: number;
  39062. /**
  39063. * Vector2 animation type
  39064. */
  39065. static readonly ANIMATIONTYPE_VECTOR2: number;
  39066. /**
  39067. * Size animation type
  39068. */
  39069. static readonly ANIMATIONTYPE_SIZE: number;
  39070. /**
  39071. * Relative Loop Mode
  39072. */
  39073. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  39074. /**
  39075. * Cycle Loop Mode
  39076. */
  39077. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  39078. /**
  39079. * Constant Loop Mode
  39080. */
  39081. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  39082. /** @hidden */
  39083. static _UniversalLerp(left: any, right: any, amount: number): any;
  39084. /**
  39085. * Parses an animation object and creates an animation
  39086. * @param parsedAnimation Parsed animation object
  39087. * @returns Animation object
  39088. */
  39089. static Parse(parsedAnimation: any): Animation;
  39090. /**
  39091. * Appends the serialized animations from the source animations
  39092. * @param source Source containing the animations
  39093. * @param destination Target to store the animations
  39094. */
  39095. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39096. /**
  39097. * Creates a new animation or an array of animations from a snippet saved in a remote file
  39098. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  39099. * @param url defines the url to load from
  39100. * @returns a promise that will resolve to the new animation or an array of animations
  39101. */
  39102. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  39103. /**
  39104. * Creates an animation or an array of animations from a snippet saved by the Inspector
  39105. * @param snippetId defines the snippet to load
  39106. * @returns a promise that will resolve to the new animation or a new array of animations
  39107. */
  39108. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  39109. }
  39110. }
  39111. declare module "babylonjs/Animations/animatable.interface" {
  39112. import { Nullable } from "babylonjs/types";
  39113. import { Animation } from "babylonjs/Animations/animation";
  39114. /**
  39115. * Interface containing an array of animations
  39116. */
  39117. export interface IAnimatable {
  39118. /**
  39119. * Array of animations
  39120. */
  39121. animations: Nullable<Array<Animation>>;
  39122. }
  39123. }
  39124. declare module "babylonjs/Misc/decorators" {
  39125. import { Nullable } from "babylonjs/types";
  39126. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39127. import { Scene } from "babylonjs/scene";
  39128. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39129. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39130. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39132. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  39133. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39134. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39135. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39136. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39137. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39138. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39139. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39140. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39141. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39142. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39143. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39144. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39145. /**
  39146. * Decorator used to define property that can be serialized as reference to a camera
  39147. * @param sourceName defines the name of the property to decorate
  39148. */
  39149. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39150. /**
  39151. * Class used to help serialization objects
  39152. */
  39153. export class SerializationHelper {
  39154. /** @hidden */
  39155. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  39156. /** @hidden */
  39157. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  39158. /** @hidden */
  39159. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  39160. /** @hidden */
  39161. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  39162. /**
  39163. * Appends the serialized animations from the source animations
  39164. * @param source Source containing the animations
  39165. * @param destination Target to store the animations
  39166. */
  39167. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39168. /**
  39169. * Static function used to serialized a specific entity
  39170. * @param entity defines the entity to serialize
  39171. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  39172. * @returns a JSON compatible object representing the serialization of the entity
  39173. */
  39174. static Serialize<T>(entity: T, serializationObject?: any): any;
  39175. /**
  39176. * Creates a new entity from a serialization data object
  39177. * @param creationFunction defines a function used to instanciated the new entity
  39178. * @param source defines the source serialization data
  39179. * @param scene defines the hosting scene
  39180. * @param rootUrl defines the root url for resources
  39181. * @returns a new entity
  39182. */
  39183. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  39184. /**
  39185. * Clones an object
  39186. * @param creationFunction defines the function used to instanciate the new object
  39187. * @param source defines the source object
  39188. * @returns the cloned object
  39189. */
  39190. static Clone<T>(creationFunction: () => T, source: T): T;
  39191. /**
  39192. * Instanciates a new object based on a source one (some data will be shared between both object)
  39193. * @param creationFunction defines the function used to instanciate the new object
  39194. * @param source defines the source object
  39195. * @returns the new object
  39196. */
  39197. static Instanciate<T>(creationFunction: () => T, source: T): T;
  39198. }
  39199. }
  39200. declare module "babylonjs/Cameras/camera" {
  39201. import { SmartArray } from "babylonjs/Misc/smartArray";
  39202. import { Observable } from "babylonjs/Misc/observable";
  39203. import { Nullable } from "babylonjs/types";
  39204. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39205. import { Scene } from "babylonjs/scene";
  39206. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39207. import { Node } from "babylonjs/node";
  39208. import { Mesh } from "babylonjs/Meshes/mesh";
  39209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39210. import { ICullable } from "babylonjs/Culling/boundingInfo";
  39211. import { Viewport } from "babylonjs/Maths/math.viewport";
  39212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39214. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39215. import { Ray } from "babylonjs/Culling/ray";
  39216. /**
  39217. * This is the base class of all the camera used in the application.
  39218. * @see https://doc.babylonjs.com/features/cameras
  39219. */
  39220. export class Camera extends Node {
  39221. /** @hidden */
  39222. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  39223. /**
  39224. * This is the default projection mode used by the cameras.
  39225. * It helps recreating a feeling of perspective and better appreciate depth.
  39226. * This is the best way to simulate real life cameras.
  39227. */
  39228. static readonly PERSPECTIVE_CAMERA: number;
  39229. /**
  39230. * This helps creating camera with an orthographic mode.
  39231. * 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.
  39232. */
  39233. static readonly ORTHOGRAPHIC_CAMERA: number;
  39234. /**
  39235. * This is the default FOV mode for perspective cameras.
  39236. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  39237. */
  39238. static readonly FOVMODE_VERTICAL_FIXED: number;
  39239. /**
  39240. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  39241. */
  39242. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  39243. /**
  39244. * This specifies ther is no need for a camera rig.
  39245. * Basically only one eye is rendered corresponding to the camera.
  39246. */
  39247. static readonly RIG_MODE_NONE: number;
  39248. /**
  39249. * Simulates a camera Rig with one blue eye and one red eye.
  39250. * This can be use with 3d blue and red glasses.
  39251. */
  39252. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  39253. /**
  39254. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  39255. */
  39256. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  39257. /**
  39258. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  39259. */
  39260. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  39261. /**
  39262. * Defines that both eyes of the camera will be rendered over under each other.
  39263. */
  39264. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  39265. /**
  39266. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  39267. */
  39268. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  39269. /**
  39270. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  39271. */
  39272. static readonly RIG_MODE_VR: number;
  39273. /**
  39274. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  39275. */
  39276. static readonly RIG_MODE_WEBVR: number;
  39277. /**
  39278. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  39279. */
  39280. static readonly RIG_MODE_CUSTOM: number;
  39281. /**
  39282. * Defines if by default attaching controls should prevent the default javascript event to continue.
  39283. */
  39284. static ForceAttachControlToAlwaysPreventDefault: boolean;
  39285. /**
  39286. * Define the input manager associated with the camera.
  39287. */
  39288. inputs: CameraInputsManager<Camera>;
  39289. /** @hidden */
  39290. _position: Vector3;
  39291. /**
  39292. * Define the current local position of the camera in the scene
  39293. */
  39294. get position(): Vector3;
  39295. set position(newPosition: Vector3);
  39296. protected _upVector: Vector3;
  39297. /**
  39298. * The vector the camera should consider as up.
  39299. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  39300. */
  39301. set upVector(vec: Vector3);
  39302. get upVector(): Vector3;
  39303. /**
  39304. * Define the current limit on the left side for an orthographic camera
  39305. * In scene unit
  39306. */
  39307. orthoLeft: Nullable<number>;
  39308. /**
  39309. * Define the current limit on the right side for an orthographic camera
  39310. * In scene unit
  39311. */
  39312. orthoRight: Nullable<number>;
  39313. /**
  39314. * Define the current limit on the bottom side for an orthographic camera
  39315. * In scene unit
  39316. */
  39317. orthoBottom: Nullable<number>;
  39318. /**
  39319. * Define the current limit on the top side for an orthographic camera
  39320. * In scene unit
  39321. */
  39322. orthoTop: Nullable<number>;
  39323. /**
  39324. * Field Of View is set in Radians. (default is 0.8)
  39325. */
  39326. fov: number;
  39327. /**
  39328. * Define the minimum distance the camera can see from.
  39329. * This is important to note that the depth buffer are not infinite and the closer it starts
  39330. * the more your scene might encounter depth fighting issue.
  39331. */
  39332. minZ: number;
  39333. /**
  39334. * Define the maximum distance the camera can see to.
  39335. * This is important to note that the depth buffer are not infinite and the further it end
  39336. * the more your scene might encounter depth fighting issue.
  39337. */
  39338. maxZ: number;
  39339. /**
  39340. * Define the default inertia of the camera.
  39341. * This helps giving a smooth feeling to the camera movement.
  39342. */
  39343. inertia: number;
  39344. /**
  39345. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  39346. */
  39347. mode: number;
  39348. /**
  39349. * Define whether the camera is intermediate.
  39350. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  39351. */
  39352. isIntermediate: boolean;
  39353. /**
  39354. * Define the viewport of the camera.
  39355. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  39356. */
  39357. viewport: Viewport;
  39358. /**
  39359. * Restricts the camera to viewing objects with the same layerMask.
  39360. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  39361. */
  39362. layerMask: number;
  39363. /**
  39364. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  39365. */
  39366. fovMode: number;
  39367. /**
  39368. * Rig mode of the camera.
  39369. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  39370. * This is normally controlled byt the camera themselves as internal use.
  39371. */
  39372. cameraRigMode: number;
  39373. /**
  39374. * Defines the distance between both "eyes" in case of a RIG
  39375. */
  39376. interaxialDistance: number;
  39377. /**
  39378. * Defines if stereoscopic rendering is done side by side or over under.
  39379. */
  39380. isStereoscopicSideBySide: boolean;
  39381. /**
  39382. * 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
  39383. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  39384. * else in the scene. (Eg. security camera)
  39385. *
  39386. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  39387. */
  39388. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  39389. /**
  39390. * When set, the camera will render to this render target instead of the default canvas
  39391. *
  39392. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  39393. */
  39394. outputRenderTarget: Nullable<RenderTargetTexture>;
  39395. /**
  39396. * Observable triggered when the camera view matrix has changed.
  39397. */
  39398. onViewMatrixChangedObservable: Observable<Camera>;
  39399. /**
  39400. * Observable triggered when the camera Projection matrix has changed.
  39401. */
  39402. onProjectionMatrixChangedObservable: Observable<Camera>;
  39403. /**
  39404. * Observable triggered when the inputs have been processed.
  39405. */
  39406. onAfterCheckInputsObservable: Observable<Camera>;
  39407. /**
  39408. * Observable triggered when reset has been called and applied to the camera.
  39409. */
  39410. onRestoreStateObservable: Observable<Camera>;
  39411. /**
  39412. * Is this camera a part of a rig system?
  39413. */
  39414. isRigCamera: boolean;
  39415. /**
  39416. * If isRigCamera set to true this will be set with the parent camera.
  39417. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  39418. */
  39419. rigParent?: Camera;
  39420. /** @hidden */
  39421. _cameraRigParams: any;
  39422. /** @hidden */
  39423. _rigCameras: Camera[];
  39424. /** @hidden */
  39425. _rigPostProcess: Nullable<PostProcess>;
  39426. protected _webvrViewMatrix: Matrix;
  39427. /** @hidden */
  39428. _skipRendering: boolean;
  39429. /** @hidden */
  39430. _projectionMatrix: Matrix;
  39431. /** @hidden */
  39432. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  39433. /** @hidden */
  39434. _activeMeshes: SmartArray<AbstractMesh>;
  39435. protected _globalPosition: Vector3;
  39436. /** @hidden */
  39437. _computedViewMatrix: Matrix;
  39438. private _doNotComputeProjectionMatrix;
  39439. private _transformMatrix;
  39440. private _frustumPlanes;
  39441. private _refreshFrustumPlanes;
  39442. private _storedFov;
  39443. private _stateStored;
  39444. /**
  39445. * Instantiates a new camera object.
  39446. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  39447. * @see https://doc.babylonjs.com/features/cameras
  39448. * @param name Defines the name of the camera in the scene
  39449. * @param position Defines the position of the camera
  39450. * @param scene Defines the scene the camera belongs too
  39451. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  39452. */
  39453. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39454. /**
  39455. * Store current camera state (fov, position, etc..)
  39456. * @returns the camera
  39457. */
  39458. storeState(): Camera;
  39459. /**
  39460. * Restores the camera state values if it has been stored. You must call storeState() first
  39461. */
  39462. protected _restoreStateValues(): boolean;
  39463. /**
  39464. * Restored camera state. You must call storeState() first.
  39465. * @returns true if restored and false otherwise
  39466. */
  39467. restoreState(): boolean;
  39468. /**
  39469. * Gets the class name of the camera.
  39470. * @returns the class name
  39471. */
  39472. getClassName(): string;
  39473. /** @hidden */
  39474. readonly _isCamera: boolean;
  39475. /**
  39476. * Gets a string representation of the camera useful for debug purpose.
  39477. * @param fullDetails Defines that a more verboe level of logging is required
  39478. * @returns the string representation
  39479. */
  39480. toString(fullDetails?: boolean): string;
  39481. /**
  39482. * Gets the current world space position of the camera.
  39483. */
  39484. get globalPosition(): Vector3;
  39485. /**
  39486. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  39487. * @returns the active meshe list
  39488. */
  39489. getActiveMeshes(): SmartArray<AbstractMesh>;
  39490. /**
  39491. * Check whether a mesh is part of the current active mesh list of the camera
  39492. * @param mesh Defines the mesh to check
  39493. * @returns true if active, false otherwise
  39494. */
  39495. isActiveMesh(mesh: Mesh): boolean;
  39496. /**
  39497. * Is this camera ready to be used/rendered
  39498. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  39499. * @return true if the camera is ready
  39500. */
  39501. isReady(completeCheck?: boolean): boolean;
  39502. /** @hidden */
  39503. _initCache(): void;
  39504. /** @hidden */
  39505. _updateCache(ignoreParentClass?: boolean): void;
  39506. /** @hidden */
  39507. _isSynchronized(): boolean;
  39508. /** @hidden */
  39509. _isSynchronizedViewMatrix(): boolean;
  39510. /** @hidden */
  39511. _isSynchronizedProjectionMatrix(): boolean;
  39512. /**
  39513. * Attach the input controls to a specific dom element to get the input from.
  39514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39515. */
  39516. attachControl(noPreventDefault?: boolean): void;
  39517. /**
  39518. * Attach the input controls to a specific dom element to get the input from.
  39519. * @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
  39520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39521. * BACK COMPAT SIGNATURE ONLY.
  39522. */
  39523. attachControl(ignored: any, noPreventDefault?: boolean): void;
  39524. /**
  39525. * Detach the current controls from the specified dom element.
  39526. */
  39527. detachControl(): void;
  39528. /**
  39529. * Detach the current controls from the specified dom element.
  39530. * @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
  39531. */
  39532. detachControl(ignored: any): void;
  39533. /**
  39534. * Update the camera state according to the different inputs gathered during the frame.
  39535. */
  39536. update(): void;
  39537. /** @hidden */
  39538. _checkInputs(): void;
  39539. /** @hidden */
  39540. get rigCameras(): Camera[];
  39541. /**
  39542. * Gets the post process used by the rig cameras
  39543. */
  39544. get rigPostProcess(): Nullable<PostProcess>;
  39545. /**
  39546. * Internal, gets the first post proces.
  39547. * @returns the first post process to be run on this camera.
  39548. */
  39549. _getFirstPostProcess(): Nullable<PostProcess>;
  39550. private _cascadePostProcessesToRigCams;
  39551. /**
  39552. * Attach a post process to the camera.
  39553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39554. * @param postProcess The post process to attach to the camera
  39555. * @param insertAt The position of the post process in case several of them are in use in the scene
  39556. * @returns the position the post process has been inserted at
  39557. */
  39558. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  39559. /**
  39560. * Detach a post process to the camera.
  39561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39562. * @param postProcess The post process to detach from the camera
  39563. */
  39564. detachPostProcess(postProcess: PostProcess): void;
  39565. /**
  39566. * Gets the current world matrix of the camera
  39567. */
  39568. getWorldMatrix(): Matrix;
  39569. /** @hidden */
  39570. _getViewMatrix(): Matrix;
  39571. /**
  39572. * Gets the current view matrix of the camera.
  39573. * @param force forces the camera to recompute the matrix without looking at the cached state
  39574. * @returns the view matrix
  39575. */
  39576. getViewMatrix(force?: boolean): Matrix;
  39577. /**
  39578. * Freeze the projection matrix.
  39579. * It will prevent the cache check of the camera projection compute and can speed up perf
  39580. * if no parameter of the camera are meant to change
  39581. * @param projection Defines manually a projection if necessary
  39582. */
  39583. freezeProjectionMatrix(projection?: Matrix): void;
  39584. /**
  39585. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  39586. */
  39587. unfreezeProjectionMatrix(): void;
  39588. /**
  39589. * Gets the current projection matrix of the camera.
  39590. * @param force forces the camera to recompute the matrix without looking at the cached state
  39591. * @returns the projection matrix
  39592. */
  39593. getProjectionMatrix(force?: boolean): Matrix;
  39594. /**
  39595. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  39596. * @returns a Matrix
  39597. */
  39598. getTransformationMatrix(): Matrix;
  39599. private _updateFrustumPlanes;
  39600. /**
  39601. * Checks if a cullable object (mesh...) is in the camera frustum
  39602. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  39603. * @param target The object to check
  39604. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  39605. * @returns true if the object is in frustum otherwise false
  39606. */
  39607. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  39608. /**
  39609. * Checks if a cullable object (mesh...) is in the camera frustum
  39610. * Unlike isInFrustum this cheks the full bounding box
  39611. * @param target The object to check
  39612. * @returns true if the object is in frustum otherwise false
  39613. */
  39614. isCompletelyInFrustum(target: ICullable): boolean;
  39615. /**
  39616. * Gets a ray in the forward direction from the camera.
  39617. * @param length Defines the length of the ray to create
  39618. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39619. * @param origin Defines the start point of the ray which defaults to the camera position
  39620. * @returns the forward ray
  39621. */
  39622. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39623. /**
  39624. * Gets a ray in the forward direction from the camera.
  39625. * @param refRay the ray to (re)use when setting the values
  39626. * @param length Defines the length of the ray to create
  39627. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39628. * @param origin Defines the start point of the ray which defaults to the camera position
  39629. * @returns the forward ray
  39630. */
  39631. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39632. /**
  39633. * Releases resources associated with this node.
  39634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39636. */
  39637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  39638. /** @hidden */
  39639. _isLeftCamera: boolean;
  39640. /**
  39641. * Gets the left camera of a rig setup in case of Rigged Camera
  39642. */
  39643. get isLeftCamera(): boolean;
  39644. /** @hidden */
  39645. _isRightCamera: boolean;
  39646. /**
  39647. * Gets the right camera of a rig setup in case of Rigged Camera
  39648. */
  39649. get isRightCamera(): boolean;
  39650. /**
  39651. * Gets the left camera of a rig setup in case of Rigged Camera
  39652. */
  39653. get leftCamera(): Nullable<FreeCamera>;
  39654. /**
  39655. * Gets the right camera of a rig setup in case of Rigged Camera
  39656. */
  39657. get rightCamera(): Nullable<FreeCamera>;
  39658. /**
  39659. * Gets the left camera target of a rig setup in case of Rigged Camera
  39660. * @returns the target position
  39661. */
  39662. getLeftTarget(): Nullable<Vector3>;
  39663. /**
  39664. * Gets the right camera target of a rig setup in case of Rigged Camera
  39665. * @returns the target position
  39666. */
  39667. getRightTarget(): Nullable<Vector3>;
  39668. /**
  39669. * @hidden
  39670. */
  39671. setCameraRigMode(mode: number, rigParams: any): void;
  39672. /** @hidden */
  39673. static _setStereoscopicRigMode(camera: Camera): void;
  39674. /** @hidden */
  39675. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  39676. /** @hidden */
  39677. static _setVRRigMode(camera: Camera, rigParams: any): void;
  39678. /** @hidden */
  39679. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  39680. /** @hidden */
  39681. _getVRProjectionMatrix(): Matrix;
  39682. protected _updateCameraRotationMatrix(): void;
  39683. protected _updateWebVRCameraRotationMatrix(): void;
  39684. /**
  39685. * This function MUST be overwritten by the different WebVR cameras available.
  39686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39687. * @hidden
  39688. */
  39689. _getWebVRProjectionMatrix(): Matrix;
  39690. /**
  39691. * This function MUST be overwritten by the different WebVR cameras available.
  39692. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39693. * @hidden
  39694. */
  39695. _getWebVRViewMatrix(): Matrix;
  39696. /** @hidden */
  39697. setCameraRigParameter(name: string, value: any): void;
  39698. /**
  39699. * needs to be overridden by children so sub has required properties to be copied
  39700. * @hidden
  39701. */
  39702. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  39703. /**
  39704. * May need to be overridden by children
  39705. * @hidden
  39706. */
  39707. _updateRigCameras(): void;
  39708. /** @hidden */
  39709. _setupInputs(): void;
  39710. /**
  39711. * Serialiaze the camera setup to a json represention
  39712. * @returns the JSON representation
  39713. */
  39714. serialize(): any;
  39715. /**
  39716. * Clones the current camera.
  39717. * @param name The cloned camera name
  39718. * @returns the cloned camera
  39719. */
  39720. clone(name: string): Camera;
  39721. /**
  39722. * Gets the direction of the camera relative to a given local axis.
  39723. * @param localAxis Defines the reference axis to provide a relative direction.
  39724. * @return the direction
  39725. */
  39726. getDirection(localAxis: Vector3): Vector3;
  39727. /**
  39728. * Returns the current camera absolute rotation
  39729. */
  39730. get absoluteRotation(): Quaternion;
  39731. /**
  39732. * Gets the direction of the camera relative to a given local axis into a passed vector.
  39733. * @param localAxis Defines the reference axis to provide a relative direction.
  39734. * @param result Defines the vector to store the result in
  39735. */
  39736. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  39737. /**
  39738. * Gets a camera constructor for a given camera type
  39739. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  39740. * @param name The name of the camera the result will be able to instantiate
  39741. * @param scene The scene the result will construct the camera in
  39742. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  39743. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  39744. * @returns a factory method to construc the camera
  39745. */
  39746. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  39747. /**
  39748. * Compute the world matrix of the camera.
  39749. * @returns the camera world matrix
  39750. */
  39751. computeWorldMatrix(): Matrix;
  39752. /**
  39753. * Parse a JSON and creates the camera from the parsed information
  39754. * @param parsedCamera The JSON to parse
  39755. * @param scene The scene to instantiate the camera in
  39756. * @returns the newly constructed camera
  39757. */
  39758. static Parse(parsedCamera: any, scene: Scene): Camera;
  39759. }
  39760. }
  39761. declare module "babylonjs/PostProcesses/postProcessManager" {
  39762. import { Nullable } from "babylonjs/types";
  39763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39765. import { Scene } from "babylonjs/scene";
  39766. /**
  39767. * PostProcessManager is used to manage one or more post processes or post process pipelines
  39768. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  39769. */
  39770. export class PostProcessManager {
  39771. private _scene;
  39772. private _indexBuffer;
  39773. private _vertexBuffers;
  39774. /**
  39775. * Creates a new instance PostProcess
  39776. * @param scene The scene that the post process is associated with.
  39777. */
  39778. constructor(scene: Scene);
  39779. private _prepareBuffers;
  39780. private _buildIndexBuffer;
  39781. /**
  39782. * Rebuilds the vertex buffers of the manager.
  39783. * @hidden
  39784. */
  39785. _rebuild(): void;
  39786. /**
  39787. * Prepares a frame to be run through a post process.
  39788. * @param sourceTexture The input texture to the post procesess. (default: null)
  39789. * @param postProcesses An array of post processes to be run. (default: null)
  39790. * @returns True if the post processes were able to be run.
  39791. * @hidden
  39792. */
  39793. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39794. /**
  39795. * Manually render a set of post processes to a texture.
  39796. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39797. * @param postProcesses An array of post processes to be run.
  39798. * @param targetTexture The target texture to render to.
  39799. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39800. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39801. * @param lodLevel defines which lod of the texture to render to
  39802. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39803. */
  39804. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39805. /**
  39806. * Finalize the result of the output of the postprocesses.
  39807. * @param doNotPresent If true the result will not be displayed to the screen.
  39808. * @param targetTexture The target texture to render to.
  39809. * @param faceIndex The index of the face to bind the target texture to.
  39810. * @param postProcesses The array of post processes to render.
  39811. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39812. * @hidden
  39813. */
  39814. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39815. /**
  39816. * Disposes of the post process manager.
  39817. */
  39818. dispose(): void;
  39819. }
  39820. }
  39821. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39822. import { Observable } from "babylonjs/Misc/observable";
  39823. import { SmartArray } from "babylonjs/Misc/smartArray";
  39824. import { Nullable, Immutable } from "babylonjs/types";
  39825. import { Camera } from "babylonjs/Cameras/camera";
  39826. import { Scene } from "babylonjs/scene";
  39827. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39828. import { Color4 } from "babylonjs/Maths/math.color";
  39829. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39833. import { Texture } from "babylonjs/Materials/Textures/texture";
  39834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39835. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39836. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39837. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39838. import { Engine } from "babylonjs/Engines/engine";
  39839. /**
  39840. * This Helps creating a texture that will be created from a camera in your scene.
  39841. * It is basically a dynamic texture that could be used to create special effects for instance.
  39842. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39843. */
  39844. export class RenderTargetTexture extends Texture {
  39845. /**
  39846. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39847. */
  39848. static readonly REFRESHRATE_RENDER_ONCE: number;
  39849. /**
  39850. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39851. */
  39852. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39853. /**
  39854. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39855. * the central point of your effect and can save a lot of performances.
  39856. */
  39857. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39858. /**
  39859. * Use this predicate to dynamically define the list of mesh you want to render.
  39860. * If set, the renderList property will be overwritten.
  39861. */
  39862. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39863. private _renderList;
  39864. /**
  39865. * Use this list to define the list of mesh you want to render.
  39866. */
  39867. get renderList(): Nullable<Array<AbstractMesh>>;
  39868. set renderList(value: Nullable<Array<AbstractMesh>>);
  39869. /**
  39870. * Use this function to overload the renderList array at rendering time.
  39871. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39872. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39873. * the cube (if the RTT is a cube, else layerOrFace=0).
  39874. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39875. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39876. * hold dummy elements!
  39877. */
  39878. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39879. private _hookArray;
  39880. /**
  39881. * Define if particles should be rendered in your texture.
  39882. */
  39883. renderParticles: boolean;
  39884. /**
  39885. * Define if sprites should be rendered in your texture.
  39886. */
  39887. renderSprites: boolean;
  39888. /**
  39889. * Define the camera used to render the texture.
  39890. */
  39891. activeCamera: Nullable<Camera>;
  39892. /**
  39893. * Override the mesh isReady function with your own one.
  39894. */
  39895. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39896. /**
  39897. * Override the render function of the texture with your own one.
  39898. */
  39899. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39900. /**
  39901. * Define if camera post processes should be use while rendering the texture.
  39902. */
  39903. useCameraPostProcesses: boolean;
  39904. /**
  39905. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39906. */
  39907. ignoreCameraViewport: boolean;
  39908. private _postProcessManager;
  39909. private _postProcesses;
  39910. private _resizeObserver;
  39911. /**
  39912. * An event triggered when the texture is unbind.
  39913. */
  39914. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39915. /**
  39916. * An event triggered when the texture is unbind.
  39917. */
  39918. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39919. private _onAfterUnbindObserver;
  39920. /**
  39921. * Set a after unbind callback in the texture.
  39922. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39923. */
  39924. set onAfterUnbind(callback: () => void);
  39925. /**
  39926. * An event triggered before rendering the texture
  39927. */
  39928. onBeforeRenderObservable: Observable<number>;
  39929. private _onBeforeRenderObserver;
  39930. /**
  39931. * Set a before render callback in the texture.
  39932. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39933. */
  39934. set onBeforeRender(callback: (faceIndex: number) => void);
  39935. /**
  39936. * An event triggered after rendering the texture
  39937. */
  39938. onAfterRenderObservable: Observable<number>;
  39939. private _onAfterRenderObserver;
  39940. /**
  39941. * Set a after render callback in the texture.
  39942. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39943. */
  39944. set onAfterRender(callback: (faceIndex: number) => void);
  39945. /**
  39946. * An event triggered after the texture clear
  39947. */
  39948. onClearObservable: Observable<Engine>;
  39949. private _onClearObserver;
  39950. /**
  39951. * Set a clear callback in the texture.
  39952. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39953. */
  39954. set onClear(callback: (Engine: Engine) => void);
  39955. /**
  39956. * An event triggered when the texture is resized.
  39957. */
  39958. onResizeObservable: Observable<RenderTargetTexture>;
  39959. /**
  39960. * Define the clear color of the Render Target if it should be different from the scene.
  39961. */
  39962. clearColor: Color4;
  39963. protected _size: number | {
  39964. width: number;
  39965. height: number;
  39966. layers?: number;
  39967. };
  39968. protected _initialSizeParameter: number | {
  39969. width: number;
  39970. height: number;
  39971. } | {
  39972. ratio: number;
  39973. };
  39974. protected _sizeRatio: Nullable<number>;
  39975. /** @hidden */
  39976. _generateMipMaps: boolean;
  39977. protected _renderingManager: RenderingManager;
  39978. /** @hidden */
  39979. _waitingRenderList?: string[];
  39980. protected _doNotChangeAspectRatio: boolean;
  39981. protected _currentRefreshId: number;
  39982. protected _refreshRate: number;
  39983. protected _textureMatrix: Matrix;
  39984. protected _samples: number;
  39985. protected _renderTargetOptions: RenderTargetCreationOptions;
  39986. /**
  39987. * Gets render target creation options that were used.
  39988. */
  39989. get renderTargetOptions(): RenderTargetCreationOptions;
  39990. protected _onRatioRescale(): void;
  39991. /**
  39992. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39993. * It must define where the camera used to render the texture is set
  39994. */
  39995. boundingBoxPosition: Vector3;
  39996. private _boundingBoxSize;
  39997. /**
  39998. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39999. * When defined, the cubemap will switch to local mode
  40000. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  40001. * @example https://www.babylonjs-playground.com/#RNASML
  40002. */
  40003. set boundingBoxSize(value: Vector3);
  40004. get boundingBoxSize(): Vector3;
  40005. /**
  40006. * In case the RTT has been created with a depth texture, get the associated
  40007. * depth texture.
  40008. * Otherwise, return null.
  40009. */
  40010. get depthStencilTexture(): Nullable<InternalTexture>;
  40011. /**
  40012. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  40013. * or used a shadow, depth texture...
  40014. * @param name The friendly name of the texture
  40015. * @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)
  40016. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  40017. * @param generateMipMaps True if mip maps need to be generated after render.
  40018. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  40019. * @param type The type of the buffer in the RTT (int, half float, float...)
  40020. * @param isCube True if a cube texture needs to be created
  40021. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  40022. * @param generateDepthBuffer True to generate a depth buffer
  40023. * @param generateStencilBuffer True to generate a stencil buffer
  40024. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  40025. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  40026. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40027. * @param samples sample count to use when creating the RTT
  40028. */
  40029. constructor(name: string, size: number | {
  40030. width: number;
  40031. height: number;
  40032. layers?: number;
  40033. } | {
  40034. ratio: number;
  40035. }, 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);
  40036. /**
  40037. * Creates a depth stencil texture.
  40038. * This is only available in WebGL 2 or with the depth texture extension available.
  40039. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  40040. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  40041. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  40042. * @param samples sample count of the depth/stencil texture
  40043. */
  40044. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  40045. private _processSizeParameter;
  40046. /**
  40047. * Define the number of samples to use in case of MSAA.
  40048. * It defaults to one meaning no MSAA has been enabled.
  40049. */
  40050. get samples(): number;
  40051. set samples(value: number);
  40052. /**
  40053. * Resets the refresh counter of the texture and start bak from scratch.
  40054. * Could be useful to regenerate the texture if it is setup to render only once.
  40055. */
  40056. resetRefreshCounter(): void;
  40057. /**
  40058. * Define the refresh rate of the texture or the rendering frequency.
  40059. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  40060. */
  40061. get refreshRate(): number;
  40062. set refreshRate(value: number);
  40063. /**
  40064. * Adds a post process to the render target rendering passes.
  40065. * @param postProcess define the post process to add
  40066. */
  40067. addPostProcess(postProcess: PostProcess): void;
  40068. /**
  40069. * Clear all the post processes attached to the render target
  40070. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  40071. */
  40072. clearPostProcesses(dispose?: boolean): void;
  40073. /**
  40074. * Remove one of the post process from the list of attached post processes to the texture
  40075. * @param postProcess define the post process to remove from the list
  40076. */
  40077. removePostProcess(postProcess: PostProcess): void;
  40078. /** @hidden */
  40079. _shouldRender(): boolean;
  40080. /**
  40081. * Gets the actual render size of the texture.
  40082. * @returns the width of the render size
  40083. */
  40084. getRenderSize(): number;
  40085. /**
  40086. * Gets the actual render width of the texture.
  40087. * @returns the width of the render size
  40088. */
  40089. getRenderWidth(): number;
  40090. /**
  40091. * Gets the actual render height of the texture.
  40092. * @returns the height of the render size
  40093. */
  40094. getRenderHeight(): number;
  40095. /**
  40096. * Gets the actual number of layers of the texture.
  40097. * @returns the number of layers
  40098. */
  40099. getRenderLayers(): number;
  40100. /**
  40101. * Get if the texture can be rescaled or not.
  40102. */
  40103. get canRescale(): boolean;
  40104. /**
  40105. * Resize the texture using a ratio.
  40106. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  40107. */
  40108. scale(ratio: number): void;
  40109. /**
  40110. * Get the texture reflection matrix used to rotate/transform the reflection.
  40111. * @returns the reflection matrix
  40112. */
  40113. getReflectionTextureMatrix(): Matrix;
  40114. /**
  40115. * Resize the texture to a new desired size.
  40116. * Be carrefull as it will recreate all the data in the new texture.
  40117. * @param size Define the new size. It can be:
  40118. * - a number for squared texture,
  40119. * - an object containing { width: number, height: number }
  40120. * - or an object containing a ratio { ratio: number }
  40121. */
  40122. resize(size: number | {
  40123. width: number;
  40124. height: number;
  40125. } | {
  40126. ratio: number;
  40127. }): void;
  40128. private _defaultRenderListPrepared;
  40129. /**
  40130. * Renders all the objects from the render list into the texture.
  40131. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  40132. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  40133. */
  40134. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  40135. private _bestReflectionRenderTargetDimension;
  40136. private _prepareRenderingManager;
  40137. /**
  40138. * @hidden
  40139. * @param faceIndex face index to bind to if this is a cubetexture
  40140. * @param layer defines the index of the texture to bind in the array
  40141. */
  40142. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  40143. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40144. private renderToTarget;
  40145. /**
  40146. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40147. * This allowed control for front to back rendering or reversly depending of the special needs.
  40148. *
  40149. * @param renderingGroupId The rendering group id corresponding to its index
  40150. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40151. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40152. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40153. */
  40154. 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;
  40155. /**
  40156. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40157. *
  40158. * @param renderingGroupId The rendering group id corresponding to its index
  40159. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40160. */
  40161. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  40162. /**
  40163. * Clones the texture.
  40164. * @returns the cloned texture
  40165. */
  40166. clone(): RenderTargetTexture;
  40167. /**
  40168. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  40169. * @returns The JSON representation of the texture
  40170. */
  40171. serialize(): any;
  40172. /**
  40173. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  40174. */
  40175. disposeFramebufferObjects(): void;
  40176. /**
  40177. * Dispose the texture and release its associated resources.
  40178. */
  40179. dispose(): void;
  40180. /** @hidden */
  40181. _rebuild(): void;
  40182. /**
  40183. * Clear the info related to rendering groups preventing retention point in material dispose.
  40184. */
  40185. freeRenderingGroups(): void;
  40186. /**
  40187. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  40188. * @returns the view count
  40189. */
  40190. getViewCount(): number;
  40191. }
  40192. }
  40193. declare module "babylonjs/Materials/effect" {
  40194. import { Observable } from "babylonjs/Misc/observable";
  40195. import { FloatArray, Nullable } from "babylonjs/types";
  40196. import { IDisposable } from "babylonjs/scene";
  40197. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40198. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40199. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  40200. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40201. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40202. import { Engine } from "babylonjs/Engines/engine";
  40203. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40204. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40206. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40207. /**
  40208. * Options to be used when creating an effect.
  40209. */
  40210. export interface IEffectCreationOptions {
  40211. /**
  40212. * Atrributes that will be used in the shader.
  40213. */
  40214. attributes: string[];
  40215. /**
  40216. * Uniform varible names that will be set in the shader.
  40217. */
  40218. uniformsNames: string[];
  40219. /**
  40220. * Uniform buffer variable names that will be set in the shader.
  40221. */
  40222. uniformBuffersNames: string[];
  40223. /**
  40224. * Sampler texture variable names that will be set in the shader.
  40225. */
  40226. samplers: string[];
  40227. /**
  40228. * Define statements that will be set in the shader.
  40229. */
  40230. defines: any;
  40231. /**
  40232. * Possible fallbacks for this effect to improve performance when needed.
  40233. */
  40234. fallbacks: Nullable<IEffectFallbacks>;
  40235. /**
  40236. * Callback that will be called when the shader is compiled.
  40237. */
  40238. onCompiled: Nullable<(effect: Effect) => void>;
  40239. /**
  40240. * Callback that will be called if an error occurs during shader compilation.
  40241. */
  40242. onError: Nullable<(effect: Effect, errors: string) => void>;
  40243. /**
  40244. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40245. */
  40246. indexParameters?: any;
  40247. /**
  40248. * Max number of lights that can be used in the shader.
  40249. */
  40250. maxSimultaneousLights?: number;
  40251. /**
  40252. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  40253. */
  40254. transformFeedbackVaryings?: Nullable<string[]>;
  40255. /**
  40256. * 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
  40257. */
  40258. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  40259. /**
  40260. * Is this effect rendering to several color attachments ?
  40261. */
  40262. multiTarget?: boolean;
  40263. }
  40264. /**
  40265. * Effect containing vertex and fragment shader that can be executed on an object.
  40266. */
  40267. export class Effect implements IDisposable {
  40268. /**
  40269. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40270. */
  40271. static ShadersRepository: string;
  40272. /**
  40273. * Enable logging of the shader code when a compilation error occurs
  40274. */
  40275. static LogShaderCodeOnCompilationError: boolean;
  40276. /**
  40277. * Name of the effect.
  40278. */
  40279. name: any;
  40280. /**
  40281. * String container all the define statements that should be set on the shader.
  40282. */
  40283. defines: string;
  40284. /**
  40285. * Callback that will be called when the shader is compiled.
  40286. */
  40287. onCompiled: Nullable<(effect: Effect) => void>;
  40288. /**
  40289. * Callback that will be called if an error occurs during shader compilation.
  40290. */
  40291. onError: Nullable<(effect: Effect, errors: string) => void>;
  40292. /**
  40293. * Callback that will be called when effect is bound.
  40294. */
  40295. onBind: Nullable<(effect: Effect) => void>;
  40296. /**
  40297. * Unique ID of the effect.
  40298. */
  40299. uniqueId: number;
  40300. /**
  40301. * Observable that will be called when the shader is compiled.
  40302. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  40303. */
  40304. onCompileObservable: Observable<Effect>;
  40305. /**
  40306. * Observable that will be called if an error occurs during shader compilation.
  40307. */
  40308. onErrorObservable: Observable<Effect>;
  40309. /** @hidden */
  40310. _onBindObservable: Nullable<Observable<Effect>>;
  40311. /**
  40312. * @hidden
  40313. * Specifies if the effect was previously ready
  40314. */
  40315. _wasPreviouslyReady: boolean;
  40316. /**
  40317. * Observable that will be called when effect is bound.
  40318. */
  40319. get onBindObservable(): Observable<Effect>;
  40320. /** @hidden */
  40321. _bonesComputationForcedToCPU: boolean;
  40322. /** @hidden */
  40323. _uniformBuffersNames: {
  40324. [key: string]: number;
  40325. };
  40326. /** @hidden */
  40327. _samplerList: string[];
  40328. /** @hidden */
  40329. _multiTarget: boolean;
  40330. private static _uniqueIdSeed;
  40331. private _engine;
  40332. private _uniformBuffersNamesList;
  40333. private _uniformsNames;
  40334. private _samplers;
  40335. private _isReady;
  40336. private _compilationError;
  40337. private _allFallbacksProcessed;
  40338. private _attributesNames;
  40339. private _attributes;
  40340. private _attributeLocationByName;
  40341. private _uniforms;
  40342. /**
  40343. * Key for the effect.
  40344. * @hidden
  40345. */
  40346. _key: string;
  40347. private _indexParameters;
  40348. private _fallbacks;
  40349. private _vertexSourceCodeOverride;
  40350. private _fragmentSourceCodeOverride;
  40351. private _transformFeedbackVaryings;
  40352. /**
  40353. * Compiled shader to webGL program.
  40354. * @hidden
  40355. */
  40356. _pipelineContext: Nullable<IPipelineContext>;
  40357. /** @hidden */
  40358. _vertexSourceCode: string;
  40359. /** @hidden */
  40360. _fragmentSourceCode: string;
  40361. /** @hidden */
  40362. private _rawVertexSourceCode;
  40363. /** @hidden */
  40364. private _rawFragmentSourceCode;
  40365. private static _baseCache;
  40366. private _processingContext;
  40367. /**
  40368. * Instantiates an effect.
  40369. * An effect can be used to create/manage/execute vertex and fragment shaders.
  40370. * @param baseName Name of the effect.
  40371. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  40372. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  40373. * @param samplers List of sampler variables that will be passed to the shader.
  40374. * @param engine Engine to be used to render the effect
  40375. * @param defines Define statements to be added to the shader.
  40376. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  40377. * @param onCompiled Callback that will be called when the shader is compiled.
  40378. * @param onError Callback that will be called if an error occurs during shader compilation.
  40379. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40380. * @param key Effect Key identifying uniquely compiled shader variants
  40381. */
  40382. 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);
  40383. private _useFinalCode;
  40384. /**
  40385. * Unique key for this effect
  40386. */
  40387. get key(): string;
  40388. /**
  40389. * If the effect has been compiled and prepared.
  40390. * @returns if the effect is compiled and prepared.
  40391. */
  40392. isReady(): boolean;
  40393. private _isReadyInternal;
  40394. /**
  40395. * The engine the effect was initialized with.
  40396. * @returns the engine.
  40397. */
  40398. getEngine(): Engine;
  40399. /**
  40400. * The pipeline context for this effect
  40401. * @returns the associated pipeline context
  40402. */
  40403. getPipelineContext(): Nullable<IPipelineContext>;
  40404. /**
  40405. * The set of names of attribute variables for the shader.
  40406. * @returns An array of attribute names.
  40407. */
  40408. getAttributesNames(): string[];
  40409. /**
  40410. * Returns the attribute at the given index.
  40411. * @param index The index of the attribute.
  40412. * @returns The location of the attribute.
  40413. */
  40414. getAttributeLocation(index: number): number;
  40415. /**
  40416. * Returns the attribute based on the name of the variable.
  40417. * @param name of the attribute to look up.
  40418. * @returns the attribute location.
  40419. */
  40420. getAttributeLocationByName(name: string): number;
  40421. /**
  40422. * The number of attributes.
  40423. * @returns the numnber of attributes.
  40424. */
  40425. getAttributesCount(): number;
  40426. /**
  40427. * Gets the index of a uniform variable.
  40428. * @param uniformName of the uniform to look up.
  40429. * @returns the index.
  40430. */
  40431. getUniformIndex(uniformName: string): number;
  40432. /**
  40433. * Returns the attribute based on the name of the variable.
  40434. * @param uniformName of the uniform to look up.
  40435. * @returns the location of the uniform.
  40436. */
  40437. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  40438. /**
  40439. * Returns an array of sampler variable names
  40440. * @returns The array of sampler variable names.
  40441. */
  40442. getSamplers(): string[];
  40443. /**
  40444. * Returns an array of uniform variable names
  40445. * @returns The array of uniform variable names.
  40446. */
  40447. getUniformNames(): string[];
  40448. /**
  40449. * Returns an array of uniform buffer variable names
  40450. * @returns The array of uniform buffer variable names.
  40451. */
  40452. getUniformBuffersNames(): string[];
  40453. /**
  40454. * Returns the index parameters used to create the effect
  40455. * @returns The index parameters object
  40456. */
  40457. getIndexParameters(): any;
  40458. /**
  40459. * The error from the last compilation.
  40460. * @returns the error string.
  40461. */
  40462. getCompilationError(): string;
  40463. /**
  40464. * Gets a boolean indicating that all fallbacks were used during compilation
  40465. * @returns true if all fallbacks were used
  40466. */
  40467. allFallbacksProcessed(): boolean;
  40468. /**
  40469. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  40470. * @param func The callback to be used.
  40471. */
  40472. executeWhenCompiled(func: (effect: Effect) => void): void;
  40473. private _checkIsReady;
  40474. private _loadShader;
  40475. /**
  40476. * Gets the vertex shader source code of this effect
  40477. */
  40478. get vertexSourceCode(): string;
  40479. /**
  40480. * Gets the fragment shader source code of this effect
  40481. */
  40482. get fragmentSourceCode(): string;
  40483. /**
  40484. * Gets the vertex shader source code before it has been processed by the preprocessor
  40485. */
  40486. get rawVertexSourceCode(): string;
  40487. /**
  40488. * Gets the fragment shader source code before it has been processed by the preprocessor
  40489. */
  40490. get rawFragmentSourceCode(): string;
  40491. /**
  40492. * Recompiles the webGL program
  40493. * @param vertexSourceCode The source code for the vertex shader.
  40494. * @param fragmentSourceCode The source code for the fragment shader.
  40495. * @param onCompiled Callback called when completed.
  40496. * @param onError Callback called on error.
  40497. * @hidden
  40498. */
  40499. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  40500. /**
  40501. * Prepares the effect
  40502. * @hidden
  40503. */
  40504. _prepareEffect(): void;
  40505. private _getShaderCodeAndErrorLine;
  40506. private _processCompilationErrors;
  40507. /**
  40508. * Checks if the effect is supported. (Must be called after compilation)
  40509. */
  40510. get isSupported(): boolean;
  40511. /**
  40512. * Binds a texture to the engine to be used as output of the shader.
  40513. * @param channel Name of the output variable.
  40514. * @param texture Texture to bind.
  40515. * @hidden
  40516. */
  40517. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  40518. /**
  40519. * Sets a texture on the engine to be used in the shader.
  40520. * @param channel Name of the sampler variable.
  40521. * @param texture Texture to set.
  40522. */
  40523. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  40524. /**
  40525. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  40526. * @param channel Name of the sampler variable.
  40527. * @param texture Texture to set.
  40528. */
  40529. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  40530. /**
  40531. * Sets an array of textures on the engine to be used in the shader.
  40532. * @param channel Name of the variable.
  40533. * @param textures Textures to set.
  40534. */
  40535. setTextureArray(channel: string, textures: ThinTexture[]): void;
  40536. /**
  40537. * 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)
  40538. * @param channel Name of the sampler variable.
  40539. * @param postProcess Post process to get the input texture from.
  40540. */
  40541. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  40542. /**
  40543. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  40544. * 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)
  40545. * @param channel Name of the sampler variable.
  40546. * @param postProcess Post process to get the output texture from.
  40547. */
  40548. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  40549. /**
  40550. * Binds a buffer to a uniform.
  40551. * @param buffer Buffer to bind.
  40552. * @param name Name of the uniform variable to bind to.
  40553. */
  40554. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  40555. /**
  40556. * Binds block to a uniform.
  40557. * @param blockName Name of the block to bind.
  40558. * @param index Index to bind.
  40559. */
  40560. bindUniformBlock(blockName: string, index: number): void;
  40561. /**
  40562. * Sets an interger value on a uniform variable.
  40563. * @param uniformName Name of the variable.
  40564. * @param value Value to be set.
  40565. * @returns this effect.
  40566. */
  40567. setInt(uniformName: string, value: number): Effect;
  40568. /**
  40569. * Sets an int2 value on a uniform variable.
  40570. * @param uniformName Name of the variable.
  40571. * @param x First int in int2.
  40572. * @param y Second int in int2.
  40573. * @returns this effect.
  40574. */
  40575. setInt2(uniformName: string, x: number, y: number): Effect;
  40576. /**
  40577. * Sets an int3 value on a uniform variable.
  40578. * @param uniformName Name of the variable.
  40579. * @param x First int in int3.
  40580. * @param y Second int in int3.
  40581. * @param z Third int in int3.
  40582. * @returns this effect.
  40583. */
  40584. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  40585. /**
  40586. * Sets an int4 value on a uniform variable.
  40587. * @param uniformName Name of the variable.
  40588. * @param x First int in int4.
  40589. * @param y Second int in int4.
  40590. * @param z Third int in int4.
  40591. * @param w Fourth int in int4.
  40592. * @returns this effect.
  40593. */
  40594. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40595. /**
  40596. * Sets an int array on a uniform variable.
  40597. * @param uniformName Name of the variable.
  40598. * @param array array to be set.
  40599. * @returns this effect.
  40600. */
  40601. setIntArray(uniformName: string, array: Int32Array): Effect;
  40602. /**
  40603. * 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)
  40604. * @param uniformName Name of the variable.
  40605. * @param array array to be set.
  40606. * @returns this effect.
  40607. */
  40608. setIntArray2(uniformName: string, array: Int32Array): Effect;
  40609. /**
  40610. * 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)
  40611. * @param uniformName Name of the variable.
  40612. * @param array array to be set.
  40613. * @returns this effect.
  40614. */
  40615. setIntArray3(uniformName: string, array: Int32Array): Effect;
  40616. /**
  40617. * 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)
  40618. * @param uniformName Name of the variable.
  40619. * @param array array to be set.
  40620. * @returns this effect.
  40621. */
  40622. setIntArray4(uniformName: string, array: Int32Array): Effect;
  40623. /**
  40624. * Sets an float array on a uniform variable.
  40625. * @param uniformName Name of the variable.
  40626. * @param array array to be set.
  40627. * @returns this effect.
  40628. */
  40629. setFloatArray(uniformName: string, array: FloatArray): Effect;
  40630. /**
  40631. * 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)
  40632. * @param uniformName Name of the variable.
  40633. * @param array array to be set.
  40634. * @returns this effect.
  40635. */
  40636. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  40637. /**
  40638. * 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)
  40639. * @param uniformName Name of the variable.
  40640. * @param array array to be set.
  40641. * @returns this effect.
  40642. */
  40643. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  40644. /**
  40645. * 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)
  40646. * @param uniformName Name of the variable.
  40647. * @param array array to be set.
  40648. * @returns this effect.
  40649. */
  40650. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  40651. /**
  40652. * Sets an array on a uniform variable.
  40653. * @param uniformName Name of the variable.
  40654. * @param array array to be set.
  40655. * @returns this effect.
  40656. */
  40657. setArray(uniformName: string, array: number[]): Effect;
  40658. /**
  40659. * 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)
  40660. * @param uniformName Name of the variable.
  40661. * @param array array to be set.
  40662. * @returns this effect.
  40663. */
  40664. setArray2(uniformName: string, array: number[]): Effect;
  40665. /**
  40666. * 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)
  40667. * @param uniformName Name of the variable.
  40668. * @param array array to be set.
  40669. * @returns this effect.
  40670. */
  40671. setArray3(uniformName: string, array: number[]): Effect;
  40672. /**
  40673. * 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)
  40674. * @param uniformName Name of the variable.
  40675. * @param array array to be set.
  40676. * @returns this effect.
  40677. */
  40678. setArray4(uniformName: string, array: number[]): Effect;
  40679. /**
  40680. * Sets matrices on a uniform variable.
  40681. * @param uniformName Name of the variable.
  40682. * @param matrices matrices to be set.
  40683. * @returns this effect.
  40684. */
  40685. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  40686. /**
  40687. * Sets matrix on a uniform variable.
  40688. * @param uniformName Name of the variable.
  40689. * @param matrix matrix to be set.
  40690. * @returns this effect.
  40691. */
  40692. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  40693. /**
  40694. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  40695. * @param uniformName Name of the variable.
  40696. * @param matrix matrix to be set.
  40697. * @returns this effect.
  40698. */
  40699. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40700. /**
  40701. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  40702. * @param uniformName Name of the variable.
  40703. * @param matrix matrix to be set.
  40704. * @returns this effect.
  40705. */
  40706. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40707. /**
  40708. * Sets a float on a uniform variable.
  40709. * @param uniformName Name of the variable.
  40710. * @param value value to be set.
  40711. * @returns this effect.
  40712. */
  40713. setFloat(uniformName: string, value: number): Effect;
  40714. /**
  40715. * Sets a boolean on a uniform variable.
  40716. * @param uniformName Name of the variable.
  40717. * @param bool value to be set.
  40718. * @returns this effect.
  40719. */
  40720. setBool(uniformName: string, bool: boolean): Effect;
  40721. /**
  40722. * Sets a Vector2 on a uniform variable.
  40723. * @param uniformName Name of the variable.
  40724. * @param vector2 vector2 to be set.
  40725. * @returns this effect.
  40726. */
  40727. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  40728. /**
  40729. * Sets a float2 on a uniform variable.
  40730. * @param uniformName Name of the variable.
  40731. * @param x First float in float2.
  40732. * @param y Second float in float2.
  40733. * @returns this effect.
  40734. */
  40735. setFloat2(uniformName: string, x: number, y: number): Effect;
  40736. /**
  40737. * Sets a Vector3 on a uniform variable.
  40738. * @param uniformName Name of the variable.
  40739. * @param vector3 Value to be set.
  40740. * @returns this effect.
  40741. */
  40742. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  40743. /**
  40744. * Sets a float3 on a uniform variable.
  40745. * @param uniformName Name of the variable.
  40746. * @param x First float in float3.
  40747. * @param y Second float in float3.
  40748. * @param z Third float in float3.
  40749. * @returns this effect.
  40750. */
  40751. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  40752. /**
  40753. * Sets a Vector4 on a uniform variable.
  40754. * @param uniformName Name of the variable.
  40755. * @param vector4 Value to be set.
  40756. * @returns this effect.
  40757. */
  40758. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  40759. /**
  40760. * Sets a float4 on a uniform variable.
  40761. * @param uniformName Name of the variable.
  40762. * @param x First float in float4.
  40763. * @param y Second float in float4.
  40764. * @param z Third float in float4.
  40765. * @param w Fourth float in float4.
  40766. * @returns this effect.
  40767. */
  40768. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40769. /**
  40770. * Sets a Color3 on a uniform variable.
  40771. * @param uniformName Name of the variable.
  40772. * @param color3 Value to be set.
  40773. * @returns this effect.
  40774. */
  40775. setColor3(uniformName: string, color3: IColor3Like): Effect;
  40776. /**
  40777. * Sets a Color4 on a uniform variable.
  40778. * @param uniformName Name of the variable.
  40779. * @param color3 Value to be set.
  40780. * @param alpha Alpha value to be set.
  40781. * @returns this effect.
  40782. */
  40783. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  40784. /**
  40785. * Sets a Color4 on a uniform variable
  40786. * @param uniformName defines the name of the variable
  40787. * @param color4 defines the value to be set
  40788. * @returns this effect.
  40789. */
  40790. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  40791. /**
  40792. * Release all associated resources.
  40793. **/
  40794. dispose(): void;
  40795. /**
  40796. * This function will add a new shader to the shader store
  40797. * @param name the name of the shader
  40798. * @param pixelShader optional pixel shader content
  40799. * @param vertexShader optional vertex shader content
  40800. */
  40801. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  40802. /**
  40803. * Store of each shader (The can be looked up using effect.key)
  40804. */
  40805. static ShadersStore: {
  40806. [key: string]: string;
  40807. };
  40808. /**
  40809. * Store of each included file for a shader (The can be looked up using effect.key)
  40810. */
  40811. static IncludesShadersStore: {
  40812. [key: string]: string;
  40813. };
  40814. /**
  40815. * Resets the cache of effects.
  40816. */
  40817. static ResetCache(): void;
  40818. }
  40819. }
  40820. declare module "babylonjs/Engines/engineCapabilities" {
  40821. /**
  40822. * Interface used to describe the capabilities of the engine relatively to the current browser
  40823. */
  40824. export interface EngineCapabilities {
  40825. /** Maximum textures units per fragment shader */
  40826. maxTexturesImageUnits: number;
  40827. /** Maximum texture units per vertex shader */
  40828. maxVertexTextureImageUnits: number;
  40829. /** Maximum textures units in the entire pipeline */
  40830. maxCombinedTexturesImageUnits: number;
  40831. /** Maximum texture size */
  40832. maxTextureSize: number;
  40833. /** Maximum texture samples */
  40834. maxSamples?: number;
  40835. /** Maximum cube texture size */
  40836. maxCubemapTextureSize: number;
  40837. /** Maximum render texture size */
  40838. maxRenderTextureSize: number;
  40839. /** Maximum number of vertex attributes */
  40840. maxVertexAttribs: number;
  40841. /** Maximum number of varyings */
  40842. maxVaryingVectors: number;
  40843. /** Maximum number of uniforms per vertex shader */
  40844. maxVertexUniformVectors: number;
  40845. /** Maximum number of uniforms per fragment shader */
  40846. maxFragmentUniformVectors: number;
  40847. /** Defines if standard derivates (dx/dy) are supported */
  40848. standardDerivatives: boolean;
  40849. /** Defines if s3tc texture compression is supported */
  40850. s3tc?: WEBGL_compressed_texture_s3tc;
  40851. /** Defines if pvrtc texture compression is supported */
  40852. pvrtc: any;
  40853. /** Defines if etc1 texture compression is supported */
  40854. etc1: any;
  40855. /** Defines if etc2 texture compression is supported */
  40856. etc2: any;
  40857. /** Defines if astc texture compression is supported */
  40858. astc: any;
  40859. /** Defines if bptc texture compression is supported */
  40860. bptc: any;
  40861. /** Defines if float textures are supported */
  40862. textureFloat: boolean;
  40863. /** Defines if vertex array objects are supported */
  40864. vertexArrayObject: boolean;
  40865. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40866. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40867. /** Gets the maximum level of anisotropy supported */
  40868. maxAnisotropy: number;
  40869. /** Defines if instancing is supported */
  40870. instancedArrays: boolean;
  40871. /** Defines if 32 bits indices are supported */
  40872. uintIndices: boolean;
  40873. /** Defines if high precision shaders are supported */
  40874. highPrecisionShaderSupported: boolean;
  40875. /** Defines if depth reading in the fragment shader is supported */
  40876. fragmentDepthSupported: boolean;
  40877. /** Defines if float texture linear filtering is supported*/
  40878. textureFloatLinearFiltering: boolean;
  40879. /** Defines if rendering to float textures is supported */
  40880. textureFloatRender: boolean;
  40881. /** Defines if half float textures are supported*/
  40882. textureHalfFloat: boolean;
  40883. /** Defines if half float texture linear filtering is supported*/
  40884. textureHalfFloatLinearFiltering: boolean;
  40885. /** Defines if rendering to half float textures is supported */
  40886. textureHalfFloatRender: boolean;
  40887. /** Defines if textureLOD shader command is supported */
  40888. textureLOD: boolean;
  40889. /** Defines if draw buffers extension is supported */
  40890. drawBuffersExtension: boolean;
  40891. /** Defines if depth textures are supported */
  40892. depthTextureExtension: boolean;
  40893. /** Defines if float color buffer are supported */
  40894. colorBufferFloat: boolean;
  40895. /** Gets disjoint timer query extension (null if not supported) */
  40896. timerQuery?: EXT_disjoint_timer_query;
  40897. /** Defines if timestamp can be used with timer query */
  40898. canUseTimestampForTimerQuery: boolean;
  40899. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40900. multiview?: any;
  40901. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40902. oculusMultiview?: any;
  40903. /** Function used to let the system compiles shaders in background */
  40904. parallelShaderCompile?: {
  40905. COMPLETION_STATUS_KHR: number;
  40906. };
  40907. /** Max number of texture samples for MSAA */
  40908. maxMSAASamples: number;
  40909. /** Defines if the blend min max extension is supported */
  40910. blendMinMax: boolean;
  40911. /** 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 */
  40912. canUseGLInstanceID: boolean;
  40913. }
  40914. }
  40915. declare module "babylonjs/States/depthCullingState" {
  40916. import { Nullable } from "babylonjs/types";
  40917. /**
  40918. * @hidden
  40919. **/
  40920. export class DepthCullingState {
  40921. private _isDepthTestDirty;
  40922. private _isDepthMaskDirty;
  40923. private _isDepthFuncDirty;
  40924. private _isCullFaceDirty;
  40925. private _isCullDirty;
  40926. private _isZOffsetDirty;
  40927. private _isFrontFaceDirty;
  40928. private _depthTest;
  40929. private _depthMask;
  40930. private _depthFunc;
  40931. private _cull;
  40932. private _cullFace;
  40933. private _zOffset;
  40934. private _frontFace;
  40935. /**
  40936. * Initializes the state.
  40937. */
  40938. constructor();
  40939. get isDirty(): boolean;
  40940. get zOffset(): number;
  40941. set zOffset(value: number);
  40942. get cullFace(): Nullable<number>;
  40943. set cullFace(value: Nullable<number>);
  40944. get cull(): Nullable<boolean>;
  40945. set cull(value: Nullable<boolean>);
  40946. get depthFunc(): Nullable<number>;
  40947. set depthFunc(value: Nullable<number>);
  40948. get depthMask(): boolean;
  40949. set depthMask(value: boolean);
  40950. get depthTest(): boolean;
  40951. set depthTest(value: boolean);
  40952. get frontFace(): Nullable<number>;
  40953. set frontFace(value: Nullable<number>);
  40954. reset(): void;
  40955. apply(gl: WebGLRenderingContext): void;
  40956. }
  40957. }
  40958. declare module "babylonjs/States/stencilState" {
  40959. /**
  40960. * @hidden
  40961. **/
  40962. export class StencilState {
  40963. /** 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 */
  40964. static readonly ALWAYS: number;
  40965. /** Passed to stencilOperation to specify that stencil value must be kept */
  40966. static readonly KEEP: number;
  40967. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40968. static readonly REPLACE: number;
  40969. private _isStencilTestDirty;
  40970. private _isStencilMaskDirty;
  40971. private _isStencilFuncDirty;
  40972. private _isStencilOpDirty;
  40973. private _stencilTest;
  40974. private _stencilMask;
  40975. private _stencilFunc;
  40976. private _stencilFuncRef;
  40977. private _stencilFuncMask;
  40978. private _stencilOpStencilFail;
  40979. private _stencilOpDepthFail;
  40980. private _stencilOpStencilDepthPass;
  40981. get isDirty(): boolean;
  40982. get stencilFunc(): number;
  40983. set stencilFunc(value: number);
  40984. get stencilFuncRef(): number;
  40985. set stencilFuncRef(value: number);
  40986. get stencilFuncMask(): number;
  40987. set stencilFuncMask(value: number);
  40988. get stencilOpStencilFail(): number;
  40989. set stencilOpStencilFail(value: number);
  40990. get stencilOpDepthFail(): number;
  40991. set stencilOpDepthFail(value: number);
  40992. get stencilOpStencilDepthPass(): number;
  40993. set stencilOpStencilDepthPass(value: number);
  40994. get stencilMask(): number;
  40995. set stencilMask(value: number);
  40996. get stencilTest(): boolean;
  40997. set stencilTest(value: boolean);
  40998. constructor();
  40999. reset(): void;
  41000. apply(gl: WebGLRenderingContext): void;
  41001. }
  41002. }
  41003. declare module "babylonjs/States/alphaCullingState" {
  41004. import { Nullable } from "babylonjs/types";
  41005. /**
  41006. * @hidden
  41007. **/
  41008. export class AlphaState {
  41009. _blendFunctionParameters: Nullable<number>[];
  41010. _blendEquationParameters: Nullable<number>[];
  41011. _blendConstants: Nullable<number>[];
  41012. _isBlendConstantsDirty: boolean;
  41013. private _alphaBlend;
  41014. private _isAlphaBlendDirty;
  41015. private _isBlendFunctionParametersDirty;
  41016. private _isBlendEquationParametersDirty;
  41017. /**
  41018. * Initializes the state.
  41019. */
  41020. constructor();
  41021. get isDirty(): boolean;
  41022. get alphaBlend(): boolean;
  41023. set alphaBlend(value: boolean);
  41024. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  41025. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  41026. setAlphaEquationParameters(rgb: number, alpha: number): void;
  41027. reset(): void;
  41028. apply(gl: WebGLRenderingContext): void;
  41029. }
  41030. }
  41031. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  41032. import { Nullable } from "babylonjs/types";
  41033. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41034. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41035. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41036. /** @hidden */
  41037. export class WebGLShaderProcessor implements IShaderProcessor {
  41038. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41039. }
  41040. }
  41041. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  41042. import { Nullable } from "babylonjs/types";
  41043. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41044. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41045. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41046. /** @hidden */
  41047. export class WebGL2ShaderProcessor implements IShaderProcessor {
  41048. attributeProcessor(attribute: string): string;
  41049. varyingProcessor(varying: string, isFragment: boolean): string;
  41050. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41051. }
  41052. }
  41053. declare module "babylonjs/Engines/instancingAttributeInfo" {
  41054. /**
  41055. * Interface for attribute information associated with buffer instanciation
  41056. */
  41057. export interface InstancingAttributeInfo {
  41058. /**
  41059. * Name of the GLSL attribute
  41060. * if attribute index is not specified, this is used to retrieve the index from the effect
  41061. */
  41062. attributeName: string;
  41063. /**
  41064. * Index/offset of the attribute in the vertex shader
  41065. * if not specified, this will be computes from the name.
  41066. */
  41067. index?: number;
  41068. /**
  41069. * size of the attribute, 1, 2, 3 or 4
  41070. */
  41071. attributeSize: number;
  41072. /**
  41073. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  41074. */
  41075. offset: number;
  41076. /**
  41077. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  41078. * default to 1
  41079. */
  41080. divisor?: number;
  41081. /**
  41082. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  41083. * default is FLOAT
  41084. */
  41085. attributeType?: number;
  41086. /**
  41087. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  41088. */
  41089. normalized?: boolean;
  41090. }
  41091. }
  41092. declare module "babylonjs/Engines/engineFeatures" {
  41093. /** @hidden */
  41094. export interface EngineFeatures {
  41095. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  41096. forceBitmapOverHTMLImageElement: boolean;
  41097. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  41098. supportRenderAndCopyToLodForFloatTextures: boolean;
  41099. /** Indicates that the engine support handling depth/stencil textures */
  41100. supportDepthStencilTexture: boolean;
  41101. /** Indicates that the engine support shadow samplers */
  41102. supportShadowSamplers: boolean;
  41103. /** 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 */
  41104. uniformBufferHardCheckMatrix: boolean;
  41105. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  41106. allowTexturePrefiltering: boolean;
  41107. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  41108. trackUbosInFrame: boolean;
  41109. /** Indicates that the Cascaded Shadow Map technic is supported */
  41110. supportCSM: boolean;
  41111. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  41112. basisNeedsPOT: boolean;
  41113. /** Indicates that the engine supports 3D textures */
  41114. support3DTextures: boolean;
  41115. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  41116. needTypeSuffixInShaderConstants: boolean;
  41117. /** Indicates that MSAA is supported */
  41118. supportMSAA: boolean;
  41119. /** Indicates that SSAO2 is supported */
  41120. supportSSAO2: boolean;
  41121. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  41122. supportExtendedTextureFormats: boolean;
  41123. /** Indicates that the switch/case construct is supported in shaders */
  41124. supportSwitchCaseInShader: boolean;
  41125. /** @hidden */
  41126. _collectUbosUpdatedInFrame: boolean;
  41127. }
  41128. }
  41129. declare module "babylonjs/Engines/WebGL/webGLHardwareTexture" {
  41130. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41131. import { Nullable } from "babylonjs/types";
  41132. /** @hidden */
  41133. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  41134. private _webGLTexture;
  41135. private _context;
  41136. get underlyingResource(): Nullable<WebGLTexture>;
  41137. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  41138. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  41139. set(hardwareTexture: WebGLTexture): void;
  41140. reset(): void;
  41141. release(): void;
  41142. }
  41143. }
  41144. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  41145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41146. import { Nullable } from "babylonjs/types";
  41147. module "babylonjs/Engines/thinEngine" {
  41148. interface ThinEngine {
  41149. /**
  41150. * Update a video texture
  41151. * @param texture defines the texture to update
  41152. * @param video defines the video element to use
  41153. * @param invertY defines if data must be stored with Y axis inverted
  41154. */
  41155. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  41156. }
  41157. }
  41158. }
  41159. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  41160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41161. import { Nullable } from "babylonjs/types";
  41162. module "babylonjs/Engines/thinEngine" {
  41163. interface ThinEngine {
  41164. /**
  41165. * Creates a dynamic texture
  41166. * @param width defines the width of the texture
  41167. * @param height defines the height of the texture
  41168. * @param generateMipMaps defines if the engine should generate the mip levels
  41169. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  41170. * @returns the dynamic texture inside an InternalTexture
  41171. */
  41172. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  41173. /**
  41174. * Update the content of a dynamic texture
  41175. * @param texture defines the texture to update
  41176. * @param source defines the source containing the data
  41177. * @param invertY defines if data must be stored with Y axis inverted
  41178. * @param premulAlpha defines if alpha is stored as premultiplied
  41179. * @param format defines the format of the data
  41180. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  41181. */
  41182. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  41183. }
  41184. }
  41185. }
  41186. declare module "babylonjs/Materials/Textures/videoTexture" {
  41187. import { Observable } from "babylonjs/Misc/observable";
  41188. import { Nullable } from "babylonjs/types";
  41189. import { Scene } from "babylonjs/scene";
  41190. import { Texture } from "babylonjs/Materials/Textures/texture";
  41191. import "babylonjs/Engines/Extensions/engine.videoTexture";
  41192. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  41193. /**
  41194. * Settings for finer control over video usage
  41195. */
  41196. export interface VideoTextureSettings {
  41197. /**
  41198. * Applies `autoplay` to video, if specified
  41199. */
  41200. autoPlay?: boolean;
  41201. /**
  41202. * Applies `muted` to video, if specified
  41203. */
  41204. muted?: boolean;
  41205. /**
  41206. * Applies `loop` to video, if specified
  41207. */
  41208. loop?: boolean;
  41209. /**
  41210. * Automatically updates internal texture from video at every frame in the render loop
  41211. */
  41212. autoUpdateTexture: boolean;
  41213. /**
  41214. * Image src displayed during the video loading or until the user interacts with the video.
  41215. */
  41216. poster?: string;
  41217. }
  41218. /**
  41219. * If you want to display a video in your scene, this is the special texture for that.
  41220. * This special texture works similar to other textures, with the exception of a few parameters.
  41221. * @see https://doc.babylonjs.com/how_to/video_texture
  41222. */
  41223. export class VideoTexture extends Texture {
  41224. /**
  41225. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  41226. */
  41227. readonly autoUpdateTexture: boolean;
  41228. /**
  41229. * The video instance used by the texture internally
  41230. */
  41231. readonly video: HTMLVideoElement;
  41232. private _onUserActionRequestedObservable;
  41233. /**
  41234. * Event triggerd when a dom action is required by the user to play the video.
  41235. * This happens due to recent changes in browser policies preventing video to auto start.
  41236. */
  41237. get onUserActionRequestedObservable(): Observable<Texture>;
  41238. private _generateMipMaps;
  41239. private _stillImageCaptured;
  41240. private _displayingPosterTexture;
  41241. private _settings;
  41242. private _createInternalTextureOnEvent;
  41243. private _frameId;
  41244. private _currentSrc;
  41245. /**
  41246. * Creates a video texture.
  41247. * If you want to display a video in your scene, this is the special texture for that.
  41248. * This special texture works similar to other textures, with the exception of a few parameters.
  41249. * @see https://doc.babylonjs.com/how_to/video_texture
  41250. * @param name optional name, will detect from video source, if not defined
  41251. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  41252. * @param scene is obviously the current scene.
  41253. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  41254. * @param invertY is false by default but can be used to invert video on Y axis
  41255. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  41256. * @param settings allows finer control over video usage
  41257. */
  41258. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  41259. private _getName;
  41260. private _getVideo;
  41261. private _createInternalTexture;
  41262. private reset;
  41263. /**
  41264. * @hidden Internal method to initiate `update`.
  41265. */
  41266. _rebuild(): void;
  41267. /**
  41268. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  41269. */
  41270. update(): void;
  41271. /**
  41272. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  41273. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  41274. */
  41275. updateTexture(isVisible: boolean): void;
  41276. protected _updateInternalTexture: () => void;
  41277. /**
  41278. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  41279. * @param url New url.
  41280. */
  41281. updateURL(url: string): void;
  41282. /**
  41283. * Clones the texture.
  41284. * @returns the cloned texture
  41285. */
  41286. clone(): VideoTexture;
  41287. /**
  41288. * Dispose the texture and release its associated resources.
  41289. */
  41290. dispose(): void;
  41291. /**
  41292. * Creates a video texture straight from a stream.
  41293. * @param scene Define the scene the texture should be created in
  41294. * @param stream Define the stream the texture should be created from
  41295. * @returns The created video texture as a promise
  41296. */
  41297. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  41298. /**
  41299. * Creates a video texture straight from your WebCam video feed.
  41300. * @param scene Define the scene the texture should be created in
  41301. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41302. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41303. * @returns The created video texture as a promise
  41304. */
  41305. static CreateFromWebCamAsync(scene: Scene, constraints: {
  41306. minWidth: number;
  41307. maxWidth: number;
  41308. minHeight: number;
  41309. maxHeight: number;
  41310. deviceId: string;
  41311. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  41312. /**
  41313. * Creates a video texture straight from your WebCam video feed.
  41314. * @param scene Define the scene the texture should be created in
  41315. * @param onReady Define a callback to triggered once the texture will be ready
  41316. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41317. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41318. */
  41319. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  41320. minWidth: number;
  41321. maxWidth: number;
  41322. minHeight: number;
  41323. maxHeight: number;
  41324. deviceId: string;
  41325. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  41326. }
  41327. }
  41328. declare module "babylonjs/Engines/thinEngine" {
  41329. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  41330. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  41331. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41332. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  41334. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  41335. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  41336. import { Observable } from "babylonjs/Misc/observable";
  41337. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  41338. import { StencilState } from "babylonjs/States/stencilState";
  41339. import { AlphaState } from "babylonjs/States/alphaCullingState";
  41340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41341. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41342. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41343. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  41344. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41345. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41346. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41347. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  41348. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  41349. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41350. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  41351. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  41352. import { EngineFeatures } from "babylonjs/Engines/engineFeatures";
  41353. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41354. import { WebRequest } from "babylonjs/Misc/webRequest";
  41355. import { LoadFileError } from "babylonjs/Misc/fileTools";
  41356. /**
  41357. * Defines the interface used by objects working like Scene
  41358. * @hidden
  41359. */
  41360. export interface ISceneLike {
  41361. _addPendingData(data: any): void;
  41362. _removePendingData(data: any): void;
  41363. offlineProvider: IOfflineProvider;
  41364. }
  41365. /**
  41366. * Information about the current host
  41367. */
  41368. export interface HostInformation {
  41369. /**
  41370. * Defines if the current host is a mobile
  41371. */
  41372. isMobile: boolean;
  41373. }
  41374. /** Interface defining initialization parameters for Engine class */
  41375. export interface EngineOptions extends WebGLContextAttributes {
  41376. /**
  41377. * Defines if the engine should no exceed a specified device ratio
  41378. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  41379. */
  41380. limitDeviceRatio?: number;
  41381. /**
  41382. * Defines if webvr should be enabled automatically
  41383. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41384. */
  41385. autoEnableWebVR?: boolean;
  41386. /**
  41387. * Defines if webgl2 should be turned off even if supported
  41388. * @see https://doc.babylonjs.com/features/webgl2
  41389. */
  41390. disableWebGL2Support?: boolean;
  41391. /**
  41392. * Defines if webaudio should be initialized as well
  41393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41394. */
  41395. audioEngine?: boolean;
  41396. /**
  41397. * Defines if animations should run using a deterministic lock step
  41398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41399. */
  41400. deterministicLockstep?: boolean;
  41401. /** Defines the maximum steps to use with deterministic lock step mode */
  41402. lockstepMaxSteps?: number;
  41403. /** Defines the seconds between each deterministic lock step */
  41404. timeStep?: number;
  41405. /**
  41406. * Defines that engine should ignore context lost events
  41407. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  41408. */
  41409. doNotHandleContextLost?: boolean;
  41410. /**
  41411. * Defines that engine should ignore modifying touch action attribute and style
  41412. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  41413. */
  41414. doNotHandleTouchAction?: boolean;
  41415. /**
  41416. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  41417. */
  41418. useHighPrecisionFloats?: boolean;
  41419. /**
  41420. * Make the canvas XR Compatible for XR sessions
  41421. */
  41422. xrCompatible?: boolean;
  41423. /**
  41424. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  41425. */
  41426. useHighPrecisionMatrix?: boolean;
  41427. /**
  41428. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  41429. */
  41430. failIfMajorPerformanceCaveat?: boolean;
  41431. /**
  41432. * Defines whether to adapt to the device's viewport characteristics (default: false)
  41433. */
  41434. adaptToDeviceRatio?: boolean;
  41435. }
  41436. /**
  41437. * The base engine class (root of all engines)
  41438. */
  41439. export class ThinEngine {
  41440. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  41441. static ExceptionList: ({
  41442. key: string;
  41443. capture: string;
  41444. captureConstraint: number;
  41445. targets: string[];
  41446. } | {
  41447. key: string;
  41448. capture: null;
  41449. captureConstraint: null;
  41450. targets: string[];
  41451. })[];
  41452. /** @hidden */
  41453. static _TextureLoaders: IInternalTextureLoader[];
  41454. /**
  41455. * Returns the current npm package of the sdk
  41456. */
  41457. static get NpmPackage(): string;
  41458. /**
  41459. * Returns the current version of the framework
  41460. */
  41461. static get Version(): string;
  41462. /**
  41463. * Returns a string describing the current engine
  41464. */
  41465. get description(): string;
  41466. /**
  41467. * Returns the name of the engine
  41468. */
  41469. get name(): string;
  41470. /**
  41471. * Returns the version of the engine
  41472. */
  41473. get version(): number;
  41474. /**
  41475. * Gets or sets the epsilon value used by collision engine
  41476. */
  41477. static CollisionsEpsilon: number;
  41478. /**
  41479. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  41480. */
  41481. static get ShadersRepository(): string;
  41482. static set ShadersRepository(value: string);
  41483. /** @hidden */
  41484. _shaderProcessor: Nullable<IShaderProcessor>;
  41485. /**
  41486. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  41487. */
  41488. forcePOTTextures: boolean;
  41489. /**
  41490. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  41491. */
  41492. isFullscreen: boolean;
  41493. /**
  41494. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  41495. */
  41496. cullBackFaces: boolean;
  41497. /**
  41498. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  41499. */
  41500. renderEvenInBackground: boolean;
  41501. /**
  41502. * Gets or sets a boolean indicating that cache can be kept between frames
  41503. */
  41504. preventCacheWipeBetweenFrames: boolean;
  41505. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  41506. validateShaderPrograms: boolean;
  41507. /**
  41508. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  41509. * This can provide greater z depth for distant objects.
  41510. */
  41511. useReverseDepthBuffer: boolean;
  41512. /**
  41513. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  41514. */
  41515. disableUniformBuffers: boolean;
  41516. private _frameId;
  41517. /**
  41518. * Gets the current frame id
  41519. */
  41520. get frameId(): number;
  41521. /** @hidden */
  41522. _uniformBuffers: UniformBuffer[];
  41523. /**
  41524. * Gets a boolean indicating that the engine supports uniform buffers
  41525. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  41526. */
  41527. get supportsUniformBuffers(): boolean;
  41528. /** @hidden */
  41529. _gl: WebGLRenderingContext;
  41530. /** @hidden */
  41531. _webGLVersion: number;
  41532. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  41533. protected _windowIsBackground: boolean;
  41534. protected _creationOptions: EngineOptions;
  41535. protected _highPrecisionShadersAllowed: boolean;
  41536. /** @hidden */
  41537. get _shouldUseHighPrecisionShader(): boolean;
  41538. /**
  41539. * Gets a boolean indicating that only power of 2 textures are supported
  41540. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  41541. */
  41542. get needPOTTextures(): boolean;
  41543. /** @hidden */
  41544. _badOS: boolean;
  41545. /** @hidden */
  41546. _badDesktopOS: boolean;
  41547. protected _hardwareScalingLevel: number;
  41548. /** @hidden */
  41549. _caps: EngineCapabilities;
  41550. /** @hidden */
  41551. _features: EngineFeatures;
  41552. protected _isStencilEnable: boolean;
  41553. private _glVersion;
  41554. private _glRenderer;
  41555. private _glVendor;
  41556. /** @hidden */
  41557. _videoTextureSupported: boolean;
  41558. protected _renderingQueueLaunched: boolean;
  41559. protected _activeRenderLoops: (() => void)[];
  41560. /**
  41561. * Observable signaled when a context lost event is raised
  41562. */
  41563. onContextLostObservable: Observable<ThinEngine>;
  41564. /**
  41565. * Observable signaled when a context restored event is raised
  41566. */
  41567. onContextRestoredObservable: Observable<ThinEngine>;
  41568. private _onContextLost;
  41569. private _onContextRestored;
  41570. protected _contextWasLost: boolean;
  41571. /** @hidden */
  41572. _doNotHandleContextLost: boolean;
  41573. /**
  41574. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  41575. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  41576. */
  41577. get doNotHandleContextLost(): boolean;
  41578. set doNotHandleContextLost(value: boolean);
  41579. /**
  41580. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  41581. */
  41582. disableVertexArrayObjects: boolean;
  41583. /** @hidden */
  41584. protected _colorWrite: boolean;
  41585. /** @hidden */
  41586. protected _colorWriteChanged: boolean;
  41587. /** @hidden */
  41588. protected _depthCullingState: DepthCullingState;
  41589. /** @hidden */
  41590. protected _stencilState: StencilState;
  41591. /** @hidden */
  41592. _alphaState: AlphaState;
  41593. /** @hidden */
  41594. _alphaMode: number;
  41595. /** @hidden */
  41596. _alphaEquation: number;
  41597. /** @hidden */
  41598. _internalTexturesCache: InternalTexture[];
  41599. /** @hidden */
  41600. protected _activeChannel: number;
  41601. private _currentTextureChannel;
  41602. /** @hidden */
  41603. protected _boundTexturesCache: {
  41604. [key: string]: Nullable<InternalTexture>;
  41605. };
  41606. /** @hidden */
  41607. protected _currentEffect: Nullable<Effect>;
  41608. /** @hidden */
  41609. protected _currentProgram: Nullable<WebGLProgram>;
  41610. protected _compiledEffects: {
  41611. [key: string]: Effect;
  41612. };
  41613. private _vertexAttribArraysEnabled;
  41614. /** @hidden */
  41615. protected _cachedViewport: Nullable<IViewportLike>;
  41616. private _cachedVertexArrayObject;
  41617. /** @hidden */
  41618. protected _cachedVertexBuffers: any;
  41619. /** @hidden */
  41620. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  41621. /** @hidden */
  41622. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  41623. /** @hidden */
  41624. _currentRenderTarget: Nullable<InternalTexture>;
  41625. private _uintIndicesCurrentlySet;
  41626. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  41627. /** @hidden */
  41628. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  41629. /** @hidden */
  41630. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  41631. private _currentBufferPointers;
  41632. private _currentInstanceLocations;
  41633. private _currentInstanceBuffers;
  41634. private _textureUnits;
  41635. /** @hidden */
  41636. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41637. /** @hidden */
  41638. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41639. /** @hidden */
  41640. _boundRenderFunction: any;
  41641. private _vaoRecordInProgress;
  41642. private _mustWipeVertexAttributes;
  41643. private _emptyTexture;
  41644. private _emptyCubeTexture;
  41645. private _emptyTexture3D;
  41646. private _emptyTexture2DArray;
  41647. /** @hidden */
  41648. _frameHandler: number;
  41649. private _nextFreeTextureSlots;
  41650. private _maxSimultaneousTextures;
  41651. private _activeRequests;
  41652. /** @hidden */
  41653. _transformTextureUrl: Nullable<(url: string) => string>;
  41654. /**
  41655. * Gets information about the current host
  41656. */
  41657. hostInformation: HostInformation;
  41658. protected get _supportsHardwareTextureRescaling(): boolean;
  41659. private _framebufferDimensionsObject;
  41660. /**
  41661. * sets the object from which width and height will be taken from when getting render width and height
  41662. * Will fallback to the gl object
  41663. * @param dimensions the framebuffer width and height that will be used.
  41664. */
  41665. set framebufferDimensionsObject(dimensions: Nullable<{
  41666. framebufferWidth: number;
  41667. framebufferHeight: number;
  41668. }>);
  41669. /**
  41670. * Gets the current viewport
  41671. */
  41672. get currentViewport(): Nullable<IViewportLike>;
  41673. /**
  41674. * Gets the default empty texture
  41675. */
  41676. get emptyTexture(): InternalTexture;
  41677. /**
  41678. * Gets the default empty 3D texture
  41679. */
  41680. get emptyTexture3D(): InternalTexture;
  41681. /**
  41682. * Gets the default empty 2D array texture
  41683. */
  41684. get emptyTexture2DArray(): InternalTexture;
  41685. /**
  41686. * Gets the default empty cube texture
  41687. */
  41688. get emptyCubeTexture(): InternalTexture;
  41689. /**
  41690. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  41691. */
  41692. premultipliedAlpha: boolean;
  41693. /**
  41694. * Observable event triggered before each texture is initialized
  41695. */
  41696. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  41697. /** @hidden */
  41698. protected _isWebGPU: boolean;
  41699. /**
  41700. * Gets a boolean indicating if the engine runs in WebGPU or not.
  41701. */
  41702. get isWebGPU(): boolean;
  41703. /** @hidden */
  41704. protected _shaderPlatformName: string;
  41705. /**
  41706. * Gets the shader platfrom name used by the effects.
  41707. */
  41708. get shaderPlatformName(): string;
  41709. /**
  41710. * Creates a new engine
  41711. * @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
  41712. * @param antialias defines enable antialiasing (default: false)
  41713. * @param options defines further options to be sent to the getContext() function
  41714. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41715. */
  41716. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41717. /**
  41718. * @hidden
  41719. */
  41720. _debugPushGroup(groupName: string, targetObject?: number): void;
  41721. /**
  41722. * @hidden
  41723. */
  41724. _debugPopGroup(targetObject?: number): void;
  41725. /**
  41726. * @hidden
  41727. */
  41728. _debugInsertMarker(text: string, targetObject?: number): void;
  41729. /**
  41730. * Shared initialization across engines types.
  41731. * @param canvas The canvas associated with this instance of the engine.
  41732. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  41733. * @param audioEngine Defines if an audio engine should be created by default
  41734. */
  41735. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  41736. /**
  41737. * Gets a shader processor implementation fitting with the current engine type.
  41738. * @returns The shader processor implementation.
  41739. */
  41740. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  41741. /** @hidden */
  41742. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  41743. private _rebuildInternalTextures;
  41744. private _rebuildEffects;
  41745. /**
  41746. * Gets a boolean indicating if all created effects are ready
  41747. * @returns true if all effects are ready
  41748. */
  41749. areAllEffectsReady(): boolean;
  41750. protected _rebuildBuffers(): void;
  41751. protected _initGLContext(): void;
  41752. protected _initFeatures(): void;
  41753. /**
  41754. * Gets version of the current webGL context
  41755. * Keep it for back compat - use version instead
  41756. */
  41757. get webGLVersion(): number;
  41758. /**
  41759. * Gets a string identifying the name of the class
  41760. * @returns "Engine" string
  41761. */
  41762. getClassName(): string;
  41763. /**
  41764. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  41765. */
  41766. get isStencilEnable(): boolean;
  41767. /** @hidden */
  41768. _prepareWorkingCanvas(): void;
  41769. /**
  41770. * Reset the texture cache to empty state
  41771. */
  41772. resetTextureCache(): void;
  41773. /**
  41774. * Gets an object containing information about the current webGL context
  41775. * @returns an object containing the vender, the renderer and the version of the current webGL context
  41776. */
  41777. getGlInfo(): {
  41778. vendor: string;
  41779. renderer: string;
  41780. version: string;
  41781. };
  41782. /**
  41783. * Defines the hardware scaling level.
  41784. * By default the hardware scaling level is computed from the window device ratio.
  41785. * 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.
  41786. * @param level defines the level to use
  41787. */
  41788. setHardwareScalingLevel(level: number): void;
  41789. /**
  41790. * Gets the current hardware scaling level.
  41791. * By default the hardware scaling level is computed from the window device ratio.
  41792. * 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.
  41793. * @returns a number indicating the current hardware scaling level
  41794. */
  41795. getHardwareScalingLevel(): number;
  41796. /**
  41797. * Gets the list of loaded textures
  41798. * @returns an array containing all loaded textures
  41799. */
  41800. getLoadedTexturesCache(): InternalTexture[];
  41801. /**
  41802. * Gets the object containing all engine capabilities
  41803. * @returns the EngineCapabilities object
  41804. */
  41805. getCaps(): EngineCapabilities;
  41806. /**
  41807. * stop executing a render loop function and remove it from the execution array
  41808. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  41809. */
  41810. stopRenderLoop(renderFunction?: () => void): void;
  41811. /** @hidden */
  41812. _renderLoop(): void;
  41813. /**
  41814. * Gets the HTML canvas attached with the current webGL context
  41815. * @returns a HTML canvas
  41816. */
  41817. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  41818. /**
  41819. * Gets host window
  41820. * @returns the host window object
  41821. */
  41822. getHostWindow(): Nullable<Window>;
  41823. /**
  41824. * Gets the current render width
  41825. * @param useScreen defines if screen size must be used (or the current render target if any)
  41826. * @returns a number defining the current render width
  41827. */
  41828. getRenderWidth(useScreen?: boolean): number;
  41829. /**
  41830. * Gets the current render height
  41831. * @param useScreen defines if screen size must be used (or the current render target if any)
  41832. * @returns a number defining the current render height
  41833. */
  41834. getRenderHeight(useScreen?: boolean): number;
  41835. /**
  41836. * Can be used to override the current requestAnimationFrame requester.
  41837. * @hidden
  41838. */
  41839. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  41840. /**
  41841. * Register and execute a render loop. The engine can have more than one render function
  41842. * @param renderFunction defines the function to continuously execute
  41843. */
  41844. runRenderLoop(renderFunction: () => void): void;
  41845. /**
  41846. * Clear the current render buffer or the current render target (if any is set up)
  41847. * @param color defines the color to use
  41848. * @param backBuffer defines if the back buffer must be cleared
  41849. * @param depth defines if the depth buffer must be cleared
  41850. * @param stencil defines if the stencil buffer must be cleared
  41851. */
  41852. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41853. protected _viewportCached: {
  41854. x: number;
  41855. y: number;
  41856. z: number;
  41857. w: number;
  41858. };
  41859. /** @hidden */
  41860. _viewport(x: number, y: number, width: number, height: number): void;
  41861. /**
  41862. * Set the WebGL's viewport
  41863. * @param viewport defines the viewport element to be used
  41864. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41865. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41866. */
  41867. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41868. /**
  41869. * Begin a new frame
  41870. */
  41871. beginFrame(): void;
  41872. /**
  41873. * Enf the current frame
  41874. */
  41875. endFrame(): void;
  41876. /**
  41877. * Resize the view according to the canvas' size
  41878. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41879. */
  41880. resize(forceSetSize?: boolean): void;
  41881. /**
  41882. * Force a specific size of the canvas
  41883. * @param width defines the new canvas' width
  41884. * @param height defines the new canvas' height
  41885. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41886. * @returns true if the size was changed
  41887. */
  41888. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41889. /**
  41890. * Binds the frame buffer to the specified texture.
  41891. * @param texture The texture to render to or null for the default canvas
  41892. * @param faceIndex The face of the texture to render to in case of cube texture
  41893. * @param requiredWidth The width of the target to render to
  41894. * @param requiredHeight The height of the target to render to
  41895. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41896. * @param lodLevel defines the lod level to bind to the frame buffer
  41897. * @param layer defines the 2d array index to bind to frame buffer to
  41898. */
  41899. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41900. /** @hidden */
  41901. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41902. /**
  41903. * Unbind the current render target texture from the webGL context
  41904. * @param texture defines the render target texture to unbind
  41905. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41906. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41907. */
  41908. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41909. /**
  41910. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41911. */
  41912. flushFramebuffer(): void;
  41913. /**
  41914. * Unbind the current render target and bind the default framebuffer
  41915. */
  41916. restoreDefaultFramebuffer(): void;
  41917. /** @hidden */
  41918. protected _resetVertexBufferBinding(): void;
  41919. /**
  41920. * Creates a vertex buffer
  41921. * @param data the data for the vertex buffer
  41922. * @returns the new WebGL static buffer
  41923. */
  41924. createVertexBuffer(data: DataArray): DataBuffer;
  41925. private _createVertexBuffer;
  41926. /**
  41927. * Creates a dynamic vertex buffer
  41928. * @param data the data for the dynamic vertex buffer
  41929. * @returns the new WebGL dynamic buffer
  41930. */
  41931. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41932. protected _resetIndexBufferBinding(): void;
  41933. /**
  41934. * Creates a new index buffer
  41935. * @param indices defines the content of the index buffer
  41936. * @param updatable defines if the index buffer must be updatable
  41937. * @returns a new webGL buffer
  41938. */
  41939. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41940. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41941. /**
  41942. * Bind a webGL buffer to the webGL context
  41943. * @param buffer defines the buffer to bind
  41944. */
  41945. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41946. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41947. private bindBuffer;
  41948. /**
  41949. * update the bound buffer with the given data
  41950. * @param data defines the data to update
  41951. */
  41952. updateArrayBuffer(data: Float32Array): void;
  41953. private _vertexAttribPointer;
  41954. /** @hidden */
  41955. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41956. private _bindVertexBuffersAttributes;
  41957. /**
  41958. * Records a vertex array object
  41959. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41960. * @param vertexBuffers defines the list of vertex buffers to store
  41961. * @param indexBuffer defines the index buffer to store
  41962. * @param effect defines the effect to store
  41963. * @returns the new vertex array object
  41964. */
  41965. recordVertexArrayObject(vertexBuffers: {
  41966. [key: string]: VertexBuffer;
  41967. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  41968. /**
  41969. * Bind a specific vertex array object
  41970. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41971. * @param vertexArrayObject defines the vertex array object to bind
  41972. * @param indexBuffer defines the index buffer to bind
  41973. */
  41974. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41975. /**
  41976. * Bind webGl buffers directly to the webGL context
  41977. * @param vertexBuffer defines the vertex buffer to bind
  41978. * @param indexBuffer defines the index buffer to bind
  41979. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41980. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41981. * @param effect defines the effect associated with the vertex buffer
  41982. */
  41983. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41984. private _unbindVertexArrayObject;
  41985. /**
  41986. * Bind a list of vertex buffers to the webGL context
  41987. * @param vertexBuffers defines the list of vertex buffers to bind
  41988. * @param indexBuffer defines the index buffer to bind
  41989. * @param effect defines the effect associated with the vertex buffers
  41990. */
  41991. bindBuffers(vertexBuffers: {
  41992. [key: string]: Nullable<VertexBuffer>;
  41993. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41994. /**
  41995. * Unbind all instance attributes
  41996. */
  41997. unbindInstanceAttributes(): void;
  41998. /**
  41999. * Release and free the memory of a vertex array object
  42000. * @param vao defines the vertex array object to delete
  42001. */
  42002. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  42003. /** @hidden */
  42004. _releaseBuffer(buffer: DataBuffer): boolean;
  42005. protected _deleteBuffer(buffer: DataBuffer): void;
  42006. /**
  42007. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  42008. * @param instancesBuffer defines the webGL buffer to update and bind
  42009. * @param data defines the data to store in the buffer
  42010. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  42011. */
  42012. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  42013. /**
  42014. * Bind the content of a webGL buffer used with instantiation
  42015. * @param instancesBuffer defines the webGL buffer to bind
  42016. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  42017. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  42018. */
  42019. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  42020. /**
  42021. * Disable the instance attribute corresponding to the name in parameter
  42022. * @param name defines the name of the attribute to disable
  42023. */
  42024. disableInstanceAttributeByName(name: string): void;
  42025. /**
  42026. * Disable the instance attribute corresponding to the location in parameter
  42027. * @param attributeLocation defines the attribute location of the attribute to disable
  42028. */
  42029. disableInstanceAttribute(attributeLocation: number): void;
  42030. /**
  42031. * Disable the attribute corresponding to the location in parameter
  42032. * @param attributeLocation defines the attribute location of the attribute to disable
  42033. */
  42034. disableAttributeByIndex(attributeLocation: number): void;
  42035. /**
  42036. * Send a draw order
  42037. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42038. * @param indexStart defines the starting index
  42039. * @param indexCount defines the number of index to draw
  42040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42041. */
  42042. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42043. /**
  42044. * Draw a list of points
  42045. * @param verticesStart defines the index of first vertex to draw
  42046. * @param verticesCount defines the count of vertices to draw
  42047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42048. */
  42049. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42050. /**
  42051. * Draw a list of unindexed primitives
  42052. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42053. * @param verticesStart defines the index of first vertex to draw
  42054. * @param verticesCount defines the count of vertices to draw
  42055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42056. */
  42057. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42058. /**
  42059. * Draw a list of indexed primitives
  42060. * @param fillMode defines the primitive to use
  42061. * @param indexStart defines the starting index
  42062. * @param indexCount defines the number of index to draw
  42063. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42064. */
  42065. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42066. /**
  42067. * Draw a list of unindexed primitives
  42068. * @param fillMode defines the primitive to use
  42069. * @param verticesStart defines the index of first vertex to draw
  42070. * @param verticesCount defines the count of vertices to draw
  42071. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42072. */
  42073. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42074. private _drawMode;
  42075. /** @hidden */
  42076. protected _reportDrawCall(): void;
  42077. /** @hidden */
  42078. _releaseEffect(effect: Effect): void;
  42079. /** @hidden */
  42080. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42081. /**
  42082. * Create a new effect (used to store vertex/fragment shaders)
  42083. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  42084. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  42085. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  42086. * @param samplers defines an array of string used to represent textures
  42087. * @param defines defines the string containing the defines to use to compile the shaders
  42088. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  42089. * @param onCompiled defines a function to call when the effect creation is successful
  42090. * @param onError defines a function to call when the effect creation has failed
  42091. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  42092. * @returns the new Effect
  42093. */
  42094. 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;
  42095. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  42096. private _compileShader;
  42097. private _compileRawShader;
  42098. /** @hidden */
  42099. _getShaderSource(shader: WebGLShader): Nullable<string>;
  42100. /**
  42101. * Directly creates a webGL program
  42102. * @param pipelineContext defines the pipeline context to attach to
  42103. * @param vertexCode defines the vertex shader code to use
  42104. * @param fragmentCode defines the fragment shader code to use
  42105. * @param context defines the webGL context to use (if not set, the current one will be used)
  42106. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42107. * @returns the new webGL program
  42108. */
  42109. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42110. /**
  42111. * Creates a webGL program
  42112. * @param pipelineContext defines the pipeline context to attach to
  42113. * @param vertexCode defines the vertex shader code to use
  42114. * @param fragmentCode defines the fragment shader code to use
  42115. * @param defines defines the string containing the defines to use to compile the shaders
  42116. * @param context defines the webGL context to use (if not set, the current one will be used)
  42117. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42118. * @returns the new webGL program
  42119. */
  42120. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42121. /**
  42122. * Creates a new pipeline context
  42123. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  42124. * @returns the new pipeline
  42125. */
  42126. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  42127. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42128. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  42129. /** @hidden */
  42130. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  42131. /** @hidden */
  42132. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  42133. /** @hidden */
  42134. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  42135. /**
  42136. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42137. * @param pipelineContext defines the pipeline context to use
  42138. * @param uniformsNames defines the list of uniform names
  42139. * @returns an array of webGL uniform locations
  42140. */
  42141. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42142. /**
  42143. * Gets the list of active attributes for a given webGL program
  42144. * @param pipelineContext defines the pipeline context to use
  42145. * @param attributesNames defines the list of attribute names to get
  42146. * @returns an array of indices indicating the offset of each attribute
  42147. */
  42148. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42149. /**
  42150. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42151. * @param effect defines the effect to activate
  42152. */
  42153. enableEffect(effect: Nullable<Effect>): void;
  42154. /**
  42155. * Set the value of an uniform to a number (int)
  42156. * @param uniform defines the webGL uniform location where to store the value
  42157. * @param value defines the int number to store
  42158. * @returns true if the value was set
  42159. */
  42160. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42161. /**
  42162. * Set the value of an uniform to a int2
  42163. * @param uniform defines the webGL uniform location where to store the value
  42164. * @param x defines the 1st component of the value
  42165. * @param y defines the 2nd component of the value
  42166. * @returns true if the value was set
  42167. */
  42168. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42169. /**
  42170. * Set the value of an uniform to a int3
  42171. * @param uniform defines the webGL uniform location where to store the value
  42172. * @param x defines the 1st component of the value
  42173. * @param y defines the 2nd component of the value
  42174. * @param z defines the 3rd component of the value
  42175. * @returns true if the value was set
  42176. */
  42177. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42178. /**
  42179. * Set the value of an uniform to a int4
  42180. * @param uniform defines the webGL uniform location where to store the value
  42181. * @param x defines the 1st component of the value
  42182. * @param y defines the 2nd component of the value
  42183. * @param z defines the 3rd component of the value
  42184. * @param w defines the 4th component of the value
  42185. * @returns true if the value was set
  42186. */
  42187. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42188. /**
  42189. * Set the value of an uniform to an array of int32
  42190. * @param uniform defines the webGL uniform location where to store the value
  42191. * @param array defines the array of int32 to store
  42192. * @returns true if the value was set
  42193. */
  42194. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42195. /**
  42196. * Set the value of an uniform to an array of int32 (stored as vec2)
  42197. * @param uniform defines the webGL uniform location where to store the value
  42198. * @param array defines the array of int32 to store
  42199. * @returns true if the value was set
  42200. */
  42201. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42202. /**
  42203. * Set the value of an uniform to an array of int32 (stored as vec3)
  42204. * @param uniform defines the webGL uniform location where to store the value
  42205. * @param array defines the array of int32 to store
  42206. * @returns true if the value was set
  42207. */
  42208. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42209. /**
  42210. * Set the value of an uniform to an array of int32 (stored as vec4)
  42211. * @param uniform defines the webGL uniform location where to store the value
  42212. * @param array defines the array of int32 to store
  42213. * @returns true if the value was set
  42214. */
  42215. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42216. /**
  42217. * Set the value of an uniform to an array of number
  42218. * @param uniform defines the webGL uniform location where to store the value
  42219. * @param array defines the array of number to store
  42220. * @returns true if the value was set
  42221. */
  42222. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42223. /**
  42224. * Set the value of an uniform to an array of number (stored as vec2)
  42225. * @param uniform defines the webGL uniform location where to store the value
  42226. * @param array defines the array of number to store
  42227. * @returns true if the value was set
  42228. */
  42229. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42230. /**
  42231. * Set the value of an uniform to an array of number (stored as vec3)
  42232. * @param uniform defines the webGL uniform location where to store the value
  42233. * @param array defines the array of number to store
  42234. * @returns true if the value was set
  42235. */
  42236. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42237. /**
  42238. * Set the value of an uniform to an array of number (stored as vec4)
  42239. * @param uniform defines the webGL uniform location where to store the value
  42240. * @param array defines the array of number to store
  42241. * @returns true if the value was set
  42242. */
  42243. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42244. /**
  42245. * Set the value of an uniform to an array of float32 (stored as matrices)
  42246. * @param uniform defines the webGL uniform location where to store the value
  42247. * @param matrices defines the array of float32 to store
  42248. * @returns true if the value was set
  42249. */
  42250. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  42251. /**
  42252. * Set the value of an uniform to a matrix (3x3)
  42253. * @param uniform defines the webGL uniform location where to store the value
  42254. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42255. * @returns true if the value was set
  42256. */
  42257. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42258. /**
  42259. * Set the value of an uniform to a matrix (2x2)
  42260. * @param uniform defines the webGL uniform location where to store the value
  42261. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42262. * @returns true if the value was set
  42263. */
  42264. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42265. /**
  42266. * Set the value of an uniform to a number (float)
  42267. * @param uniform defines the webGL uniform location where to store the value
  42268. * @param value defines the float number to store
  42269. * @returns true if the value was transfered
  42270. */
  42271. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42272. /**
  42273. * Set the value of an uniform to a vec2
  42274. * @param uniform defines the webGL uniform location where to store the value
  42275. * @param x defines the 1st component of the value
  42276. * @param y defines the 2nd component of the value
  42277. * @returns true if the value was set
  42278. */
  42279. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42280. /**
  42281. * Set the value of an uniform to a vec3
  42282. * @param uniform defines the webGL uniform location where to store the value
  42283. * @param x defines the 1st component of the value
  42284. * @param y defines the 2nd component of the value
  42285. * @param z defines the 3rd component of the value
  42286. * @returns true if the value was set
  42287. */
  42288. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42289. /**
  42290. * Set the value of an uniform to a vec4
  42291. * @param uniform defines the webGL uniform location where to store the value
  42292. * @param x defines the 1st component of the value
  42293. * @param y defines the 2nd component of the value
  42294. * @param z defines the 3rd component of the value
  42295. * @param w defines the 4th component of the value
  42296. * @returns true if the value was set
  42297. */
  42298. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42299. /**
  42300. * Apply all cached states (depth, culling, stencil and alpha)
  42301. */
  42302. applyStates(): void;
  42303. /**
  42304. * Enable or disable color writing
  42305. * @param enable defines the state to set
  42306. */
  42307. setColorWrite(enable: boolean): void;
  42308. /**
  42309. * Gets a boolean indicating if color writing is enabled
  42310. * @returns the current color writing state
  42311. */
  42312. getColorWrite(): boolean;
  42313. /**
  42314. * Gets the depth culling state manager
  42315. */
  42316. get depthCullingState(): DepthCullingState;
  42317. /**
  42318. * Gets the alpha state manager
  42319. */
  42320. get alphaState(): AlphaState;
  42321. /**
  42322. * Gets the stencil state manager
  42323. */
  42324. get stencilState(): StencilState;
  42325. /**
  42326. * Clears the list of texture accessible through engine.
  42327. * This can help preventing texture load conflict due to name collision.
  42328. */
  42329. clearInternalTexturesCache(): void;
  42330. /**
  42331. * Force the entire cache to be cleared
  42332. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42333. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42334. */
  42335. wipeCaches(bruteForce?: boolean): void;
  42336. /** @hidden */
  42337. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  42338. min: number;
  42339. mag: number;
  42340. };
  42341. /** @hidden */
  42342. protected _createTexture(): WebGLTexture;
  42343. /** @hidden */
  42344. _createHardwareTexture(): HardwareTextureWrapper;
  42345. 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 | {
  42346. width: number;
  42347. height: number;
  42348. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42349. width: number;
  42350. height: number;
  42351. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42352. width: number;
  42353. height: number;
  42354. }, 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;
  42355. /**
  42356. * Usually called from Texture.ts.
  42357. * Passed information to create a WebGLTexture
  42358. * @param url defines a value which contains one of the following:
  42359. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42360. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42361. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42363. * @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)
  42364. * @param scene needed for loading to the correct scene
  42365. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42366. * @param onLoad optional callback to be called upon successful completion
  42367. * @param onError optional callback to be called upon failure
  42368. * @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
  42369. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42370. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42371. * @param forcedExtension defines the extension to use to pick the right loader
  42372. * @param mimeType defines an optional mime type
  42373. * @param loaderOptions options to be passed to the loader
  42374. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42375. */
  42376. 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;
  42377. /**
  42378. * Loads an image as an HTMLImageElement.
  42379. * @param input url string, ArrayBuffer, or Blob to load
  42380. * @param onLoad callback called when the image successfully loads
  42381. * @param onError callback called when the image fails to load
  42382. * @param offlineProvider offline provider for caching
  42383. * @param mimeType optional mime type
  42384. * @returns the HTMLImageElement of the loaded image
  42385. * @hidden
  42386. */
  42387. 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>;
  42388. /**
  42389. * @hidden
  42390. */
  42391. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42392. private _unpackFlipYCached;
  42393. /**
  42394. * In case you are sharing the context with other applications, it might
  42395. * be interested to not cache the unpack flip y state to ensure a consistent
  42396. * value would be set.
  42397. */
  42398. enableUnpackFlipYCached: boolean;
  42399. /** @hidden */
  42400. _unpackFlipY(value: boolean): void;
  42401. /** @hidden */
  42402. _getUnpackAlignement(): number;
  42403. private _getTextureTarget;
  42404. /**
  42405. * Update the sampling mode of a given texture
  42406. * @param samplingMode defines the required sampling mode
  42407. * @param texture defines the texture to update
  42408. * @param generateMipMaps defines whether to generate mipmaps for the texture
  42409. */
  42410. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  42411. /**
  42412. * Update the dimensions of a texture
  42413. * @param texture texture to update
  42414. * @param width new width of the texture
  42415. * @param height new height of the texture
  42416. * @param depth new depth of the texture
  42417. */
  42418. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  42419. /**
  42420. * Update the sampling mode of a given texture
  42421. * @param texture defines the texture to update
  42422. * @param wrapU defines the texture wrap mode of the u coordinates
  42423. * @param wrapV defines the texture wrap mode of the v coordinates
  42424. * @param wrapR defines the texture wrap mode of the r coordinates
  42425. */
  42426. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  42427. /** @hidden */
  42428. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  42429. width: number;
  42430. height: number;
  42431. layers?: number;
  42432. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  42433. /** @hidden */
  42434. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42435. /** @hidden */
  42436. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  42437. /**
  42438. * Update a portion of an internal texture
  42439. * @param texture defines the texture to update
  42440. * @param imageData defines the data to store into the texture
  42441. * @param xOffset defines the x coordinates of the update rectangle
  42442. * @param yOffset defines the y coordinates of the update rectangle
  42443. * @param width defines the width of the update rectangle
  42444. * @param height defines the height of the update rectangle
  42445. * @param faceIndex defines the face index if texture is a cube (0 by default)
  42446. * @param lod defines the lod level to update (0 by default)
  42447. */
  42448. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  42449. /** @hidden */
  42450. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42451. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  42452. private _prepareWebGLTexture;
  42453. /** @hidden */
  42454. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  42455. private _getDepthStencilBuffer;
  42456. /** @hidden */
  42457. _releaseFramebufferObjects(texture: InternalTexture): void;
  42458. /** @hidden */
  42459. _releaseTexture(texture: InternalTexture): void;
  42460. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  42461. protected _setProgram(program: WebGLProgram): void;
  42462. protected _boundUniforms: {
  42463. [key: number]: WebGLUniformLocation;
  42464. };
  42465. /**
  42466. * Binds an effect to the webGL context
  42467. * @param effect defines the effect to bind
  42468. */
  42469. bindSamplers(effect: Effect): void;
  42470. private _activateCurrentTexture;
  42471. /** @hidden */
  42472. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  42473. /** @hidden */
  42474. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  42475. /**
  42476. * Unbind all textures from the webGL context
  42477. */
  42478. unbindAllTextures(): void;
  42479. /**
  42480. * Sets a texture to the according uniform.
  42481. * @param channel The texture channel
  42482. * @param uniform The uniform to set
  42483. * @param texture The texture to apply
  42484. * @param name The name of the uniform in the effect
  42485. */
  42486. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  42487. private _bindSamplerUniformToChannel;
  42488. private _getTextureWrapMode;
  42489. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  42490. /**
  42491. * Sets an array of texture to the webGL context
  42492. * @param channel defines the channel where the texture array must be set
  42493. * @param uniform defines the associated uniform location
  42494. * @param textures defines the array of textures to bind
  42495. * @param name name of the channel
  42496. */
  42497. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  42498. /** @hidden */
  42499. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  42500. private _setTextureParameterFloat;
  42501. private _setTextureParameterInteger;
  42502. /**
  42503. * Unbind all vertex attributes from the webGL context
  42504. */
  42505. unbindAllAttributes(): void;
  42506. /**
  42507. * 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
  42508. */
  42509. releaseEffects(): void;
  42510. /**
  42511. * Dispose and release all associated resources
  42512. */
  42513. dispose(): void;
  42514. /**
  42515. * Attach a new callback raised when context lost event is fired
  42516. * @param callback defines the callback to call
  42517. */
  42518. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42519. /**
  42520. * Attach a new callback raised when context restored event is fired
  42521. * @param callback defines the callback to call
  42522. */
  42523. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42524. /**
  42525. * Get the current error code of the webGL context
  42526. * @returns the error code
  42527. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42528. */
  42529. getError(): number;
  42530. private _canRenderToFloatFramebuffer;
  42531. private _canRenderToHalfFloatFramebuffer;
  42532. private _canRenderToFramebuffer;
  42533. /** @hidden */
  42534. _getWebGLTextureType(type: number): number;
  42535. /** @hidden */
  42536. _getInternalFormat(format: number): number;
  42537. /** @hidden */
  42538. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  42539. /** @hidden */
  42540. _getRGBAMultiSampleBufferFormat(type: number): number;
  42541. /** @hidden */
  42542. _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;
  42543. /**
  42544. * Loads a file from a url
  42545. * @param url url to load
  42546. * @param onSuccess callback called when the file successfully loads
  42547. * @param onProgress callback called while file is loading (if the server supports this mode)
  42548. * @param offlineProvider defines the offline provider for caching
  42549. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42550. * @param onError callback called when the file fails to load
  42551. * @returns a file request object
  42552. * @hidden
  42553. */
  42554. 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;
  42555. /**
  42556. * Reads pixels from the current frame buffer. Please note that this function can be slow
  42557. * @param x defines the x coordinate of the rectangle where pixels must be read
  42558. * @param y defines the y coordinate of the rectangle where pixels must be read
  42559. * @param width defines the width of the rectangle where pixels must be read
  42560. * @param height defines the height of the rectangle where pixels must be read
  42561. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  42562. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  42563. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  42564. */
  42565. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42566. private static _IsSupported;
  42567. private static _HasMajorPerformanceCaveat;
  42568. /**
  42569. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42570. */
  42571. static get IsSupported(): boolean;
  42572. /**
  42573. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42574. * @returns true if the engine can be created
  42575. * @ignorenaming
  42576. */
  42577. static isSupported(): boolean;
  42578. /**
  42579. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  42580. */
  42581. static get HasMajorPerformanceCaveat(): boolean;
  42582. /**
  42583. * Find the next highest power of two.
  42584. * @param x Number to start search from.
  42585. * @return Next highest power of two.
  42586. */
  42587. static CeilingPOT(x: number): number;
  42588. /**
  42589. * Find the next lowest power of two.
  42590. * @param x Number to start search from.
  42591. * @return Next lowest power of two.
  42592. */
  42593. static FloorPOT(x: number): number;
  42594. /**
  42595. * Find the nearest power of two.
  42596. * @param x Number to start search from.
  42597. * @return Next nearest power of two.
  42598. */
  42599. static NearestPOT(x: number): number;
  42600. /**
  42601. * Get the closest exponent of two
  42602. * @param value defines the value to approximate
  42603. * @param max defines the maximum value to return
  42604. * @param mode defines how to define the closest value
  42605. * @returns closest exponent of two of the given value
  42606. */
  42607. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  42608. /**
  42609. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  42610. * @param func - the function to be called
  42611. * @param requester - the object that will request the next frame. Falls back to window.
  42612. * @returns frame number
  42613. */
  42614. static QueueNewFrame(func: () => void, requester?: any): number;
  42615. /**
  42616. * Gets host document
  42617. * @returns the host document object
  42618. */
  42619. getHostDocument(): Nullable<Document>;
  42620. }
  42621. }
  42622. declare module "babylonjs/Materials/Textures/internalTexture" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable, int } from "babylonjs/types";
  42625. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  42626. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  42627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42628. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  42629. /**
  42630. * Defines the source of the internal texture
  42631. */
  42632. export enum InternalTextureSource {
  42633. /**
  42634. * The source of the texture data is unknown
  42635. */
  42636. Unknown = 0,
  42637. /**
  42638. * Texture data comes from an URL
  42639. */
  42640. Url = 1,
  42641. /**
  42642. * Texture data is only used for temporary storage
  42643. */
  42644. Temp = 2,
  42645. /**
  42646. * Texture data comes from raw data (ArrayBuffer)
  42647. */
  42648. Raw = 3,
  42649. /**
  42650. * Texture content is dynamic (video or dynamic texture)
  42651. */
  42652. Dynamic = 4,
  42653. /**
  42654. * Texture content is generated by rendering to it
  42655. */
  42656. RenderTarget = 5,
  42657. /**
  42658. * Texture content is part of a multi render target process
  42659. */
  42660. MultiRenderTarget = 6,
  42661. /**
  42662. * Texture data comes from a cube data file
  42663. */
  42664. Cube = 7,
  42665. /**
  42666. * Texture data comes from a raw cube data
  42667. */
  42668. CubeRaw = 8,
  42669. /**
  42670. * Texture data come from a prefiltered cube data file
  42671. */
  42672. CubePrefiltered = 9,
  42673. /**
  42674. * Texture content is raw 3D data
  42675. */
  42676. Raw3D = 10,
  42677. /**
  42678. * Texture content is raw 2D array data
  42679. */
  42680. Raw2DArray = 11,
  42681. /**
  42682. * Texture content is a depth texture
  42683. */
  42684. Depth = 12,
  42685. /**
  42686. * Texture data comes from a raw cube data encoded with RGBD
  42687. */
  42688. CubeRawRGBD = 13
  42689. }
  42690. /**
  42691. * Class used to store data associated with WebGL texture data for the engine
  42692. * This class should not be used directly
  42693. */
  42694. export class InternalTexture {
  42695. /** @hidden */
  42696. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  42697. /**
  42698. * Defines if the texture is ready
  42699. */
  42700. isReady: boolean;
  42701. /**
  42702. * Defines if the texture is a cube texture
  42703. */
  42704. isCube: boolean;
  42705. /**
  42706. * Defines if the texture contains 3D data
  42707. */
  42708. is3D: boolean;
  42709. /**
  42710. * Defines if the texture contains 2D array data
  42711. */
  42712. is2DArray: boolean;
  42713. /**
  42714. * Defines if the texture contains multiview data
  42715. */
  42716. isMultiview: boolean;
  42717. /**
  42718. * Gets the URL used to load this texture
  42719. */
  42720. url: string;
  42721. /** @hidden */
  42722. _originalUrl: string;
  42723. /**
  42724. * Gets the sampling mode of the texture
  42725. */
  42726. samplingMode: number;
  42727. /**
  42728. * Gets a boolean indicating if the texture needs mipmaps generation
  42729. */
  42730. generateMipMaps: boolean;
  42731. /**
  42732. * Gets the number of samples used by the texture (WebGL2+ only)
  42733. */
  42734. samples: number;
  42735. /**
  42736. * Gets the type of the texture (int, float...)
  42737. */
  42738. type: number;
  42739. /**
  42740. * Gets the format of the texture (RGB, RGBA...)
  42741. */
  42742. format: number;
  42743. /**
  42744. * Observable called when the texture is loaded
  42745. */
  42746. onLoadedObservable: Observable<InternalTexture>;
  42747. /**
  42748. * Gets the width of the texture
  42749. */
  42750. width: number;
  42751. /**
  42752. * Gets the height of the texture
  42753. */
  42754. height: number;
  42755. /**
  42756. * Gets the depth of the texture
  42757. */
  42758. depth: number;
  42759. /**
  42760. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  42761. */
  42762. baseWidth: number;
  42763. /**
  42764. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  42765. */
  42766. baseHeight: number;
  42767. /**
  42768. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  42769. */
  42770. baseDepth: number;
  42771. /**
  42772. * Gets a boolean indicating if the texture is inverted on Y axis
  42773. */
  42774. invertY: boolean;
  42775. /** @hidden */
  42776. _invertVScale: boolean;
  42777. /** @hidden */
  42778. _associatedChannel: number;
  42779. /** @hidden */
  42780. _source: InternalTextureSource;
  42781. /** @hidden */
  42782. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  42783. /** @hidden */
  42784. _bufferView: Nullable<ArrayBufferView>;
  42785. /** @hidden */
  42786. _bufferViewArray: Nullable<ArrayBufferView[]>;
  42787. /** @hidden */
  42788. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  42789. /** @hidden */
  42790. _size: number;
  42791. /** @hidden */
  42792. _extension: string;
  42793. /** @hidden */
  42794. _files: Nullable<string[]>;
  42795. /** @hidden */
  42796. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  42797. /** @hidden */
  42798. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  42799. /** @hidden */
  42800. _framebuffer: Nullable<WebGLFramebuffer>;
  42801. /** @hidden */
  42802. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  42803. /** @hidden */
  42804. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  42805. /** @hidden */
  42806. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  42807. /** @hidden */
  42808. _attachments: Nullable<number[]>;
  42809. /** @hidden */
  42810. _textureArray: Nullable<InternalTexture[]>;
  42811. /** @hidden */
  42812. _cachedCoordinatesMode: Nullable<number>;
  42813. /** @hidden */
  42814. _cachedWrapU: Nullable<number>;
  42815. /** @hidden */
  42816. _cachedWrapV: Nullable<number>;
  42817. /** @hidden */
  42818. _cachedWrapR: Nullable<number>;
  42819. /** @hidden */
  42820. _cachedAnisotropicFilteringLevel: Nullable<number>;
  42821. /** @hidden */
  42822. _isDisabled: boolean;
  42823. /** @hidden */
  42824. _compression: Nullable<string>;
  42825. /** @hidden */
  42826. _generateStencilBuffer: boolean;
  42827. /** @hidden */
  42828. _generateDepthBuffer: boolean;
  42829. /** @hidden */
  42830. _comparisonFunction: number;
  42831. /** @hidden */
  42832. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  42833. /** @hidden */
  42834. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  42835. /** @hidden */
  42836. _sphericalPolynomialComputed: boolean;
  42837. /** @hidden */
  42838. _lodGenerationScale: number;
  42839. /** @hidden */
  42840. _lodGenerationOffset: number;
  42841. /** @hidden */
  42842. _depthStencilTexture: Nullable<InternalTexture>;
  42843. /** @hidden */
  42844. _colorTextureArray: Nullable<WebGLTexture>;
  42845. /** @hidden */
  42846. _depthStencilTextureArray: Nullable<WebGLTexture>;
  42847. /** @hidden */
  42848. _lodTextureHigh: Nullable<BaseTexture>;
  42849. /** @hidden */
  42850. _lodTextureMid: Nullable<BaseTexture>;
  42851. /** @hidden */
  42852. _lodTextureLow: Nullable<BaseTexture>;
  42853. /** @hidden */
  42854. _isRGBD: boolean;
  42855. /** @hidden */
  42856. _linearSpecularLOD: boolean;
  42857. /** @hidden */
  42858. _irradianceTexture: Nullable<BaseTexture>;
  42859. /** @hidden */
  42860. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42861. /** @hidden */
  42862. _references: number;
  42863. /** @hidden */
  42864. _gammaSpace: Nullable<boolean>;
  42865. private _engine;
  42866. private _uniqueId;
  42867. private static _Counter;
  42868. /** Gets the unique id of the internal texture */
  42869. get uniqueId(): number;
  42870. /**
  42871. * Gets the Engine the texture belongs to.
  42872. * @returns The babylon engine
  42873. */
  42874. getEngine(): ThinEngine;
  42875. /**
  42876. * Gets the data source type of the texture
  42877. */
  42878. get source(): InternalTextureSource;
  42879. /**
  42880. * Creates a new InternalTexture
  42881. * @param engine defines the engine to use
  42882. * @param source defines the type of data that will be used
  42883. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42884. */
  42885. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42886. /**
  42887. * Increments the number of references (ie. the number of Texture that point to it)
  42888. */
  42889. incrementReferences(): void;
  42890. /**
  42891. * Change the size of the texture (not the size of the content)
  42892. * @param width defines the new width
  42893. * @param height defines the new height
  42894. * @param depth defines the new depth (1 by default)
  42895. */
  42896. updateSize(width: int, height: int, depth?: int): void;
  42897. /** @hidden */
  42898. _rebuild(): void;
  42899. /** @hidden */
  42900. _swapAndDie(target: InternalTexture): void;
  42901. /**
  42902. * Dispose the current allocated resources
  42903. */
  42904. dispose(): void;
  42905. }
  42906. }
  42907. declare module "babylonjs/Loading/loadingScreen" {
  42908. /**
  42909. * Interface used to present a loading screen while loading a scene
  42910. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42911. */
  42912. export interface ILoadingScreen {
  42913. /**
  42914. * Function called to display the loading screen
  42915. */
  42916. displayLoadingUI: () => void;
  42917. /**
  42918. * Function called to hide the loading screen
  42919. */
  42920. hideLoadingUI: () => void;
  42921. /**
  42922. * Gets or sets the color to use for the background
  42923. */
  42924. loadingUIBackgroundColor: string;
  42925. /**
  42926. * Gets or sets the text to display while loading
  42927. */
  42928. loadingUIText: string;
  42929. }
  42930. /**
  42931. * Class used for the default loading screen
  42932. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42933. */
  42934. export class DefaultLoadingScreen implements ILoadingScreen {
  42935. private _renderingCanvas;
  42936. private _loadingText;
  42937. private _loadingDivBackgroundColor;
  42938. private _loadingDiv;
  42939. private _loadingTextDiv;
  42940. /** Gets or sets the logo url to use for the default loading screen */
  42941. static DefaultLogoUrl: string;
  42942. /** Gets or sets the spinner url to use for the default loading screen */
  42943. static DefaultSpinnerUrl: string;
  42944. /**
  42945. * Creates a new default loading screen
  42946. * @param _renderingCanvas defines the canvas used to render the scene
  42947. * @param _loadingText defines the default text to display
  42948. * @param _loadingDivBackgroundColor defines the default background color
  42949. */
  42950. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42951. /**
  42952. * Function called to display the loading screen
  42953. */
  42954. displayLoadingUI(): void;
  42955. /**
  42956. * Function called to hide the loading screen
  42957. */
  42958. hideLoadingUI(): void;
  42959. /**
  42960. * Gets or sets the text to display while loading
  42961. */
  42962. set loadingUIText(text: string);
  42963. get loadingUIText(): string;
  42964. /**
  42965. * Gets or sets the color to use for the background
  42966. */
  42967. get loadingUIBackgroundColor(): string;
  42968. set loadingUIBackgroundColor(color: string);
  42969. private _resizeLoadingUI;
  42970. }
  42971. }
  42972. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  42973. /**
  42974. * Interface for any object that can request an animation frame
  42975. */
  42976. export interface ICustomAnimationFrameRequester {
  42977. /**
  42978. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42979. */
  42980. renderFunction?: Function;
  42981. /**
  42982. * Called to request the next frame to render to
  42983. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42984. */
  42985. requestAnimationFrame: Function;
  42986. /**
  42987. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42988. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42989. */
  42990. requestID?: number;
  42991. }
  42992. }
  42993. declare module "babylonjs/Misc/performanceMonitor" {
  42994. /**
  42995. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42996. */
  42997. export class PerformanceMonitor {
  42998. private _enabled;
  42999. private _rollingFrameTime;
  43000. private _lastFrameTimeMs;
  43001. /**
  43002. * constructor
  43003. * @param frameSampleSize The number of samples required to saturate the sliding window
  43004. */
  43005. constructor(frameSampleSize?: number);
  43006. /**
  43007. * Samples current frame
  43008. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  43009. */
  43010. sampleFrame(timeMs?: number): void;
  43011. /**
  43012. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43013. */
  43014. get averageFrameTime(): number;
  43015. /**
  43016. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43017. */
  43018. get averageFrameTimeVariance(): number;
  43019. /**
  43020. * Returns the frame time of the most recent frame
  43021. */
  43022. get instantaneousFrameTime(): number;
  43023. /**
  43024. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  43025. */
  43026. get averageFPS(): number;
  43027. /**
  43028. * Returns the average framerate in frames per second using the most recent frame time
  43029. */
  43030. get instantaneousFPS(): number;
  43031. /**
  43032. * Returns true if enough samples have been taken to completely fill the sliding window
  43033. */
  43034. get isSaturated(): boolean;
  43035. /**
  43036. * Enables contributions to the sliding window sample set
  43037. */
  43038. enable(): void;
  43039. /**
  43040. * Disables contributions to the sliding window sample set
  43041. * Samples will not be interpolated over the disabled period
  43042. */
  43043. disable(): void;
  43044. /**
  43045. * Returns true if sampling is enabled
  43046. */
  43047. get isEnabled(): boolean;
  43048. /**
  43049. * Resets performance monitor
  43050. */
  43051. reset(): void;
  43052. }
  43053. /**
  43054. * RollingAverage
  43055. *
  43056. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  43057. */
  43058. export class RollingAverage {
  43059. /**
  43060. * Current average
  43061. */
  43062. average: number;
  43063. /**
  43064. * Current variance
  43065. */
  43066. variance: number;
  43067. protected _samples: Array<number>;
  43068. protected _sampleCount: number;
  43069. protected _pos: number;
  43070. protected _m2: number;
  43071. /**
  43072. * constructor
  43073. * @param length The number of samples required to saturate the sliding window
  43074. */
  43075. constructor(length: number);
  43076. /**
  43077. * Adds a sample to the sample set
  43078. * @param v The sample value
  43079. */
  43080. add(v: number): void;
  43081. /**
  43082. * Returns previously added values or null if outside of history or outside the sliding window domain
  43083. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  43084. * @return Value previously recorded with add() or null if outside of range
  43085. */
  43086. history(i: number): number;
  43087. /**
  43088. * Returns true if enough samples have been taken to completely fill the sliding window
  43089. * @return true if sample-set saturated
  43090. */
  43091. isSaturated(): boolean;
  43092. /**
  43093. * Resets the rolling average (equivalent to 0 samples taken so far)
  43094. */
  43095. reset(): void;
  43096. /**
  43097. * Wraps a value around the sample range boundaries
  43098. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  43099. * @return Wrapped position in sample range
  43100. */
  43101. protected _wrapPosition(i: number): number;
  43102. }
  43103. }
  43104. declare module "babylonjs/Misc/perfCounter" {
  43105. /**
  43106. * This class is used to track a performance counter which is number based.
  43107. * The user has access to many properties which give statistics of different nature.
  43108. *
  43109. * The implementer can track two kinds of Performance Counter: time and count.
  43110. * 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.
  43111. * 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.
  43112. */
  43113. export class PerfCounter {
  43114. /**
  43115. * Gets or sets a global boolean to turn on and off all the counters
  43116. */
  43117. static Enabled: boolean;
  43118. /**
  43119. * Returns the smallest value ever
  43120. */
  43121. get min(): number;
  43122. /**
  43123. * Returns the biggest value ever
  43124. */
  43125. get max(): number;
  43126. /**
  43127. * Returns the average value since the performance counter is running
  43128. */
  43129. get average(): number;
  43130. /**
  43131. * Returns the average value of the last second the counter was monitored
  43132. */
  43133. get lastSecAverage(): number;
  43134. /**
  43135. * Returns the current value
  43136. */
  43137. get current(): number;
  43138. /**
  43139. * Gets the accumulated total
  43140. */
  43141. get total(): number;
  43142. /**
  43143. * Gets the total value count
  43144. */
  43145. get count(): number;
  43146. /**
  43147. * Creates a new counter
  43148. */
  43149. constructor();
  43150. /**
  43151. * Call this method to start monitoring a new frame.
  43152. * 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.
  43153. */
  43154. fetchNewFrame(): void;
  43155. /**
  43156. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  43157. * @param newCount the count value to add to the monitored count
  43158. * @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.
  43159. */
  43160. addCount(newCount: number, fetchResult: boolean): void;
  43161. /**
  43162. * Start monitoring this performance counter
  43163. */
  43164. beginMonitoring(): void;
  43165. /**
  43166. * Compute the time lapsed since the previous beginMonitoring() call.
  43167. * @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
  43168. */
  43169. endMonitoring(newFrame?: boolean): void;
  43170. private _fetchResult;
  43171. private _startMonitoringTime;
  43172. private _min;
  43173. private _max;
  43174. private _average;
  43175. private _current;
  43176. private _totalValueCount;
  43177. private _totalAccumulated;
  43178. private _lastSecAverage;
  43179. private _lastSecAccumulated;
  43180. private _lastSecTime;
  43181. private _lastSecValueCount;
  43182. }
  43183. }
  43184. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  43185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43186. import { Nullable } from "babylonjs/types";
  43187. module "babylonjs/Engines/thinEngine" {
  43188. interface ThinEngine {
  43189. /** @hidden */
  43190. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  43191. }
  43192. }
  43193. }
  43194. declare module "babylonjs/Audio/analyser" {
  43195. import { Scene } from "babylonjs/scene";
  43196. /**
  43197. * Class used to work with sound analyzer using fast fourier transform (FFT)
  43198. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43199. */
  43200. export class Analyser {
  43201. /**
  43202. * Gets or sets the smoothing
  43203. * @ignorenaming
  43204. */
  43205. SMOOTHING: number;
  43206. /**
  43207. * Gets or sets the FFT table size
  43208. * @ignorenaming
  43209. */
  43210. FFT_SIZE: number;
  43211. /**
  43212. * Gets or sets the bar graph amplitude
  43213. * @ignorenaming
  43214. */
  43215. BARGRAPHAMPLITUDE: number;
  43216. /**
  43217. * Gets or sets the position of the debug canvas
  43218. * @ignorenaming
  43219. */
  43220. DEBUGCANVASPOS: {
  43221. x: number;
  43222. y: number;
  43223. };
  43224. /**
  43225. * Gets or sets the debug canvas size
  43226. * @ignorenaming
  43227. */
  43228. DEBUGCANVASSIZE: {
  43229. width: number;
  43230. height: number;
  43231. };
  43232. private _byteFreqs;
  43233. private _byteTime;
  43234. private _floatFreqs;
  43235. private _webAudioAnalyser;
  43236. private _debugCanvas;
  43237. private _debugCanvasContext;
  43238. private _scene;
  43239. private _registerFunc;
  43240. private _audioEngine;
  43241. /**
  43242. * Creates a new analyser
  43243. * @param scene defines hosting scene
  43244. */
  43245. constructor(scene: Scene);
  43246. /**
  43247. * Get the number of data values you will have to play with for the visualization
  43248. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  43249. * @returns a number
  43250. */
  43251. getFrequencyBinCount(): number;
  43252. /**
  43253. * Gets the current frequency data as a byte array
  43254. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43255. * @returns a Uint8Array
  43256. */
  43257. getByteFrequencyData(): Uint8Array;
  43258. /**
  43259. * Gets the current waveform as a byte array
  43260. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  43261. * @returns a Uint8Array
  43262. */
  43263. getByteTimeDomainData(): Uint8Array;
  43264. /**
  43265. * Gets the current frequency data as a float array
  43266. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43267. * @returns a Float32Array
  43268. */
  43269. getFloatFrequencyData(): Float32Array;
  43270. /**
  43271. * Renders the debug canvas
  43272. */
  43273. drawDebugCanvas(): void;
  43274. /**
  43275. * Stops rendering the debug canvas and removes it
  43276. */
  43277. stopDebugCanvas(): void;
  43278. /**
  43279. * Connects two audio nodes
  43280. * @param inputAudioNode defines first node to connect
  43281. * @param outputAudioNode defines second node to connect
  43282. */
  43283. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  43284. /**
  43285. * Releases all associated resources
  43286. */
  43287. dispose(): void;
  43288. }
  43289. }
  43290. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  43291. import { Observable } from "babylonjs/Misc/observable";
  43292. import { IDisposable } from "babylonjs/scene";
  43293. import { Nullable } from "babylonjs/types";
  43294. import { Analyser } from "babylonjs/Audio/analyser";
  43295. /**
  43296. * This represents an audio engine and it is responsible
  43297. * to play, synchronize and analyse sounds throughout the application.
  43298. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43299. */
  43300. export interface IAudioEngine extends IDisposable {
  43301. /**
  43302. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  43303. */
  43304. readonly canUseWebAudio: boolean;
  43305. /**
  43306. * Gets the current AudioContext if available.
  43307. */
  43308. readonly audioContext: Nullable<AudioContext>;
  43309. /**
  43310. * The master gain node defines the global audio volume of your audio engine.
  43311. */
  43312. readonly masterGain: GainNode;
  43313. /**
  43314. * Gets whether or not mp3 are supported by your browser.
  43315. */
  43316. readonly isMP3supported: boolean;
  43317. /**
  43318. * Gets whether or not ogg are supported by your browser.
  43319. */
  43320. readonly isOGGsupported: boolean;
  43321. /**
  43322. * Defines if Babylon should emit a warning if WebAudio is not supported.
  43323. * @ignoreNaming
  43324. */
  43325. WarnedWebAudioUnsupported: boolean;
  43326. /**
  43327. * Defines if the audio engine relies on a custom unlocked button.
  43328. * In this case, the embedded button will not be displayed.
  43329. */
  43330. useCustomUnlockedButton: boolean;
  43331. /**
  43332. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  43333. */
  43334. readonly unlocked: boolean;
  43335. /**
  43336. * Event raised when audio has been unlocked on the browser.
  43337. */
  43338. onAudioUnlockedObservable: Observable<IAudioEngine>;
  43339. /**
  43340. * Event raised when audio has been locked on the browser.
  43341. */
  43342. onAudioLockedObservable: Observable<IAudioEngine>;
  43343. /**
  43344. * Flags the audio engine in Locked state.
  43345. * This happens due to new browser policies preventing audio to autoplay.
  43346. */
  43347. lock(): void;
  43348. /**
  43349. * Unlocks the audio engine once a user action has been done on the dom.
  43350. * This is helpful to resume play once browser policies have been satisfied.
  43351. */
  43352. unlock(): void;
  43353. /**
  43354. * Gets the global volume sets on the master gain.
  43355. * @returns the global volume if set or -1 otherwise
  43356. */
  43357. getGlobalVolume(): number;
  43358. /**
  43359. * Sets the global volume of your experience (sets on the master gain).
  43360. * @param newVolume Defines the new global volume of the application
  43361. */
  43362. setGlobalVolume(newVolume: number): void;
  43363. /**
  43364. * Connect the audio engine to an audio analyser allowing some amazing
  43365. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43366. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43367. * @param analyser The analyser to connect to the engine
  43368. */
  43369. connectToAnalyser(analyser: Analyser): void;
  43370. }
  43371. }
  43372. declare module "babylonjs/Engines/engine" {
  43373. import { Observable } from "babylonjs/Misc/observable";
  43374. import { Nullable } from "babylonjs/types";
  43375. import { Scene } from "babylonjs/scene";
  43376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43377. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43378. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  43379. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43380. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43381. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  43382. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  43383. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  43384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43385. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  43386. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43387. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43388. import "babylonjs/Engines/Extensions/engine.alpha";
  43389. import "babylonjs/Engines/Extensions/engine.readTexture";
  43390. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  43391. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  43392. import { Material } from "babylonjs/Materials/material";
  43393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43394. /**
  43395. * Defines the interface used by display changed events
  43396. */
  43397. export interface IDisplayChangedEventArgs {
  43398. /** Gets the vrDisplay object (if any) */
  43399. vrDisplay: Nullable<any>;
  43400. /** Gets a boolean indicating if webVR is supported */
  43401. vrSupported: boolean;
  43402. }
  43403. /**
  43404. * Defines the interface used by objects containing a viewport (like a camera)
  43405. */
  43406. interface IViewportOwnerLike {
  43407. /**
  43408. * Gets or sets the viewport
  43409. */
  43410. viewport: IViewportLike;
  43411. }
  43412. /**
  43413. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  43414. */
  43415. export class Engine extends ThinEngine {
  43416. /** Defines that alpha blending is disabled */
  43417. static readonly ALPHA_DISABLE: number;
  43418. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  43419. static readonly ALPHA_ADD: number;
  43420. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  43421. static readonly ALPHA_COMBINE: number;
  43422. /** Defines that alpha blending to DEST - SRC * DEST */
  43423. static readonly ALPHA_SUBTRACT: number;
  43424. /** Defines that alpha blending to SRC * DEST */
  43425. static readonly ALPHA_MULTIPLY: number;
  43426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  43427. static readonly ALPHA_MAXIMIZED: number;
  43428. /** Defines that alpha blending to SRC + DEST */
  43429. static readonly ALPHA_ONEONE: number;
  43430. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  43431. static readonly ALPHA_PREMULTIPLIED: number;
  43432. /**
  43433. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  43434. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  43435. */
  43436. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  43437. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  43438. static readonly ALPHA_INTERPOLATE: number;
  43439. /**
  43440. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  43441. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  43442. */
  43443. static readonly ALPHA_SCREENMODE: number;
  43444. /** Defines that the ressource is not delayed*/
  43445. static readonly DELAYLOADSTATE_NONE: number;
  43446. /** Defines that the ressource was successfully delay loaded */
  43447. static readonly DELAYLOADSTATE_LOADED: number;
  43448. /** Defines that the ressource is currently delay loading */
  43449. static readonly DELAYLOADSTATE_LOADING: number;
  43450. /** Defines that the ressource is delayed and has not started loading */
  43451. static readonly DELAYLOADSTATE_NOTLOADED: number;
  43452. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  43453. static readonly NEVER: number;
  43454. /** 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 */
  43455. static readonly ALWAYS: number;
  43456. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  43457. static readonly LESS: number;
  43458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  43459. static readonly EQUAL: number;
  43460. /** 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 */
  43461. static readonly LEQUAL: number;
  43462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  43463. static readonly GREATER: number;
  43464. /** 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 */
  43465. static readonly GEQUAL: number;
  43466. /** 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 */
  43467. static readonly NOTEQUAL: number;
  43468. /** Passed to stencilOperation to specify that stencil value must be kept */
  43469. static readonly KEEP: number;
  43470. /** Passed to stencilOperation to specify that stencil value must be replaced */
  43471. static readonly REPLACE: number;
  43472. /** Passed to stencilOperation to specify that stencil value must be incremented */
  43473. static readonly INCR: number;
  43474. /** Passed to stencilOperation to specify that stencil value must be decremented */
  43475. static readonly DECR: number;
  43476. /** Passed to stencilOperation to specify that stencil value must be inverted */
  43477. static readonly INVERT: number;
  43478. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  43479. static readonly INCR_WRAP: number;
  43480. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  43481. static readonly DECR_WRAP: number;
  43482. /** Texture is not repeating outside of 0..1 UVs */
  43483. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  43484. /** Texture is repeating outside of 0..1 UVs */
  43485. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  43486. /** Texture is repeating and mirrored */
  43487. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  43488. /** ALPHA */
  43489. static readonly TEXTUREFORMAT_ALPHA: number;
  43490. /** LUMINANCE */
  43491. static readonly TEXTUREFORMAT_LUMINANCE: number;
  43492. /** LUMINANCE_ALPHA */
  43493. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  43494. /** RGB */
  43495. static readonly TEXTUREFORMAT_RGB: number;
  43496. /** RGBA */
  43497. static readonly TEXTUREFORMAT_RGBA: number;
  43498. /** RED */
  43499. static readonly TEXTUREFORMAT_RED: number;
  43500. /** RED (2nd reference) */
  43501. static readonly TEXTUREFORMAT_R: number;
  43502. /** RG */
  43503. static readonly TEXTUREFORMAT_RG: number;
  43504. /** RED_INTEGER */
  43505. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  43506. /** RED_INTEGER (2nd reference) */
  43507. static readonly TEXTUREFORMAT_R_INTEGER: number;
  43508. /** RG_INTEGER */
  43509. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  43510. /** RGB_INTEGER */
  43511. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  43512. /** RGBA_INTEGER */
  43513. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  43514. /** UNSIGNED_BYTE */
  43515. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  43516. /** UNSIGNED_BYTE (2nd reference) */
  43517. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  43518. /** FLOAT */
  43519. static readonly TEXTURETYPE_FLOAT: number;
  43520. /** HALF_FLOAT */
  43521. static readonly TEXTURETYPE_HALF_FLOAT: number;
  43522. /** BYTE */
  43523. static readonly TEXTURETYPE_BYTE: number;
  43524. /** SHORT */
  43525. static readonly TEXTURETYPE_SHORT: number;
  43526. /** UNSIGNED_SHORT */
  43527. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  43528. /** INT */
  43529. static readonly TEXTURETYPE_INT: number;
  43530. /** UNSIGNED_INT */
  43531. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  43532. /** UNSIGNED_SHORT_4_4_4_4 */
  43533. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  43534. /** UNSIGNED_SHORT_5_5_5_1 */
  43535. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  43536. /** UNSIGNED_SHORT_5_6_5 */
  43537. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  43538. /** UNSIGNED_INT_2_10_10_10_REV */
  43539. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  43540. /** UNSIGNED_INT_24_8 */
  43541. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  43542. /** UNSIGNED_INT_10F_11F_11F_REV */
  43543. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  43544. /** UNSIGNED_INT_5_9_9_9_REV */
  43545. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  43546. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  43547. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  43548. /** nearest is mag = nearest and min = nearest and mip = none */
  43549. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  43550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43551. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  43552. /** Trilinear is mag = linear and min = linear and mip = linear */
  43553. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  43554. /** nearest is mag = nearest and min = nearest and mip = linear */
  43555. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  43556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43557. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  43558. /** Trilinear is mag = linear and min = linear and mip = linear */
  43559. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  43560. /** mag = nearest and min = nearest and mip = nearest */
  43561. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  43562. /** mag = nearest and min = linear and mip = nearest */
  43563. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  43564. /** mag = nearest and min = linear and mip = linear */
  43565. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  43566. /** mag = nearest and min = linear and mip = none */
  43567. static readonly TEXTURE_NEAREST_LINEAR: number;
  43568. /** mag = nearest and min = nearest and mip = none */
  43569. static readonly TEXTURE_NEAREST_NEAREST: number;
  43570. /** mag = linear and min = nearest and mip = nearest */
  43571. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  43572. /** mag = linear and min = nearest and mip = linear */
  43573. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  43574. /** mag = linear and min = linear and mip = none */
  43575. static readonly TEXTURE_LINEAR_LINEAR: number;
  43576. /** mag = linear and min = nearest and mip = none */
  43577. static readonly TEXTURE_LINEAR_NEAREST: number;
  43578. /** Explicit coordinates mode */
  43579. static readonly TEXTURE_EXPLICIT_MODE: number;
  43580. /** Spherical coordinates mode */
  43581. static readonly TEXTURE_SPHERICAL_MODE: number;
  43582. /** Planar coordinates mode */
  43583. static readonly TEXTURE_PLANAR_MODE: number;
  43584. /** Cubic coordinates mode */
  43585. static readonly TEXTURE_CUBIC_MODE: number;
  43586. /** Projection coordinates mode */
  43587. static readonly TEXTURE_PROJECTION_MODE: number;
  43588. /** Skybox coordinates mode */
  43589. static readonly TEXTURE_SKYBOX_MODE: number;
  43590. /** Inverse Cubic coordinates mode */
  43591. static readonly TEXTURE_INVCUBIC_MODE: number;
  43592. /** Equirectangular coordinates mode */
  43593. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  43594. /** Equirectangular Fixed coordinates mode */
  43595. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  43596. /** Equirectangular Fixed Mirrored coordinates mode */
  43597. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  43598. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  43599. static readonly SCALEMODE_FLOOR: number;
  43600. /** Defines that texture rescaling will look for the nearest power of 2 size */
  43601. static readonly SCALEMODE_NEAREST: number;
  43602. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  43603. static readonly SCALEMODE_CEILING: number;
  43604. /**
  43605. * Returns the current npm package of the sdk
  43606. */
  43607. static get NpmPackage(): string;
  43608. /**
  43609. * Returns the current version of the framework
  43610. */
  43611. static get Version(): string;
  43612. /** Gets the list of created engines */
  43613. static get Instances(): Engine[];
  43614. /**
  43615. * Gets the latest created engine
  43616. */
  43617. static get LastCreatedEngine(): Nullable<Engine>;
  43618. /**
  43619. * Gets the latest created scene
  43620. */
  43621. static get LastCreatedScene(): Nullable<Scene>;
  43622. /**
  43623. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  43624. * @param flag defines which part of the materials must be marked as dirty
  43625. * @param predicate defines a predicate used to filter which materials should be affected
  43626. */
  43627. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  43628. /**
  43629. * Method called to create the default loading screen.
  43630. * This can be overriden in your own app.
  43631. * @param canvas The rendering canvas element
  43632. * @returns The loading screen
  43633. */
  43634. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  43635. /**
  43636. * Method called to create the default rescale post process on each engine.
  43637. */
  43638. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  43639. /**
  43640. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  43641. **/
  43642. enableOfflineSupport: boolean;
  43643. /**
  43644. * 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)
  43645. **/
  43646. disableManifestCheck: boolean;
  43647. /**
  43648. * Gets the list of created scenes
  43649. */
  43650. scenes: Scene[];
  43651. /**
  43652. * Event raised when a new scene is created
  43653. */
  43654. onNewSceneAddedObservable: Observable<Scene>;
  43655. /**
  43656. * Gets the list of created postprocesses
  43657. */
  43658. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43659. /**
  43660. * Gets a boolean indicating if the pointer is currently locked
  43661. */
  43662. isPointerLock: boolean;
  43663. /**
  43664. * Observable event triggered each time the rendering canvas is resized
  43665. */
  43666. onResizeObservable: Observable<Engine>;
  43667. /**
  43668. * Observable event triggered each time the canvas loses focus
  43669. */
  43670. onCanvasBlurObservable: Observable<Engine>;
  43671. /**
  43672. * Observable event triggered each time the canvas gains focus
  43673. */
  43674. onCanvasFocusObservable: Observable<Engine>;
  43675. /**
  43676. * Observable event triggered each time the canvas receives pointerout event
  43677. */
  43678. onCanvasPointerOutObservable: Observable<PointerEvent>;
  43679. /**
  43680. * Observable raised when the engine begins a new frame
  43681. */
  43682. onBeginFrameObservable: Observable<Engine>;
  43683. /**
  43684. * If set, will be used to request the next animation frame for the render loop
  43685. */
  43686. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  43687. /**
  43688. * Observable raised when the engine ends the current frame
  43689. */
  43690. onEndFrameObservable: Observable<Engine>;
  43691. /**
  43692. * Observable raised when the engine is about to compile a shader
  43693. */
  43694. onBeforeShaderCompilationObservable: Observable<Engine>;
  43695. /**
  43696. * Observable raised when the engine has jsut compiled a shader
  43697. */
  43698. onAfterShaderCompilationObservable: Observable<Engine>;
  43699. /**
  43700. * Gets the audio engine
  43701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43702. * @ignorenaming
  43703. */
  43704. static audioEngine: IAudioEngine;
  43705. /**
  43706. * Default AudioEngine factory responsible of creating the Audio Engine.
  43707. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  43708. */
  43709. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  43710. /**
  43711. * Default offline support factory responsible of creating a tool used to store data locally.
  43712. * By default, this will create a Database object if the workload has been embedded.
  43713. */
  43714. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  43715. private _loadingScreen;
  43716. private _pointerLockRequested;
  43717. private _rescalePostProcess;
  43718. protected _deterministicLockstep: boolean;
  43719. protected _lockstepMaxSteps: number;
  43720. protected _timeStep: number;
  43721. protected get _supportsHardwareTextureRescaling(): boolean;
  43722. private _fps;
  43723. private _deltaTime;
  43724. /** @hidden */
  43725. _drawCalls: PerfCounter;
  43726. /** 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 */
  43727. canvasTabIndex: number;
  43728. /**
  43729. * Turn this value on if you want to pause FPS computation when in background
  43730. */
  43731. disablePerformanceMonitorInBackground: boolean;
  43732. private _performanceMonitor;
  43733. /**
  43734. * Gets the performance monitor attached to this engine
  43735. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43736. */
  43737. get performanceMonitor(): PerformanceMonitor;
  43738. private _onFocus;
  43739. private _onBlur;
  43740. private _onCanvasPointerOut;
  43741. private _onCanvasBlur;
  43742. private _onCanvasFocus;
  43743. private _onFullscreenChange;
  43744. private _onPointerLockChange;
  43745. /**
  43746. * Gets the HTML element used to attach event listeners
  43747. * @returns a HTML element
  43748. */
  43749. getInputElement(): Nullable<HTMLElement>;
  43750. /**
  43751. * Creates a new engine
  43752. * @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
  43753. * @param antialias defines enable antialiasing (default: false)
  43754. * @param options defines further options to be sent to the getContext() function
  43755. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  43756. */
  43757. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  43758. /**
  43759. * Shared initialization across engines types.
  43760. * @param canvas The canvas associated with this instance of the engine.
  43761. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  43762. * @param audioEngine Defines if an audio engine should be created by default
  43763. */
  43764. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  43765. /**
  43766. * Gets current aspect ratio
  43767. * @param viewportOwner defines the camera to use to get the aspect ratio
  43768. * @param useScreen defines if screen size must be used (or the current render target if any)
  43769. * @returns a number defining the aspect ratio
  43770. */
  43771. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  43772. /**
  43773. * Gets current screen aspect ratio
  43774. * @returns a number defining the aspect ratio
  43775. */
  43776. getScreenAspectRatio(): number;
  43777. /**
  43778. * Gets the client rect of the HTML canvas attached with the current webGL context
  43779. * @returns a client rectanglee
  43780. */
  43781. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  43782. /**
  43783. * Gets the client rect of the HTML element used for events
  43784. * @returns a client rectanglee
  43785. */
  43786. getInputElementClientRect(): Nullable<ClientRect>;
  43787. /**
  43788. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43789. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43790. * @returns true if engine is in deterministic lock step mode
  43791. */
  43792. isDeterministicLockStep(): boolean;
  43793. /**
  43794. * Gets the max steps when engine is running in deterministic lock step
  43795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43796. * @returns the max steps
  43797. */
  43798. getLockstepMaxSteps(): number;
  43799. /**
  43800. * Returns the time in ms between steps when using deterministic lock step.
  43801. * @returns time step in (ms)
  43802. */
  43803. getTimeStep(): number;
  43804. /**
  43805. * Force the mipmap generation for the given render target texture
  43806. * @param texture defines the render target texture to use
  43807. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  43808. */
  43809. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  43810. /** States */
  43811. /**
  43812. * Set various states to the webGL context
  43813. * @param culling defines backface culling state
  43814. * @param zOffset defines the value to apply to zOffset (0 by default)
  43815. * @param force defines if states must be applied even if cache is up to date
  43816. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43817. */
  43818. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43819. /**
  43820. * Set the z offset to apply to current rendering
  43821. * @param value defines the offset to apply
  43822. */
  43823. setZOffset(value: number): void;
  43824. /**
  43825. * Gets the current value of the zOffset
  43826. * @returns the current zOffset state
  43827. */
  43828. getZOffset(): number;
  43829. /**
  43830. * Gets a boolean indicating if depth testing is enabled
  43831. * @returns the current state
  43832. */
  43833. getDepthBuffer(): boolean;
  43834. /**
  43835. * Enable or disable depth buffering
  43836. * @param enable defines the state to set
  43837. */
  43838. setDepthBuffer(enable: boolean): void;
  43839. /**
  43840. * Gets a boolean indicating if depth writing is enabled
  43841. * @returns the current depth writing state
  43842. */
  43843. getDepthWrite(): boolean;
  43844. /**
  43845. * Enable or disable depth writing
  43846. * @param enable defines the state to set
  43847. */
  43848. setDepthWrite(enable: boolean): void;
  43849. /**
  43850. * Gets a boolean indicating if stencil buffer is enabled
  43851. * @returns the current stencil buffer state
  43852. */
  43853. getStencilBuffer(): boolean;
  43854. /**
  43855. * Enable or disable the stencil buffer
  43856. * @param enable defines if the stencil buffer must be enabled or disabled
  43857. */
  43858. setStencilBuffer(enable: boolean): void;
  43859. /**
  43860. * Gets the current stencil mask
  43861. * @returns a number defining the new stencil mask to use
  43862. */
  43863. getStencilMask(): number;
  43864. /**
  43865. * Sets the current stencil mask
  43866. * @param mask defines the new stencil mask to use
  43867. */
  43868. setStencilMask(mask: number): void;
  43869. /**
  43870. * Gets the current stencil function
  43871. * @returns a number defining the stencil function to use
  43872. */
  43873. getStencilFunction(): number;
  43874. /**
  43875. * Gets the current stencil reference value
  43876. * @returns a number defining the stencil reference value to use
  43877. */
  43878. getStencilFunctionReference(): number;
  43879. /**
  43880. * Gets the current stencil mask
  43881. * @returns a number defining the stencil mask to use
  43882. */
  43883. getStencilFunctionMask(): number;
  43884. /**
  43885. * Sets the current stencil function
  43886. * @param stencilFunc defines the new stencil function to use
  43887. */
  43888. setStencilFunction(stencilFunc: number): void;
  43889. /**
  43890. * Sets the current stencil reference
  43891. * @param reference defines the new stencil reference to use
  43892. */
  43893. setStencilFunctionReference(reference: number): void;
  43894. /**
  43895. * Sets the current stencil mask
  43896. * @param mask defines the new stencil mask to use
  43897. */
  43898. setStencilFunctionMask(mask: number): void;
  43899. /**
  43900. * Gets the current stencil operation when stencil fails
  43901. * @returns a number defining stencil operation to use when stencil fails
  43902. */
  43903. getStencilOperationFail(): number;
  43904. /**
  43905. * Gets the current stencil operation when depth fails
  43906. * @returns a number defining stencil operation to use when depth fails
  43907. */
  43908. getStencilOperationDepthFail(): number;
  43909. /**
  43910. * Gets the current stencil operation when stencil passes
  43911. * @returns a number defining stencil operation to use when stencil passes
  43912. */
  43913. getStencilOperationPass(): number;
  43914. /**
  43915. * Sets the stencil operation to use when stencil fails
  43916. * @param operation defines the stencil operation to use when stencil fails
  43917. */
  43918. setStencilOperationFail(operation: number): void;
  43919. /**
  43920. * Sets the stencil operation to use when depth fails
  43921. * @param operation defines the stencil operation to use when depth fails
  43922. */
  43923. setStencilOperationDepthFail(operation: number): void;
  43924. /**
  43925. * Sets the stencil operation to use when stencil passes
  43926. * @param operation defines the stencil operation to use when stencil passes
  43927. */
  43928. setStencilOperationPass(operation: number): void;
  43929. /**
  43930. * Sets a boolean indicating if the dithering state is enabled or disabled
  43931. * @param value defines the dithering state
  43932. */
  43933. setDitheringState(value: boolean): void;
  43934. /**
  43935. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43936. * @param value defines the rasterizer state
  43937. */
  43938. setRasterizerState(value: boolean): void;
  43939. /**
  43940. * Gets the current depth function
  43941. * @returns a number defining the depth function
  43942. */
  43943. getDepthFunction(): Nullable<number>;
  43944. /**
  43945. * Sets the current depth function
  43946. * @param depthFunc defines the function to use
  43947. */
  43948. setDepthFunction(depthFunc: number): void;
  43949. /**
  43950. * Sets the current depth function to GREATER
  43951. */
  43952. setDepthFunctionToGreater(): void;
  43953. /**
  43954. * Sets the current depth function to GEQUAL
  43955. */
  43956. setDepthFunctionToGreaterOrEqual(): void;
  43957. /**
  43958. * Sets the current depth function to LESS
  43959. */
  43960. setDepthFunctionToLess(): void;
  43961. /**
  43962. * Sets the current depth function to LEQUAL
  43963. */
  43964. setDepthFunctionToLessOrEqual(): void;
  43965. private _cachedStencilBuffer;
  43966. private _cachedStencilFunction;
  43967. private _cachedStencilMask;
  43968. private _cachedStencilOperationPass;
  43969. private _cachedStencilOperationFail;
  43970. private _cachedStencilOperationDepthFail;
  43971. private _cachedStencilReference;
  43972. /**
  43973. * Caches the the state of the stencil buffer
  43974. */
  43975. cacheStencilState(): void;
  43976. /**
  43977. * Restores the state of the stencil buffer
  43978. */
  43979. restoreStencilState(): void;
  43980. /**
  43981. * Directly set the WebGL Viewport
  43982. * @param x defines the x coordinate of the viewport (in screen space)
  43983. * @param y defines the y coordinate of the viewport (in screen space)
  43984. * @param width defines the width of the viewport (in screen space)
  43985. * @param height defines the height of the viewport (in screen space)
  43986. * @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
  43987. */
  43988. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43989. /**
  43990. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43991. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43992. * @param y defines the y-coordinate of the corner of the clear rectangle
  43993. * @param width defines the width of the clear rectangle
  43994. * @param height defines the height of the clear rectangle
  43995. * @param clearColor defines the clear color
  43996. */
  43997. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43998. /**
  43999. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  44000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  44001. * @param y defines the y-coordinate of the corner of the clear rectangle
  44002. * @param width defines the width of the clear rectangle
  44003. * @param height defines the height of the clear rectangle
  44004. */
  44005. enableScissor(x: number, y: number, width: number, height: number): void;
  44006. /**
  44007. * Disable previously set scissor test rectangle
  44008. */
  44009. disableScissor(): void;
  44010. protected _reportDrawCall(): void;
  44011. /**
  44012. * Initializes a webVR display and starts listening to display change events
  44013. * The onVRDisplayChangedObservable will be notified upon these changes
  44014. * @returns The onVRDisplayChangedObservable
  44015. */
  44016. initWebVR(): Observable<IDisplayChangedEventArgs>;
  44017. /** @hidden */
  44018. _prepareVRComponent(): void;
  44019. /** @hidden */
  44020. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  44021. /** @hidden */
  44022. _submitVRFrame(): void;
  44023. /**
  44024. * Call this function to leave webVR mode
  44025. * Will do nothing if webVR is not supported or if there is no webVR device
  44026. * @see https://doc.babylonjs.com/how_to/webvr_camera
  44027. */
  44028. disableVR(): void;
  44029. /**
  44030. * Gets a boolean indicating that the system is in VR mode and is presenting
  44031. * @returns true if VR mode is engaged
  44032. */
  44033. isVRPresenting(): boolean;
  44034. /** @hidden */
  44035. _requestVRFrame(): void;
  44036. /** @hidden */
  44037. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44038. /**
  44039. * Gets the source code of the vertex shader associated with a specific webGL program
  44040. * @param program defines the program to use
  44041. * @returns a string containing the source code of the vertex shader associated with the program
  44042. */
  44043. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  44044. /**
  44045. * Gets the source code of the fragment shader associated with a specific webGL program
  44046. * @param program defines the program to use
  44047. * @returns a string containing the source code of the fragment shader associated with the program
  44048. */
  44049. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  44050. /**
  44051. * Sets a depth stencil texture from a render target to the according uniform.
  44052. * @param channel The texture channel
  44053. * @param uniform The uniform to set
  44054. * @param texture The render target texture containing the depth stencil texture to apply
  44055. * @param name The texture name
  44056. */
  44057. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  44058. /**
  44059. * Sets a texture to the webGL context from a postprocess
  44060. * @param channel defines the channel to use
  44061. * @param postProcess defines the source postprocess
  44062. * @param name name of the channel
  44063. */
  44064. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44065. /**
  44066. * Binds the output of the passed in post process to the texture channel specified
  44067. * @param channel The channel the texture should be bound to
  44068. * @param postProcess The post process which's output should be bound
  44069. * @param name name of the channel
  44070. */
  44071. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44072. protected _rebuildBuffers(): void;
  44073. /** @hidden */
  44074. _renderFrame(): void;
  44075. _renderLoop(): void;
  44076. /** @hidden */
  44077. _renderViews(): boolean;
  44078. /**
  44079. * Toggle full screen mode
  44080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44081. */
  44082. switchFullscreen(requestPointerLock: boolean): void;
  44083. /**
  44084. * Enters full screen mode
  44085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44086. */
  44087. enterFullscreen(requestPointerLock: boolean): void;
  44088. /**
  44089. * Exits full screen mode
  44090. */
  44091. exitFullscreen(): void;
  44092. /**
  44093. * Enters Pointerlock mode
  44094. */
  44095. enterPointerlock(): void;
  44096. /**
  44097. * Exits Pointerlock mode
  44098. */
  44099. exitPointerlock(): void;
  44100. /**
  44101. * Begin a new frame
  44102. */
  44103. beginFrame(): void;
  44104. /**
  44105. * End the current frame
  44106. */
  44107. endFrame(): void;
  44108. /**
  44109. * Resize the view according to the canvas' size
  44110. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44111. */
  44112. resize(forceSetSize?: boolean): void;
  44113. /**
  44114. * Force a specific size of the canvas
  44115. * @param width defines the new canvas' width
  44116. * @param height defines the new canvas' height
  44117. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44118. * @returns true if the size was changed
  44119. */
  44120. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44121. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44123. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44124. _releaseTexture(texture: InternalTexture): void;
  44125. /**
  44126. * @hidden
  44127. * Rescales a texture
  44128. * @param source input texutre
  44129. * @param destination destination texture
  44130. * @param scene scene to use to render the resize
  44131. * @param internalFormat format to use when resizing
  44132. * @param onComplete callback to be called when resize has completed
  44133. */
  44134. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  44135. /**
  44136. * Gets the current framerate
  44137. * @returns a number representing the framerate
  44138. */
  44139. getFps(): number;
  44140. /**
  44141. * Gets the time spent between current and previous frame
  44142. * @returns a number representing the delta time in ms
  44143. */
  44144. getDeltaTime(): number;
  44145. private _measureFps;
  44146. /** @hidden */
  44147. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  44148. /**
  44149. * Updates the sample count of a render target texture
  44150. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44151. * @param texture defines the texture to update
  44152. * @param samples defines the sample count to set
  44153. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44154. */
  44155. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  44156. /**
  44157. * Updates a depth texture Comparison Mode and Function.
  44158. * If the comparison Function is equal to 0, the mode will be set to none.
  44159. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  44160. * @param texture The texture to set the comparison function for
  44161. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  44162. */
  44163. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  44164. /**
  44165. * Creates a webGL buffer to use with instanciation
  44166. * @param capacity defines the size of the buffer
  44167. * @returns the webGL buffer
  44168. */
  44169. createInstancesBuffer(capacity: number): DataBuffer;
  44170. /**
  44171. * Delete a webGL buffer used with instanciation
  44172. * @param buffer defines the webGL buffer to delete
  44173. */
  44174. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  44175. private _clientWaitAsync;
  44176. /** @hidden */
  44177. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  44178. dispose(): void;
  44179. private _disableTouchAction;
  44180. /**
  44181. * Display the loading screen
  44182. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44183. */
  44184. displayLoadingUI(): void;
  44185. /**
  44186. * Hide the loading screen
  44187. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44188. */
  44189. hideLoadingUI(): void;
  44190. /**
  44191. * Gets the current loading screen object
  44192. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44193. */
  44194. get loadingScreen(): ILoadingScreen;
  44195. /**
  44196. * Sets the current loading screen object
  44197. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44198. */
  44199. set loadingScreen(loadingScreen: ILoadingScreen);
  44200. /**
  44201. * Sets the current loading screen text
  44202. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44203. */
  44204. set loadingUIText(text: string);
  44205. /**
  44206. * Sets the current loading screen background color
  44207. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44208. */
  44209. set loadingUIBackgroundColor(color: string);
  44210. /** Pointerlock and fullscreen */
  44211. /**
  44212. * Ask the browser to promote the current element to pointerlock mode
  44213. * @param element defines the DOM element to promote
  44214. */
  44215. static _RequestPointerlock(element: HTMLElement): void;
  44216. /**
  44217. * Asks the browser to exit pointerlock mode
  44218. */
  44219. static _ExitPointerlock(): void;
  44220. /**
  44221. * Ask the browser to promote the current element to fullscreen rendering mode
  44222. * @param element defines the DOM element to promote
  44223. */
  44224. static _RequestFullscreen(element: HTMLElement): void;
  44225. /**
  44226. * Asks the browser to exit fullscreen mode
  44227. */
  44228. static _ExitFullscreen(): void;
  44229. }
  44230. }
  44231. declare module "babylonjs/Engines/engineStore" {
  44232. import { Nullable } from "babylonjs/types";
  44233. import { Engine } from "babylonjs/Engines/engine";
  44234. import { Scene } from "babylonjs/scene";
  44235. /**
  44236. * The engine store class is responsible to hold all the instances of Engine and Scene created
  44237. * during the life time of the application.
  44238. */
  44239. export class EngineStore {
  44240. /** Gets the list of created engines */
  44241. static Instances: import("babylonjs/Engines/engine").Engine[];
  44242. /** @hidden */
  44243. static _LastCreatedScene: Nullable<Scene>;
  44244. /**
  44245. * Gets the latest created engine
  44246. */
  44247. static get LastCreatedEngine(): Nullable<Engine>;
  44248. /**
  44249. * Gets the latest created scene
  44250. */
  44251. static get LastCreatedScene(): Nullable<Scene>;
  44252. /**
  44253. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44254. * @ignorenaming
  44255. */
  44256. static UseFallbackTexture: boolean;
  44257. /**
  44258. * Texture content used if a texture cannot loaded
  44259. * @ignorenaming
  44260. */
  44261. static FallbackTexture: string;
  44262. }
  44263. }
  44264. declare module "babylonjs/Misc/promise" {
  44265. /**
  44266. * Helper class that provides a small promise polyfill
  44267. */
  44268. export class PromisePolyfill {
  44269. /**
  44270. * Static function used to check if the polyfill is required
  44271. * If this is the case then the function will inject the polyfill to window.Promise
  44272. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  44273. */
  44274. static Apply(force?: boolean): void;
  44275. }
  44276. }
  44277. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  44278. /**
  44279. * Interface for screenshot methods with describe argument called `size` as object with options
  44280. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  44281. */
  44282. export interface IScreenshotSize {
  44283. /**
  44284. * number in pixels for canvas height
  44285. */
  44286. height?: number;
  44287. /**
  44288. * multiplier allowing render at a higher or lower resolution
  44289. * If value is defined then height and width will be ignored and taken from camera
  44290. */
  44291. precision?: number;
  44292. /**
  44293. * number in pixels for canvas width
  44294. */
  44295. width?: number;
  44296. }
  44297. }
  44298. declare module "babylonjs/Misc/tools" {
  44299. import { Nullable, float } from "babylonjs/types";
  44300. import { DomManagement } from "babylonjs/Misc/domManagement";
  44301. import { WebRequest } from "babylonjs/Misc/webRequest";
  44302. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44303. import { ReadFileError } from "babylonjs/Misc/fileTools";
  44304. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44305. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  44306. import { Camera } from "babylonjs/Cameras/camera";
  44307. import { Engine } from "babylonjs/Engines/engine";
  44308. interface IColor4Like {
  44309. r: float;
  44310. g: float;
  44311. b: float;
  44312. a: float;
  44313. }
  44314. /**
  44315. * Class containing a set of static utilities functions
  44316. */
  44317. export class Tools {
  44318. /**
  44319. * Gets or sets the base URL to use to load assets
  44320. */
  44321. static get BaseUrl(): string;
  44322. static set BaseUrl(value: string);
  44323. /**
  44324. * Enable/Disable Custom HTTP Request Headers globally.
  44325. * default = false
  44326. * @see CustomRequestHeaders
  44327. */
  44328. static UseCustomRequestHeaders: boolean;
  44329. /**
  44330. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  44331. * i.e. when loading files, where the server/service expects an Authorization header
  44332. */
  44333. static CustomRequestHeaders: {
  44334. [key: string]: string;
  44335. };
  44336. /**
  44337. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  44338. */
  44339. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  44340. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  44341. /**
  44342. * Default behaviour for cors in the application.
  44343. * It can be a string if the expected behavior is identical in the entire app.
  44344. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  44345. */
  44346. static get CorsBehavior(): string | ((url: string | string[]) => string);
  44347. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  44348. /**
  44349. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44350. * @ignorenaming
  44351. */
  44352. static get UseFallbackTexture(): boolean;
  44353. static set UseFallbackTexture(value: boolean);
  44354. /**
  44355. * Use this object to register external classes like custom textures or material
  44356. * to allow the laoders to instantiate them
  44357. */
  44358. static get RegisteredExternalClasses(): {
  44359. [key: string]: Object;
  44360. };
  44361. static set RegisteredExternalClasses(classes: {
  44362. [key: string]: Object;
  44363. });
  44364. /**
  44365. * Texture content used if a texture cannot loaded
  44366. * @ignorenaming
  44367. */
  44368. static get fallbackTexture(): string;
  44369. static set fallbackTexture(value: string);
  44370. /**
  44371. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  44372. * @param u defines the coordinate on X axis
  44373. * @param v defines the coordinate on Y axis
  44374. * @param width defines the width of the source data
  44375. * @param height defines the height of the source data
  44376. * @param pixels defines the source byte array
  44377. * @param color defines the output color
  44378. */
  44379. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  44380. /**
  44381. * Interpolates between a and b via alpha
  44382. * @param a The lower value (returned when alpha = 0)
  44383. * @param b The upper value (returned when alpha = 1)
  44384. * @param alpha The interpolation-factor
  44385. * @return The mixed value
  44386. */
  44387. static Mix(a: number, b: number, alpha: number): number;
  44388. /**
  44389. * Tries to instantiate a new object from a given class name
  44390. * @param className defines the class name to instantiate
  44391. * @returns the new object or null if the system was not able to do the instantiation
  44392. */
  44393. static Instantiate(className: string): any;
  44394. /**
  44395. * Provides a slice function that will work even on IE
  44396. * @param data defines the array to slice
  44397. * @param start defines the start of the data (optional)
  44398. * @param end defines the end of the data (optional)
  44399. * @returns the new sliced array
  44400. */
  44401. static Slice<T>(data: T, start?: number, end?: number): T;
  44402. /**
  44403. * Provides a slice function that will work even on IE
  44404. * The difference between this and Slice is that this will force-convert to array
  44405. * @param data defines the array to slice
  44406. * @param start defines the start of the data (optional)
  44407. * @param end defines the end of the data (optional)
  44408. * @returns the new sliced array
  44409. */
  44410. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  44411. /**
  44412. * Polyfill for setImmediate
  44413. * @param action defines the action to execute after the current execution block
  44414. */
  44415. static SetImmediate(action: () => void): void;
  44416. /**
  44417. * Function indicating if a number is an exponent of 2
  44418. * @param value defines the value to test
  44419. * @returns true if the value is an exponent of 2
  44420. */
  44421. static IsExponentOfTwo(value: number): boolean;
  44422. private static _tmpFloatArray;
  44423. /**
  44424. * Returns the nearest 32-bit single precision float representation of a Number
  44425. * @param value A Number. If the parameter is of a different type, it will get converted
  44426. * to a number or to NaN if it cannot be converted
  44427. * @returns number
  44428. */
  44429. static FloatRound(value: number): number;
  44430. /**
  44431. * Extracts the filename from a path
  44432. * @param path defines the path to use
  44433. * @returns the filename
  44434. */
  44435. static GetFilename(path: string): string;
  44436. /**
  44437. * Extracts the "folder" part of a path (everything before the filename).
  44438. * @param uri The URI to extract the info from
  44439. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  44440. * @returns The "folder" part of the path
  44441. */
  44442. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  44443. /**
  44444. * Extracts text content from a DOM element hierarchy
  44445. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  44446. */
  44447. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  44448. /**
  44449. * Convert an angle in radians to degrees
  44450. * @param angle defines the angle to convert
  44451. * @returns the angle in degrees
  44452. */
  44453. static ToDegrees(angle: number): number;
  44454. /**
  44455. * Convert an angle in degrees to radians
  44456. * @param angle defines the angle to convert
  44457. * @returns the angle in radians
  44458. */
  44459. static ToRadians(angle: number): number;
  44460. /**
  44461. * Returns an array if obj is not an array
  44462. * @param obj defines the object to evaluate as an array
  44463. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  44464. * @returns either obj directly if obj is an array or a new array containing obj
  44465. */
  44466. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  44467. /**
  44468. * Gets the pointer prefix to use
  44469. * @param engine defines the engine we are finding the prefix for
  44470. * @returns "pointer" if touch is enabled. Else returns "mouse"
  44471. */
  44472. static GetPointerPrefix(engine: Engine): string;
  44473. /**
  44474. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  44475. * @param url define the url we are trying
  44476. * @param element define the dom element where to configure the cors policy
  44477. */
  44478. static SetCorsBehavior(url: string | string[], element: {
  44479. crossOrigin: string | null;
  44480. }): void;
  44481. /**
  44482. * Removes unwanted characters from an url
  44483. * @param url defines the url to clean
  44484. * @returns the cleaned url
  44485. */
  44486. static CleanUrl(url: string): string;
  44487. /**
  44488. * Gets or sets a function used to pre-process url before using them to load assets
  44489. */
  44490. static get PreprocessUrl(): (url: string) => string;
  44491. static set PreprocessUrl(processor: (url: string) => string);
  44492. /**
  44493. * Loads an image as an HTMLImageElement.
  44494. * @param input url string, ArrayBuffer, or Blob to load
  44495. * @param onLoad callback called when the image successfully loads
  44496. * @param onError callback called when the image fails to load
  44497. * @param offlineProvider offline provider for caching
  44498. * @param mimeType optional mime type
  44499. * @returns the HTMLImageElement of the loaded image
  44500. */
  44501. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  44502. /**
  44503. * Loads a file from a url
  44504. * @param url url string, ArrayBuffer, or Blob to load
  44505. * @param onSuccess callback called when the file successfully loads
  44506. * @param onProgress callback called while file is loading (if the server supports this mode)
  44507. * @param offlineProvider defines the offline provider for caching
  44508. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44509. * @param onError callback called when the file fails to load
  44510. * @returns a file request object
  44511. */
  44512. 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;
  44513. /**
  44514. * Loads a file from a url
  44515. * @param url the file url to load
  44516. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44517. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  44518. */
  44519. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  44520. /**
  44521. * Load a script (identified by an url). When the url returns, the
  44522. * content of this file is added into a new script element, attached to the DOM (body element)
  44523. * @param scriptUrl defines the url of the script to laod
  44524. * @param onSuccess defines the callback called when the script is loaded
  44525. * @param onError defines the callback to call if an error occurs
  44526. * @param scriptId defines the id of the script element
  44527. */
  44528. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  44529. /**
  44530. * Load an asynchronous script (identified by an url). When the url returns, the
  44531. * content of this file is added into a new script element, attached to the DOM (body element)
  44532. * @param scriptUrl defines the url of the script to laod
  44533. * @param scriptId defines the id of the script element
  44534. * @returns a promise request object
  44535. */
  44536. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  44537. /**
  44538. * Loads a file from a blob
  44539. * @param fileToLoad defines the blob to use
  44540. * @param callback defines the callback to call when data is loaded
  44541. * @param progressCallback defines the callback to call during loading process
  44542. * @returns a file request object
  44543. */
  44544. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  44545. /**
  44546. * Reads a file from a File object
  44547. * @param file defines the file to load
  44548. * @param onSuccess defines the callback to call when data is loaded
  44549. * @param onProgress defines the callback to call during loading process
  44550. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44551. * @param onError defines the callback to call when an error occurs
  44552. * @returns a file request object
  44553. */
  44554. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44555. /**
  44556. * Creates a data url from a given string content
  44557. * @param content defines the content to convert
  44558. * @returns the new data url link
  44559. */
  44560. static FileAsURL(content: string): string;
  44561. /**
  44562. * Format the given number to a specific decimal format
  44563. * @param value defines the number to format
  44564. * @param decimals defines the number of decimals to use
  44565. * @returns the formatted string
  44566. */
  44567. static Format(value: number, decimals?: number): string;
  44568. /**
  44569. * Tries to copy an object by duplicating every property
  44570. * @param source defines the source object
  44571. * @param destination defines the target object
  44572. * @param doNotCopyList defines a list of properties to avoid
  44573. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  44574. */
  44575. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  44576. /**
  44577. * Gets a boolean indicating if the given object has no own property
  44578. * @param obj defines the object to test
  44579. * @returns true if object has no own property
  44580. */
  44581. static IsEmpty(obj: any): boolean;
  44582. /**
  44583. * Function used to register events at window level
  44584. * @param windowElement defines the Window object to use
  44585. * @param events defines the events to register
  44586. */
  44587. static RegisterTopRootEvents(windowElement: Window, events: {
  44588. name: string;
  44589. handler: Nullable<(e: FocusEvent) => any>;
  44590. }[]): void;
  44591. /**
  44592. * Function used to unregister events from window level
  44593. * @param windowElement defines the Window object to use
  44594. * @param events defines the events to unregister
  44595. */
  44596. static UnregisterTopRootEvents(windowElement: Window, events: {
  44597. name: string;
  44598. handler: Nullable<(e: FocusEvent) => any>;
  44599. }[]): void;
  44600. /**
  44601. * @ignore
  44602. */
  44603. static _ScreenshotCanvas: HTMLCanvasElement;
  44604. /**
  44605. * Dumps the current bound framebuffer
  44606. * @param width defines the rendering width
  44607. * @param height defines the rendering height
  44608. * @param engine defines the hosting engine
  44609. * @param successCallback defines the callback triggered once the data are available
  44610. * @param mimeType defines the mime type of the result
  44611. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44612. * @return a void promise
  44613. */
  44614. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  44615. /**
  44616. * Dumps an array buffer
  44617. * @param width defines the rendering width
  44618. * @param height defines the rendering height
  44619. * @param data the data array
  44620. * @param successCallback defines the callback triggered once the data are available
  44621. * @param mimeType defines the mime type of the result
  44622. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44623. * @param invertY true to invert the picture in the Y dimension
  44624. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44625. */
  44626. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  44627. /**
  44628. * Dumps an array buffer
  44629. * @param width defines the rendering width
  44630. * @param height defines the rendering height
  44631. * @param data the data array
  44632. * @param successCallback defines the callback triggered once the data are available
  44633. * @param mimeType defines the mime type of the result
  44634. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44635. * @param invertY true to invert the picture in the Y dimension
  44636. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44637. * @return a promise that resolve to the final data
  44638. */
  44639. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44640. /**
  44641. * Converts the canvas data to blob.
  44642. * This acts as a polyfill for browsers not supporting the to blob function.
  44643. * @param canvas Defines the canvas to extract the data from
  44644. * @param successCallback Defines the callback triggered once the data are available
  44645. * @param mimeType Defines the mime type of the result
  44646. */
  44647. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  44648. /**
  44649. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  44650. * @param successCallback defines the callback triggered once the data are available
  44651. * @param mimeType defines the mime type of the result
  44652. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  44653. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  44654. */
  44655. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  44656. /**
  44657. * Downloads a blob in the browser
  44658. * @param blob defines the blob to download
  44659. * @param fileName defines the name of the downloaded file
  44660. */
  44661. static Download(blob: Blob, fileName: string): void;
  44662. /**
  44663. * Will return the right value of the noPreventDefault variable
  44664. * Needed to keep backwards compatibility to the old API.
  44665. *
  44666. * @param args arguments passed to the attachControl function
  44667. * @returns the correct value for noPreventDefault
  44668. */
  44669. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  44670. /**
  44671. * Captures a screenshot of the current rendering
  44672. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44673. * @param engine defines the rendering engine
  44674. * @param camera defines the source camera
  44675. * @param size This parameter can be set to a single number or to an object with the
  44676. * following (optional) properties: precision, width, height. If a single number is passed,
  44677. * it will be used for both width and height. If an object is passed, the screenshot size
  44678. * will be derived from the parameters. The precision property is a multiplier allowing
  44679. * rendering at a higher or lower resolution
  44680. * @param successCallback defines the callback receives a single parameter which contains the
  44681. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44682. * src parameter of an <img> to display it
  44683. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44684. * Check your browser for supported MIME types
  44685. */
  44686. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  44687. /**
  44688. * Captures a screenshot of the current rendering
  44689. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44690. * @param engine defines the rendering engine
  44691. * @param camera defines the source camera
  44692. * @param size This parameter can be set to a single number or to an object with the
  44693. * following (optional) properties: precision, width, height. If a single number is passed,
  44694. * it will be used for both width and height. If an object is passed, the screenshot size
  44695. * will be derived from the parameters. The precision property is a multiplier allowing
  44696. * rendering at a higher or lower resolution
  44697. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44698. * Check your browser for supported MIME types
  44699. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44700. * to the src parameter of an <img> to display it
  44701. */
  44702. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  44703. /**
  44704. * Generates an image screenshot from the specified camera.
  44705. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44706. * @param engine The engine to use for rendering
  44707. * @param camera The camera to use for rendering
  44708. * @param size This parameter can be set to a single number or to an object with the
  44709. * following (optional) properties: precision, width, height. If a single number is passed,
  44710. * it will be used for both width and height. If an object is passed, the screenshot size
  44711. * will be derived from the parameters. The precision property is a multiplier allowing
  44712. * rendering at a higher or lower resolution
  44713. * @param successCallback The callback receives a single parameter which contains the
  44714. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44715. * src parameter of an <img> to display it
  44716. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44717. * Check your browser for supported MIME types
  44718. * @param samples Texture samples (default: 1)
  44719. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44720. * @param fileName A name for for the downloaded file.
  44721. */
  44722. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  44723. /**
  44724. * Generates an image screenshot from the specified camera.
  44725. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44726. * @param engine The engine to use for rendering
  44727. * @param camera The camera to use for rendering
  44728. * @param size This parameter can be set to a single number or to an object with the
  44729. * following (optional) properties: precision, width, height. If a single number is passed,
  44730. * it will be used for both width and height. If an object is passed, the screenshot size
  44731. * will be derived from the parameters. The precision property is a multiplier allowing
  44732. * rendering at a higher or lower resolution
  44733. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44734. * Check your browser for supported MIME types
  44735. * @param samples Texture samples (default: 1)
  44736. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44737. * @param fileName A name for for the downloaded file.
  44738. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44739. * to the src parameter of an <img> to display it
  44740. */
  44741. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  44742. /**
  44743. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  44744. * Be aware Math.random() could cause collisions, but:
  44745. * "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"
  44746. * @returns a pseudo random id
  44747. */
  44748. static RandomId(): string;
  44749. /**
  44750. * Test if the given uri is a base64 string
  44751. * @param uri The uri to test
  44752. * @return True if the uri is a base64 string or false otherwise
  44753. */
  44754. static IsBase64(uri: string): boolean;
  44755. /**
  44756. * Decode the given base64 uri.
  44757. * @param uri The uri to decode
  44758. * @return The decoded base64 data.
  44759. */
  44760. static DecodeBase64(uri: string): ArrayBuffer;
  44761. /**
  44762. * Gets the absolute url.
  44763. * @param url the input url
  44764. * @return the absolute url
  44765. */
  44766. static GetAbsoluteUrl(url: string): string;
  44767. /**
  44768. * No log
  44769. */
  44770. static readonly NoneLogLevel: number;
  44771. /**
  44772. * Only message logs
  44773. */
  44774. static readonly MessageLogLevel: number;
  44775. /**
  44776. * Only warning logs
  44777. */
  44778. static readonly WarningLogLevel: number;
  44779. /**
  44780. * Only error logs
  44781. */
  44782. static readonly ErrorLogLevel: number;
  44783. /**
  44784. * All logs
  44785. */
  44786. static readonly AllLogLevel: number;
  44787. /**
  44788. * Gets a value indicating the number of loading errors
  44789. * @ignorenaming
  44790. */
  44791. static get errorsCount(): number;
  44792. /**
  44793. * Callback called when a new log is added
  44794. */
  44795. static OnNewCacheEntry: (entry: string) => void;
  44796. /**
  44797. * Log a message to the console
  44798. * @param message defines the message to log
  44799. */
  44800. static Log(message: string): void;
  44801. /**
  44802. * Write a warning message to the console
  44803. * @param message defines the message to log
  44804. */
  44805. static Warn(message: string): void;
  44806. /**
  44807. * Write an error message to the console
  44808. * @param message defines the message to log
  44809. */
  44810. static Error(message: string): void;
  44811. /**
  44812. * Gets current log cache (list of logs)
  44813. */
  44814. static get LogCache(): string;
  44815. /**
  44816. * Clears the log cache
  44817. */
  44818. static ClearLogCache(): void;
  44819. /**
  44820. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  44821. */
  44822. static set LogLevels(level: number);
  44823. /**
  44824. * Checks if the window object exists
  44825. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  44826. */
  44827. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  44828. /**
  44829. * No performance log
  44830. */
  44831. static readonly PerformanceNoneLogLevel: number;
  44832. /**
  44833. * Use user marks to log performance
  44834. */
  44835. static readonly PerformanceUserMarkLogLevel: number;
  44836. /**
  44837. * Log performance to the console
  44838. */
  44839. static readonly PerformanceConsoleLogLevel: number;
  44840. private static _performance;
  44841. /**
  44842. * Sets the current performance log level
  44843. */
  44844. static set PerformanceLogLevel(level: number);
  44845. private static _StartPerformanceCounterDisabled;
  44846. private static _EndPerformanceCounterDisabled;
  44847. private static _StartUserMark;
  44848. private static _EndUserMark;
  44849. private static _StartPerformanceConsole;
  44850. private static _EndPerformanceConsole;
  44851. /**
  44852. * Starts a performance counter
  44853. */
  44854. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44855. /**
  44856. * Ends a specific performance coutner
  44857. */
  44858. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44859. /**
  44860. * Gets either window.performance.now() if supported or Date.now() else
  44861. */
  44862. static get Now(): number;
  44863. /**
  44864. * This method will return the name of the class used to create the instance of the given object.
  44865. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  44866. * @param object the object to get the class name from
  44867. * @param isType defines if the object is actually a type
  44868. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  44869. */
  44870. static GetClassName(object: any, isType?: boolean): string;
  44871. /**
  44872. * Gets the first element of an array satisfying a given predicate
  44873. * @param array defines the array to browse
  44874. * @param predicate defines the predicate to use
  44875. * @returns null if not found or the element
  44876. */
  44877. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  44878. /**
  44879. * This method will return the name of the full name of the class, including its owning module (if any).
  44880. * 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).
  44881. * @param object the object to get the class name from
  44882. * @param isType defines if the object is actually a type
  44883. * @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.
  44884. * @ignorenaming
  44885. */
  44886. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  44887. /**
  44888. * Returns a promise that resolves after the given amount of time.
  44889. * @param delay Number of milliseconds to delay
  44890. * @returns Promise that resolves after the given amount of time
  44891. */
  44892. static DelayAsync(delay: number): Promise<void>;
  44893. /**
  44894. * Utility function to detect if the current user agent is Safari
  44895. * @returns whether or not the current user agent is safari
  44896. */
  44897. static IsSafari(): boolean;
  44898. }
  44899. /**
  44900. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  44901. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  44902. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44903. * @param name The name of the class, case should be preserved
  44904. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44905. */
  44906. export function className(name: string, module?: string): (target: Object) => void;
  44907. /**
  44908. * An implementation of a loop for asynchronous functions.
  44909. */
  44910. export class AsyncLoop {
  44911. /**
  44912. * Defines the number of iterations for the loop
  44913. */
  44914. iterations: number;
  44915. /**
  44916. * Defines the current index of the loop.
  44917. */
  44918. index: number;
  44919. private _done;
  44920. private _fn;
  44921. private _successCallback;
  44922. /**
  44923. * Constructor.
  44924. * @param iterations the number of iterations.
  44925. * @param func the function to run each iteration
  44926. * @param successCallback the callback that will be called upon succesful execution
  44927. * @param offset starting offset.
  44928. */
  44929. constructor(
  44930. /**
  44931. * Defines the number of iterations for the loop
  44932. */
  44933. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44934. /**
  44935. * Execute the next iteration. Must be called after the last iteration was finished.
  44936. */
  44937. executeNext(): void;
  44938. /**
  44939. * Break the loop and run the success callback.
  44940. */
  44941. breakLoop(): void;
  44942. /**
  44943. * Create and run an async loop.
  44944. * @param iterations the number of iterations.
  44945. * @param fn the function to run each iteration
  44946. * @param successCallback the callback that will be called upon succesful execution
  44947. * @param offset starting offset.
  44948. * @returns the created async loop object
  44949. */
  44950. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44951. /**
  44952. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44953. * @param iterations total number of iterations
  44954. * @param syncedIterations number of synchronous iterations in each async iteration.
  44955. * @param fn the function to call each iteration.
  44956. * @param callback a success call back that will be called when iterating stops.
  44957. * @param breakFunction a break condition (optional)
  44958. * @param timeout timeout settings for the setTimeout function. default - 0.
  44959. * @returns the created async loop object
  44960. */
  44961. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44962. }
  44963. }
  44964. declare module "babylonjs/Misc/stringDictionary" {
  44965. import { Nullable } from "babylonjs/types";
  44966. /**
  44967. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44968. * The underlying implementation relies on an associative array to ensure the best performances.
  44969. * The value can be anything including 'null' but except 'undefined'
  44970. */
  44971. export class StringDictionary<T> {
  44972. /**
  44973. * This will clear this dictionary and copy the content from the 'source' one.
  44974. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44975. * @param source the dictionary to take the content from and copy to this dictionary
  44976. */
  44977. copyFrom(source: StringDictionary<T>): void;
  44978. /**
  44979. * Get a value based from its key
  44980. * @param key the given key to get the matching value from
  44981. * @return the value if found, otherwise undefined is returned
  44982. */
  44983. get(key: string): T | undefined;
  44984. /**
  44985. * Get a value from its key or add it if it doesn't exist.
  44986. * This method will ensure you that a given key/data will be present in the dictionary.
  44987. * @param key the given key to get the matching value from
  44988. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44989. * The factory will only be invoked if there's no data for the given key.
  44990. * @return the value corresponding to the key.
  44991. */
  44992. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44993. /**
  44994. * Get a value from its key if present in the dictionary otherwise add it
  44995. * @param key the key to get the value from
  44996. * @param val if there's no such key/value pair in the dictionary add it with this value
  44997. * @return the value corresponding to the key
  44998. */
  44999. getOrAdd(key: string, val: T): T;
  45000. /**
  45001. * Check if there's a given key in the dictionary
  45002. * @param key the key to check for
  45003. * @return true if the key is present, false otherwise
  45004. */
  45005. contains(key: string): boolean;
  45006. /**
  45007. * Add a new key and its corresponding value
  45008. * @param key the key to add
  45009. * @param value the value corresponding to the key
  45010. * @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
  45011. */
  45012. add(key: string, value: T): boolean;
  45013. /**
  45014. * Update a specific value associated to a key
  45015. * @param key defines the key to use
  45016. * @param value defines the value to store
  45017. * @returns true if the value was updated (or false if the key was not found)
  45018. */
  45019. set(key: string, value: T): boolean;
  45020. /**
  45021. * Get the element of the given key and remove it from the dictionary
  45022. * @param key defines the key to search
  45023. * @returns the value associated with the key or null if not found
  45024. */
  45025. getAndRemove(key: string): Nullable<T>;
  45026. /**
  45027. * Remove a key/value from the dictionary.
  45028. * @param key the key to remove
  45029. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  45030. */
  45031. remove(key: string): boolean;
  45032. /**
  45033. * Clear the whole content of the dictionary
  45034. */
  45035. clear(): void;
  45036. /**
  45037. * Gets the current count
  45038. */
  45039. get count(): number;
  45040. /**
  45041. * Execute a callback on each key/val of the dictionary.
  45042. * Note that you can remove any element in this dictionary in the callback implementation
  45043. * @param callback the callback to execute on a given key/value pair
  45044. */
  45045. forEach(callback: (key: string, val: T) => void): void;
  45046. /**
  45047. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  45048. * If the callback returns null or undefined the method will iterate to the next key/value pair
  45049. * Note that you can remove any element in this dictionary in the callback implementation
  45050. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  45051. * @returns the first item
  45052. */
  45053. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  45054. private _count;
  45055. private _data;
  45056. }
  45057. }
  45058. declare module "babylonjs/Collisions/collisionCoordinator" {
  45059. import { Nullable } from "babylonjs/types";
  45060. import { Scene } from "babylonjs/scene";
  45061. import { Vector3 } from "babylonjs/Maths/math.vector";
  45062. import { Collider } from "babylonjs/Collisions/collider";
  45063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45064. /** @hidden */
  45065. export interface ICollisionCoordinator {
  45066. createCollider(): Collider;
  45067. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45068. init(scene: Scene): void;
  45069. }
  45070. /** @hidden */
  45071. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  45072. private _scene;
  45073. private _scaledPosition;
  45074. private _scaledVelocity;
  45075. private _finalPosition;
  45076. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45077. createCollider(): Collider;
  45078. init(scene: Scene): void;
  45079. private _collideWithWorld;
  45080. }
  45081. }
  45082. declare module "babylonjs/Inputs/scene.inputManager" {
  45083. import { Nullable } from "babylonjs/types";
  45084. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45085. import { Vector2 } from "babylonjs/Maths/math.vector";
  45086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45087. import { Scene } from "babylonjs/scene";
  45088. /**
  45089. * Class used to manage all inputs for the scene.
  45090. */
  45091. export class InputManager {
  45092. /** The distance in pixel that you have to move to prevent some events */
  45093. static DragMovementThreshold: number;
  45094. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  45095. static LongPressDelay: number;
  45096. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  45097. static DoubleClickDelay: number;
  45098. /** If you need to check double click without raising a single click at first click, enable this flag */
  45099. static ExclusiveDoubleClickMode: boolean;
  45100. /** 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. */
  45101. private _alreadyAttached;
  45102. private _alreadyAttachedTo;
  45103. private _wheelEventName;
  45104. private _onPointerMove;
  45105. private _onPointerDown;
  45106. private _onPointerUp;
  45107. private _initClickEvent;
  45108. private _initActionManager;
  45109. private _delayedSimpleClick;
  45110. private _delayedSimpleClickTimeout;
  45111. private _previousDelayedSimpleClickTimeout;
  45112. private _meshPickProceed;
  45113. private _previousButtonPressed;
  45114. private _currentPickResult;
  45115. private _previousPickResult;
  45116. private _totalPointersPressed;
  45117. private _doubleClickOccured;
  45118. private _pointerOverMesh;
  45119. private _pickedDownMesh;
  45120. private _pickedUpMesh;
  45121. private _pointerX;
  45122. private _pointerY;
  45123. private _unTranslatedPointerX;
  45124. private _unTranslatedPointerY;
  45125. private _startingPointerPosition;
  45126. private _previousStartingPointerPosition;
  45127. private _startingPointerTime;
  45128. private _previousStartingPointerTime;
  45129. private _pointerCaptures;
  45130. private _meshUnderPointerId;
  45131. private _onKeyDown;
  45132. private _onKeyUp;
  45133. private _keyboardIsAttached;
  45134. private _onCanvasFocusObserver;
  45135. private _onCanvasBlurObserver;
  45136. private _scene;
  45137. /**
  45138. * Creates a new InputManager
  45139. * @param scene defines the hosting scene
  45140. */
  45141. constructor(scene: Scene);
  45142. /**
  45143. * Gets the mesh that is currently under the pointer
  45144. */
  45145. get meshUnderPointer(): Nullable<AbstractMesh>;
  45146. /**
  45147. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  45148. * @param pointerId the pointer id to use
  45149. * @returns The mesh under this pointer id or null if not found
  45150. */
  45151. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  45152. /**
  45153. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  45154. */
  45155. get unTranslatedPointer(): Vector2;
  45156. /**
  45157. * Gets or sets the current on-screen X position of the pointer
  45158. */
  45159. get pointerX(): number;
  45160. set pointerX(value: number);
  45161. /**
  45162. * Gets or sets the current on-screen Y position of the pointer
  45163. */
  45164. get pointerY(): number;
  45165. set pointerY(value: number);
  45166. private _updatePointerPosition;
  45167. private _processPointerMove;
  45168. private _setRayOnPointerInfo;
  45169. private _checkPrePointerObservable;
  45170. /**
  45171. * Use this method to simulate a pointer move on a mesh
  45172. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45173. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45174. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45175. */
  45176. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45177. /**
  45178. * Use this method to simulate a pointer down on a mesh
  45179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45182. */
  45183. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45184. private _processPointerDown;
  45185. /** @hidden */
  45186. _isPointerSwiping(): boolean;
  45187. /**
  45188. * Use this method to simulate a pointer up on a mesh
  45189. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45190. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45191. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45192. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45193. */
  45194. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  45195. private _processPointerUp;
  45196. /**
  45197. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45198. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45199. * @returns true if the pointer was captured
  45200. */
  45201. isPointerCaptured(pointerId?: number): boolean;
  45202. /**
  45203. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45204. * @param attachUp defines if you want to attach events to pointerup
  45205. * @param attachDown defines if you want to attach events to pointerdown
  45206. * @param attachMove defines if you want to attach events to pointermove
  45207. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  45208. */
  45209. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  45210. /**
  45211. * Detaches all event handlers
  45212. */
  45213. detachControl(): void;
  45214. /**
  45215. * Force the value of meshUnderPointer
  45216. * @param mesh defines the mesh to use
  45217. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  45218. */
  45219. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45220. /**
  45221. * Gets the mesh under the pointer
  45222. * @returns a Mesh or null if no mesh is under the pointer
  45223. */
  45224. getPointerOverMesh(): Nullable<AbstractMesh>;
  45225. }
  45226. }
  45227. declare module "babylonjs/Animations/animationGroup" {
  45228. import { Animatable } from "babylonjs/Animations/animatable";
  45229. import { Animation } from "babylonjs/Animations/animation";
  45230. import { Scene, IDisposable } from "babylonjs/scene";
  45231. import { Observable } from "babylonjs/Misc/observable";
  45232. import { Nullable } from "babylonjs/types";
  45233. import "babylonjs/Animations/animatable";
  45234. /**
  45235. * This class defines the direct association between an animation and a target
  45236. */
  45237. export class TargetedAnimation {
  45238. /**
  45239. * Animation to perform
  45240. */
  45241. animation: Animation;
  45242. /**
  45243. * Target to animate
  45244. */
  45245. target: any;
  45246. /**
  45247. * Returns the string "TargetedAnimation"
  45248. * @returns "TargetedAnimation"
  45249. */
  45250. getClassName(): string;
  45251. /**
  45252. * Serialize the object
  45253. * @returns the JSON object representing the current entity
  45254. */
  45255. serialize(): any;
  45256. }
  45257. /**
  45258. * Use this class to create coordinated animations on multiple targets
  45259. */
  45260. export class AnimationGroup implements IDisposable {
  45261. /** The name of the animation group */
  45262. name: string;
  45263. private _scene;
  45264. private _targetedAnimations;
  45265. private _animatables;
  45266. private _from;
  45267. private _to;
  45268. private _isStarted;
  45269. private _isPaused;
  45270. private _speedRatio;
  45271. private _loopAnimation;
  45272. private _isAdditive;
  45273. /**
  45274. * Gets or sets the unique id of the node
  45275. */
  45276. uniqueId: number;
  45277. /**
  45278. * This observable will notify when one animation have ended
  45279. */
  45280. onAnimationEndObservable: Observable<TargetedAnimation>;
  45281. /**
  45282. * Observer raised when one animation loops
  45283. */
  45284. onAnimationLoopObservable: Observable<TargetedAnimation>;
  45285. /**
  45286. * Observer raised when all animations have looped
  45287. */
  45288. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  45289. /**
  45290. * This observable will notify when all animations have ended.
  45291. */
  45292. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  45293. /**
  45294. * This observable will notify when all animations have paused.
  45295. */
  45296. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  45297. /**
  45298. * This observable will notify when all animations are playing.
  45299. */
  45300. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  45301. /**
  45302. * Gets the first frame
  45303. */
  45304. get from(): number;
  45305. /**
  45306. * Gets the last frame
  45307. */
  45308. get to(): number;
  45309. /**
  45310. * Define if the animations are started
  45311. */
  45312. get isStarted(): boolean;
  45313. /**
  45314. * Gets a value indicating that the current group is playing
  45315. */
  45316. get isPlaying(): boolean;
  45317. /**
  45318. * Gets or sets the speed ratio to use for all animations
  45319. */
  45320. get speedRatio(): number;
  45321. /**
  45322. * Gets or sets the speed ratio to use for all animations
  45323. */
  45324. set speedRatio(value: number);
  45325. /**
  45326. * Gets or sets if all animations should loop or not
  45327. */
  45328. get loopAnimation(): boolean;
  45329. set loopAnimation(value: boolean);
  45330. /**
  45331. * Gets or sets if all animations should be evaluated additively
  45332. */
  45333. get isAdditive(): boolean;
  45334. set isAdditive(value: boolean);
  45335. /**
  45336. * Gets the targeted animations for this animation group
  45337. */
  45338. get targetedAnimations(): Array<TargetedAnimation>;
  45339. /**
  45340. * returning the list of animatables controlled by this animation group.
  45341. */
  45342. get animatables(): Array<Animatable>;
  45343. /**
  45344. * Gets the list of target animations
  45345. */
  45346. get children(): TargetedAnimation[];
  45347. /**
  45348. * Instantiates a new Animation Group.
  45349. * This helps managing several animations at once.
  45350. * @see https://doc.babylonjs.com/how_to/group
  45351. * @param name Defines the name of the group
  45352. * @param scene Defines the scene the group belongs to
  45353. */
  45354. constructor(
  45355. /** The name of the animation group */
  45356. name: string, scene?: Nullable<Scene>);
  45357. /**
  45358. * Add an animation (with its target) in the group
  45359. * @param animation defines the animation we want to add
  45360. * @param target defines the target of the animation
  45361. * @returns the TargetedAnimation object
  45362. */
  45363. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  45364. /**
  45365. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  45366. * It can add constant keys at begin or end
  45367. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  45368. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  45369. * @returns the animation group
  45370. */
  45371. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  45372. private _animationLoopCount;
  45373. private _animationLoopFlags;
  45374. private _processLoop;
  45375. /**
  45376. * Start all animations on given targets
  45377. * @param loop defines if animations must loop
  45378. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  45379. * @param from defines the from key (optional)
  45380. * @param to defines the to key (optional)
  45381. * @param isAdditive defines the additive state for the resulting animatables (optional)
  45382. * @returns the current animation group
  45383. */
  45384. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  45385. /**
  45386. * Pause all animations
  45387. * @returns the animation group
  45388. */
  45389. pause(): AnimationGroup;
  45390. /**
  45391. * Play all animations to initial state
  45392. * This function will start() the animations if they were not started or will restart() them if they were paused
  45393. * @param loop defines if animations must loop
  45394. * @returns the animation group
  45395. */
  45396. play(loop?: boolean): AnimationGroup;
  45397. /**
  45398. * Reset all animations to initial state
  45399. * @returns the animation group
  45400. */
  45401. reset(): AnimationGroup;
  45402. /**
  45403. * Restart animations from key 0
  45404. * @returns the animation group
  45405. */
  45406. restart(): AnimationGroup;
  45407. /**
  45408. * Stop all animations
  45409. * @returns the animation group
  45410. */
  45411. stop(): AnimationGroup;
  45412. /**
  45413. * Set animation weight for all animatables
  45414. * @param weight defines the weight to use
  45415. * @return the animationGroup
  45416. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45417. */
  45418. setWeightForAllAnimatables(weight: number): AnimationGroup;
  45419. /**
  45420. * Synchronize and normalize all animatables with a source animatable
  45421. * @param root defines the root animatable to synchronize with
  45422. * @return the animationGroup
  45423. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45424. */
  45425. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  45426. /**
  45427. * Goes to a specific frame in this animation group
  45428. * @param frame the frame number to go to
  45429. * @return the animationGroup
  45430. */
  45431. goToFrame(frame: number): AnimationGroup;
  45432. /**
  45433. * Dispose all associated resources
  45434. */
  45435. dispose(): void;
  45436. private _checkAnimationGroupEnded;
  45437. /**
  45438. * Clone the current animation group and returns a copy
  45439. * @param newName defines the name of the new group
  45440. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  45441. * @returns the new aniamtion group
  45442. */
  45443. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  45444. /**
  45445. * Serializes the animationGroup to an object
  45446. * @returns Serialized object
  45447. */
  45448. serialize(): any;
  45449. /**
  45450. * Returns a new AnimationGroup object parsed from the source provided.
  45451. * @param parsedAnimationGroup defines the source
  45452. * @param scene defines the scene that will receive the animationGroup
  45453. * @returns a new AnimationGroup
  45454. */
  45455. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  45456. /**
  45457. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  45458. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  45459. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  45460. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  45461. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  45462. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  45463. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  45464. */
  45465. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  45466. /**
  45467. * Returns the string "AnimationGroup"
  45468. * @returns "AnimationGroup"
  45469. */
  45470. getClassName(): string;
  45471. /**
  45472. * Creates a detailled string about the object
  45473. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  45474. * @returns a string representing the object
  45475. */
  45476. toString(fullDetails?: boolean): string;
  45477. }
  45478. }
  45479. declare module "babylonjs/Instrumentation/timeToken" {
  45480. import { Nullable } from "babylonjs/types";
  45481. /**
  45482. * @hidden
  45483. **/
  45484. export class _TimeToken {
  45485. _startTimeQuery: Nullable<WebGLQuery>;
  45486. _endTimeQuery: Nullable<WebGLQuery>;
  45487. _timeElapsedQuery: Nullable<WebGLQuery>;
  45488. _timeElapsedQueryEnded: boolean;
  45489. }
  45490. }
  45491. declare module "babylonjs/Engines/WebGPU/webgpuConstants" {
  45492. /** @hidden */
  45493. export enum ExtensionName {
  45494. DepthClamping = "depth-clamping",
  45495. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45496. Depth32FloatStencil8 = "depth32float-stencil8",
  45497. PipelineStatisticsQuery = "pipeline-statistics-query",
  45498. TextureCompressionBC = "texture-compression-bc",
  45499. TimestampQuery = "timestamp-query"
  45500. }
  45501. /** @hidden */
  45502. export enum AddressMode {
  45503. ClampToEdge = "clamp-to-edge",
  45504. Repeat = "repeat",
  45505. MirrorRepeat = "mirror-repeat"
  45506. }
  45507. /** @hidden */
  45508. export enum BindingType {
  45509. UniformBuffer = "uniform-buffer",
  45510. StorageBuffer = "storage-buffer",
  45511. ReadonlyStorageBuffer = "readonly-storage-buffer",
  45512. Sampler = "sampler",
  45513. ComparisonSampler = "comparison-sampler",
  45514. SampledTexture = "sampled-texture",
  45515. ReadonlyStorageTexture = "readonly-storage-texture",
  45516. WriteonlyStorageTexture = "writeonly-storage-texture"
  45517. }
  45518. /** @hidden */
  45519. export enum BlendFactor {
  45520. Zero = "zero",
  45521. One = "one",
  45522. SrcColor = "src-color",
  45523. OneMinusSrcColor = "one-minus-src-color",
  45524. SrcAlpha = "src-alpha",
  45525. OneMinusSrcAlpha = "one-minus-src-alpha",
  45526. DstColor = "dst-color",
  45527. OneMinusDstColor = "one-minus-dst-color",
  45528. DstAlpha = "dst-alpha",
  45529. OneMinusDstAlpha = "one-minus-dst-alpha",
  45530. SrcAlphaSaturated = "src-alpha-saturated",
  45531. BlendColor = "blend-color",
  45532. OneMinusBlendColor = "one-minus-blend-color"
  45533. }
  45534. /** @hidden */
  45535. export enum BlendOperation {
  45536. Add = "add",
  45537. Subtract = "subtract",
  45538. ReverseSubtract = "reverse-subtract",
  45539. Min = "min",
  45540. Max = "max"
  45541. }
  45542. /** @hidden */
  45543. export enum CompareFunction {
  45544. Never = "never",
  45545. Less = "less",
  45546. Equal = "equal",
  45547. LessEqual = "less-equal",
  45548. Greater = "greater",
  45549. NotEqual = "not-equal",
  45550. GreaterEqual = "greater-equal",
  45551. Always = "always"
  45552. }
  45553. /** @hidden */
  45554. export enum CullMode {
  45555. None = "none",
  45556. Front = "front",
  45557. Back = "back"
  45558. }
  45559. /** @hidden */
  45560. export enum FilterMode {
  45561. Nearest = "nearest",
  45562. Linear = "linear"
  45563. }
  45564. /** @hidden */
  45565. export enum FrontFace {
  45566. CCW = "ccw",
  45567. CW = "cw"
  45568. }
  45569. /** @hidden */
  45570. export enum IndexFormat {
  45571. Uint16 = "uint16",
  45572. Uint32 = "uint32"
  45573. }
  45574. /** @hidden */
  45575. export enum InputStepMode {
  45576. Vertex = "vertex",
  45577. Instance = "instance"
  45578. }
  45579. /** @hidden */
  45580. export enum LoadOp {
  45581. Load = "load"
  45582. }
  45583. /** @hidden */
  45584. export enum PrimitiveTopology {
  45585. PointList = "point-list",
  45586. LineList = "line-list",
  45587. LineStrip = "line-strip",
  45588. TriangleList = "triangle-list",
  45589. TriangleStrip = "triangle-strip"
  45590. }
  45591. /** @hidden */
  45592. export enum StencilOperation {
  45593. Keep = "keep",
  45594. Zero = "zero",
  45595. Replace = "replace",
  45596. Invert = "invert",
  45597. IncrementClamp = "increment-clamp",
  45598. DecrementClamp = "decrement-clamp",
  45599. IncrementWrap = "increment-wrap",
  45600. DecrementWrap = "decrement-wrap"
  45601. }
  45602. /** @hidden */
  45603. export enum StoreOp {
  45604. Store = "store",
  45605. Clear = "clear"
  45606. }
  45607. /** @hidden */
  45608. export enum TextureDimension {
  45609. E1d = "1d",
  45610. E2d = "2d",
  45611. E3d = "3d"
  45612. }
  45613. /** @hidden */
  45614. export enum TextureFormat {
  45615. R8Unorm = "r8unorm",
  45616. R8Snorm = "r8snorm",
  45617. R8Uint = "r8uint",
  45618. R8Sint = "r8sint",
  45619. R16Uint = "r16uint",
  45620. R16Sint = "r16sint",
  45621. R16Float = "r16float",
  45622. RG8Unorm = "rg8unorm",
  45623. RG8Snorm = "rg8snorm",
  45624. RG8Uint = "rg8uint",
  45625. RG8Sint = "rg8sint",
  45626. R32Uint = "r32uint",
  45627. R32Sint = "r32sint",
  45628. R32Float = "r32float",
  45629. RG16Uint = "rg16uint",
  45630. RG16Sint = "rg16sint",
  45631. RG16Float = "rg16float",
  45632. RGBA8Unorm = "rgba8unorm",
  45633. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45634. RGBA8Snorm = "rgba8snorm",
  45635. RGBA8Uint = "rgba8uint",
  45636. RGBA8Sint = "rgba8sint",
  45637. BGRA8Unorm = "bgra8unorm",
  45638. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45639. RGB9E5UFloat = "rgb9e5ufloat",
  45640. RGB10A2Unorm = "rgb10a2unorm",
  45641. RG11B10UFloat = "rg11b10ufloat",
  45642. RG32Uint = "rg32uint",
  45643. RG32Sint = "rg32sint",
  45644. RG32Float = "rg32float",
  45645. RGBA16Uint = "rgba16uint",
  45646. RGBA16Sint = "rgba16sint",
  45647. RGBA16Float = "rgba16float",
  45648. RGBA32Uint = "rgba32uint",
  45649. RGBA32Sint = "rgba32sint",
  45650. RGBA32Float = "rgba32float",
  45651. Stencil8 = "stencil8",
  45652. Depth16Unorm = "depth16unorm",
  45653. Depth24Plus = "depth24plus",
  45654. Depth24PlusStencil8 = "depth24plus-stencil8",
  45655. Depth32Float = "depth32float",
  45656. BC1RGBAUNorm = "bc1-rgba-unorm",
  45657. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45658. BC2RGBAUnorm = "bc2-rgba-unorm",
  45659. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45660. BC3RGBAUnorm = "bc3-rgba-unorm",
  45661. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45662. BC4RUnorm = "bc4-r-unorm",
  45663. BC4RSnorm = "bc4-r-snorm",
  45664. BC5RGUnorm = "bc5-rg-unorm",
  45665. BC5RGSnorm = "bc5-rg-snorm",
  45666. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45667. BC6HRGBFloat = "bc6h-rgb-float",
  45668. BC7RGBAUnorm = "bc7-rgba-unorm",
  45669. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45670. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45671. Depth32FloatStencil8 = "depth32float-stencil8"
  45672. }
  45673. /** @hidden */
  45674. export enum TextureComponentType {
  45675. Float = "float",
  45676. Sint = "sint",
  45677. Uint = "uint",
  45678. DepthComparison = "depth-comparison"
  45679. }
  45680. /** @hidden */
  45681. export enum TextureViewDimension {
  45682. E1d = "1d",
  45683. E2d = "2d",
  45684. E2dArray = "2d-array",
  45685. Cube = "cube",
  45686. CubeArray = "cube-array",
  45687. E3d = "3d"
  45688. }
  45689. /** @hidden */
  45690. export enum VertexFormat {
  45691. Uchar2 = "uchar2",
  45692. Uchar4 = "uchar4",
  45693. Char2 = "char2",
  45694. Char4 = "char4",
  45695. Uchar2Norm = "uchar2norm",
  45696. Uchar4Norm = "uchar4norm",
  45697. Char2Norm = "char2norm",
  45698. Char4Norm = "char4norm",
  45699. Ushort2 = "ushort2",
  45700. Ushort4 = "ushort4",
  45701. Short2 = "short2",
  45702. Short4 = "short4",
  45703. Ushort2Norm = "ushort2norm",
  45704. Ushort4Norm = "ushort4norm",
  45705. Short2Norm = "short2norm",
  45706. Short4Norm = "short4norm",
  45707. Half2 = "half2",
  45708. Half4 = "half4",
  45709. Float = "float",
  45710. Float2 = "float2",
  45711. Float3 = "float3",
  45712. Float4 = "float4",
  45713. Uint = "uint",
  45714. Uint2 = "uint2",
  45715. Uint3 = "uint3",
  45716. Uint4 = "uint4",
  45717. Int = "int",
  45718. Int2 = "int2",
  45719. Int3 = "int3",
  45720. Int4 = "int4"
  45721. }
  45722. /** @hidden */
  45723. export enum TextureAspect {
  45724. All = "all",
  45725. StencilOnly = "stencil-only",
  45726. DepthOnly = "depth-only"
  45727. }
  45728. /** @hidden */
  45729. export enum CompilationMessageType {
  45730. Error = "error",
  45731. Warning = "warning",
  45732. Info = "info"
  45733. }
  45734. /** @hidden */
  45735. export enum QueryType {
  45736. Occlusion = "occlusion"
  45737. }
  45738. /** @hidden */
  45739. export enum BufferUsage {
  45740. MapRead = 1,
  45741. MapWrite = 2,
  45742. CopySrc = 4,
  45743. CopyDst = 8,
  45744. Index = 16,
  45745. Vertex = 32,
  45746. Uniform = 64,
  45747. Storage = 128,
  45748. Indirect = 256,
  45749. QueryResolve = 512
  45750. }
  45751. /** @hidden */
  45752. export enum ColorWrite {
  45753. Red = 1,
  45754. Green = 2,
  45755. Blue = 4,
  45756. Alpha = 8,
  45757. All = 15
  45758. }
  45759. /** @hidden */
  45760. export enum ShaderStage {
  45761. Vertex = 1,
  45762. Fragment = 2,
  45763. Compute = 4
  45764. }
  45765. /** @hidden */
  45766. export enum TextureUsage {
  45767. CopySrc = 1,
  45768. CopyDst = 2,
  45769. Sampled = 4,
  45770. Storage = 8,
  45771. OutputAttachment = 16
  45772. }
  45773. /** @hidden */
  45774. export enum MapMode {
  45775. Read = 1,
  45776. Write = 2
  45777. }
  45778. }
  45779. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext" {
  45780. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  45781. /** @hidden */
  45782. export interface WebGPUBindingInfo {
  45783. setIndex: number;
  45784. bindingIndex: number;
  45785. }
  45786. /** @hidden */
  45787. export interface WebGPUTextureSamplerBindingDescription {
  45788. sampler: WebGPUBindingInfo;
  45789. isTextureArray: boolean;
  45790. textures: Array<WebGPUBindingInfo>;
  45791. }
  45792. /** @hidden
  45793. * If the binding is a UBO, isSampler=isTexture=false
  45794. */
  45795. export interface WebGPUBindingDescription {
  45796. name: string;
  45797. usedInVertex: boolean;
  45798. usedInFragment: boolean;
  45799. isSampler: boolean;
  45800. isComparisonSampler?: boolean;
  45801. isTexture: boolean;
  45802. componentType?: GPUTextureComponentType;
  45803. textureDimension?: GPUTextureViewDimension;
  45804. }
  45805. /**
  45806. * @hidden
  45807. */
  45808. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45809. uboNextBindingIndex: number;
  45810. freeSetIndex: number;
  45811. freeBindingIndex: number;
  45812. availableVaryings: {
  45813. [key: string]: number;
  45814. };
  45815. availableAttributes: {
  45816. [key: string]: number;
  45817. };
  45818. availableUBOs: {
  45819. [key: string]: {
  45820. setIndex: number;
  45821. bindingIndex: number;
  45822. };
  45823. };
  45824. availableSamplers: {
  45825. [key: string]: WebGPUTextureSamplerBindingDescription;
  45826. };
  45827. leftOverUniforms: {
  45828. name: string;
  45829. type: string;
  45830. length: number;
  45831. }[];
  45832. orderedAttributes: string[];
  45833. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45834. uniformBufferNames: string[];
  45835. private _attributeNextLocation;
  45836. private _varyingNextLocation;
  45837. constructor();
  45838. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45839. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45840. getNextFreeUBOBinding(): {
  45841. setIndex: number;
  45842. bindingIndex: number;
  45843. };
  45844. private _getNextFreeBinding;
  45845. }
  45846. }
  45847. declare module "babylonjs/Engines/WebGPU/webgpuPipelineContext" {
  45848. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45849. import { Nullable } from "babylonjs/types";
  45850. import { WebGPUEngine } from "babylonjs/Engines/webgpuEngine";
  45851. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45852. import { Effect } from "babylonjs/Materials/effect";
  45853. import { WebGPUShaderProcessingContext } from "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext";
  45854. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45855. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  45856. /** @hidden */
  45857. export interface IWebGPUPipelineContextSamplerCache {
  45858. samplerBinding: number;
  45859. firstTextureName: string;
  45860. }
  45861. /** @hidden */
  45862. export interface IWebGPUPipelineContextTextureCache {
  45863. textureBinding: number;
  45864. texture: InternalTexture;
  45865. }
  45866. /** @hidden */
  45867. export interface IWebGPUPipelineContextVertexInputsCache {
  45868. indexBuffer: Nullable<GPUBuffer>;
  45869. indexOffset: number;
  45870. vertexStartSlot: number;
  45871. vertexBuffers: GPUBuffer[];
  45872. vertexOffsets: number[];
  45873. }
  45874. /** @hidden */
  45875. export interface IWebGPURenderPipelineStageDescriptor {
  45876. vertexStage: GPUProgrammableStageDescriptor;
  45877. fragmentStage?: GPUProgrammableStageDescriptor;
  45878. }
  45879. /** @hidden */
  45880. export class WebGPUPipelineContext implements IPipelineContext {
  45881. engine: WebGPUEngine;
  45882. shaderProcessingContext: WebGPUShaderProcessingContext;
  45883. leftOverUniformsByName: {
  45884. [name: string]: string;
  45885. };
  45886. sources: {
  45887. vertex: string;
  45888. fragment: string;
  45889. rawVertex: string;
  45890. rawFragment: string;
  45891. };
  45892. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45893. samplers: {
  45894. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45895. };
  45896. textures: {
  45897. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45898. };
  45899. bindGroupLayouts: GPUBindGroupLayout[];
  45900. bindGroupsCache: {
  45901. [key: string]: GPUBindGroup[];
  45902. };
  45903. /**
  45904. * Stores the uniform buffer
  45905. */
  45906. uniformBuffer: Nullable<UniformBuffer>;
  45907. onCompiled?: () => void;
  45908. get isAsync(): boolean;
  45909. get isReady(): boolean;
  45910. /** @hidden */
  45911. _name: string;
  45912. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45913. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45914. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45915. [key: string]: number;
  45916. }, uniformsNames: string[], uniforms: {
  45917. [key: string]: Nullable<WebGLUniformLocation>;
  45918. }, samplerList: string[], samplers: {
  45919. [key: string]: number;
  45920. }, attributesNames: string[], attributes: number[]): void;
  45921. /** @hidden */
  45922. /**
  45923. * Build the uniform buffer used in the material.
  45924. */
  45925. buildUniformLayout(): void;
  45926. /**
  45927. * Release all associated resources.
  45928. **/
  45929. dispose(): void;
  45930. /**
  45931. * Sets an integer value on a uniform variable.
  45932. * @param uniformName Name of the variable.
  45933. * @param value Value to be set.
  45934. */
  45935. setInt(uniformName: string, value: number): void;
  45936. /**
  45937. * Sets an int2 value on a uniform variable.
  45938. * @param uniformName Name of the variable.
  45939. * @param x First int in int2.
  45940. * @param y Second int in int2.
  45941. */
  45942. setInt2(uniformName: string, x: number, y: number): void;
  45943. /**
  45944. * Sets an int3 value on a uniform variable.
  45945. * @param uniformName Name of the variable.
  45946. * @param x First int in int3.
  45947. * @param y Second int in int3.
  45948. * @param z Third int in int3.
  45949. */
  45950. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45951. /**
  45952. * Sets an int4 value on a uniform variable.
  45953. * @param uniformName Name of the variable.
  45954. * @param x First int in int4.
  45955. * @param y Second int in int4.
  45956. * @param z Third int in int4.
  45957. * @param w Fourth int in int4.
  45958. */
  45959. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45960. /**
  45961. * Sets an int array on a uniform variable.
  45962. * @param uniformName Name of the variable.
  45963. * @param array array to be set.
  45964. */
  45965. setIntArray(uniformName: string, array: Int32Array): void;
  45966. /**
  45967. * 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)
  45968. * @param uniformName Name of the variable.
  45969. * @param array array to be set.
  45970. */
  45971. setIntArray2(uniformName: string, array: Int32Array): void;
  45972. /**
  45973. * 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)
  45974. * @param uniformName Name of the variable.
  45975. * @param array array to be set.
  45976. */
  45977. setIntArray3(uniformName: string, array: Int32Array): void;
  45978. /**
  45979. * 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)
  45980. * @param uniformName Name of the variable.
  45981. * @param array array to be set.
  45982. */
  45983. setIntArray4(uniformName: string, array: Int32Array): void;
  45984. /**
  45985. * Sets an array on a uniform variable.
  45986. * @param uniformName Name of the variable.
  45987. * @param array array to be set.
  45988. */
  45989. setArray(uniformName: string, array: number[]): void;
  45990. /**
  45991. * 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)
  45992. * @param uniformName Name of the variable.
  45993. * @param array array to be set.
  45994. */
  45995. setArray2(uniformName: string, array: number[]): void;
  45996. /**
  45997. * 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)
  45998. * @param uniformName Name of the variable.
  45999. * @param array array to be set.
  46000. * @returns this effect.
  46001. */
  46002. setArray3(uniformName: string, array: number[]): void;
  46003. /**
  46004. * 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)
  46005. * @param uniformName Name of the variable.
  46006. * @param array array to be set.
  46007. */
  46008. setArray4(uniformName: string, array: number[]): void;
  46009. /**
  46010. * Sets matrices on a uniform variable.
  46011. * @param uniformName Name of the variable.
  46012. * @param matrices matrices to be set.
  46013. */
  46014. setMatrices(uniformName: string, matrices: Float32Array): void;
  46015. /**
  46016. * Sets matrix on a uniform variable.
  46017. * @param uniformName Name of the variable.
  46018. * @param matrix matrix to be set.
  46019. */
  46020. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  46021. /**
  46022. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  46023. * @param uniformName Name of the variable.
  46024. * @param matrix matrix to be set.
  46025. */
  46026. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  46027. /**
  46028. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  46029. * @param uniformName Name of the variable.
  46030. * @param matrix matrix to be set.
  46031. */
  46032. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  46033. /**
  46034. * Sets a float on a uniform variable.
  46035. * @param uniformName Name of the variable.
  46036. * @param value value to be set.
  46037. * @returns this effect.
  46038. */
  46039. setFloat(uniformName: string, value: number): void;
  46040. /**
  46041. * Sets a Vector2 on a uniform variable.
  46042. * @param uniformName Name of the variable.
  46043. * @param vector2 vector2 to be set.
  46044. */
  46045. setVector2(uniformName: string, vector2: IVector2Like): void;
  46046. /**
  46047. * Sets a float2 on a uniform variable.
  46048. * @param uniformName Name of the variable.
  46049. * @param x First float in float2.
  46050. * @param y Second float in float2.
  46051. */
  46052. setFloat2(uniformName: string, x: number, y: number): void;
  46053. /**
  46054. * Sets a Vector3 on a uniform variable.
  46055. * @param uniformName Name of the variable.
  46056. * @param vector3 Value to be set.
  46057. */
  46058. setVector3(uniformName: string, vector3: IVector3Like): void;
  46059. /**
  46060. * Sets a float3 on a uniform variable.
  46061. * @param uniformName Name of the variable.
  46062. * @param x First float in float3.
  46063. * @param y Second float in float3.
  46064. * @param z Third float in float3.
  46065. */
  46066. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  46067. /**
  46068. * Sets a Vector4 on a uniform variable.
  46069. * @param uniformName Name of the variable.
  46070. * @param vector4 Value to be set.
  46071. */
  46072. setVector4(uniformName: string, vector4: IVector4Like): void;
  46073. /**
  46074. * Sets a float4 on a uniform variable.
  46075. * @param uniformName Name of the variable.
  46076. * @param x First float in float4.
  46077. * @param y Second float in float4.
  46078. * @param z Third float in float4.
  46079. * @param w Fourth float in float4.
  46080. * @returns this effect.
  46081. */
  46082. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46083. /**
  46084. * Sets a Color3 on a uniform variable.
  46085. * @param uniformName Name of the variable.
  46086. * @param color3 Value to be set.
  46087. */
  46088. setColor3(uniformName: string, color3: IColor3Like): void;
  46089. /**
  46090. * Sets a Color4 on a uniform variable.
  46091. * @param uniformName Name of the variable.
  46092. * @param color3 Value to be set.
  46093. * @param alpha Alpha value to be set.
  46094. */
  46095. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  46096. /**
  46097. * Sets a Color4 on a uniform variable
  46098. * @param uniformName defines the name of the variable
  46099. * @param color4 defines the value to be set
  46100. */
  46101. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  46102. _getVertexShaderCode(): string | null;
  46103. _getFragmentShaderCode(): string | null;
  46104. }
  46105. }
  46106. declare module "babylonjs/Meshes/WebGPU/webgpuDataBuffer" {
  46107. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46108. /** @hidden */
  46109. export class WebGPUDataBuffer extends DataBuffer {
  46110. private _buffer;
  46111. constructor(resource: GPUBuffer);
  46112. get underlyingResource(): any;
  46113. }
  46114. }
  46115. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  46116. /**
  46117. * Class used to inline functions in shader code
  46118. */
  46119. export class ShaderCodeInliner {
  46120. private static readonly _RegexpFindFunctionNameAndType;
  46121. private _sourceCode;
  46122. private _functionDescr;
  46123. private _numMaxIterations;
  46124. /** Gets or sets the token used to mark the functions to inline */
  46125. inlineToken: string;
  46126. /** Gets or sets the debug mode */
  46127. debug: boolean;
  46128. /** Gets the code after the inlining process */
  46129. get code(): string;
  46130. /**
  46131. * Initializes the inliner
  46132. * @param sourceCode shader code source to inline
  46133. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  46134. */
  46135. constructor(sourceCode: string, numMaxIterations?: number);
  46136. /**
  46137. * Start the processing of the shader code
  46138. */
  46139. processCode(): void;
  46140. private _collectFunctions;
  46141. private _processInlining;
  46142. private _extractBetweenMarkers;
  46143. private _skipWhitespaces;
  46144. private _isIdentifierChar;
  46145. private _removeComments;
  46146. private _replaceFunctionCallsByCode;
  46147. private _findBackward;
  46148. private _escapeRegExp;
  46149. private _replaceNames;
  46150. }
  46151. }
  46152. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessors" {
  46153. import { Nullable } from "babylonjs/types";
  46154. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46155. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46156. /** @hidden */
  46157. export class WebGPUShaderProcessor implements IShaderProcessor {
  46158. protected _missingVaryings: Array<string>;
  46159. protected _textureArrayProcessing: Array<string>;
  46160. protected _preProcessors: {
  46161. [key: string]: string;
  46162. };
  46163. private _getArraySize;
  46164. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  46165. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  46166. [key: string]: string;
  46167. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46168. attributeProcessor(attribute: string, preProcessors: {
  46169. [key: string]: string;
  46170. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46171. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  46172. [key: string]: string;
  46173. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46174. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46175. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46176. private _applyTextureArrayProcessing;
  46177. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  46178. vertexCode: string;
  46179. fragmentCode: string;
  46180. };
  46181. }
  46182. }
  46183. declare module "babylonjs/Engines/WebGPU/webgpuBufferManager" {
  46184. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46185. import { WebGPUDataBuffer } from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  46186. import { Nullable } from "babylonjs/types";
  46187. /** @hidden */
  46188. export class WebGPUBufferManager {
  46189. private _device;
  46190. private _deferredReleaseBuffers;
  46191. private static _IsGPUBuffer;
  46192. constructor(device: GPUDevice);
  46193. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  46194. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  46195. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  46196. private _FromHalfFloat;
  46197. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  46198. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  46199. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  46200. destroyDeferredBuffers(): void;
  46201. }
  46202. }
  46203. declare module "babylonjs/Engines/WebGPU/webgpuHardwareTexture" {
  46204. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46205. import { Nullable } from "babylonjs/types";
  46206. /** @hidden */
  46207. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  46208. private _webgpuTexture;
  46209. private _webgpuMSAATexture;
  46210. get underlyingResource(): Nullable<GPUTexture>;
  46211. get msaaTexture(): Nullable<GPUTexture>;
  46212. set msaaTexture(texture: Nullable<GPUTexture>);
  46213. view: Nullable<GPUTextureView>;
  46214. format: GPUTextureFormat;
  46215. textureUsages: number;
  46216. constructor(existingTexture?: Nullable<GPUTexture>);
  46217. set(hardwareTexture: GPUTexture): void;
  46218. setMSAATexture(hardwareTexture: GPUTexture): void;
  46219. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  46220. createView(descriptor?: GPUTextureViewDescriptor): void;
  46221. reset(): void;
  46222. release(): void;
  46223. }
  46224. }
  46225. declare module "babylonjs/Engines/WebGPU/webgpuTextureHelper" {
  46226. import { WebGPUBufferManager } from "babylonjs/Engines/WebGPU/webgpuBufferManager";
  46227. import { Nullable } from "babylonjs/types";
  46228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46229. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46230. import { IColor4Like } from "babylonjs/Maths/math.like";
  46231. /** @hidden */
  46232. export class WebGPUTextureHelper {
  46233. private _device;
  46234. private _glslang;
  46235. private _bufferManager;
  46236. private _mipmapSampler;
  46237. private _invertYPreMultiplyAlphaSampler;
  46238. private _pipelines;
  46239. private _compiledShaders;
  46240. private _deferredReleaseTextures;
  46241. private _commandEncoderForCreation;
  46242. static ComputeNumMipmapLevels(width: number, height: number): number;
  46243. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  46244. private _getPipeline;
  46245. private static _GetTextureTypeFromFormat;
  46246. private static _GetBlockInformationFromFormat;
  46247. private static _IsHardwareTexture;
  46248. private static _IsInternalTexture;
  46249. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  46250. static IsImageBitmap(imageBitmap: ImageBitmap | {
  46251. width: number;
  46252. height: number;
  46253. }): imageBitmap is ImageBitmap;
  46254. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  46255. width: number;
  46256. height: number;
  46257. }): imageBitmap is ImageBitmap[];
  46258. setCommandEncoder(encoder: GPUCommandEncoder): void;
  46259. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  46260. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  46261. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46262. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  46263. createTexture(imageBitmap: ImageBitmap | {
  46264. width: number;
  46265. height: number;
  46266. layers: number;
  46267. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46268. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  46269. width: number;
  46270. height: number;
  46271. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46272. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  46273. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46274. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  46275. createMSAATexture(texture: InternalTexture, samples: number): void;
  46276. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46277. 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;
  46278. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  46279. releaseTexture(texture: InternalTexture | GPUTexture): void;
  46280. destroyDeferredTextures(): void;
  46281. }
  46282. }
  46283. declare module "babylonjs/Engines/WebGPU/webgpuRenderPassWrapper" {
  46284. import { Nullable } from "babylonjs/types";
  46285. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46286. /** @hidden */
  46287. export class WebGPURenderPassWrapper {
  46288. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  46289. renderPass: Nullable<GPURenderPassEncoder>;
  46290. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46291. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46292. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  46293. depthTextureFormat: GPUTextureFormat | undefined;
  46294. constructor();
  46295. reset(fullReset?: boolean): void;
  46296. }
  46297. }
  46298. declare module "babylonjs/Engines/WebGPU/webgpuCacheSampler" {
  46299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46300. /** @hidden */
  46301. export class WebGPUCacheSampler {
  46302. private _samplers;
  46303. private _device;
  46304. disabled: boolean;
  46305. constructor(device: GPUDevice);
  46306. private static _GetSamplerHashCode;
  46307. private static _GetSamplerFilterDescriptor;
  46308. private static _GetWrappingMode;
  46309. private static _GetSamplerWrappingDescriptor;
  46310. private static _GetSamplerDescriptor;
  46311. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  46312. }
  46313. }
  46314. declare module "babylonjs/Engines/WebGPU/webgpuShaderManager" {
  46315. import { IWebGPURenderPipelineStageDescriptor } from "babylonjs/Engines/WebGPU/webgpuPipelineContext";
  46316. /** @hidden */
  46317. export class WebGPUShaderManager {
  46318. private _shaders;
  46319. private _device;
  46320. constructor(device: GPUDevice);
  46321. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  46322. }
  46323. }
  46324. declare module "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline" {
  46325. import { Effect } from "babylonjs/Materials/effect";
  46326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46327. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46328. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46329. import { Nullable } from "babylonjs/types";
  46330. /** @hidden */
  46331. export class WebGPUCacheRenderPipeline {
  46332. static NumCacheHitWithoutHash: number;
  46333. static NumCacheHitWithHash: number;
  46334. static NumCacheMiss: number;
  46335. static NumPipelineCreationLastFrame: number;
  46336. disabled: boolean;
  46337. private static _Cache;
  46338. private static _NumPipelineCreationCurrentFrame;
  46339. private _device;
  46340. private _states;
  46341. private _isDirty;
  46342. private _currentRenderPipeline;
  46343. private _emptyVertexBuffer;
  46344. private _shaderId;
  46345. private _alphaToCoverageEnabled;
  46346. private _frontFace;
  46347. private _cullEnabled;
  46348. private _cullFace;
  46349. private _clampDepth;
  46350. private _rasterizationState;
  46351. private _depthBias;
  46352. private _depthBiasClamp;
  46353. private _depthBiasSlopeScale;
  46354. private _colorFormat;
  46355. private _webgpuColorFormat;
  46356. private _mrtAttachments1;
  46357. private _mrtAttachments2;
  46358. private _mrtFormats;
  46359. private _alphaBlendEnabled;
  46360. private _alphaBlendFuncParams;
  46361. private _alphaBlendEqParams;
  46362. private _writeMask;
  46363. private _colorStates;
  46364. private _depthStencilFormat;
  46365. private _webgpuDepthStencilFormat;
  46366. private _depthTestEnabled;
  46367. private _depthWriteEnabled;
  46368. private _depthCompare;
  46369. private _stencilEnabled;
  46370. private _stencilFrontCompare;
  46371. private _stencilFrontDepthFailOp;
  46372. private _stencilFrontPassOp;
  46373. private _stencilFrontFailOp;
  46374. private _stencilReadMask;
  46375. private _stencilWriteMask;
  46376. private _depthStencilState;
  46377. private _vertexBuffers;
  46378. private _indexBuffer;
  46379. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  46380. reset(): void;
  46381. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  46382. endFrame(): void;
  46383. setAlphaToCoverage(enabled: boolean): void;
  46384. setFrontFace(frontFace: number): void;
  46385. setCullEnabled(enabled: boolean): void;
  46386. setCullFace(cullFace: number): void;
  46387. setClampDepth(clampDepth: boolean): void;
  46388. resetDepthCullingState(): void;
  46389. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  46390. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  46391. setColorFormat(format: GPUTextureFormat): void;
  46392. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  46393. setAlphaBlendEnabled(enabled: boolean): void;
  46394. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  46395. setWriteMask(mask: number): void;
  46396. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  46397. setDepthTestEnabled(enabled: boolean): void;
  46398. setDepthWriteEnabled(enabled: boolean): void;
  46399. setDepthCompare(func: Nullable<number>): void;
  46400. setStencilEnabled(enabled: boolean): void;
  46401. setStencilCompare(func: Nullable<number>): void;
  46402. setStencilDepthFailOp(op: Nullable<number>): void;
  46403. setStencilPassOp(op: Nullable<number>): void;
  46404. setStencilFailOp(op: Nullable<number>): void;
  46405. setStencilReadMask(mask: number): void;
  46406. setStencilWriteMask(mask: number): void;
  46407. resetStencilState(): void;
  46408. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  46409. setBuffers(vertexBuffers: Nullable<{
  46410. [key: string]: Nullable<VertexBuffer>;
  46411. }>, indexBuffer: Nullable<DataBuffer>): void;
  46412. private static _GetTopology;
  46413. private static _GetAphaBlendOperation;
  46414. private static _GetAphaBlendFactor;
  46415. private static _GetCompareFunction;
  46416. private static _GetStencilOpFunction;
  46417. private static _GetVertexInputDescriptorFormat;
  46418. private _getAphaBlendState;
  46419. private _getColorBlendState;
  46420. private _setShaderStage;
  46421. private _setRasterizationState;
  46422. private _setColorStates;
  46423. private _setDepthStencilState;
  46424. private _setVertexState;
  46425. private _createPipelineLayout;
  46426. private _getVertexInputDescriptor;
  46427. private _createRenderPipeline;
  46428. }
  46429. }
  46430. declare module "babylonjs/Shaders/clearQuad.vertex" {
  46431. /** @hidden */
  46432. export var clearQuadVertexShader: {
  46433. name: string;
  46434. shader: string;
  46435. };
  46436. }
  46437. declare module "babylonjs/Shaders/clearQuad.fragment" {
  46438. /** @hidden */
  46439. export var clearQuadPixelShader: {
  46440. name: string;
  46441. shader: string;
  46442. };
  46443. }
  46444. declare module "babylonjs/Engines/webgpuEngine" {
  46445. import { Nullable, DataArray, IndicesArray, FloatArray, Immutable } from "babylonjs/types";
  46446. import { Engine } from "babylonjs/Engines/engine";
  46447. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  46448. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46450. import { IEffectCreationOptions, Effect } from "babylonjs/Materials/effect";
  46451. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  46452. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46453. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46454. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46456. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46457. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46458. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  46459. import { Scene } from "babylonjs/scene";
  46460. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  46461. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46462. import { IColor4Like } from "babylonjs/Maths/math.like";
  46463. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46464. import "babylonjs/Shaders/clearQuad.vertex";
  46465. import "babylonjs/Shaders/clearQuad.fragment";
  46466. /**
  46467. * Options to load the associated Glslang library
  46468. */
  46469. export interface GlslangOptions {
  46470. /**
  46471. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  46472. */
  46473. glslang?: any;
  46474. /**
  46475. * Defines the URL of the glslang JS File.
  46476. */
  46477. jsPath?: string;
  46478. /**
  46479. * Defines the URL of the glslang WASM File.
  46480. */
  46481. wasmPath?: string;
  46482. }
  46483. /**
  46484. * Options to create the WebGPU engine
  46485. */
  46486. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  46487. /**
  46488. * If delta time between frames should be constant
  46489. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46490. */
  46491. deterministicLockstep?: boolean;
  46492. /**
  46493. * Maximum about of steps between frames (Default: 4)
  46494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46495. */
  46496. lockstepMaxSteps?: number;
  46497. /**
  46498. * Defines the seconds between each deterministic lock step
  46499. */
  46500. timeStep?: number;
  46501. /**
  46502. * Defines that engine should ignore modifying touch action attribute and style
  46503. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  46504. */
  46505. doNotHandleTouchAction?: boolean;
  46506. /**
  46507. * Defines if webaudio should be initialized as well
  46508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  46509. */
  46510. audioEngine?: boolean;
  46511. /**
  46512. * Defines the category of adapter to use.
  46513. * Is it the discrete or integrated device.
  46514. */
  46515. powerPreference?: GPUPowerPreference;
  46516. /**
  46517. * Defines the device descriptor used to create a device.
  46518. */
  46519. deviceDescriptor?: GPUDeviceDescriptor;
  46520. /**
  46521. * Defines the requested Swap Chain Format.
  46522. */
  46523. swapChainFormat?: GPUTextureFormat;
  46524. /**
  46525. * Defines wether MSAA is enabled on the canvas.
  46526. */
  46527. antialiasing?: boolean;
  46528. /**
  46529. * Defines wether the stencil buffer should be enabled.
  46530. */
  46531. stencil?: boolean;
  46532. /**
  46533. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  46534. */
  46535. enableGPUDebugMarkers?: boolean;
  46536. /**
  46537. * Options to load the associated Glslang library
  46538. */
  46539. glslangOptions?: GlslangOptions;
  46540. }
  46541. /**
  46542. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46543. */
  46544. export class WebGPUEngine extends Engine {
  46545. private static readonly _glslangDefaultOptions;
  46546. private readonly _uploadEncoderDescriptor;
  46547. private readonly _renderEncoderDescriptor;
  46548. private readonly _renderTargetEncoderDescriptor;
  46549. private readonly _clearDepthValue;
  46550. private readonly _clearReverseDepthValue;
  46551. private readonly _clearStencilValue;
  46552. private readonly _defaultSampleCount;
  46553. private _canvas;
  46554. private _options;
  46555. private _glslang;
  46556. private _adapter;
  46557. private _adapterSupportedExtensions;
  46558. private _device;
  46559. private _deviceEnabledExtensions;
  46560. private _context;
  46561. private _swapChain;
  46562. private _swapChainTexture;
  46563. private _mainPassSampleCount;
  46564. private _textureHelper;
  46565. private _bufferManager;
  46566. private _shaderManager;
  46567. private _cacheSampler;
  46568. private _cacheRenderPipeline;
  46569. private _emptyVertexBuffer;
  46570. private _lastCachedWrapU;
  46571. private _lastCachedWrapV;
  46572. private _lastCachedWrapR;
  46573. private _mrtAttachments;
  46574. private _counters;
  46575. private _mainTexture;
  46576. private _depthTexture;
  46577. private _mainTextureExtends;
  46578. private _depthTextureFormat;
  46579. private _colorFormat;
  46580. private _uploadEncoder;
  46581. private _renderEncoder;
  46582. private _renderTargetEncoder;
  46583. private _commandBuffers;
  46584. private _currentRenderPass;
  46585. private _mainRenderPassWrapper;
  46586. private _rttRenderPassWrapper;
  46587. private _pendingDebugCommands;
  46588. private _currentVertexBuffers;
  46589. private _currentIndexBuffer;
  46590. private __colorWrite;
  46591. private _uniformsBuffers;
  46592. private _forceEnableEffect;
  46593. /** @hidden */
  46594. dbgShowShaderCode: boolean;
  46595. /** @hidden */
  46596. dbgSanityChecks: boolean;
  46597. /** @hidden */
  46598. dbgGenerateLogs: boolean;
  46599. /** @hidden */
  46600. dbgVerboseLogsForFirstFrames: boolean;
  46601. /** @hidden */
  46602. dbgVerboseLogsNumFrames: number;
  46603. /** @hidden */
  46604. dbgShowWarningsNotImplemented: boolean;
  46605. /**
  46606. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  46607. */
  46608. get disableCacheSamplers(): boolean;
  46609. set disableCacheSamplers(disable: boolean);
  46610. /**
  46611. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  46612. */
  46613. get disableCacheRenderPipelines(): boolean;
  46614. set disableCacheRenderPipelines(disable: boolean);
  46615. /**
  46616. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  46617. * @returns true if the engine can be created
  46618. */
  46619. static get IsSupported(): boolean;
  46620. /**
  46621. * Gets a boolean indicating that the engine supports uniform buffers
  46622. */
  46623. get supportsUniformBuffers(): boolean;
  46624. /** Gets the supported extensions by the WebGPU adapter */
  46625. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46626. /** Gets the currently enabled extensions on the WebGPU device */
  46627. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46628. /**
  46629. * Returns the name of the engine
  46630. */
  46631. get name(): string;
  46632. /**
  46633. * Returns a string describing the current engine
  46634. */
  46635. get description(): string;
  46636. /**
  46637. * Returns the version of the engine
  46638. */
  46639. get version(): number;
  46640. /**
  46641. * Create a new instance of the gpu engine asynchronously
  46642. * @param canvas Defines the canvas to use to display the result
  46643. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46644. * @returns a promise that resolves with the created engine
  46645. */
  46646. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  46647. /**
  46648. * Create a new instance of the gpu engine.
  46649. * @param canvas Defines the canvas to use to display the result
  46650. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46651. */
  46652. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46653. /**
  46654. * Initializes the WebGPU context and dependencies.
  46655. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46656. * @returns a promise notifying the readiness of the engine.
  46657. */
  46658. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46659. private _initGlslang;
  46660. private _initializeLimits;
  46661. private _initializeContextAndSwapChain;
  46662. private _initializeMainAttachments;
  46663. /**
  46664. * Force a specific size of the canvas
  46665. * @param width defines the new canvas' width
  46666. * @param height defines the new canvas' height
  46667. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46668. * @returns true if the size was changed
  46669. */
  46670. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46671. /**
  46672. * Gets a shader processor implementation fitting with the current engine type.
  46673. * @returns The shader processor implementation.
  46674. */
  46675. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46676. /** @hidden */
  46677. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46678. /**
  46679. * Force the entire cache to be cleared
  46680. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46681. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46682. */
  46683. wipeCaches(bruteForce?: boolean): void;
  46684. /**
  46685. * Enable or disable color writing
  46686. * @param enable defines the state to set
  46687. */
  46688. setColorWrite(enable: boolean): void;
  46689. /**
  46690. * Gets a boolean indicating if color writing is enabled
  46691. * @returns the current color writing state
  46692. */
  46693. getColorWrite(): boolean;
  46694. private _viewportsCurrent;
  46695. private _resetCurrentViewport;
  46696. private _applyViewport;
  46697. /** @hidden */
  46698. _viewport(x: number, y: number, width: number, height: number): void;
  46699. private _scissorsCurrent;
  46700. protected _scissorCached: {
  46701. x: number;
  46702. y: number;
  46703. z: number;
  46704. w: number;
  46705. };
  46706. private _resetCurrentScissor;
  46707. private _applyScissor;
  46708. private _scissorIsActive;
  46709. enableScissor(x: number, y: number, width: number, height: number): void;
  46710. disableScissor(): void;
  46711. /**
  46712. * Clear the current render buffer or the current render target (if any is set up)
  46713. * @param color defines the color to use
  46714. * @param backBuffer defines if the back buffer must be cleared
  46715. * @param depth defines if the depth buffer must be cleared
  46716. * @param stencil defines if the stencil buffer must be cleared
  46717. */
  46718. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46719. /**
  46720. * Clears a list of attachments
  46721. * @param attachments list of the attachments
  46722. * @param colorMain clear color for the main attachment (the first one)
  46723. * @param colorOthers clear color for the other attachments
  46724. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46725. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46726. */
  46727. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46728. /**
  46729. * Creates a vertex buffer
  46730. * @param data the data for the vertex buffer
  46731. * @returns the new buffer
  46732. */
  46733. createVertexBuffer(data: DataArray): DataBuffer;
  46734. /**
  46735. * Creates a vertex buffer
  46736. * @param data the data for the dynamic vertex buffer
  46737. * @returns the new buffer
  46738. */
  46739. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46740. /**
  46741. * Updates a vertex buffer.
  46742. * @param vertexBuffer the vertex buffer to update
  46743. * @param data the data used to update the vertex buffer
  46744. * @param byteOffset the byte offset of the data
  46745. * @param byteLength the byte length of the data
  46746. */
  46747. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46748. /**
  46749. * Creates a new index buffer
  46750. * @param indices defines the content of the index buffer
  46751. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46752. * @returns a new buffer
  46753. */
  46754. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46755. /**
  46756. * Update an index buffer
  46757. * @param indexBuffer defines the target index buffer
  46758. * @param indices defines the data to update
  46759. * @param offset defines the offset in the target index buffer where update should start
  46760. */
  46761. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46762. /** @hidden */
  46763. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46764. /** @hidden */
  46765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46766. /**
  46767. * Bind a list of vertex buffers with the engine
  46768. * @param vertexBuffers defines the list of vertex buffers to bind
  46769. * @param indexBuffer defines the index buffer to bind
  46770. * @param effect defines the effect associated with the vertex buffers
  46771. */
  46772. bindBuffers(vertexBuffers: {
  46773. [key: string]: Nullable<VertexBuffer>;
  46774. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  46775. /** @hidden */
  46776. _releaseBuffer(buffer: DataBuffer): boolean;
  46777. createUniformBuffer(elements: FloatArray): DataBuffer;
  46778. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46779. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46780. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46781. /**
  46782. * Create a new effect (used to store vertex/fragment shaders)
  46783. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46784. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46785. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46786. * @param samplers defines an array of string used to represent textures
  46787. * @param defines defines the string containing the defines to use to compile the shaders
  46788. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  46789. * @param onCompiled defines a function to call when the effect creation is successful
  46790. * @param onError defines a function to call when the effect creation has failed
  46791. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46792. * @returns the new Effect
  46793. */
  46794. 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;
  46795. private _compileRawShaderToSpirV;
  46796. private _compileShaderToSpirV;
  46797. private _createPipelineStageDescriptor;
  46798. private _compileRawPipelineStageDescriptor;
  46799. private _compilePipelineStageDescriptor;
  46800. /** @hidden */
  46801. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46802. /** @hidden */
  46803. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46804. /**
  46805. * Creates a new pipeline context
  46806. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46807. * @returns the new pipeline
  46808. */
  46809. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46810. /** @hidden */
  46811. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46812. /**
  46813. * Gets the list of active attributes for a given WebGPU program
  46814. * @param pipelineContext defines the pipeline context to use
  46815. * @param attributesNames defines the list of attribute names to get
  46816. * @returns an array of indices indicating the offset of each attribute
  46817. */
  46818. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46819. /**
  46820. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46821. * @param effect defines the effect to activate
  46822. */
  46823. enableEffect(effect: Nullable<Effect>): void;
  46824. /** @hidden */
  46825. _releaseEffect(effect: Effect): void;
  46826. /**
  46827. * 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
  46828. */
  46829. releaseEffects(): void;
  46830. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46831. /**
  46832. * Gets a boolean indicating that only power of 2 textures are supported
  46833. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46834. */
  46835. get needPOTTextures(): boolean;
  46836. /** @hidden */
  46837. _createHardwareTexture(): HardwareTextureWrapper;
  46838. /** @hidden */
  46839. _releaseTexture(texture: InternalTexture): void;
  46840. /** @hidden */
  46841. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46842. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46843. /**
  46844. * Usually called from Texture.ts.
  46845. * Passed information to create a hardware texture
  46846. * @param url defines a value which contains one of the following:
  46847. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46848. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46849. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46851. * @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)
  46852. * @param scene needed for loading to the correct scene
  46853. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46854. * @param onLoad optional callback to be called upon successful completion
  46855. * @param onError optional callback to be called upon failure
  46856. * @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
  46857. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46858. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46859. * @param forcedExtension defines the extension to use to pick the right loader
  46860. * @param mimeType defines an optional mime type
  46861. * @param loaderOptions options to be passed to the loader
  46862. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46863. */
  46864. 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;
  46865. /** @hidden */
  46866. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46867. /**
  46868. * Creates a cube texture
  46869. * @param rootUrl defines the url where the files to load is located
  46870. * @param scene defines the current scene
  46871. * @param files defines the list of files to load (1 per face)
  46872. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46873. * @param onLoad defines an optional callback raised when the texture is loaded
  46874. * @param onError defines an optional callback raised if there is an issue to load the texture
  46875. * @param format defines the format of the data
  46876. * @param forcedExtension defines the extension to use to pick the right loader
  46877. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46878. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46879. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46880. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46881. * @param loaderOptions options to be passed to the loader
  46882. * @returns the cube texture as an InternalTexture
  46883. */
  46884. 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;
  46885. /**
  46886. * Creates a raw texture
  46887. * @param data defines the data to store in the texture
  46888. * @param width defines the width of the texture
  46889. * @param height defines the height of the texture
  46890. * @param format defines the format of the data
  46891. * @param generateMipMaps defines if the engine should generate the mip levels
  46892. * @param invertY defines if data must be stored with Y axis inverted
  46893. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46894. * @param compression defines the compression used (null by default)
  46895. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46896. * @returns the raw texture inside an InternalTexture
  46897. */
  46898. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46899. /**
  46900. * Creates a new raw cube texture
  46901. * @param data defines the array of data to use to create each face
  46902. * @param size defines the size of the textures
  46903. * @param format defines the format of the data
  46904. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46905. * @param generateMipMaps defines if the engine should generate the mip levels
  46906. * @param invertY defines if data must be stored with Y axis inverted
  46907. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46908. * @param compression defines the compression used (null by default)
  46909. * @returns the cube texture as an InternalTexture
  46910. */
  46911. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46912. /**
  46913. * Creates a new raw cube texture from a specified url
  46914. * @param url defines the url where the data is located
  46915. * @param scene defines the current scene
  46916. * @param size defines the size of the textures
  46917. * @param format defines the format of the data
  46918. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46919. * @param noMipmap defines if the engine should avoid generating the mip levels
  46920. * @param callback defines a callback used to extract texture data from loaded data
  46921. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46922. * @param onLoad defines a callback called when texture is loaded
  46923. * @param onError defines a callback called if there is an error
  46924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46925. * @param invertY defines if data must be stored with Y axis inverted
  46926. * @returns the cube texture as an InternalTexture
  46927. */
  46928. 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;
  46929. /**
  46930. * Creates a new raw 2D array texture
  46931. * @param data defines the data used to create the texture
  46932. * @param width defines the width of the texture
  46933. * @param height defines the height of the texture
  46934. * @param depth defines the number of layers of the texture
  46935. * @param format defines the format of the texture
  46936. * @param generateMipMaps defines if the engine must generate mip levels
  46937. * @param invertY defines if data must be stored with Y axis inverted
  46938. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46939. * @param compression defines the compressed used (can be null)
  46940. * @param textureType defines the compressed used (can be null)
  46941. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46942. */
  46943. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46944. /**
  46945. * Creates a new raw 3D texture
  46946. * @param data defines the data used to create the texture
  46947. * @param width defines the width of the texture
  46948. * @param height defines the height of the texture
  46949. * @param depth defines the depth of the texture
  46950. * @param format defines the format of the texture
  46951. * @param generateMipMaps defines if the engine must generate mip levels
  46952. * @param invertY defines if data must be stored with Y axis inverted
  46953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46954. * @param compression defines the compressed used (can be null)
  46955. * @param textureType defines the compressed used (can be null)
  46956. * @returns a new raw 3D texture (stored in an InternalTexture)
  46957. */
  46958. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46959. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46960. /**
  46961. * Update the sampling mode of a given texture
  46962. * @param samplingMode defines the required sampling mode
  46963. * @param texture defines the texture to update
  46964. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46965. */
  46966. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46967. /**
  46968. * Update the sampling mode of a given texture
  46969. * @param texture defines the texture to update
  46970. * @param wrapU defines the texture wrap mode of the u coordinates
  46971. * @param wrapV defines the texture wrap mode of the v coordinates
  46972. * @param wrapR defines the texture wrap mode of the r coordinates
  46973. */
  46974. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46975. /**
  46976. * Update the dimensions of a texture
  46977. * @param texture texture to update
  46978. * @param width new width of the texture
  46979. * @param height new height of the texture
  46980. * @param depth new depth of the texture
  46981. */
  46982. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46983. private _setInternalTexture;
  46984. /**
  46985. * Sets a texture to the according uniform.
  46986. * @param channel The texture channel
  46987. * @param unused unused parameter
  46988. * @param texture The texture to apply
  46989. * @param name The name of the uniform in the effect
  46990. */
  46991. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46992. /**
  46993. * Sets an array of texture to the WebGPU context
  46994. * @param channel defines the channel where the texture array must be set
  46995. * @param unused unused parameter
  46996. * @param textures defines the array of textures to bind
  46997. * @param name name of the channel
  46998. */
  46999. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  47000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  47001. /** @hidden */
  47002. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  47003. /** @hidden */
  47004. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  47005. private _generateMipmaps;
  47006. /**
  47007. * Update the content of a texture
  47008. * @param texture defines the texture to update
  47009. * @param canvas defines the source containing the data
  47010. * @param invertY defines if data must be stored with Y axis inverted
  47011. * @param premulAlpha defines if alpha is stored as premultiplied
  47012. * @param format defines the format of the data
  47013. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47014. */
  47015. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  47016. /**
  47017. * Update a portion of an internal texture
  47018. * @param texture defines the texture to update
  47019. * @param imageData defines the data to store into the texture
  47020. * @param xOffset defines the x coordinates of the update rectangle
  47021. * @param yOffset defines the y coordinates of the update rectangle
  47022. * @param width defines the width of the update rectangle
  47023. * @param height defines the height of the update rectangle
  47024. * @param faceIndex defines the face index if texture is a cube (0 by default)
  47025. * @param lod defines the lod level to update (0 by default)
  47026. */
  47027. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  47028. /**
  47029. * Update a video texture
  47030. * @param texture defines the texture to update
  47031. * @param video defines the video element to use
  47032. * @param invertY defines if data must be stored with Y axis inverted
  47033. */
  47034. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  47035. /** @hidden */
  47036. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47037. /** @hidden */
  47038. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  47039. /** @hidden */
  47040. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47041. /** @hidden */
  47042. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  47043. /**
  47044. * Update a raw texture
  47045. * @param texture defines the texture to update
  47046. * @param bufferView defines the data to store in the texture
  47047. * @param format defines the format of the data
  47048. * @param invertY defines if data must be stored with Y axis inverted
  47049. * @param compression defines the compression used (null by default)
  47050. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47051. */
  47052. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  47053. /**
  47054. * Update a raw cube texture
  47055. * @param texture defines the texture to udpdate
  47056. * @param bufferView defines the data to store
  47057. * @param format defines the data format
  47058. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47059. * @param invertY defines if data must be stored with Y axis inverted
  47060. * @param compression defines the compression used (null by default)
  47061. * @param level defines which level of the texture to update
  47062. */
  47063. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47064. /**
  47065. * Update a raw 2D array texture
  47066. * @param texture defines the texture to update
  47067. * @param bufferView defines the data to store
  47068. * @param format defines the data format
  47069. * @param invertY defines if data must be stored with Y axis inverted
  47070. * @param compression defines the used compression (can be null)
  47071. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47072. */
  47073. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47074. /**
  47075. * Update a raw 3D texture
  47076. * @param texture defines the texture to update
  47077. * @param bufferView defines the data to store
  47078. * @param format defines the data format
  47079. * @param invertY defines if data must be stored with Y axis inverted
  47080. * @param compression defines the used compression (can be null)
  47081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47082. */
  47083. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47084. /**
  47085. * Reads pixels from the current frame buffer. Please note that this function can be slow
  47086. * @param x defines the x coordinate of the rectangle where pixels must be read
  47087. * @param y defines the y coordinate of the rectangle where pixels must be read
  47088. * @param width defines the width of the rectangle where pixels must be read
  47089. * @param height defines the height of the rectangle where pixels must be read
  47090. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  47091. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  47092. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  47093. */
  47094. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47095. /** @hidden */
  47096. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47097. /**
  47098. * Creates a new render target texture
  47099. * @param size defines the size of the texture
  47100. * @param options defines the options used to create the texture
  47101. * @returns a new render target texture stored in an InternalTexture
  47102. */
  47103. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47104. /**
  47105. * Create a multi render target texture
  47106. * @param size defines the size of the texture
  47107. * @param options defines the creation options
  47108. * @returns the cube texture as an InternalTexture
  47109. */
  47110. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47111. /**
  47112. * Creates a new render target cube texture
  47113. * @param size defines the size of the texture
  47114. * @param options defines the options used to create the texture
  47115. * @returns a new render target cube texture stored in an InternalTexture
  47116. */
  47117. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  47118. /** @hidden */
  47119. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  47120. width: number;
  47121. height: number;
  47122. layers?: number;
  47123. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  47124. /** @hidden */
  47125. _createDepthStencilTexture(size: number | {
  47126. width: number;
  47127. height: number;
  47128. layers?: number;
  47129. }, options: DepthTextureCreationOptions): InternalTexture;
  47130. /** @hidden */
  47131. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  47132. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  47133. /**
  47134. * Update the sample count for a given multiple render target texture
  47135. * @param textures defines the textures to update
  47136. * @param samples defines the sample count to set
  47137. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47138. */
  47139. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47140. /**
  47141. * Begin a new frame
  47142. */
  47143. beginFrame(): void;
  47144. /**
  47145. * End the current frame
  47146. */
  47147. endFrame(): void;
  47148. /**
  47149. * Force a WebGPU flush (ie. a flush of all waiting commands)
  47150. */
  47151. flushFramebuffer(): void;
  47152. private _startRenderTargetRenderPass;
  47153. private _endRenderTargetRenderPass;
  47154. private _getCurrentRenderPass;
  47155. private _startMainRenderPass;
  47156. private _endMainRenderPass;
  47157. /**
  47158. * Restores the WebGPU state to only draw on the main color attachment
  47159. */
  47160. restoreSingleAttachment(): void;
  47161. /**
  47162. * Creates a layout object to draw/clear on specific textures in a MRT
  47163. * @param textureStatus textureStatus[i] indicates if the i-th is active
  47164. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  47165. */
  47166. buildTextureLayout(textureStatus: boolean[]): number[];
  47167. /**
  47168. * Select a subsets of attachments to draw to.
  47169. * @param attachments index of attachments
  47170. */
  47171. bindAttachments(attachments: number[]): void;
  47172. /**
  47173. * Binds the frame buffer to the specified texture.
  47174. * @param texture The texture to render to or null for the default canvas
  47175. * @param faceIndex The face of the texture to render to in case of cube texture
  47176. * @param requiredWidth The width of the target to render to
  47177. * @param requiredHeight The height of the target to render to
  47178. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47179. * @param lodLevel defines the lod level to bind to the frame buffer
  47180. * @param layer defines the 2d array index to bind to frame buffer to
  47181. */
  47182. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  47183. /**
  47184. * Unbind the current render target texture from the WebGPU context
  47185. * @param texture defines the render target texture to unbind
  47186. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47187. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47188. */
  47189. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47190. /**
  47191. * Unbind a list of render target textures from the WebGPU context
  47192. * @param textures defines the render target textures to unbind
  47193. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47194. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47195. */
  47196. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47197. /**
  47198. * Unbind the current render target and bind the default framebuffer
  47199. */
  47200. restoreDefaultFramebuffer(): void;
  47201. setZOffset(value: number): void;
  47202. private _setColorFormat;
  47203. private _setDepthTextureFormat;
  47204. setDepthBuffer(enable: boolean): void;
  47205. setDepthWrite(enable: boolean): void;
  47206. setStencilBuffer(enable: boolean): void;
  47207. setStencilMask(mask: number): void;
  47208. setStencilFunction(stencilFunc: number): void;
  47209. setStencilFunctionReference(reference: number): void;
  47210. setStencilFunctionMask(mask: number): void;
  47211. setStencilOperationFail(operation: number): void;
  47212. setStencilOperationDepthFail(operation: number): void;
  47213. setStencilOperationPass(operation: number): void;
  47214. setDitheringState(value: boolean): void;
  47215. setRasterizerState(value: boolean): void;
  47216. setDepthFunction(depthFunc: number): void;
  47217. setDepthFunctionToGreater(): void;
  47218. setDepthFunctionToGreaterOrEqual(): void;
  47219. setDepthFunctionToLess(): void;
  47220. setDepthFunctionToLessOrEqual(): void;
  47221. /**
  47222. * Set various states to the context
  47223. * @param culling defines backface culling state
  47224. * @param zOffset defines the value to apply to zOffset (0 by default)
  47225. * @param force defines if states must be applied even if cache is up to date
  47226. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47227. */
  47228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47229. /**
  47230. * Sets the current alpha mode
  47231. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47232. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47234. */
  47235. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47236. /**
  47237. * Sets the current alpha equation
  47238. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  47239. */
  47240. setAlphaEquation(equation: number): void;
  47241. private _getBindGroupsToRender;
  47242. private _bindVertexInputs;
  47243. private _setRenderBindGroups;
  47244. private _setRenderPipeline;
  47245. /**
  47246. * Draw a list of indexed primitives
  47247. * @param fillMode defines the primitive to use
  47248. * @param indexStart defines the starting index
  47249. * @param indexCount defines the number of index to draw
  47250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47251. */
  47252. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47253. /**
  47254. * Draw a list of unindexed primitives
  47255. * @param fillMode defines the primitive to use
  47256. * @param verticesStart defines the index of first vertex to draw
  47257. * @param verticesCount defines the count of vertices to draw
  47258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47259. */
  47260. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47261. private _bundleEncoder;
  47262. /**
  47263. * Start recording all the gpu calls into a bundle.
  47264. */
  47265. startRecordBundle(): void;
  47266. /**
  47267. * Stops recording the bundle.
  47268. * @returns the recorded bundle
  47269. */
  47270. stopRecordBundle(): GPURenderBundle;
  47271. /**
  47272. * Execute the previously recorded bundle.
  47273. * @param bundles defines the bundle to replay
  47274. */
  47275. executeBundles(bundles: GPURenderBundle[]): void;
  47276. /**
  47277. * Dispose and release all associated resources
  47278. */
  47279. dispose(): void;
  47280. /**
  47281. * Gets the current render width
  47282. * @param useScreen defines if screen size must be used (or the current render target if any)
  47283. * @returns a number defining the current render width
  47284. */
  47285. getRenderWidth(useScreen?: boolean): number;
  47286. /**
  47287. * Gets the current render height
  47288. * @param useScreen defines if screen size must be used (or the current render target if any)
  47289. * @returns a number defining the current render height
  47290. */
  47291. getRenderHeight(useScreen?: boolean): number;
  47292. /**
  47293. * Gets the HTML canvas attached with the current WebGPU context
  47294. * @returns a HTML canvas
  47295. */
  47296. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  47297. /** @hidden */
  47298. _debugPushGroup(groupName: string, targetObject?: number): void;
  47299. /** @hidden */
  47300. _debugPopGroup(targetObject?: number): void;
  47301. /** @hidden */
  47302. _debugInsertMarker(text: string, targetObject?: number): void;
  47303. private _debugFlushPendingCommands;
  47304. /**
  47305. * Get the current error code of the WebGPU context
  47306. * @returns the error code
  47307. */
  47308. getError(): number;
  47309. /** @hidden */
  47310. bindSamplers(effect: Effect): void;
  47311. /** @hidden */
  47312. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  47313. /** @hidden */
  47314. _releaseFramebufferObjects(texture: InternalTexture): void;
  47315. /** @hidden */
  47316. applyStates(): void;
  47317. /**
  47318. * Gets a boolean indicating if all created effects are ready
  47319. * @returns always true - No parallel shader compilation
  47320. */
  47321. areAllEffectsReady(): boolean;
  47322. /** @hidden */
  47323. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47324. /** @hidden */
  47325. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47326. /** @hidden */
  47327. _getUnpackAlignement(): number;
  47328. /** @hidden */
  47329. _unpackFlipY(value: boolean): void;
  47330. /** @hidden */
  47331. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  47332. min: number;
  47333. mag: number;
  47334. };
  47335. /** @hidden */
  47336. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47337. /** @hidden */
  47338. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47339. /** @hidden */
  47340. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47341. /** @hidden */
  47342. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47343. /** @hidden */
  47344. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47345. /** @hidden */
  47346. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47347. /** @hidden */
  47348. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  47349. /** @hidden */
  47350. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  47351. /** @hidden */
  47352. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  47353. /** @hidden */
  47354. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  47355. /** @hidden */
  47356. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  47357. /** @hidden */
  47358. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47359. /** @hidden */
  47360. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47361. /** @hidden */
  47362. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  47363. /** @hidden */
  47364. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  47365. /** @hidden */
  47366. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  47367. /** @hidden */
  47368. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  47369. }
  47370. }
  47371. declare module "babylonjs/scene" {
  47372. import { Nullable } from "babylonjs/types";
  47373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47374. import { Observable } from "babylonjs/Misc/observable";
  47375. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47376. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  47377. import { Geometry } from "babylonjs/Meshes/geometry";
  47378. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47381. import { Mesh } from "babylonjs/Meshes/mesh";
  47382. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47383. import { Bone } from "babylonjs/Bones/bone";
  47384. import { Skeleton } from "babylonjs/Bones/skeleton";
  47385. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  47386. import { Camera } from "babylonjs/Cameras/camera";
  47387. import { AbstractScene } from "babylonjs/abstractScene";
  47388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47390. import { Material } from "babylonjs/Materials/material";
  47391. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47392. import { Effect } from "babylonjs/Materials/effect";
  47393. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47394. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  47395. import { Light } from "babylonjs/Lights/light";
  47396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47397. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  47398. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  47399. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  47400. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  47401. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  47402. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  47403. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  47404. import { Engine } from "babylonjs/Engines/engine";
  47405. import { Node } from "babylonjs/node";
  47406. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  47407. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  47408. import { WebRequest } from "babylonjs/Misc/webRequest";
  47409. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  47410. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  47411. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47412. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  47413. import { Plane } from "babylonjs/Maths/math.plane";
  47414. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  47415. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  47416. import { Ray } from "babylonjs/Culling/ray";
  47417. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  47418. import { Animation } from "babylonjs/Animations/animation";
  47419. import { Animatable } from "babylonjs/Animations/animatable";
  47420. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47421. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  47422. import { Collider } from "babylonjs/Collisions/collider";
  47423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47424. /**
  47425. * Define an interface for all classes that will hold resources
  47426. */
  47427. export interface IDisposable {
  47428. /**
  47429. * Releases all held resources
  47430. */
  47431. dispose(): void;
  47432. }
  47433. /** Interface defining initialization parameters for Scene class */
  47434. export interface SceneOptions {
  47435. /**
  47436. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  47437. * It will improve performance when the number of geometries becomes important.
  47438. */
  47439. useGeometryUniqueIdsMap?: boolean;
  47440. /**
  47441. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  47442. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47443. */
  47444. useMaterialMeshMap?: boolean;
  47445. /**
  47446. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  47447. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47448. */
  47449. useClonedMeshMap?: boolean;
  47450. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  47451. virtual?: boolean;
  47452. }
  47453. /**
  47454. * Represents a scene to be rendered by the engine.
  47455. * @see https://doc.babylonjs.com/features/scene
  47456. */
  47457. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  47458. /** The fog is deactivated */
  47459. static readonly FOGMODE_NONE: number;
  47460. /** The fog density is following an exponential function */
  47461. static readonly FOGMODE_EXP: number;
  47462. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  47463. static readonly FOGMODE_EXP2: number;
  47464. /** The fog density is following a linear function. */
  47465. static readonly FOGMODE_LINEAR: number;
  47466. /**
  47467. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  47468. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47469. */
  47470. static MinDeltaTime: number;
  47471. /**
  47472. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  47473. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47474. */
  47475. static MaxDeltaTime: number;
  47476. /**
  47477. * Factory used to create the default material.
  47478. * @param name The name of the material to create
  47479. * @param scene The scene to create the material for
  47480. * @returns The default material
  47481. */
  47482. static DefaultMaterialFactory(scene: Scene): Material;
  47483. /**
  47484. * Factory used to create the a collision coordinator.
  47485. * @returns The collision coordinator
  47486. */
  47487. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  47488. /** @hidden */
  47489. _inputManager: InputManager;
  47490. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  47491. cameraToUseForPointers: Nullable<Camera>;
  47492. /** @hidden */
  47493. readonly _isScene: boolean;
  47494. /** @hidden */
  47495. _blockEntityCollection: boolean;
  47496. /**
  47497. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  47498. */
  47499. autoClear: boolean;
  47500. /**
  47501. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  47502. */
  47503. autoClearDepthAndStencil: boolean;
  47504. /**
  47505. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  47506. */
  47507. clearColor: Color4;
  47508. /**
  47509. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  47510. */
  47511. ambientColor: Color3;
  47512. /**
  47513. * This is use to store the default BRDF lookup for PBR materials in your scene.
  47514. * It should only be one of the following (if not the default embedded one):
  47515. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47516. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  47517. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47518. * The material properties need to be setup according to the type of texture in use.
  47519. */
  47520. environmentBRDFTexture: BaseTexture;
  47521. /**
  47522. * Texture used in all pbr material as the reflection texture.
  47523. * As in the majority of the scene they are the same (exception for multi room and so on),
  47524. * this is easier to reference from here than from all the materials.
  47525. */
  47526. get environmentTexture(): Nullable<BaseTexture>;
  47527. /**
  47528. * Texture used in all pbr material as the reflection texture.
  47529. * As in the majority of the scene they are the same (exception for multi room and so on),
  47530. * this is easier to set here than in all the materials.
  47531. */
  47532. set environmentTexture(value: Nullable<BaseTexture>);
  47533. /** @hidden */
  47534. protected _environmentIntensity: number;
  47535. /**
  47536. * Intensity of the environment in all pbr material.
  47537. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47538. * As in the majority of the scene they are the same (exception for multi room and so on),
  47539. * this is easier to reference from here than from all the materials.
  47540. */
  47541. get environmentIntensity(): number;
  47542. /**
  47543. * Intensity of the environment in all pbr material.
  47544. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47545. * As in the majority of the scene they are the same (exception for multi room and so on),
  47546. * this is easier to set here than in all the materials.
  47547. */
  47548. set environmentIntensity(value: number);
  47549. /** @hidden */
  47550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47551. /**
  47552. * Default image processing configuration used either in the rendering
  47553. * Forward main pass or through the imageProcessingPostProcess if present.
  47554. * As in the majority of the scene they are the same (exception for multi camera),
  47555. * this is easier to reference from here than from all the materials and post process.
  47556. *
  47557. * No setter as we it is a shared configuration, you can set the values instead.
  47558. */
  47559. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47560. private _forceWireframe;
  47561. /**
  47562. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  47563. */
  47564. set forceWireframe(value: boolean);
  47565. get forceWireframe(): boolean;
  47566. private _skipFrustumClipping;
  47567. /**
  47568. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  47569. */
  47570. set skipFrustumClipping(value: boolean);
  47571. get skipFrustumClipping(): boolean;
  47572. private _forcePointsCloud;
  47573. /**
  47574. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  47575. */
  47576. set forcePointsCloud(value: boolean);
  47577. get forcePointsCloud(): boolean;
  47578. /**
  47579. * Gets or sets the active clipplane 1
  47580. */
  47581. clipPlane: Nullable<Plane>;
  47582. /**
  47583. * Gets or sets the active clipplane 2
  47584. */
  47585. clipPlane2: Nullable<Plane>;
  47586. /**
  47587. * Gets or sets the active clipplane 3
  47588. */
  47589. clipPlane3: Nullable<Plane>;
  47590. /**
  47591. * Gets or sets the active clipplane 4
  47592. */
  47593. clipPlane4: Nullable<Plane>;
  47594. /**
  47595. * Gets or sets the active clipplane 5
  47596. */
  47597. clipPlane5: Nullable<Plane>;
  47598. /**
  47599. * Gets or sets the active clipplane 6
  47600. */
  47601. clipPlane6: Nullable<Plane>;
  47602. /**
  47603. * Gets or sets a boolean indicating if animations are enabled
  47604. */
  47605. animationsEnabled: boolean;
  47606. private _animationPropertiesOverride;
  47607. /**
  47608. * Gets or sets the animation properties override
  47609. */
  47610. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47611. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47612. /**
  47613. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47614. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47615. */
  47616. useConstantAnimationDeltaTime: boolean;
  47617. /**
  47618. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47619. * Please note that it requires to run a ray cast through the scene on every frame
  47620. */
  47621. constantlyUpdateMeshUnderPointer: boolean;
  47622. /**
  47623. * Defines the HTML cursor to use when hovering over interactive elements
  47624. */
  47625. hoverCursor: string;
  47626. /**
  47627. * Defines the HTML default cursor to use (empty by default)
  47628. */
  47629. defaultCursor: string;
  47630. /**
  47631. * Defines whether cursors are handled by the scene.
  47632. */
  47633. doNotHandleCursors: boolean;
  47634. /**
  47635. * This is used to call preventDefault() on pointer down
  47636. * in order to block unwanted artifacts like system double clicks
  47637. */
  47638. preventDefaultOnPointerDown: boolean;
  47639. /**
  47640. * This is used to call preventDefault() on pointer up
  47641. * in order to block unwanted artifacts like system double clicks
  47642. */
  47643. preventDefaultOnPointerUp: boolean;
  47644. /**
  47645. * Gets or sets user defined metadata
  47646. */
  47647. metadata: any;
  47648. /**
  47649. * For internal use only. Please do not use.
  47650. */
  47651. reservedDataStore: any;
  47652. /**
  47653. * Gets the name of the plugin used to load this scene (null by default)
  47654. */
  47655. loadingPluginName: string;
  47656. /**
  47657. * Use this array to add regular expressions used to disable offline support for specific urls
  47658. */
  47659. disableOfflineSupportExceptionRules: RegExp[];
  47660. /**
  47661. * An event triggered when the scene is disposed.
  47662. */
  47663. onDisposeObservable: Observable<Scene>;
  47664. private _onDisposeObserver;
  47665. /** Sets a function to be executed when this scene is disposed. */
  47666. set onDispose(callback: () => void);
  47667. /**
  47668. * An event triggered before rendering the scene (right after animations and physics)
  47669. */
  47670. onBeforeRenderObservable: Observable<Scene>;
  47671. private _onBeforeRenderObserver;
  47672. /** Sets a function to be executed before rendering this scene */
  47673. set beforeRender(callback: Nullable<() => void>);
  47674. /**
  47675. * An event triggered after rendering the scene
  47676. */
  47677. onAfterRenderObservable: Observable<Scene>;
  47678. /**
  47679. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47680. */
  47681. onAfterRenderCameraObservable: Observable<Camera>;
  47682. private _onAfterRenderObserver;
  47683. /** Sets a function to be executed after rendering this scene */
  47684. set afterRender(callback: Nullable<() => void>);
  47685. /**
  47686. * An event triggered before animating the scene
  47687. */
  47688. onBeforeAnimationsObservable: Observable<Scene>;
  47689. /**
  47690. * An event triggered after animations processing
  47691. */
  47692. onAfterAnimationsObservable: Observable<Scene>;
  47693. /**
  47694. * An event triggered before draw calls are ready to be sent
  47695. */
  47696. onBeforeDrawPhaseObservable: Observable<Scene>;
  47697. /**
  47698. * An event triggered after draw calls have been sent
  47699. */
  47700. onAfterDrawPhaseObservable: Observable<Scene>;
  47701. /**
  47702. * An event triggered when the scene is ready
  47703. */
  47704. onReadyObservable: Observable<Scene>;
  47705. /**
  47706. * An event triggered before rendering a camera
  47707. */
  47708. onBeforeCameraRenderObservable: Observable<Camera>;
  47709. private _onBeforeCameraRenderObserver;
  47710. /** Sets a function to be executed before rendering a camera*/
  47711. set beforeCameraRender(callback: () => void);
  47712. /**
  47713. * An event triggered after rendering a camera
  47714. */
  47715. onAfterCameraRenderObservable: Observable<Camera>;
  47716. private _onAfterCameraRenderObserver;
  47717. /** Sets a function to be executed after rendering a camera*/
  47718. set afterCameraRender(callback: () => void);
  47719. /**
  47720. * An event triggered when active meshes evaluation is about to start
  47721. */
  47722. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47723. /**
  47724. * An event triggered when active meshes evaluation is done
  47725. */
  47726. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47727. /**
  47728. * An event triggered when particles rendering is about to start
  47729. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47730. */
  47731. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47732. /**
  47733. * An event triggered when particles rendering is done
  47734. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47735. */
  47736. onAfterParticlesRenderingObservable: Observable<Scene>;
  47737. /**
  47738. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47739. */
  47740. onDataLoadedObservable: Observable<Scene>;
  47741. /**
  47742. * An event triggered when a camera is created
  47743. */
  47744. onNewCameraAddedObservable: Observable<Camera>;
  47745. /**
  47746. * An event triggered when a camera is removed
  47747. */
  47748. onCameraRemovedObservable: Observable<Camera>;
  47749. /**
  47750. * An event triggered when a light is created
  47751. */
  47752. onNewLightAddedObservable: Observable<Light>;
  47753. /**
  47754. * An event triggered when a light is removed
  47755. */
  47756. onLightRemovedObservable: Observable<Light>;
  47757. /**
  47758. * An event triggered when a geometry is created
  47759. */
  47760. onNewGeometryAddedObservable: Observable<Geometry>;
  47761. /**
  47762. * An event triggered when a geometry is removed
  47763. */
  47764. onGeometryRemovedObservable: Observable<Geometry>;
  47765. /**
  47766. * An event triggered when a transform node is created
  47767. */
  47768. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47769. /**
  47770. * An event triggered when a transform node is removed
  47771. */
  47772. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47773. /**
  47774. * An event triggered when a mesh is created
  47775. */
  47776. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47777. /**
  47778. * An event triggered when a mesh is removed
  47779. */
  47780. onMeshRemovedObservable: Observable<AbstractMesh>;
  47781. /**
  47782. * An event triggered when a skeleton is created
  47783. */
  47784. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47785. /**
  47786. * An event triggered when a skeleton is removed
  47787. */
  47788. onSkeletonRemovedObservable: Observable<Skeleton>;
  47789. /**
  47790. * An event triggered when a material is created
  47791. */
  47792. onNewMaterialAddedObservable: Observable<Material>;
  47793. /**
  47794. * An event triggered when a multi material is created
  47795. */
  47796. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47797. /**
  47798. * An event triggered when a material is removed
  47799. */
  47800. onMaterialRemovedObservable: Observable<Material>;
  47801. /**
  47802. * An event triggered when a multi material is removed
  47803. */
  47804. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47805. /**
  47806. * An event triggered when a texture is created
  47807. */
  47808. onNewTextureAddedObservable: Observable<BaseTexture>;
  47809. /**
  47810. * An event triggered when a texture is removed
  47811. */
  47812. onTextureRemovedObservable: Observable<BaseTexture>;
  47813. /**
  47814. * An event triggered when render targets are about to be rendered
  47815. * Can happen multiple times per frame.
  47816. */
  47817. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47818. /**
  47819. * An event triggered when render targets were rendered.
  47820. * Can happen multiple times per frame.
  47821. */
  47822. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47823. /**
  47824. * An event triggered before calculating deterministic simulation step
  47825. */
  47826. onBeforeStepObservable: Observable<Scene>;
  47827. /**
  47828. * An event triggered after calculating deterministic simulation step
  47829. */
  47830. onAfterStepObservable: Observable<Scene>;
  47831. /**
  47832. * An event triggered when the activeCamera property is updated
  47833. */
  47834. onActiveCameraChanged: Observable<Scene>;
  47835. /**
  47836. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47837. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47838. * 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)
  47839. */
  47840. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47841. /**
  47842. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47843. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47844. * 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)
  47845. */
  47846. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47847. /**
  47848. * This Observable will when a mesh has been imported into the scene.
  47849. */
  47850. onMeshImportedObservable: Observable<AbstractMesh>;
  47851. /**
  47852. * This Observable will when an animation file has been imported into the scene.
  47853. */
  47854. onAnimationFileImportedObservable: Observable<Scene>;
  47855. /**
  47856. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47857. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47858. */
  47859. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47860. /** @hidden */
  47861. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47862. /**
  47863. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47864. */
  47865. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47866. /**
  47867. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47868. */
  47869. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47870. /**
  47871. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47872. */
  47873. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47874. /** Callback called when a pointer move is detected */
  47875. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47876. /** Callback called when a pointer down is detected */
  47877. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47878. /** Callback called when a pointer up is detected */
  47879. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47880. /** Callback called when a pointer pick is detected */
  47881. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  47882. /**
  47883. * 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).
  47884. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47885. */
  47886. onPrePointerObservable: Observable<PointerInfoPre>;
  47887. /**
  47888. * Observable event triggered each time an input event is received from the rendering canvas
  47889. */
  47890. onPointerObservable: Observable<PointerInfo>;
  47891. /**
  47892. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47893. */
  47894. get unTranslatedPointer(): Vector2;
  47895. /**
  47896. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47897. */
  47898. static get DragMovementThreshold(): number;
  47899. static set DragMovementThreshold(value: number);
  47900. /**
  47901. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47902. */
  47903. static get LongPressDelay(): number;
  47904. static set LongPressDelay(value: number);
  47905. /**
  47906. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47907. */
  47908. static get DoubleClickDelay(): number;
  47909. static set DoubleClickDelay(value: number);
  47910. /** If you need to check double click without raising a single click at first click, enable this flag */
  47911. static get ExclusiveDoubleClickMode(): boolean;
  47912. static set ExclusiveDoubleClickMode(value: boolean);
  47913. /** @hidden */
  47914. _mirroredCameraPosition: Nullable<Vector3>;
  47915. /**
  47916. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47917. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47918. */
  47919. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47920. /**
  47921. * Observable event triggered each time an keyboard event is received from the hosting window
  47922. */
  47923. onKeyboardObservable: Observable<KeyboardInfo>;
  47924. private _useRightHandedSystem;
  47925. /**
  47926. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47927. */
  47928. set useRightHandedSystem(value: boolean);
  47929. get useRightHandedSystem(): boolean;
  47930. private _timeAccumulator;
  47931. private _currentStepId;
  47932. private _currentInternalStep;
  47933. /**
  47934. * Sets the step Id used by deterministic lock step
  47935. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47936. * @param newStepId defines the step Id
  47937. */
  47938. setStepId(newStepId: number): void;
  47939. /**
  47940. * Gets the step Id used by deterministic lock step
  47941. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47942. * @returns the step Id
  47943. */
  47944. getStepId(): number;
  47945. /**
  47946. * Gets the internal step used by deterministic lock step
  47947. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47948. * @returns the internal step
  47949. */
  47950. getInternalStep(): number;
  47951. private _fogEnabled;
  47952. /**
  47953. * Gets or sets a boolean indicating if fog is enabled on this scene
  47954. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47955. * (Default is true)
  47956. */
  47957. set fogEnabled(value: boolean);
  47958. get fogEnabled(): boolean;
  47959. private _fogMode;
  47960. /**
  47961. * Gets or sets the fog mode to use
  47962. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47963. * | mode | value |
  47964. * | --- | --- |
  47965. * | FOGMODE_NONE | 0 |
  47966. * | FOGMODE_EXP | 1 |
  47967. * | FOGMODE_EXP2 | 2 |
  47968. * | FOGMODE_LINEAR | 3 |
  47969. */
  47970. set fogMode(value: number);
  47971. get fogMode(): number;
  47972. /**
  47973. * Gets or sets the fog color to use
  47974. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47975. * (Default is Color3(0.2, 0.2, 0.3))
  47976. */
  47977. fogColor: Color3;
  47978. /**
  47979. * Gets or sets the fog density to use
  47980. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47981. * (Default is 0.1)
  47982. */
  47983. fogDensity: number;
  47984. /**
  47985. * Gets or sets the fog start distance to use
  47986. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47987. * (Default is 0)
  47988. */
  47989. fogStart: number;
  47990. /**
  47991. * Gets or sets the fog end distance to use
  47992. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47993. * (Default is 1000)
  47994. */
  47995. fogEnd: number;
  47996. /**
  47997. * Flag indicating that the frame buffer binding is handled by another component
  47998. */
  47999. prePass: boolean;
  48000. private _shadowsEnabled;
  48001. /**
  48002. * Gets or sets a boolean indicating if shadows are enabled on this scene
  48003. */
  48004. set shadowsEnabled(value: boolean);
  48005. get shadowsEnabled(): boolean;
  48006. private _lightsEnabled;
  48007. /**
  48008. * Gets or sets a boolean indicating if lights are enabled on this scene
  48009. */
  48010. set lightsEnabled(value: boolean);
  48011. get lightsEnabled(): boolean;
  48012. /** All of the active cameras added to this scene. */
  48013. activeCameras: Nullable<Camera[]>;
  48014. /** @hidden */
  48015. _activeCamera: Nullable<Camera>;
  48016. /** Gets or sets the current active camera */
  48017. get activeCamera(): Nullable<Camera>;
  48018. set activeCamera(value: Nullable<Camera>);
  48019. private _defaultMaterial;
  48020. /** The default material used on meshes when no material is affected */
  48021. get defaultMaterial(): Material;
  48022. /** The default material used on meshes when no material is affected */
  48023. set defaultMaterial(value: Material);
  48024. private _texturesEnabled;
  48025. /**
  48026. * Gets or sets a boolean indicating if textures are enabled on this scene
  48027. */
  48028. set texturesEnabled(value: boolean);
  48029. get texturesEnabled(): boolean;
  48030. /**
  48031. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  48032. */
  48033. physicsEnabled: boolean;
  48034. /**
  48035. * Gets or sets a boolean indicating if particles are enabled on this scene
  48036. */
  48037. particlesEnabled: boolean;
  48038. /**
  48039. * Gets or sets a boolean indicating if sprites are enabled on this scene
  48040. */
  48041. spritesEnabled: boolean;
  48042. private _skeletonsEnabled;
  48043. /**
  48044. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  48045. */
  48046. set skeletonsEnabled(value: boolean);
  48047. get skeletonsEnabled(): boolean;
  48048. /**
  48049. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  48050. */
  48051. lensFlaresEnabled: boolean;
  48052. /**
  48053. * Gets or sets a boolean indicating if collisions are enabled on this scene
  48054. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48055. */
  48056. collisionsEnabled: boolean;
  48057. private _collisionCoordinator;
  48058. /** @hidden */
  48059. get collisionCoordinator(): ICollisionCoordinator;
  48060. /**
  48061. * Defines the gravity applied to this scene (used only for collisions)
  48062. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48063. */
  48064. gravity: Vector3;
  48065. /**
  48066. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  48067. */
  48068. postProcessesEnabled: boolean;
  48069. /**
  48070. * Gets the current postprocess manager
  48071. */
  48072. postProcessManager: PostProcessManager;
  48073. /**
  48074. * Gets or sets a boolean indicating if render targets are enabled on this scene
  48075. */
  48076. renderTargetsEnabled: boolean;
  48077. /**
  48078. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  48079. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  48080. */
  48081. dumpNextRenderTargets: boolean;
  48082. /**
  48083. * The list of user defined render targets added to the scene
  48084. */
  48085. customRenderTargets: RenderTargetTexture[];
  48086. /**
  48087. * Defines if texture loading must be delayed
  48088. * If true, textures will only be loaded when they need to be rendered
  48089. */
  48090. useDelayedTextureLoading: boolean;
  48091. /**
  48092. * Gets the list of meshes imported to the scene through SceneLoader
  48093. */
  48094. importedMeshesFiles: String[];
  48095. /**
  48096. * Gets or sets a boolean indicating if probes are enabled on this scene
  48097. */
  48098. probesEnabled: boolean;
  48099. /**
  48100. * Gets or sets the current offline provider to use to store scene data
  48101. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48102. */
  48103. offlineProvider: IOfflineProvider;
  48104. /**
  48105. * Gets or sets the action manager associated with the scene
  48106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48107. */
  48108. actionManager: AbstractActionManager;
  48109. private _meshesForIntersections;
  48110. /**
  48111. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  48112. */
  48113. proceduralTexturesEnabled: boolean;
  48114. private _engine;
  48115. private _totalVertices;
  48116. /** @hidden */
  48117. _activeIndices: PerfCounter;
  48118. /** @hidden */
  48119. _activeParticles: PerfCounter;
  48120. /** @hidden */
  48121. _activeBones: PerfCounter;
  48122. private _animationRatio;
  48123. /** @hidden */
  48124. _animationTimeLast: number;
  48125. /** @hidden */
  48126. _animationTime: number;
  48127. /**
  48128. * Gets or sets a general scale for animation speed
  48129. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  48130. */
  48131. animationTimeScale: number;
  48132. /** @hidden */
  48133. _cachedMaterial: Nullable<Material>;
  48134. /** @hidden */
  48135. _cachedEffect: Nullable<Effect>;
  48136. /** @hidden */
  48137. _cachedVisibility: Nullable<number>;
  48138. private _renderId;
  48139. private _frameId;
  48140. private _executeWhenReadyTimeoutId;
  48141. private _intermediateRendering;
  48142. private _viewUpdateFlag;
  48143. private _projectionUpdateFlag;
  48144. /** @hidden */
  48145. _toBeDisposed: Nullable<IDisposable>[];
  48146. private _activeRequests;
  48147. /** @hidden */
  48148. _pendingData: any[];
  48149. private _isDisposed;
  48150. /**
  48151. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  48152. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  48153. */
  48154. dispatchAllSubMeshesOfActiveMeshes: boolean;
  48155. private _activeMeshes;
  48156. private _processedMaterials;
  48157. private _renderTargets;
  48158. /** @hidden */
  48159. _activeParticleSystems: SmartArray<IParticleSystem>;
  48160. private _activeSkeletons;
  48161. private _softwareSkinnedMeshes;
  48162. private _renderingManager;
  48163. /** @hidden */
  48164. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  48165. private _transformMatrix;
  48166. private _sceneUbo;
  48167. /** @hidden */
  48168. _viewMatrix: Matrix;
  48169. /** @hidden */
  48170. _projectionMatrix: Matrix;
  48171. /** @hidden */
  48172. _forcedViewPosition: Nullable<Vector3>;
  48173. /** @hidden */
  48174. _frustumPlanes: Plane[];
  48175. /**
  48176. * Gets the list of frustum planes (built from the active camera)
  48177. */
  48178. get frustumPlanes(): Plane[];
  48179. /**
  48180. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  48181. * This is useful if there are more lights that the maximum simulteanous authorized
  48182. */
  48183. requireLightSorting: boolean;
  48184. /** @hidden */
  48185. readonly useMaterialMeshMap: boolean;
  48186. /** @hidden */
  48187. readonly useClonedMeshMap: boolean;
  48188. private _externalData;
  48189. private _uid;
  48190. /**
  48191. * @hidden
  48192. * Backing store of defined scene components.
  48193. */
  48194. _components: ISceneComponent[];
  48195. /**
  48196. * @hidden
  48197. * Backing store of defined scene components.
  48198. */
  48199. _serializableComponents: ISceneSerializableComponent[];
  48200. /**
  48201. * List of components to register on the next registration step.
  48202. */
  48203. private _transientComponents;
  48204. /**
  48205. * Registers the transient components if needed.
  48206. */
  48207. private _registerTransientComponents;
  48208. /**
  48209. * @hidden
  48210. * Add a component to the scene.
  48211. * Note that the ccomponent could be registered on th next frame if this is called after
  48212. * the register component stage.
  48213. * @param component Defines the component to add to the scene
  48214. */
  48215. _addComponent(component: ISceneComponent): void;
  48216. /**
  48217. * @hidden
  48218. * Gets a component from the scene.
  48219. * @param name defines the name of the component to retrieve
  48220. * @returns the component or null if not present
  48221. */
  48222. _getComponent(name: string): Nullable<ISceneComponent>;
  48223. /**
  48224. * @hidden
  48225. * Defines the actions happening before camera updates.
  48226. */
  48227. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  48228. /**
  48229. * @hidden
  48230. * Defines the actions happening before clear the canvas.
  48231. */
  48232. _beforeClearStage: Stage<SimpleStageAction>;
  48233. /**
  48234. * @hidden
  48235. * Defines the actions when collecting render targets for the frame.
  48236. */
  48237. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48238. /**
  48239. * @hidden
  48240. * Defines the actions happening for one camera in the frame.
  48241. */
  48242. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48243. /**
  48244. * @hidden
  48245. * Defines the actions happening during the per mesh ready checks.
  48246. */
  48247. _isReadyForMeshStage: Stage<MeshStageAction>;
  48248. /**
  48249. * @hidden
  48250. * Defines the actions happening before evaluate active mesh checks.
  48251. */
  48252. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  48253. /**
  48254. * @hidden
  48255. * Defines the actions happening during the evaluate sub mesh checks.
  48256. */
  48257. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  48258. /**
  48259. * @hidden
  48260. * Defines the actions happening during the active mesh stage.
  48261. */
  48262. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  48263. /**
  48264. * @hidden
  48265. * Defines the actions happening during the per camera render target step.
  48266. */
  48267. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  48268. /**
  48269. * @hidden
  48270. * Defines the actions happening just before the active camera is drawing.
  48271. */
  48272. _beforeCameraDrawStage: Stage<CameraStageAction>;
  48273. /**
  48274. * @hidden
  48275. * Defines the actions happening just before a render target is drawing.
  48276. */
  48277. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48278. /**
  48279. * @hidden
  48280. * Defines the actions happening just before a rendering group is drawing.
  48281. */
  48282. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48283. /**
  48284. * @hidden
  48285. * Defines the actions happening just before a mesh is drawing.
  48286. */
  48287. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48288. /**
  48289. * @hidden
  48290. * Defines the actions happening just after a mesh has been drawn.
  48291. */
  48292. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48293. /**
  48294. * @hidden
  48295. * Defines the actions happening just after a rendering group has been drawn.
  48296. */
  48297. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48298. /**
  48299. * @hidden
  48300. * Defines the actions happening just after the active camera has been drawn.
  48301. */
  48302. _afterCameraDrawStage: Stage<CameraStageAction>;
  48303. /**
  48304. * @hidden
  48305. * Defines the actions happening just after a render target has been drawn.
  48306. */
  48307. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48308. /**
  48309. * @hidden
  48310. * Defines the actions happening just after rendering all cameras and computing intersections.
  48311. */
  48312. _afterRenderStage: Stage<SimpleStageAction>;
  48313. /**
  48314. * @hidden
  48315. * Defines the actions happening when a pointer move event happens.
  48316. */
  48317. _pointerMoveStage: Stage<PointerMoveStageAction>;
  48318. /**
  48319. * @hidden
  48320. * Defines the actions happening when a pointer down event happens.
  48321. */
  48322. _pointerDownStage: Stage<PointerUpDownStageAction>;
  48323. /**
  48324. * @hidden
  48325. * Defines the actions happening when a pointer up event happens.
  48326. */
  48327. _pointerUpStage: Stage<PointerUpDownStageAction>;
  48328. /**
  48329. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  48330. */
  48331. private geometriesByUniqueId;
  48332. private _renderBundles;
  48333. /**
  48334. * Creates a new Scene
  48335. * @param engine defines the engine to use to render this scene
  48336. * @param options defines the scene options
  48337. */
  48338. constructor(engine: Engine, options?: SceneOptions);
  48339. /**
  48340. * Gets a string identifying the name of the class
  48341. * @returns "Scene" string
  48342. */
  48343. getClassName(): string;
  48344. private _defaultMeshCandidates;
  48345. /**
  48346. * @hidden
  48347. */
  48348. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48349. private _defaultSubMeshCandidates;
  48350. /**
  48351. * @hidden
  48352. */
  48353. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48354. /**
  48355. * Sets the default candidate providers for the scene.
  48356. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  48357. * and getCollidingSubMeshCandidates to their default function
  48358. */
  48359. setDefaultCandidateProviders(): void;
  48360. /**
  48361. * Gets the mesh that is currently under the pointer
  48362. */
  48363. get meshUnderPointer(): Nullable<AbstractMesh>;
  48364. /**
  48365. * Gets or sets the current on-screen X position of the pointer
  48366. */
  48367. get pointerX(): number;
  48368. set pointerX(value: number);
  48369. /**
  48370. * Gets or sets the current on-screen Y position of the pointer
  48371. */
  48372. get pointerY(): number;
  48373. set pointerY(value: number);
  48374. /**
  48375. * Gets the cached material (ie. the latest rendered one)
  48376. * @returns the cached material
  48377. */
  48378. getCachedMaterial(): Nullable<Material>;
  48379. /**
  48380. * Gets the cached effect (ie. the latest rendered one)
  48381. * @returns the cached effect
  48382. */
  48383. getCachedEffect(): Nullable<Effect>;
  48384. /**
  48385. * Gets the cached visibility state (ie. the latest rendered one)
  48386. * @returns the cached visibility state
  48387. */
  48388. getCachedVisibility(): Nullable<number>;
  48389. /**
  48390. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  48391. * @param material defines the current material
  48392. * @param effect defines the current effect
  48393. * @param visibility defines the current visibility state
  48394. * @returns true if one parameter is not cached
  48395. */
  48396. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  48397. /**
  48398. * Gets the engine associated with the scene
  48399. * @returns an Engine
  48400. */
  48401. getEngine(): Engine;
  48402. /**
  48403. * Gets the total number of vertices rendered per frame
  48404. * @returns the total number of vertices rendered per frame
  48405. */
  48406. getTotalVertices(): number;
  48407. /**
  48408. * Gets the performance counter for total vertices
  48409. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48410. */
  48411. get totalVerticesPerfCounter(): PerfCounter;
  48412. /**
  48413. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  48414. * @returns the total number of active indices rendered per frame
  48415. */
  48416. getActiveIndices(): number;
  48417. /**
  48418. * Gets the performance counter for active indices
  48419. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48420. */
  48421. get totalActiveIndicesPerfCounter(): PerfCounter;
  48422. /**
  48423. * Gets the total number of active particles rendered per frame
  48424. * @returns the total number of active particles rendered per frame
  48425. */
  48426. getActiveParticles(): number;
  48427. /**
  48428. * Gets the performance counter for active particles
  48429. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48430. */
  48431. get activeParticlesPerfCounter(): PerfCounter;
  48432. /**
  48433. * Gets the total number of active bones rendered per frame
  48434. * @returns the total number of active bones rendered per frame
  48435. */
  48436. getActiveBones(): number;
  48437. /**
  48438. * Gets the performance counter for active bones
  48439. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48440. */
  48441. get activeBonesPerfCounter(): PerfCounter;
  48442. /**
  48443. * Gets the array of active meshes
  48444. * @returns an array of AbstractMesh
  48445. */
  48446. getActiveMeshes(): SmartArray<AbstractMesh>;
  48447. /**
  48448. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  48449. * @returns a number
  48450. */
  48451. getAnimationRatio(): number;
  48452. /**
  48453. * Gets an unique Id for the current render phase
  48454. * @returns a number
  48455. */
  48456. getRenderId(): number;
  48457. /**
  48458. * Gets an unique Id for the current frame
  48459. * @returns a number
  48460. */
  48461. getFrameId(): number;
  48462. /** Call this function if you want to manually increment the render Id*/
  48463. incrementRenderId(): void;
  48464. private _createUbo;
  48465. /**
  48466. * Use this method to simulate a pointer move on a mesh
  48467. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48468. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48469. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48470. * @returns the current scene
  48471. */
  48472. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48473. /**
  48474. * Use this method to simulate a pointer down on a mesh
  48475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48478. * @returns the current scene
  48479. */
  48480. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48481. /**
  48482. * Use this method to simulate a pointer up on a mesh
  48483. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48484. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48485. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48486. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  48487. * @returns the current scene
  48488. */
  48489. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  48490. /**
  48491. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  48492. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  48493. * @returns true if the pointer was captured
  48494. */
  48495. isPointerCaptured(pointerId?: number): boolean;
  48496. /**
  48497. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  48498. * @param attachUp defines if you want to attach events to pointerup
  48499. * @param attachDown defines if you want to attach events to pointerdown
  48500. * @param attachMove defines if you want to attach events to pointermove
  48501. */
  48502. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  48503. /** Detaches all event handlers*/
  48504. detachControl(): void;
  48505. /**
  48506. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  48507. * Delay loaded resources are not taking in account
  48508. * @return true if all required resources are ready
  48509. */
  48510. isReady(): boolean;
  48511. /** Resets all cached information relative to material (including effect and visibility) */
  48512. resetCachedMaterial(): void;
  48513. /**
  48514. * Registers a function to be called before every frame render
  48515. * @param func defines the function to register
  48516. */
  48517. registerBeforeRender(func: () => void): void;
  48518. /**
  48519. * Unregisters a function called before every frame render
  48520. * @param func defines the function to unregister
  48521. */
  48522. unregisterBeforeRender(func: () => void): void;
  48523. /**
  48524. * Registers a function to be called after every frame render
  48525. * @param func defines the function to register
  48526. */
  48527. registerAfterRender(func: () => void): void;
  48528. /**
  48529. * Unregisters a function called after every frame render
  48530. * @param func defines the function to unregister
  48531. */
  48532. unregisterAfterRender(func: () => void): void;
  48533. private _executeOnceBeforeRender;
  48534. /**
  48535. * The provided function will run before render once and will be disposed afterwards.
  48536. * A timeout delay can be provided so that the function will be executed in N ms.
  48537. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  48538. * @param func The function to be executed.
  48539. * @param timeout optional delay in ms
  48540. */
  48541. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  48542. /** @hidden */
  48543. _addPendingData(data: any): void;
  48544. /** @hidden */
  48545. _removePendingData(data: any): void;
  48546. /**
  48547. * Returns the number of items waiting to be loaded
  48548. * @returns the number of items waiting to be loaded
  48549. */
  48550. getWaitingItemsCount(): number;
  48551. /**
  48552. * Returns a boolean indicating if the scene is still loading data
  48553. */
  48554. get isLoading(): boolean;
  48555. /**
  48556. * Registers a function to be executed when the scene is ready
  48557. * @param {Function} func - the function to be executed
  48558. */
  48559. executeWhenReady(func: () => void): void;
  48560. /**
  48561. * Returns a promise that resolves when the scene is ready
  48562. * @returns A promise that resolves when the scene is ready
  48563. */
  48564. whenReadyAsync(): Promise<void>;
  48565. /** @hidden */
  48566. _checkIsReady(): void;
  48567. /**
  48568. * Gets all animatable attached to the scene
  48569. */
  48570. get animatables(): Animatable[];
  48571. /**
  48572. * Resets the last animation time frame.
  48573. * Useful to override when animations start running when loading a scene for the first time.
  48574. */
  48575. resetLastAnimationTimeFrame(): void;
  48576. /**
  48577. * Gets the current view matrix
  48578. * @returns a Matrix
  48579. */
  48580. getViewMatrix(): Matrix;
  48581. /**
  48582. * Gets the current projection matrix
  48583. * @returns a Matrix
  48584. */
  48585. getProjectionMatrix(): Matrix;
  48586. /**
  48587. * Gets the current transform matrix
  48588. * @returns a Matrix made of View * Projection
  48589. */
  48590. getTransformMatrix(): Matrix;
  48591. /**
  48592. * Sets the current transform matrix
  48593. * @param viewL defines the View matrix to use
  48594. * @param projectionL defines the Projection matrix to use
  48595. * @param viewR defines the right View matrix to use (if provided)
  48596. * @param projectionR defines the right Projection matrix to use (if provided)
  48597. */
  48598. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  48599. /**
  48600. * Gets the uniform buffer used to store scene data
  48601. * @returns a UniformBuffer
  48602. */
  48603. getSceneUniformBuffer(): UniformBuffer;
  48604. /**
  48605. * Gets an unique (relatively to the current scene) Id
  48606. * @returns an unique number for the scene
  48607. */
  48608. getUniqueId(): number;
  48609. /**
  48610. * Add a mesh to the list of scene's meshes
  48611. * @param newMesh defines the mesh to add
  48612. * @param recursive if all child meshes should also be added to the scene
  48613. */
  48614. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48615. /**
  48616. * Remove a mesh for the list of scene's meshes
  48617. * @param toRemove defines the mesh to remove
  48618. * @param recursive if all child meshes should also be removed from the scene
  48619. * @returns the index where the mesh was in the mesh list
  48620. */
  48621. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48622. /**
  48623. * Add a transform node to the list of scene's transform nodes
  48624. * @param newTransformNode defines the transform node to add
  48625. */
  48626. addTransformNode(newTransformNode: TransformNode): void;
  48627. /**
  48628. * Remove a transform node for the list of scene's transform nodes
  48629. * @param toRemove defines the transform node to remove
  48630. * @returns the index where the transform node was in the transform node list
  48631. */
  48632. removeTransformNode(toRemove: TransformNode): number;
  48633. /**
  48634. * Remove a skeleton for the list of scene's skeletons
  48635. * @param toRemove defines the skeleton to remove
  48636. * @returns the index where the skeleton was in the skeleton list
  48637. */
  48638. removeSkeleton(toRemove: Skeleton): number;
  48639. /**
  48640. * Remove a morph target for the list of scene's morph targets
  48641. * @param toRemove defines the morph target to remove
  48642. * @returns the index where the morph target was in the morph target list
  48643. */
  48644. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48645. /**
  48646. * Remove a light for the list of scene's lights
  48647. * @param toRemove defines the light to remove
  48648. * @returns the index where the light was in the light list
  48649. */
  48650. removeLight(toRemove: Light): number;
  48651. /**
  48652. * Remove a camera for the list of scene's cameras
  48653. * @param toRemove defines the camera to remove
  48654. * @returns the index where the camera was in the camera list
  48655. */
  48656. removeCamera(toRemove: Camera): number;
  48657. /**
  48658. * Remove a particle system for the list of scene's particle systems
  48659. * @param toRemove defines the particle system to remove
  48660. * @returns the index where the particle system was in the particle system list
  48661. */
  48662. removeParticleSystem(toRemove: IParticleSystem): number;
  48663. /**
  48664. * Remove a animation for the list of scene's animations
  48665. * @param toRemove defines the animation to remove
  48666. * @returns the index where the animation was in the animation list
  48667. */
  48668. removeAnimation(toRemove: Animation): number;
  48669. /**
  48670. * Will stop the animation of the given target
  48671. * @param target - the target
  48672. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48673. * @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)
  48674. */
  48675. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48676. /**
  48677. * Removes the given animation group from this scene.
  48678. * @param toRemove The animation group to remove
  48679. * @returns The index of the removed animation group
  48680. */
  48681. removeAnimationGroup(toRemove: AnimationGroup): number;
  48682. /**
  48683. * Removes the given multi-material from this scene.
  48684. * @param toRemove The multi-material to remove
  48685. * @returns The index of the removed multi-material
  48686. */
  48687. removeMultiMaterial(toRemove: MultiMaterial): number;
  48688. /**
  48689. * Removes the given material from this scene.
  48690. * @param toRemove The material to remove
  48691. * @returns The index of the removed material
  48692. */
  48693. removeMaterial(toRemove: Material): number;
  48694. /**
  48695. * Removes the given action manager from this scene.
  48696. * @param toRemove The action manager to remove
  48697. * @returns The index of the removed action manager
  48698. */
  48699. removeActionManager(toRemove: AbstractActionManager): number;
  48700. /**
  48701. * Removes the given texture from this scene.
  48702. * @param toRemove The texture to remove
  48703. * @returns The index of the removed texture
  48704. */
  48705. removeTexture(toRemove: BaseTexture): number;
  48706. /**
  48707. * Adds the given light to this scene
  48708. * @param newLight The light to add
  48709. */
  48710. addLight(newLight: Light): void;
  48711. /**
  48712. * Sorts the list list based on light priorities
  48713. */
  48714. sortLightsByPriority(): void;
  48715. /**
  48716. * Adds the given camera to this scene
  48717. * @param newCamera The camera to add
  48718. */
  48719. addCamera(newCamera: Camera): void;
  48720. /**
  48721. * Adds the given skeleton to this scene
  48722. * @param newSkeleton The skeleton to add
  48723. */
  48724. addSkeleton(newSkeleton: Skeleton): void;
  48725. /**
  48726. * Adds the given particle system to this scene
  48727. * @param newParticleSystem The particle system to add
  48728. */
  48729. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48730. /**
  48731. * Adds the given animation to this scene
  48732. * @param newAnimation The animation to add
  48733. */
  48734. addAnimation(newAnimation: Animation): void;
  48735. /**
  48736. * Adds the given animation group to this scene.
  48737. * @param newAnimationGroup The animation group to add
  48738. */
  48739. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48740. /**
  48741. * Adds the given multi-material to this scene
  48742. * @param newMultiMaterial The multi-material to add
  48743. */
  48744. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48745. /**
  48746. * Adds the given material to this scene
  48747. * @param newMaterial The material to add
  48748. */
  48749. addMaterial(newMaterial: Material): void;
  48750. /**
  48751. * Adds the given morph target to this scene
  48752. * @param newMorphTargetManager The morph target to add
  48753. */
  48754. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48755. /**
  48756. * Adds the given geometry to this scene
  48757. * @param newGeometry The geometry to add
  48758. */
  48759. addGeometry(newGeometry: Geometry): void;
  48760. /**
  48761. * Adds the given action manager to this scene
  48762. * @param newActionManager The action manager to add
  48763. */
  48764. addActionManager(newActionManager: AbstractActionManager): void;
  48765. /**
  48766. * Adds the given texture to this scene.
  48767. * @param newTexture The texture to add
  48768. */
  48769. addTexture(newTexture: BaseTexture): void;
  48770. /**
  48771. * Switch active camera
  48772. * @param newCamera defines the new active camera
  48773. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48774. */
  48775. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48776. /**
  48777. * sets the active camera of the scene using its ID
  48778. * @param id defines the camera's ID
  48779. * @return the new active camera or null if none found.
  48780. */
  48781. setActiveCameraByID(id: string): Nullable<Camera>;
  48782. /**
  48783. * sets the active camera of the scene using its name
  48784. * @param name defines the camera's name
  48785. * @returns the new active camera or null if none found.
  48786. */
  48787. setActiveCameraByName(name: string): Nullable<Camera>;
  48788. /**
  48789. * get an animation group using its name
  48790. * @param name defines the material's name
  48791. * @return the animation group or null if none found.
  48792. */
  48793. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48794. /**
  48795. * Get a material using its unique id
  48796. * @param uniqueId defines the material's unique id
  48797. * @return the material or null if none found.
  48798. */
  48799. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48800. /**
  48801. * get a material using its id
  48802. * @param id defines the material's ID
  48803. * @return the material or null if none found.
  48804. */
  48805. getMaterialByID(id: string): Nullable<Material>;
  48806. /**
  48807. * Gets a the last added material using a given id
  48808. * @param id defines the material's ID
  48809. * @return the last material with the given id or null if none found.
  48810. */
  48811. getLastMaterialByID(id: string): Nullable<Material>;
  48812. /**
  48813. * Gets a material using its name
  48814. * @param name defines the material's name
  48815. * @return the material or null if none found.
  48816. */
  48817. getMaterialByName(name: string): Nullable<Material>;
  48818. /**
  48819. * Get a texture using its unique id
  48820. * @param uniqueId defines the texture's unique id
  48821. * @return the texture or null if none found.
  48822. */
  48823. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48824. /**
  48825. * Gets a camera using its id
  48826. * @param id defines the id to look for
  48827. * @returns the camera or null if not found
  48828. */
  48829. getCameraByID(id: string): Nullable<Camera>;
  48830. /**
  48831. * Gets a camera using its unique id
  48832. * @param uniqueId defines the unique id to look for
  48833. * @returns the camera or null if not found
  48834. */
  48835. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48836. /**
  48837. * Gets a camera using its name
  48838. * @param name defines the camera's name
  48839. * @return the camera or null if none found.
  48840. */
  48841. getCameraByName(name: string): Nullable<Camera>;
  48842. /**
  48843. * Gets a bone using its id
  48844. * @param id defines the bone's id
  48845. * @return the bone or null if not found
  48846. */
  48847. getBoneByID(id: string): Nullable<Bone>;
  48848. /**
  48849. * Gets a bone using its id
  48850. * @param name defines the bone's name
  48851. * @return the bone or null if not found
  48852. */
  48853. getBoneByName(name: string): Nullable<Bone>;
  48854. /**
  48855. * Gets a light node using its name
  48856. * @param name defines the the light's name
  48857. * @return the light or null if none found.
  48858. */
  48859. getLightByName(name: string): Nullable<Light>;
  48860. /**
  48861. * Gets a light node using its id
  48862. * @param id defines the light's id
  48863. * @return the light or null if none found.
  48864. */
  48865. getLightByID(id: string): Nullable<Light>;
  48866. /**
  48867. * Gets a light node using its scene-generated unique ID
  48868. * @param uniqueId defines the light's unique id
  48869. * @return the light or null if none found.
  48870. */
  48871. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48872. /**
  48873. * Gets a particle system by id
  48874. * @param id defines the particle system id
  48875. * @return the corresponding system or null if none found
  48876. */
  48877. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48878. /**
  48879. * Gets a geometry using its ID
  48880. * @param id defines the geometry's id
  48881. * @return the geometry or null if none found.
  48882. */
  48883. getGeometryByID(id: string): Nullable<Geometry>;
  48884. private _getGeometryByUniqueID;
  48885. /**
  48886. * Add a new geometry to this scene
  48887. * @param geometry defines the geometry to be added to the scene.
  48888. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48889. * @return a boolean defining if the geometry was added or not
  48890. */
  48891. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48892. /**
  48893. * Removes an existing geometry
  48894. * @param geometry defines the geometry to be removed from the scene
  48895. * @return a boolean defining if the geometry was removed or not
  48896. */
  48897. removeGeometry(geometry: Geometry): boolean;
  48898. /**
  48899. * Gets the list of geometries attached to the scene
  48900. * @returns an array of Geometry
  48901. */
  48902. getGeometries(): Geometry[];
  48903. /**
  48904. * Gets the first added mesh found of a given ID
  48905. * @param id defines the id to search for
  48906. * @return the mesh found or null if not found at all
  48907. */
  48908. getMeshByID(id: string): Nullable<AbstractMesh>;
  48909. /**
  48910. * Gets a list of meshes using their id
  48911. * @param id defines the id to search for
  48912. * @returns a list of meshes
  48913. */
  48914. getMeshesByID(id: string): Array<AbstractMesh>;
  48915. /**
  48916. * Gets the first added transform node found of a given ID
  48917. * @param id defines the id to search for
  48918. * @return the found transform node or null if not found at all.
  48919. */
  48920. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48921. /**
  48922. * Gets a transform node with its auto-generated unique id
  48923. * @param uniqueId efines the unique id to search for
  48924. * @return the found transform node or null if not found at all.
  48925. */
  48926. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48927. /**
  48928. * Gets a list of transform nodes using their id
  48929. * @param id defines the id to search for
  48930. * @returns a list of transform nodes
  48931. */
  48932. getTransformNodesByID(id: string): Array<TransformNode>;
  48933. /**
  48934. * Gets a mesh with its auto-generated unique id
  48935. * @param uniqueId defines the unique id to search for
  48936. * @return the found mesh or null if not found at all.
  48937. */
  48938. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48939. /**
  48940. * Gets a the last added mesh using a given id
  48941. * @param id defines the id to search for
  48942. * @return the found mesh or null if not found at all.
  48943. */
  48944. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48945. /**
  48946. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48947. * @param id defines the id to search for
  48948. * @return the found node or null if not found at all
  48949. */
  48950. getLastEntryByID(id: string): Nullable<Node>;
  48951. /**
  48952. * Gets a node (Mesh, Camera, Light) using a given id
  48953. * @param id defines the id to search for
  48954. * @return the found node or null if not found at all
  48955. */
  48956. getNodeByID(id: string): Nullable<Node>;
  48957. /**
  48958. * Gets a node (Mesh, Camera, Light) using a given name
  48959. * @param name defines the name to search for
  48960. * @return the found node or null if not found at all.
  48961. */
  48962. getNodeByName(name: string): Nullable<Node>;
  48963. /**
  48964. * Gets a mesh using a given name
  48965. * @param name defines the name to search for
  48966. * @return the found mesh or null if not found at all.
  48967. */
  48968. getMeshByName(name: string): Nullable<AbstractMesh>;
  48969. /**
  48970. * Gets a transform node using a given name
  48971. * @param name defines the name to search for
  48972. * @return the found transform node or null if not found at all.
  48973. */
  48974. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48975. /**
  48976. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48977. * @param id defines the id to search for
  48978. * @return the found skeleton or null if not found at all.
  48979. */
  48980. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48981. /**
  48982. * Gets a skeleton using a given auto generated unique id
  48983. * @param uniqueId defines the unique id to search for
  48984. * @return the found skeleton or null if not found at all.
  48985. */
  48986. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48987. /**
  48988. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48989. * @param id defines the id to search for
  48990. * @return the found skeleton or null if not found at all.
  48991. */
  48992. getSkeletonById(id: string): Nullable<Skeleton>;
  48993. /**
  48994. * Gets a skeleton using a given name
  48995. * @param name defines the name to search for
  48996. * @return the found skeleton or null if not found at all.
  48997. */
  48998. getSkeletonByName(name: string): Nullable<Skeleton>;
  48999. /**
  49000. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  49001. * @param id defines the id to search for
  49002. * @return the found morph target manager or null if not found at all.
  49003. */
  49004. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  49005. /**
  49006. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  49007. * @param id defines the id to search for
  49008. * @return the found morph target or null if not found at all.
  49009. */
  49010. getMorphTargetById(id: string): Nullable<MorphTarget>;
  49011. /**
  49012. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  49013. * @param name defines the name to search for
  49014. * @return the found morph target or null if not found at all.
  49015. */
  49016. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  49017. /**
  49018. * Gets a post process using a given name (if many are found, this function will pick the first one)
  49019. * @param name defines the name to search for
  49020. * @return the found post process or null if not found at all.
  49021. */
  49022. getPostProcessByName(name: string): Nullable<PostProcess>;
  49023. /**
  49024. * Gets a boolean indicating if the given mesh is active
  49025. * @param mesh defines the mesh to look for
  49026. * @returns true if the mesh is in the active list
  49027. */
  49028. isActiveMesh(mesh: AbstractMesh): boolean;
  49029. /**
  49030. * Return a unique id as a string which can serve as an identifier for the scene
  49031. */
  49032. get uid(): string;
  49033. /**
  49034. * Add an externaly attached data from its key.
  49035. * This method call will fail and return false, if such key already exists.
  49036. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  49037. * @param key the unique key that identifies the data
  49038. * @param data the data object to associate to the key for this Engine instance
  49039. * @return true if no such key were already present and the data was added successfully, false otherwise
  49040. */
  49041. addExternalData<T>(key: string, data: T): boolean;
  49042. /**
  49043. * Get an externaly attached data from its key
  49044. * @param key the unique key that identifies the data
  49045. * @return the associated data, if present (can be null), or undefined if not present
  49046. */
  49047. getExternalData<T>(key: string): Nullable<T>;
  49048. /**
  49049. * Get an externaly attached data from its key, create it using a factory if it's not already present
  49050. * @param key the unique key that identifies the data
  49051. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  49052. * @return the associated data, can be null if the factory returned null.
  49053. */
  49054. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  49055. /**
  49056. * Remove an externaly attached data from the Engine instance
  49057. * @param key the unique key that identifies the data
  49058. * @return true if the data was successfully removed, false if it doesn't exist
  49059. */
  49060. removeExternalData(key: string): boolean;
  49061. private _evaluateSubMesh;
  49062. /**
  49063. * Clear the processed materials smart array preventing retention point in material dispose.
  49064. */
  49065. freeProcessedMaterials(): void;
  49066. private _preventFreeActiveMeshesAndRenderingGroups;
  49067. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  49068. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  49069. * when disposing several meshes in a row or a hierarchy of meshes.
  49070. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  49071. */
  49072. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  49073. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  49074. /**
  49075. * Clear the active meshes smart array preventing retention point in mesh dispose.
  49076. */
  49077. freeActiveMeshes(): void;
  49078. /**
  49079. * Clear the info related to rendering groups preventing retention points during dispose.
  49080. */
  49081. freeRenderingGroups(): void;
  49082. /** @hidden */
  49083. _isInIntermediateRendering(): boolean;
  49084. /**
  49085. * Lambda returning the list of potentially active meshes.
  49086. */
  49087. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  49088. /**
  49089. * Lambda returning the list of potentially active sub meshes.
  49090. */
  49091. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  49092. /**
  49093. * Lambda returning the list of potentially intersecting sub meshes.
  49094. */
  49095. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  49096. /**
  49097. * Lambda returning the list of potentially colliding sub meshes.
  49098. */
  49099. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  49100. /** @hidden */
  49101. _activeMeshesFrozen: boolean;
  49102. private _skipEvaluateActiveMeshesCompletely;
  49103. /**
  49104. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  49105. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  49106. * @param onSuccess optional success callback
  49107. * @param onError optional error callback
  49108. * @returns the current scene
  49109. */
  49110. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  49111. /**
  49112. * Use this function to restart evaluating active meshes on every frame
  49113. * @returns the current scene
  49114. */
  49115. unfreezeActiveMeshes(): Scene;
  49116. private _evaluateActiveMeshes;
  49117. private _activeMesh;
  49118. /**
  49119. * Update the transform matrix to update from the current active camera
  49120. * @param force defines a boolean used to force the update even if cache is up to date
  49121. */
  49122. updateTransformMatrix(force?: boolean): void;
  49123. private _bindFrameBuffer;
  49124. /** @hidden */
  49125. _allowPostProcessClearColor: boolean;
  49126. /** @hidden */
  49127. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  49128. private _processSubCameras;
  49129. private _checkIntersections;
  49130. /** @hidden */
  49131. _advancePhysicsEngineStep(step: number): void;
  49132. /**
  49133. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  49134. */
  49135. getDeterministicFrameTime: () => number;
  49136. /** @hidden */
  49137. _animate(): void;
  49138. /** Execute all animations (for a frame) */
  49139. animate(): void;
  49140. /**
  49141. * Render the scene
  49142. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  49143. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  49144. */
  49145. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  49146. /**
  49147. * Freeze all materials
  49148. * A frozen material will not be updatable but should be faster to render
  49149. */
  49150. freezeMaterials(): void;
  49151. /**
  49152. * Unfreeze all materials
  49153. * A frozen material will not be updatable but should be faster to render
  49154. */
  49155. unfreezeMaterials(): void;
  49156. /**
  49157. * Releases all held ressources
  49158. */
  49159. dispose(): void;
  49160. /**
  49161. * Gets if the scene is already disposed
  49162. */
  49163. get isDisposed(): boolean;
  49164. /**
  49165. * Call this function to reduce memory footprint of the scene.
  49166. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  49167. */
  49168. clearCachedVertexData(): void;
  49169. /**
  49170. * This function will remove the local cached buffer data from texture.
  49171. * It will save memory but will prevent the texture from being rebuilt
  49172. */
  49173. cleanCachedTextureBuffer(): void;
  49174. /**
  49175. * Get the world extend vectors with an optional filter
  49176. *
  49177. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  49178. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  49179. */
  49180. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  49181. min: Vector3;
  49182. max: Vector3;
  49183. };
  49184. /**
  49185. * Creates a ray that can be used to pick in the scene
  49186. * @param x defines the x coordinate of the origin (on-screen)
  49187. * @param y defines the y coordinate of the origin (on-screen)
  49188. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49189. * @param camera defines the camera to use for the picking
  49190. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49191. * @returns a Ray
  49192. */
  49193. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  49194. /**
  49195. * Creates a ray that can be used to pick in the scene
  49196. * @param x defines the x coordinate of the origin (on-screen)
  49197. * @param y defines the y coordinate of the origin (on-screen)
  49198. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49199. * @param result defines the ray where to store the picking ray
  49200. * @param camera defines the camera to use for the picking
  49201. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49202. * @returns the current scene
  49203. */
  49204. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  49205. /**
  49206. * Creates a ray that can be used to pick in the scene
  49207. * @param x defines the x coordinate of the origin (on-screen)
  49208. * @param y defines the y coordinate of the origin (on-screen)
  49209. * @param camera defines the camera to use for the picking
  49210. * @returns a Ray
  49211. */
  49212. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  49213. /**
  49214. * Creates a ray that can be used to pick in the scene
  49215. * @param x defines the x coordinate of the origin (on-screen)
  49216. * @param y defines the y coordinate of the origin (on-screen)
  49217. * @param result defines the ray where to store the picking ray
  49218. * @param camera defines the camera to use for the picking
  49219. * @returns the current scene
  49220. */
  49221. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  49222. /** Launch a ray to try to pick a mesh in the scene
  49223. * @param x position on screen
  49224. * @param y position on screen
  49225. * @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
  49226. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49227. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49228. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49229. * @returns a PickingInfo
  49230. */
  49231. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49232. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  49233. * @param x position on screen
  49234. * @param y position on screen
  49235. * @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
  49236. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49237. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49238. * @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)
  49239. */
  49240. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  49241. /** Use the given ray to pick a mesh in the scene
  49242. * @param ray The ray to use to pick meshes
  49243. * @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
  49244. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49245. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49246. * @returns a PickingInfo
  49247. */
  49248. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49249. /**
  49250. * Launch a ray to try to pick a mesh in the scene
  49251. * @param x X position on screen
  49252. * @param y Y position on screen
  49253. * @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
  49254. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49255. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49256. * @returns an array of PickingInfo
  49257. */
  49258. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49259. /**
  49260. * Launch a ray to try to pick a mesh in the scene
  49261. * @param ray Ray to use
  49262. * @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
  49263. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49264. * @returns an array of PickingInfo
  49265. */
  49266. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49267. /**
  49268. * Force the value of meshUnderPointer
  49269. * @param mesh defines the mesh to use
  49270. * @param pointerId optional pointer id when using more than one pointer
  49271. */
  49272. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  49273. /**
  49274. * Gets the mesh under the pointer
  49275. * @returns a Mesh or null if no mesh is under the pointer
  49276. */
  49277. getPointerOverMesh(): Nullable<AbstractMesh>;
  49278. /** @hidden */
  49279. _rebuildGeometries(): void;
  49280. /** @hidden */
  49281. _rebuildTextures(): void;
  49282. private _getByTags;
  49283. /**
  49284. * Get a list of meshes by tags
  49285. * @param tagsQuery defines the tags query to use
  49286. * @param forEach defines a predicate used to filter results
  49287. * @returns an array of Mesh
  49288. */
  49289. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  49290. /**
  49291. * Get a list of cameras by tags
  49292. * @param tagsQuery defines the tags query to use
  49293. * @param forEach defines a predicate used to filter results
  49294. * @returns an array of Camera
  49295. */
  49296. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  49297. /**
  49298. * Get a list of lights by tags
  49299. * @param tagsQuery defines the tags query to use
  49300. * @param forEach defines a predicate used to filter results
  49301. * @returns an array of Light
  49302. */
  49303. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  49304. /**
  49305. * Get a list of materials by tags
  49306. * @param tagsQuery defines the tags query to use
  49307. * @param forEach defines a predicate used to filter results
  49308. * @returns an array of Material
  49309. */
  49310. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  49311. /**
  49312. * Get a list of transform nodes by tags
  49313. * @param tagsQuery defines the tags query to use
  49314. * @param forEach defines a predicate used to filter results
  49315. * @returns an array of TransformNode
  49316. */
  49317. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  49318. /**
  49319. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  49320. * This allowed control for front to back rendering or reversly depending of the special needs.
  49321. *
  49322. * @param renderingGroupId The rendering group id corresponding to its index
  49323. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  49324. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  49325. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  49326. */
  49327. 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;
  49328. /**
  49329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  49330. *
  49331. * @param renderingGroupId The rendering group id corresponding to its index
  49332. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49333. * @param depth Automatically clears depth between groups if true and autoClear is true.
  49334. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  49335. */
  49336. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  49337. /**
  49338. * Gets the current auto clear configuration for one rendering group of the rendering
  49339. * manager.
  49340. * @param index the rendering group index to get the information for
  49341. * @returns The auto clear setup for the requested rendering group
  49342. */
  49343. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  49344. private _blockMaterialDirtyMechanism;
  49345. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  49346. get blockMaterialDirtyMechanism(): boolean;
  49347. set blockMaterialDirtyMechanism(value: boolean);
  49348. /**
  49349. * Will flag all materials as dirty to trigger new shader compilation
  49350. * @param flag defines the flag used to specify which material part must be marked as dirty
  49351. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  49352. */
  49353. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  49354. /** @hidden */
  49355. _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;
  49356. /** @hidden */
  49357. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49358. /** @hidden */
  49359. _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;
  49360. /** @hidden */
  49361. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  49362. /** @hidden */
  49363. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  49364. /** @hidden */
  49365. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49366. }
  49367. }
  49368. declare module "babylonjs/assetContainer" {
  49369. import { AbstractScene } from "babylonjs/abstractScene";
  49370. import { Scene } from "babylonjs/scene";
  49371. import { Mesh } from "babylonjs/Meshes/mesh";
  49372. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49373. import { Skeleton } from "babylonjs/Bones/skeleton";
  49374. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49375. import { Animatable } from "babylonjs/Animations/animatable";
  49376. import { Nullable } from "babylonjs/types";
  49377. import { Node } from "babylonjs/node";
  49378. /**
  49379. * Set of assets to keep when moving a scene into an asset container.
  49380. */
  49381. export class KeepAssets extends AbstractScene {
  49382. }
  49383. /**
  49384. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  49385. */
  49386. export class InstantiatedEntries {
  49387. /**
  49388. * List of new root nodes (eg. nodes with no parent)
  49389. */
  49390. rootNodes: TransformNode[];
  49391. /**
  49392. * List of new skeletons
  49393. */
  49394. skeletons: Skeleton[];
  49395. /**
  49396. * List of new animation groups
  49397. */
  49398. animationGroups: AnimationGroup[];
  49399. }
  49400. /**
  49401. * Container with a set of assets that can be added or removed from a scene.
  49402. */
  49403. export class AssetContainer extends AbstractScene {
  49404. private _wasAddedToScene;
  49405. /**
  49406. * The scene the AssetContainer belongs to.
  49407. */
  49408. scene: Scene;
  49409. /**
  49410. * Instantiates an AssetContainer.
  49411. * @param scene The scene the AssetContainer belongs to.
  49412. */
  49413. constructor(scene: Scene);
  49414. /**
  49415. * Instantiate or clone all meshes and add the new ones to the scene.
  49416. * Skeletons and animation groups will all be cloned
  49417. * @param nameFunction defines an optional function used to get new names for clones
  49418. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  49419. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  49420. */
  49421. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  49422. /**
  49423. * Adds all the assets from the container to the scene.
  49424. */
  49425. addAllToScene(): void;
  49426. /**
  49427. * Removes all the assets in the container from the scene
  49428. */
  49429. removeAllFromScene(): void;
  49430. /**
  49431. * Disposes all the assets in the container
  49432. */
  49433. dispose(): void;
  49434. private _moveAssets;
  49435. /**
  49436. * Removes all the assets contained in the scene and adds them to the container.
  49437. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  49438. */
  49439. moveAllFromScene(keepAssets?: KeepAssets): void;
  49440. /**
  49441. * 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.
  49442. * @returns the root mesh
  49443. */
  49444. createRootMesh(): Mesh;
  49445. /**
  49446. * Merge animations (direct and animation groups) from this asset container into a scene
  49447. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49448. * @param animatables set of animatables to retarget to a node from the scene
  49449. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  49450. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  49451. */
  49452. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  49453. }
  49454. }
  49455. declare module "babylonjs/abstractScene" {
  49456. import { Scene } from "babylonjs/scene";
  49457. import { Nullable } from "babylonjs/types";
  49458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49460. import { Geometry } from "babylonjs/Meshes/geometry";
  49461. import { Skeleton } from "babylonjs/Bones/skeleton";
  49462. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  49463. import { AssetContainer } from "babylonjs/assetContainer";
  49464. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49465. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49467. import { Material } from "babylonjs/Materials/material";
  49468. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  49469. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  49470. import { Camera } from "babylonjs/Cameras/camera";
  49471. import { Light } from "babylonjs/Lights/light";
  49472. import { Node } from "babylonjs/node";
  49473. import { Animation } from "babylonjs/Animations/animation";
  49474. /**
  49475. * Defines how the parser contract is defined.
  49476. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  49477. */
  49478. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  49479. /**
  49480. * Defines how the individual parser contract is defined.
  49481. * These parser can parse an individual asset
  49482. */
  49483. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  49484. /**
  49485. * Base class of the scene acting as a container for the different elements composing a scene.
  49486. * This class is dynamically extended by the different components of the scene increasing
  49487. * flexibility and reducing coupling
  49488. */
  49489. export abstract class AbstractScene {
  49490. /**
  49491. * Stores the list of available parsers in the application.
  49492. */
  49493. private static _BabylonFileParsers;
  49494. /**
  49495. * Stores the list of available individual parsers in the application.
  49496. */
  49497. private static _IndividualBabylonFileParsers;
  49498. /**
  49499. * Adds a parser in the list of available ones
  49500. * @param name Defines the name of the parser
  49501. * @param parser Defines the parser to add
  49502. */
  49503. static AddParser(name: string, parser: BabylonFileParser): void;
  49504. /**
  49505. * Gets a general parser from the list of avaialble ones
  49506. * @param name Defines the name of the parser
  49507. * @returns the requested parser or null
  49508. */
  49509. static GetParser(name: string): Nullable<BabylonFileParser>;
  49510. /**
  49511. * Adds n individual parser in the list of available ones
  49512. * @param name Defines the name of the parser
  49513. * @param parser Defines the parser to add
  49514. */
  49515. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  49516. /**
  49517. * Gets an individual parser from the list of avaialble ones
  49518. * @param name Defines the name of the parser
  49519. * @returns the requested parser or null
  49520. */
  49521. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  49522. /**
  49523. * Parser json data and populate both a scene and its associated container object
  49524. * @param jsonData Defines the data to parse
  49525. * @param scene Defines the scene to parse the data for
  49526. * @param container Defines the container attached to the parsing sequence
  49527. * @param rootUrl Defines the root url of the data
  49528. */
  49529. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  49530. /**
  49531. * Gets the list of root nodes (ie. nodes with no parent)
  49532. */
  49533. rootNodes: Node[];
  49534. /** All of the cameras added to this scene
  49535. * @see https://doc.babylonjs.com/babylon101/cameras
  49536. */
  49537. cameras: Camera[];
  49538. /**
  49539. * All of the lights added to this scene
  49540. * @see https://doc.babylonjs.com/babylon101/lights
  49541. */
  49542. lights: Light[];
  49543. /**
  49544. * All of the (abstract) meshes added to this scene
  49545. */
  49546. meshes: AbstractMesh[];
  49547. /**
  49548. * The list of skeletons added to the scene
  49549. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49550. */
  49551. skeletons: Skeleton[];
  49552. /**
  49553. * All of the particle systems added to this scene
  49554. * @see https://doc.babylonjs.com/babylon101/particles
  49555. */
  49556. particleSystems: IParticleSystem[];
  49557. /**
  49558. * Gets a list of Animations associated with the scene
  49559. */
  49560. animations: Animation[];
  49561. /**
  49562. * All of the animation groups added to this scene
  49563. * @see https://doc.babylonjs.com/how_to/group
  49564. */
  49565. animationGroups: AnimationGroup[];
  49566. /**
  49567. * All of the multi-materials added to this scene
  49568. * @see https://doc.babylonjs.com/how_to/multi_materials
  49569. */
  49570. multiMaterials: MultiMaterial[];
  49571. /**
  49572. * All of the materials added to this scene
  49573. * In the context of a Scene, it is not supposed to be modified manually.
  49574. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  49575. * Note also that the order of the Material within the array is not significant and might change.
  49576. * @see https://doc.babylonjs.com/babylon101/materials
  49577. */
  49578. materials: Material[];
  49579. /**
  49580. * The list of morph target managers added to the scene
  49581. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  49582. */
  49583. morphTargetManagers: MorphTargetManager[];
  49584. /**
  49585. * The list of geometries used in the scene.
  49586. */
  49587. geometries: Geometry[];
  49588. /**
  49589. * All of the tranform nodes added to this scene
  49590. * In the context of a Scene, it is not supposed to be modified manually.
  49591. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  49592. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  49593. * @see https://doc.babylonjs.com/how_to/transformnode
  49594. */
  49595. transformNodes: TransformNode[];
  49596. /**
  49597. * ActionManagers available on the scene.
  49598. */
  49599. actionManagers: AbstractActionManager[];
  49600. /**
  49601. * Textures to keep.
  49602. */
  49603. textures: BaseTexture[];
  49604. /** @hidden */
  49605. protected _environmentTexture: Nullable<BaseTexture>;
  49606. /**
  49607. * Texture used in all pbr material as the reflection texture.
  49608. * As in the majority of the scene they are the same (exception for multi room and so on),
  49609. * this is easier to reference from here than from all the materials.
  49610. */
  49611. get environmentTexture(): Nullable<BaseTexture>;
  49612. set environmentTexture(value: Nullable<BaseTexture>);
  49613. /**
  49614. * The list of postprocesses added to the scene
  49615. */
  49616. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  49617. /**
  49618. * @returns all meshes, lights, cameras, transformNodes and bones
  49619. */
  49620. getNodes(): Array<Node>;
  49621. }
  49622. }
  49623. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  49624. /**
  49625. * Interface used to define options for Sound class
  49626. */
  49627. export interface ISoundOptions {
  49628. /**
  49629. * Does the sound autoplay once loaded.
  49630. */
  49631. autoplay?: boolean;
  49632. /**
  49633. * Does the sound loop after it finishes playing once.
  49634. */
  49635. loop?: boolean;
  49636. /**
  49637. * Sound's volume
  49638. */
  49639. volume?: number;
  49640. /**
  49641. * Is it a spatial sound?
  49642. */
  49643. spatialSound?: boolean;
  49644. /**
  49645. * Maximum distance to hear that sound
  49646. */
  49647. maxDistance?: number;
  49648. /**
  49649. * Uses user defined attenuation function
  49650. */
  49651. useCustomAttenuation?: boolean;
  49652. /**
  49653. * Define the roll off factor of spatial sounds.
  49654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49655. */
  49656. rolloffFactor?: number;
  49657. /**
  49658. * Define the reference distance the sound should be heard perfectly.
  49659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49660. */
  49661. refDistance?: number;
  49662. /**
  49663. * Define the distance attenuation model the sound will follow.
  49664. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49665. */
  49666. distanceModel?: string;
  49667. /**
  49668. * Defines the playback speed (1 by default)
  49669. */
  49670. playbackRate?: number;
  49671. /**
  49672. * Defines if the sound is from a streaming source
  49673. */
  49674. streaming?: boolean;
  49675. /**
  49676. * Defines an optional length (in seconds) inside the sound file
  49677. */
  49678. length?: number;
  49679. /**
  49680. * Defines an optional offset (in seconds) inside the sound file
  49681. */
  49682. offset?: number;
  49683. /**
  49684. * If true, URLs will not be required to state the audio file codec to use.
  49685. */
  49686. skipCodecCheck?: boolean;
  49687. }
  49688. }
  49689. declare module "babylonjs/Audio/sound" {
  49690. import { Observable } from "babylonjs/Misc/observable";
  49691. import { Vector3 } from "babylonjs/Maths/math.vector";
  49692. import { Nullable } from "babylonjs/types";
  49693. import { Scene } from "babylonjs/scene";
  49694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49695. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  49696. /**
  49697. * Defines a sound that can be played in the application.
  49698. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49699. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49700. */
  49701. export class Sound {
  49702. /**
  49703. * The name of the sound in the scene.
  49704. */
  49705. name: string;
  49706. /**
  49707. * Does the sound autoplay once loaded.
  49708. */
  49709. autoplay: boolean;
  49710. private _loop;
  49711. /**
  49712. * Does the sound loop after it finishes playing once.
  49713. */
  49714. get loop(): boolean;
  49715. set loop(value: boolean);
  49716. /**
  49717. * Does the sound use a custom attenuation curve to simulate the falloff
  49718. * happening when the source gets further away from the camera.
  49719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49720. */
  49721. useCustomAttenuation: boolean;
  49722. /**
  49723. * The sound track id this sound belongs to.
  49724. */
  49725. soundTrackId: number;
  49726. /**
  49727. * Is this sound currently played.
  49728. */
  49729. isPlaying: boolean;
  49730. /**
  49731. * Is this sound currently paused.
  49732. */
  49733. isPaused: boolean;
  49734. /**
  49735. * Does this sound enables spatial sound.
  49736. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49737. */
  49738. spatialSound: boolean;
  49739. /**
  49740. * Define the reference distance the sound should be heard perfectly.
  49741. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49742. */
  49743. refDistance: number;
  49744. /**
  49745. * Define the roll off factor of spatial sounds.
  49746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49747. */
  49748. rolloffFactor: number;
  49749. /**
  49750. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49752. */
  49753. maxDistance: number;
  49754. /**
  49755. * Define the distance attenuation model the sound will follow.
  49756. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49757. */
  49758. distanceModel: string;
  49759. /**
  49760. * @hidden
  49761. * Back Compat
  49762. **/
  49763. onended: () => any;
  49764. /**
  49765. * Gets or sets an object used to store user defined information for the sound.
  49766. */
  49767. metadata: any;
  49768. /**
  49769. * Observable event when the current playing sound finishes.
  49770. */
  49771. onEndedObservable: Observable<Sound>;
  49772. /**
  49773. * Gets the current time for the sound.
  49774. */
  49775. get currentTime(): number;
  49776. private _panningModel;
  49777. private _playbackRate;
  49778. private _streaming;
  49779. private _startTime;
  49780. private _startOffset;
  49781. private _position;
  49782. /** @hidden */
  49783. _positionInEmitterSpace: boolean;
  49784. private _localDirection;
  49785. private _volume;
  49786. private _isReadyToPlay;
  49787. private _isDirectional;
  49788. private _readyToPlayCallback;
  49789. private _audioBuffer;
  49790. private _soundSource;
  49791. private _streamingSource;
  49792. private _soundPanner;
  49793. private _soundGain;
  49794. private _inputAudioNode;
  49795. private _outputAudioNode;
  49796. private _coneInnerAngle;
  49797. private _coneOuterAngle;
  49798. private _coneOuterGain;
  49799. private _scene;
  49800. private _connectedTransformNode;
  49801. private _customAttenuationFunction;
  49802. private _registerFunc;
  49803. private _isOutputConnected;
  49804. private _htmlAudioElement;
  49805. private _urlType;
  49806. private _length?;
  49807. private _offset?;
  49808. /** @hidden */
  49809. static _SceneComponentInitialization: (scene: Scene) => void;
  49810. /**
  49811. * Create a sound and attach it to a scene
  49812. * @param name Name of your sound
  49813. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49814. * @param scene defines the scene the sound belongs to
  49815. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49816. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49817. */
  49818. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49819. /**
  49820. * Release the sound and its associated resources
  49821. */
  49822. dispose(): void;
  49823. /**
  49824. * Gets if the sounds is ready to be played or not.
  49825. * @returns true if ready, otherwise false
  49826. */
  49827. isReady(): boolean;
  49828. /**
  49829. * Get the current class name.
  49830. * @returns current class name
  49831. */
  49832. getClassName(): string;
  49833. private _soundLoaded;
  49834. /**
  49835. * Sets the data of the sound from an audiobuffer
  49836. * @param audioBuffer The audioBuffer containing the data
  49837. */
  49838. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49839. /**
  49840. * Updates the current sounds options such as maxdistance, loop...
  49841. * @param options A JSON object containing values named as the object properties
  49842. */
  49843. updateOptions(options: ISoundOptions): void;
  49844. private _createSpatialParameters;
  49845. private _updateSpatialParameters;
  49846. /**
  49847. * Switch the panning model to HRTF:
  49848. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49850. */
  49851. switchPanningModelToHRTF(): void;
  49852. /**
  49853. * Switch the panning model to Equal Power:
  49854. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49856. */
  49857. switchPanningModelToEqualPower(): void;
  49858. private _switchPanningModel;
  49859. /**
  49860. * Connect this sound to a sound track audio node like gain...
  49861. * @param soundTrackAudioNode the sound track audio node to connect to
  49862. */
  49863. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49864. /**
  49865. * Transform this sound into a directional source
  49866. * @param coneInnerAngle Size of the inner cone in degree
  49867. * @param coneOuterAngle Size of the outer cone in degree
  49868. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49869. */
  49870. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49871. /**
  49872. * Gets or sets the inner angle for the directional cone.
  49873. */
  49874. get directionalConeInnerAngle(): number;
  49875. /**
  49876. * Gets or sets the inner angle for the directional cone.
  49877. */
  49878. set directionalConeInnerAngle(value: number);
  49879. /**
  49880. * Gets or sets the outer angle for the directional cone.
  49881. */
  49882. get directionalConeOuterAngle(): number;
  49883. /**
  49884. * Gets or sets the outer angle for the directional cone.
  49885. */
  49886. set directionalConeOuterAngle(value: number);
  49887. /**
  49888. * Sets the position of the emitter if spatial sound is enabled
  49889. * @param newPosition Defines the new posisiton
  49890. */
  49891. setPosition(newPosition: Vector3): void;
  49892. /**
  49893. * Sets the local direction of the emitter if spatial sound is enabled
  49894. * @param newLocalDirection Defines the new local direction
  49895. */
  49896. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49897. private _updateDirection;
  49898. /** @hidden */
  49899. updateDistanceFromListener(): void;
  49900. /**
  49901. * Sets a new custom attenuation function for the sound.
  49902. * @param callback Defines the function used for the attenuation
  49903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49904. */
  49905. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49906. /**
  49907. * Play the sound
  49908. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49909. * @param offset (optional) Start the sound at a specific time in seconds
  49910. * @param length (optional) Sound duration (in seconds)
  49911. */
  49912. play(time?: number, offset?: number, length?: number): void;
  49913. private _onended;
  49914. /**
  49915. * Stop the sound
  49916. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49917. */
  49918. stop(time?: number): void;
  49919. /**
  49920. * Put the sound in pause
  49921. */
  49922. pause(): void;
  49923. /**
  49924. * Sets a dedicated volume for this sounds
  49925. * @param newVolume Define the new volume of the sound
  49926. * @param time Define time for gradual change to new volume
  49927. */
  49928. setVolume(newVolume: number, time?: number): void;
  49929. /**
  49930. * Set the sound play back rate
  49931. * @param newPlaybackRate Define the playback rate the sound should be played at
  49932. */
  49933. setPlaybackRate(newPlaybackRate: number): void;
  49934. /**
  49935. * Gets the volume of the sound.
  49936. * @returns the volume of the sound
  49937. */
  49938. getVolume(): number;
  49939. /**
  49940. * Attach the sound to a dedicated mesh
  49941. * @param transformNode The transform node to connect the sound with
  49942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49943. */
  49944. attachToMesh(transformNode: TransformNode): void;
  49945. /**
  49946. * Detach the sound from the previously attached mesh
  49947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49948. */
  49949. detachFromMesh(): void;
  49950. private _onRegisterAfterWorldMatrixUpdate;
  49951. /**
  49952. * Clone the current sound in the scene.
  49953. * @returns the new sound clone
  49954. */
  49955. clone(): Nullable<Sound>;
  49956. /**
  49957. * Gets the current underlying audio buffer containing the data
  49958. * @returns the audio buffer
  49959. */
  49960. getAudioBuffer(): Nullable<AudioBuffer>;
  49961. /**
  49962. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49963. * @returns the source node
  49964. */
  49965. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49966. /**
  49967. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49968. * @returns the gain node
  49969. */
  49970. getSoundGain(): Nullable<GainNode>;
  49971. /**
  49972. * Serializes the Sound in a JSON representation
  49973. * @returns the JSON representation of the sound
  49974. */
  49975. serialize(): any;
  49976. /**
  49977. * Parse a JSON representation of a sound to innstantiate in a given scene
  49978. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49979. * @param scene Define the scene the new parsed sound should be created in
  49980. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49981. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  49982. * @returns the newly parsed sound
  49983. */
  49984. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49985. }
  49986. }
  49987. declare module "babylonjs/Actions/directAudioActions" {
  49988. import { Action } from "babylonjs/Actions/action";
  49989. import { Condition } from "babylonjs/Actions/condition";
  49990. import { Sound } from "babylonjs/Audio/sound";
  49991. /**
  49992. * This defines an action helpful to play a defined sound on a triggered action.
  49993. */
  49994. export class PlaySoundAction extends Action {
  49995. private _sound;
  49996. /**
  49997. * Instantiate the action
  49998. * @param triggerOptions defines the trigger options
  49999. * @param sound defines the sound to play
  50000. * @param condition defines the trigger related conditions
  50001. */
  50002. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50003. /** @hidden */
  50004. _prepare(): void;
  50005. /**
  50006. * Execute the action and play the sound.
  50007. */
  50008. execute(): void;
  50009. /**
  50010. * Serializes the actions and its related information.
  50011. * @param parent defines the object to serialize in
  50012. * @returns the serialized object
  50013. */
  50014. serialize(parent: any): any;
  50015. }
  50016. /**
  50017. * This defines an action helpful to stop a defined sound on a triggered action.
  50018. */
  50019. export class StopSoundAction extends Action {
  50020. private _sound;
  50021. /**
  50022. * Instantiate the action
  50023. * @param triggerOptions defines the trigger options
  50024. * @param sound defines the sound to stop
  50025. * @param condition defines the trigger related conditions
  50026. */
  50027. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50028. /** @hidden */
  50029. _prepare(): void;
  50030. /**
  50031. * Execute the action and stop the sound.
  50032. */
  50033. execute(): void;
  50034. /**
  50035. * Serializes the actions and its related information.
  50036. * @param parent defines the object to serialize in
  50037. * @returns the serialized object
  50038. */
  50039. serialize(parent: any): any;
  50040. }
  50041. }
  50042. declare module "babylonjs/Actions/interpolateValueAction" {
  50043. import { Action } from "babylonjs/Actions/action";
  50044. import { Condition } from "babylonjs/Actions/condition";
  50045. import { Observable } from "babylonjs/Misc/observable";
  50046. /**
  50047. * This defines an action responsible to change the value of a property
  50048. * by interpolating between its current value and the newly set one once triggered.
  50049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  50050. */
  50051. export class InterpolateValueAction extends Action {
  50052. /**
  50053. * Defines the path of the property where the value should be interpolated
  50054. */
  50055. propertyPath: string;
  50056. /**
  50057. * Defines the target value at the end of the interpolation.
  50058. */
  50059. value: any;
  50060. /**
  50061. * Defines the time it will take for the property to interpolate to the value.
  50062. */
  50063. duration: number;
  50064. /**
  50065. * Defines if the other scene animations should be stopped when the action has been triggered
  50066. */
  50067. stopOtherAnimations?: boolean;
  50068. /**
  50069. * Defines a callback raised once the interpolation animation has been done.
  50070. */
  50071. onInterpolationDone?: () => void;
  50072. /**
  50073. * Observable triggered once the interpolation animation has been done.
  50074. */
  50075. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  50076. private _target;
  50077. private _effectiveTarget;
  50078. private _property;
  50079. /**
  50080. * Instantiate the action
  50081. * @param triggerOptions defines the trigger options
  50082. * @param target defines the object containing the value to interpolate
  50083. * @param propertyPath defines the path to the property in the target object
  50084. * @param value defines the target value at the end of the interpolation
  50085. * @param duration deines the time it will take for the property to interpolate to the value.
  50086. * @param condition defines the trigger related conditions
  50087. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  50088. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  50089. */
  50090. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  50091. /** @hidden */
  50092. _prepare(): void;
  50093. /**
  50094. * Execute the action starts the value interpolation.
  50095. */
  50096. execute(): void;
  50097. /**
  50098. * Serializes the actions and its related information.
  50099. * @param parent defines the object to serialize in
  50100. * @returns the serialized object
  50101. */
  50102. serialize(parent: any): any;
  50103. }
  50104. }
  50105. declare module "babylonjs/Actions/index" {
  50106. export * from "babylonjs/Actions/abstractActionManager";
  50107. export * from "babylonjs/Actions/action";
  50108. export * from "babylonjs/Actions/actionEvent";
  50109. export * from "babylonjs/Actions/actionManager";
  50110. export * from "babylonjs/Actions/condition";
  50111. export * from "babylonjs/Actions/directActions";
  50112. export * from "babylonjs/Actions/directAudioActions";
  50113. export * from "babylonjs/Actions/interpolateValueAction";
  50114. }
  50115. declare module "babylonjs/Animations/index" {
  50116. export * from "babylonjs/Animations/animatable";
  50117. export * from "babylonjs/Animations/animation";
  50118. export * from "babylonjs/Animations/animationGroup";
  50119. export * from "babylonjs/Animations/animationPropertiesOverride";
  50120. export * from "babylonjs/Animations/easing";
  50121. export * from "babylonjs/Animations/runtimeAnimation";
  50122. export * from "babylonjs/Animations/animationEvent";
  50123. export * from "babylonjs/Animations/animationGroup";
  50124. export * from "babylonjs/Animations/animationKey";
  50125. export * from "babylonjs/Animations/animationRange";
  50126. export * from "babylonjs/Animations/animatable.interface";
  50127. }
  50128. declare module "babylonjs/Audio/audioEngine" {
  50129. import { Analyser } from "babylonjs/Audio/analyser";
  50130. import { Nullable } from "babylonjs/types";
  50131. import { Observable } from "babylonjs/Misc/observable";
  50132. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  50133. /**
  50134. * This represents the default audio engine used in babylon.
  50135. * It is responsible to play, synchronize and analyse sounds throughout the application.
  50136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50137. */
  50138. export class AudioEngine implements IAudioEngine {
  50139. private _audioContext;
  50140. private _audioContextInitialized;
  50141. private _muteButton;
  50142. private _hostElement;
  50143. /**
  50144. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  50145. */
  50146. canUseWebAudio: boolean;
  50147. /**
  50148. * The master gain node defines the global audio volume of your audio engine.
  50149. */
  50150. masterGain: GainNode;
  50151. /**
  50152. * Defines if Babylon should emit a warning if WebAudio is not supported.
  50153. * @ignoreNaming
  50154. */
  50155. WarnedWebAudioUnsupported: boolean;
  50156. /**
  50157. * Gets whether or not mp3 are supported by your browser.
  50158. */
  50159. isMP3supported: boolean;
  50160. /**
  50161. * Gets whether or not ogg are supported by your browser.
  50162. */
  50163. isOGGsupported: boolean;
  50164. /**
  50165. * Gets whether audio has been unlocked on the device.
  50166. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  50167. * a user interaction has happened.
  50168. */
  50169. unlocked: boolean;
  50170. /**
  50171. * Defines if the audio engine relies on a custom unlocked button.
  50172. * In this case, the embedded button will not be displayed.
  50173. */
  50174. useCustomUnlockedButton: boolean;
  50175. /**
  50176. * Event raised when audio has been unlocked on the browser.
  50177. */
  50178. onAudioUnlockedObservable: Observable<IAudioEngine>;
  50179. /**
  50180. * Event raised when audio has been locked on the browser.
  50181. */
  50182. onAudioLockedObservable: Observable<IAudioEngine>;
  50183. /**
  50184. * Gets the current AudioContext if available.
  50185. */
  50186. get audioContext(): Nullable<AudioContext>;
  50187. private _connectedAnalyser;
  50188. /**
  50189. * Instantiates a new audio engine.
  50190. *
  50191. * There should be only one per page as some browsers restrict the number
  50192. * of audio contexts you can create.
  50193. * @param hostElement defines the host element where to display the mute icon if necessary
  50194. */
  50195. constructor(hostElement?: Nullable<HTMLElement>);
  50196. /**
  50197. * Flags the audio engine in Locked state.
  50198. * This happens due to new browser policies preventing audio to autoplay.
  50199. */
  50200. lock(): void;
  50201. /**
  50202. * Unlocks the audio engine once a user action has been done on the dom.
  50203. * This is helpful to resume play once browser policies have been satisfied.
  50204. */
  50205. unlock(): void;
  50206. private _resumeAudioContext;
  50207. private _initializeAudioContext;
  50208. private _tryToRun;
  50209. private _triggerRunningState;
  50210. private _triggerSuspendedState;
  50211. private _displayMuteButton;
  50212. private _moveButtonToTopLeft;
  50213. private _onResize;
  50214. private _hideMuteButton;
  50215. /**
  50216. * Destroy and release the resources associated with the audio ccontext.
  50217. */
  50218. dispose(): void;
  50219. /**
  50220. * Gets the global volume sets on the master gain.
  50221. * @returns the global volume if set or -1 otherwise
  50222. */
  50223. getGlobalVolume(): number;
  50224. /**
  50225. * Sets the global volume of your experience (sets on the master gain).
  50226. * @param newVolume Defines the new global volume of the application
  50227. */
  50228. setGlobalVolume(newVolume: number): void;
  50229. /**
  50230. * Connect the audio engine to an audio analyser allowing some amazing
  50231. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50233. * @param analyser The analyser to connect to the engine
  50234. */
  50235. connectToAnalyser(analyser: Analyser): void;
  50236. }
  50237. }
  50238. declare module "babylonjs/Audio/soundTrack" {
  50239. import { Sound } from "babylonjs/Audio/sound";
  50240. import { Analyser } from "babylonjs/Audio/analyser";
  50241. import { Scene } from "babylonjs/scene";
  50242. /**
  50243. * Options allowed during the creation of a sound track.
  50244. */
  50245. export interface ISoundTrackOptions {
  50246. /**
  50247. * The volume the sound track should take during creation
  50248. */
  50249. volume?: number;
  50250. /**
  50251. * Define if the sound track is the main sound track of the scene
  50252. */
  50253. mainTrack?: boolean;
  50254. }
  50255. /**
  50256. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  50257. * It will be also used in a future release to apply effects on a specific track.
  50258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50259. */
  50260. export class SoundTrack {
  50261. /**
  50262. * The unique identifier of the sound track in the scene.
  50263. */
  50264. id: number;
  50265. /**
  50266. * The list of sounds included in the sound track.
  50267. */
  50268. soundCollection: Array<Sound>;
  50269. private _outputAudioNode;
  50270. private _scene;
  50271. private _connectedAnalyser;
  50272. private _options;
  50273. private _isInitialized;
  50274. /**
  50275. * Creates a new sound track.
  50276. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50277. * @param scene Define the scene the sound track belongs to
  50278. * @param options
  50279. */
  50280. constructor(scene: Scene, options?: ISoundTrackOptions);
  50281. private _initializeSoundTrackAudioGraph;
  50282. /**
  50283. * Release the sound track and its associated resources
  50284. */
  50285. dispose(): void;
  50286. /**
  50287. * Adds a sound to this sound track
  50288. * @param sound define the cound to add
  50289. * @ignoreNaming
  50290. */
  50291. addSound(sound: Sound): void;
  50292. /**
  50293. * Removes a sound to this sound track
  50294. * @param sound define the cound to remove
  50295. * @ignoreNaming
  50296. */
  50297. removeSound(sound: Sound): void;
  50298. /**
  50299. * Set a global volume for the full sound track.
  50300. * @param newVolume Define the new volume of the sound track
  50301. */
  50302. setVolume(newVolume: number): void;
  50303. /**
  50304. * Switch the panning model to HRTF:
  50305. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50307. */
  50308. switchPanningModelToHRTF(): void;
  50309. /**
  50310. * Switch the panning model to Equal Power:
  50311. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50313. */
  50314. switchPanningModelToEqualPower(): void;
  50315. /**
  50316. * Connect the sound track to an audio analyser allowing some amazing
  50317. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50318. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50319. * @param analyser The analyser to connect to the engine
  50320. */
  50321. connectToAnalyser(analyser: Analyser): void;
  50322. }
  50323. }
  50324. declare module "babylonjs/Audio/audioSceneComponent" {
  50325. import { Sound } from "babylonjs/Audio/sound";
  50326. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  50327. import { Nullable } from "babylonjs/types";
  50328. import { Vector3 } from "babylonjs/Maths/math.vector";
  50329. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50330. import { Scene } from "babylonjs/scene";
  50331. import { AbstractScene } from "babylonjs/abstractScene";
  50332. import "babylonjs/Audio/audioEngine";
  50333. module "babylonjs/abstractScene" {
  50334. interface AbstractScene {
  50335. /**
  50336. * The list of sounds used in the scene.
  50337. */
  50338. sounds: Nullable<Array<Sound>>;
  50339. }
  50340. }
  50341. module "babylonjs/scene" {
  50342. interface Scene {
  50343. /**
  50344. * @hidden
  50345. * Backing field
  50346. */
  50347. _mainSoundTrack: SoundTrack;
  50348. /**
  50349. * The main sound track played by the scene.
  50350. * It cotains your primary collection of sounds.
  50351. */
  50352. mainSoundTrack: SoundTrack;
  50353. /**
  50354. * The list of sound tracks added to the scene
  50355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50356. */
  50357. soundTracks: Nullable<Array<SoundTrack>>;
  50358. /**
  50359. * Gets a sound using a given name
  50360. * @param name defines the name to search for
  50361. * @return the found sound or null if not found at all.
  50362. */
  50363. getSoundByName(name: string): Nullable<Sound>;
  50364. /**
  50365. * Gets or sets if audio support is enabled
  50366. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50367. */
  50368. audioEnabled: boolean;
  50369. /**
  50370. * Gets or sets if audio will be output to headphones
  50371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50372. */
  50373. headphone: boolean;
  50374. /**
  50375. * Gets or sets custom audio listener position provider
  50376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50377. */
  50378. audioListenerPositionProvider: Nullable<() => Vector3>;
  50379. /**
  50380. * Gets or sets a refresh rate when using 3D audio positioning
  50381. */
  50382. audioPositioningRefreshRate: number;
  50383. }
  50384. }
  50385. /**
  50386. * Defines the sound scene component responsible to manage any sounds
  50387. * in a given scene.
  50388. */
  50389. export class AudioSceneComponent implements ISceneSerializableComponent {
  50390. private static _CameraDirectionLH;
  50391. private static _CameraDirectionRH;
  50392. /**
  50393. * The component name helpfull to identify the component in the list of scene components.
  50394. */
  50395. readonly name: string;
  50396. /**
  50397. * The scene the component belongs to.
  50398. */
  50399. scene: Scene;
  50400. private _audioEnabled;
  50401. /**
  50402. * Gets whether audio is enabled or not.
  50403. * Please use related enable/disable method to switch state.
  50404. */
  50405. get audioEnabled(): boolean;
  50406. private _headphone;
  50407. /**
  50408. * Gets whether audio is outputing to headphone or not.
  50409. * Please use the according Switch methods to change output.
  50410. */
  50411. get headphone(): boolean;
  50412. /**
  50413. * Gets or sets a refresh rate when using 3D audio positioning
  50414. */
  50415. audioPositioningRefreshRate: number;
  50416. private _audioListenerPositionProvider;
  50417. /**
  50418. * Gets the current audio listener position provider
  50419. */
  50420. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  50421. /**
  50422. * Sets a custom listener position for all sounds in the scene
  50423. * By default, this is the position of the first active camera
  50424. */
  50425. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  50426. /**
  50427. * Creates a new instance of the component for the given scene
  50428. * @param scene Defines the scene to register the component in
  50429. */
  50430. constructor(scene: Scene);
  50431. /**
  50432. * Registers the component in a given scene
  50433. */
  50434. register(): void;
  50435. /**
  50436. * Rebuilds the elements related to this component in case of
  50437. * context lost for instance.
  50438. */
  50439. rebuild(): void;
  50440. /**
  50441. * Serializes the component data to the specified json object
  50442. * @param serializationObject The object to serialize to
  50443. */
  50444. serialize(serializationObject: any): void;
  50445. /**
  50446. * Adds all the elements from the container to the scene
  50447. * @param container the container holding the elements
  50448. */
  50449. addFromContainer(container: AbstractScene): void;
  50450. /**
  50451. * Removes all the elements in the container from the scene
  50452. * @param container contains the elements to remove
  50453. * @param dispose if the removed element should be disposed (default: false)
  50454. */
  50455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50456. /**
  50457. * Disposes the component and the associated ressources.
  50458. */
  50459. dispose(): void;
  50460. /**
  50461. * Disables audio in the associated scene.
  50462. */
  50463. disableAudio(): void;
  50464. /**
  50465. * Enables audio in the associated scene.
  50466. */
  50467. enableAudio(): void;
  50468. /**
  50469. * Switch audio to headphone output.
  50470. */
  50471. switchAudioModeForHeadphones(): void;
  50472. /**
  50473. * Switch audio to normal speakers.
  50474. */
  50475. switchAudioModeForNormalSpeakers(): void;
  50476. private _cachedCameraDirection;
  50477. private _cachedCameraPosition;
  50478. private _lastCheck;
  50479. private _afterRender;
  50480. }
  50481. }
  50482. declare module "babylonjs/Audio/weightedsound" {
  50483. import { Sound } from "babylonjs/Audio/sound";
  50484. /**
  50485. * Wraps one or more Sound objects and selects one with random weight for playback.
  50486. */
  50487. export class WeightedSound {
  50488. /** When true a Sound will be selected and played when the current playing Sound completes. */
  50489. loop: boolean;
  50490. private _coneInnerAngle;
  50491. private _coneOuterAngle;
  50492. private _volume;
  50493. /** A Sound is currently playing. */
  50494. isPlaying: boolean;
  50495. /** A Sound is currently paused. */
  50496. isPaused: boolean;
  50497. private _sounds;
  50498. private _weights;
  50499. private _currentIndex?;
  50500. /**
  50501. * Creates a new WeightedSound from the list of sounds given.
  50502. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  50503. * @param sounds Array of Sounds that will be selected from.
  50504. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  50505. */
  50506. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  50507. /**
  50508. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  50509. */
  50510. get directionalConeInnerAngle(): number;
  50511. /**
  50512. * The size of cone in degress for a directional sound in which there will be no attenuation.
  50513. */
  50514. set directionalConeInnerAngle(value: number);
  50515. /**
  50516. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50517. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50518. */
  50519. get directionalConeOuterAngle(): number;
  50520. /**
  50521. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50522. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50523. */
  50524. set directionalConeOuterAngle(value: number);
  50525. /**
  50526. * Playback volume.
  50527. */
  50528. get volume(): number;
  50529. /**
  50530. * Playback volume.
  50531. */
  50532. set volume(value: number);
  50533. private _onended;
  50534. /**
  50535. * Suspend playback
  50536. */
  50537. pause(): void;
  50538. /**
  50539. * Stop playback
  50540. */
  50541. stop(): void;
  50542. /**
  50543. * Start playback.
  50544. * @param startOffset Position the clip head at a specific time in seconds.
  50545. */
  50546. play(startOffset?: number): void;
  50547. }
  50548. }
  50549. declare module "babylonjs/Audio/index" {
  50550. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  50551. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  50552. export * from "babylonjs/Audio/analyser";
  50553. export * from "babylonjs/Audio/audioEngine";
  50554. export * from "babylonjs/Audio/audioSceneComponent";
  50555. export * from "babylonjs/Audio/sound";
  50556. export * from "babylonjs/Audio/soundTrack";
  50557. export * from "babylonjs/Audio/weightedsound";
  50558. }
  50559. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  50560. import { Behavior } from "babylonjs/Behaviors/behavior";
  50561. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50562. import { BackEase } from "babylonjs/Animations/easing";
  50563. /**
  50564. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  50565. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50566. */
  50567. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  50568. /**
  50569. * Gets the name of the behavior.
  50570. */
  50571. get name(): string;
  50572. /**
  50573. * The easing function used by animations
  50574. */
  50575. static EasingFunction: BackEase;
  50576. /**
  50577. * The easing mode used by animations
  50578. */
  50579. static EasingMode: number;
  50580. /**
  50581. * The duration of the animation, in milliseconds
  50582. */
  50583. transitionDuration: number;
  50584. /**
  50585. * Length of the distance animated by the transition when lower radius is reached
  50586. */
  50587. lowerRadiusTransitionRange: number;
  50588. /**
  50589. * Length of the distance animated by the transition when upper radius is reached
  50590. */
  50591. upperRadiusTransitionRange: number;
  50592. private _autoTransitionRange;
  50593. /**
  50594. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50595. */
  50596. get autoTransitionRange(): boolean;
  50597. /**
  50598. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50599. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  50600. */
  50601. set autoTransitionRange(value: boolean);
  50602. private _attachedCamera;
  50603. private _onAfterCheckInputsObserver;
  50604. private _onMeshTargetChangedObserver;
  50605. /**
  50606. * Initializes the behavior.
  50607. */
  50608. init(): void;
  50609. /**
  50610. * Attaches the behavior to its arc rotate camera.
  50611. * @param camera Defines the camera to attach the behavior to
  50612. */
  50613. attach(camera: ArcRotateCamera): void;
  50614. /**
  50615. * Detaches the behavior from its current arc rotate camera.
  50616. */
  50617. detach(): void;
  50618. private _radiusIsAnimating;
  50619. private _radiusBounceTransition;
  50620. private _animatables;
  50621. private _cachedWheelPrecision;
  50622. /**
  50623. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  50624. * @param radiusLimit The limit to check against.
  50625. * @return Bool to indicate if at limit.
  50626. */
  50627. private _isRadiusAtLimit;
  50628. /**
  50629. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50630. * @param radiusDelta The delta by which to animate to. Can be negative.
  50631. */
  50632. private _applyBoundRadiusAnimation;
  50633. /**
  50634. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50635. */
  50636. protected _clearAnimationLocks(): void;
  50637. /**
  50638. * Stops and removes all animations that have been applied to the camera
  50639. */
  50640. stopAllAnimations(): void;
  50641. }
  50642. }
  50643. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  50644. import { Behavior } from "babylonjs/Behaviors/behavior";
  50645. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50646. import { ExponentialEase } from "babylonjs/Animations/easing";
  50647. import { Nullable } from "babylonjs/types";
  50648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50649. import { Vector3 } from "babylonjs/Maths/math.vector";
  50650. /**
  50651. * 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.
  50652. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50653. */
  50654. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50655. /**
  50656. * Gets the name of the behavior.
  50657. */
  50658. get name(): string;
  50659. private _mode;
  50660. private _radiusScale;
  50661. private _positionScale;
  50662. private _defaultElevation;
  50663. private _elevationReturnTime;
  50664. private _elevationReturnWaitTime;
  50665. private _zoomStopsAnimation;
  50666. private _framingTime;
  50667. /**
  50668. * The easing function used by animations
  50669. */
  50670. static EasingFunction: ExponentialEase;
  50671. /**
  50672. * The easing mode used by animations
  50673. */
  50674. static EasingMode: number;
  50675. /**
  50676. * Sets the current mode used by the behavior
  50677. */
  50678. set mode(mode: number);
  50679. /**
  50680. * Gets current mode used by the behavior.
  50681. */
  50682. get mode(): number;
  50683. /**
  50684. * Sets the scale applied to the radius (1 by default)
  50685. */
  50686. set radiusScale(radius: number);
  50687. /**
  50688. * Gets the scale applied to the radius
  50689. */
  50690. get radiusScale(): number;
  50691. /**
  50692. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50693. */
  50694. set positionScale(scale: number);
  50695. /**
  50696. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50697. */
  50698. get positionScale(): number;
  50699. /**
  50700. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50701. * behaviour is triggered, in radians.
  50702. */
  50703. set defaultElevation(elevation: number);
  50704. /**
  50705. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50706. * behaviour is triggered, in radians.
  50707. */
  50708. get defaultElevation(): number;
  50709. /**
  50710. * Sets the time (in milliseconds) taken to return to the default beta position.
  50711. * Negative value indicates camera should not return to default.
  50712. */
  50713. set elevationReturnTime(speed: number);
  50714. /**
  50715. * Gets the time (in milliseconds) taken to return to the default beta position.
  50716. * Negative value indicates camera should not return to default.
  50717. */
  50718. get elevationReturnTime(): number;
  50719. /**
  50720. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50721. */
  50722. set elevationReturnWaitTime(time: number);
  50723. /**
  50724. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50725. */
  50726. get elevationReturnWaitTime(): number;
  50727. /**
  50728. * Sets the flag that indicates if user zooming should stop animation.
  50729. */
  50730. set zoomStopsAnimation(flag: boolean);
  50731. /**
  50732. * Gets the flag that indicates if user zooming should stop animation.
  50733. */
  50734. get zoomStopsAnimation(): boolean;
  50735. /**
  50736. * Sets the transition time when framing the mesh, in milliseconds
  50737. */
  50738. set framingTime(time: number);
  50739. /**
  50740. * Gets the transition time when framing the mesh, in milliseconds
  50741. */
  50742. get framingTime(): number;
  50743. /**
  50744. * Define if the behavior should automatically change the configured
  50745. * camera limits and sensibilities.
  50746. */
  50747. autoCorrectCameraLimitsAndSensibility: boolean;
  50748. private _onPrePointerObservableObserver;
  50749. private _onAfterCheckInputsObserver;
  50750. private _onMeshTargetChangedObserver;
  50751. private _attachedCamera;
  50752. private _isPointerDown;
  50753. private _lastInteractionTime;
  50754. /**
  50755. * Initializes the behavior.
  50756. */
  50757. init(): void;
  50758. /**
  50759. * Attaches the behavior to its arc rotate camera.
  50760. * @param camera Defines the camera to attach the behavior to
  50761. */
  50762. attach(camera: ArcRotateCamera): void;
  50763. /**
  50764. * Detaches the behavior from its current arc rotate camera.
  50765. */
  50766. detach(): void;
  50767. private _animatables;
  50768. private _betaIsAnimating;
  50769. private _betaTransition;
  50770. private _radiusTransition;
  50771. private _vectorTransition;
  50772. /**
  50773. * Targets the given mesh and updates zoom level accordingly.
  50774. * @param mesh The mesh to target.
  50775. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50776. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50777. */
  50778. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50779. /**
  50780. * Targets the given mesh with its children and updates zoom level accordingly.
  50781. * @param mesh The mesh to target.
  50782. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50783. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50784. */
  50785. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50786. /**
  50787. * Targets the given meshes with their children and updates zoom level accordingly.
  50788. * @param meshes The mesh to target.
  50789. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50790. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50791. */
  50792. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50793. /**
  50794. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50795. * @param minimumWorld Determines the smaller position of the bounding box extend
  50796. * @param maximumWorld Determines the bigger position of the bounding box extend
  50797. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50798. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50799. */
  50800. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50801. /**
  50802. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50803. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50804. * frustum width.
  50805. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50806. * to fully enclose the mesh in the viewing frustum.
  50807. */
  50808. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50809. /**
  50810. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50811. * is automatically returned to its default position (expected to be above ground plane).
  50812. */
  50813. private _maintainCameraAboveGround;
  50814. /**
  50815. * Returns the frustum slope based on the canvas ratio and camera FOV
  50816. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50817. */
  50818. private _getFrustumSlope;
  50819. /**
  50820. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50821. */
  50822. private _clearAnimationLocks;
  50823. /**
  50824. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50825. */
  50826. private _applyUserInteraction;
  50827. /**
  50828. * Stops and removes all animations that have been applied to the camera
  50829. */
  50830. stopAllAnimations(): void;
  50831. /**
  50832. * Gets a value indicating if the user is moving the camera
  50833. */
  50834. get isUserIsMoving(): boolean;
  50835. /**
  50836. * The camera can move all the way towards the mesh.
  50837. */
  50838. static IgnoreBoundsSizeMode: number;
  50839. /**
  50840. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50841. */
  50842. static FitFrustumSidesMode: number;
  50843. }
  50844. }
  50845. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  50846. import { Nullable } from "babylonjs/types";
  50847. import { Camera } from "babylonjs/Cameras/camera";
  50848. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50849. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50850. /**
  50851. * Base class for Camera Pointer Inputs.
  50852. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50853. * for example usage.
  50854. */
  50855. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50856. /**
  50857. * Defines the camera the input is attached to.
  50858. */
  50859. abstract camera: Camera;
  50860. /**
  50861. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50862. */
  50863. protected _altKey: boolean;
  50864. protected _ctrlKey: boolean;
  50865. protected _metaKey: boolean;
  50866. protected _shiftKey: boolean;
  50867. /**
  50868. * Which mouse buttons were pressed at time of last mouse event.
  50869. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50870. */
  50871. protected _buttonsPressed: number;
  50872. /**
  50873. * Defines the buttons associated with the input to handle camera move.
  50874. */
  50875. buttons: number[];
  50876. /**
  50877. * Attach the input controls to a specific dom element to get the input from.
  50878. * @param element Defines the element the controls should be listened from
  50879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50880. */
  50881. attachControl(noPreventDefault?: boolean): void;
  50882. /**
  50883. * Detach the current controls from the specified dom element.
  50884. */
  50885. detachControl(): void;
  50886. /**
  50887. * Gets the class name of the current input.
  50888. * @returns the class name
  50889. */
  50890. getClassName(): string;
  50891. /**
  50892. * Get the friendly name associated with the input class.
  50893. * @returns the input friendly name
  50894. */
  50895. getSimpleName(): string;
  50896. /**
  50897. * Called on pointer POINTERDOUBLETAP event.
  50898. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50899. */
  50900. protected onDoubleTap(type: string): void;
  50901. /**
  50902. * Called on pointer POINTERMOVE event if only a single touch is active.
  50903. * Override this method to provide functionality.
  50904. */
  50905. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50906. /**
  50907. * Called on pointer POINTERMOVE event if multiple touches are active.
  50908. * Override this method to provide functionality.
  50909. */
  50910. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50911. /**
  50912. * Called on JS contextmenu event.
  50913. * Override this method to provide functionality.
  50914. */
  50915. protected onContextMenu(evt: PointerEvent): void;
  50916. /**
  50917. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50918. * press.
  50919. * Override this method to provide functionality.
  50920. */
  50921. protected onButtonDown(evt: PointerEvent): void;
  50922. /**
  50923. * Called each time a new POINTERUP event occurs. Ie, for each button
  50924. * release.
  50925. * Override this method to provide functionality.
  50926. */
  50927. protected onButtonUp(evt: PointerEvent): void;
  50928. /**
  50929. * Called when window becomes inactive.
  50930. * Override this method to provide functionality.
  50931. */
  50932. protected onLostFocus(): void;
  50933. private _pointerInput;
  50934. private _observer;
  50935. private _onLostFocus;
  50936. private pointA;
  50937. private pointB;
  50938. }
  50939. }
  50940. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  50941. import { Nullable } from "babylonjs/types";
  50942. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50943. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  50944. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50945. /**
  50946. * Manage the pointers inputs to control an arc rotate camera.
  50947. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50948. */
  50949. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50950. /**
  50951. * Defines the camera the input is attached to.
  50952. */
  50953. camera: ArcRotateCamera;
  50954. /**
  50955. * Gets the class name of the current input.
  50956. * @returns the class name
  50957. */
  50958. getClassName(): string;
  50959. /**
  50960. * Defines the buttons associated with the input to handle camera move.
  50961. */
  50962. buttons: number[];
  50963. /**
  50964. * Defines the pointer angular sensibility along the X axis or how fast is
  50965. * the camera rotating.
  50966. */
  50967. angularSensibilityX: number;
  50968. /**
  50969. * Defines the pointer angular sensibility along the Y axis or how fast is
  50970. * the camera rotating.
  50971. */
  50972. angularSensibilityY: number;
  50973. /**
  50974. * Defines the pointer pinch precision or how fast is the camera zooming.
  50975. */
  50976. pinchPrecision: number;
  50977. /**
  50978. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50979. * from 0.
  50980. * It defines the percentage of current camera.radius to use as delta when
  50981. * pinch zoom is used.
  50982. */
  50983. pinchDeltaPercentage: number;
  50984. /**
  50985. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50986. * that any object in the plane at the camera's target point will scale
  50987. * perfectly with finger motion.
  50988. * Overrides pinchDeltaPercentage and pinchPrecision.
  50989. */
  50990. useNaturalPinchZoom: boolean;
  50991. /**
  50992. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  50993. */
  50994. pinchZoom: boolean;
  50995. /**
  50996. * Defines the pointer panning sensibility or how fast is the camera moving.
  50997. */
  50998. panningSensibility: number;
  50999. /**
  51000. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  51001. */
  51002. multiTouchPanning: boolean;
  51003. /**
  51004. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  51005. * zoom (pinch) through multitouch.
  51006. */
  51007. multiTouchPanAndZoom: boolean;
  51008. /**
  51009. * Revers pinch action direction.
  51010. */
  51011. pinchInwards: boolean;
  51012. private _isPanClick;
  51013. private _twoFingerActivityCount;
  51014. private _isPinching;
  51015. /**
  51016. * Move camera from multi touch panning positions.
  51017. */
  51018. private _computeMultiTouchPanning;
  51019. /**
  51020. * Move camera from pinch zoom distances.
  51021. */
  51022. private _computePinchZoom;
  51023. /**
  51024. * Called on pointer POINTERMOVE event if only a single touch is active.
  51025. */
  51026. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51027. /**
  51028. * Called on pointer POINTERDOUBLETAP event.
  51029. */
  51030. protected onDoubleTap(type: string): void;
  51031. /**
  51032. * Called on pointer POINTERMOVE event if multiple touches are active.
  51033. */
  51034. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51035. /**
  51036. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  51037. * press.
  51038. */
  51039. protected onButtonDown(evt: PointerEvent): void;
  51040. /**
  51041. * Called each time a new POINTERUP event occurs. Ie, for each button
  51042. * release.
  51043. */
  51044. protected onButtonUp(evt: PointerEvent): void;
  51045. /**
  51046. * Called when window becomes inactive.
  51047. */
  51048. protected onLostFocus(): void;
  51049. }
  51050. }
  51051. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  51052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51053. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51054. /**
  51055. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  51056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51057. */
  51058. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  51059. /**
  51060. * Defines the camera the input is attached to.
  51061. */
  51062. camera: ArcRotateCamera;
  51063. /**
  51064. * Defines the list of key codes associated with the up action (increase alpha)
  51065. */
  51066. keysUp: number[];
  51067. /**
  51068. * Defines the list of key codes associated with the down action (decrease alpha)
  51069. */
  51070. keysDown: number[];
  51071. /**
  51072. * Defines the list of key codes associated with the left action (increase beta)
  51073. */
  51074. keysLeft: number[];
  51075. /**
  51076. * Defines the list of key codes associated with the right action (decrease beta)
  51077. */
  51078. keysRight: number[];
  51079. /**
  51080. * Defines the list of key codes associated with the reset action.
  51081. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  51082. */
  51083. keysReset: number[];
  51084. /**
  51085. * Defines the panning sensibility of the inputs.
  51086. * (How fast is the camera panning)
  51087. */
  51088. panningSensibility: number;
  51089. /**
  51090. * Defines the zooming sensibility of the inputs.
  51091. * (How fast is the camera zooming)
  51092. */
  51093. zoomingSensibility: number;
  51094. /**
  51095. * Defines whether maintaining the alt key down switch the movement mode from
  51096. * orientation to zoom.
  51097. */
  51098. useAltToZoom: boolean;
  51099. /**
  51100. * Rotation speed of the camera
  51101. */
  51102. angularSpeed: number;
  51103. private _keys;
  51104. private _ctrlPressed;
  51105. private _altPressed;
  51106. private _onCanvasBlurObserver;
  51107. private _onKeyboardObserver;
  51108. private _engine;
  51109. private _scene;
  51110. /**
  51111. * Attach the input controls to a specific dom element to get the input from.
  51112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51113. */
  51114. attachControl(noPreventDefault?: boolean): void;
  51115. /**
  51116. * Detach the current controls from the specified dom element.
  51117. */
  51118. detachControl(): void;
  51119. /**
  51120. * Update the current camera state depending on the inputs that have been used this frame.
  51121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51122. */
  51123. checkInputs(): void;
  51124. /**
  51125. * Gets the class name of the current intput.
  51126. * @returns the class name
  51127. */
  51128. getClassName(): string;
  51129. /**
  51130. * Get the friendly name associated with the input class.
  51131. * @returns the input friendly name
  51132. */
  51133. getSimpleName(): string;
  51134. }
  51135. }
  51136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  51137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51139. /**
  51140. * Manage the mouse wheel inputs to control an arc rotate camera.
  51141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51142. */
  51143. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  51144. /**
  51145. * Defines the camera the input is attached to.
  51146. */
  51147. camera: ArcRotateCamera;
  51148. /**
  51149. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51150. */
  51151. wheelPrecision: number;
  51152. /**
  51153. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51154. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51155. */
  51156. wheelDeltaPercentage: number;
  51157. private _wheel;
  51158. private _observer;
  51159. private computeDeltaFromMouseWheelLegacyEvent;
  51160. /**
  51161. * Attach the input controls to a specific dom element to get the input from.
  51162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51163. */
  51164. attachControl(noPreventDefault?: boolean): void;
  51165. /**
  51166. * Detach the current controls from the specified dom element.
  51167. */
  51168. detachControl(): void;
  51169. /**
  51170. * Gets the class name of the current intput.
  51171. * @returns the class name
  51172. */
  51173. getClassName(): string;
  51174. /**
  51175. * Get the friendly name associated with the input class.
  51176. * @returns the input friendly name
  51177. */
  51178. getSimpleName(): string;
  51179. }
  51180. }
  51181. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51182. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51183. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  51184. /**
  51185. * Default Inputs manager for the ArcRotateCamera.
  51186. * It groups all the default supported inputs for ease of use.
  51187. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51188. */
  51189. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  51190. /**
  51191. * Instantiates a new ArcRotateCameraInputsManager.
  51192. * @param camera Defines the camera the inputs belong to
  51193. */
  51194. constructor(camera: ArcRotateCamera);
  51195. /**
  51196. * Add mouse wheel input support to the input manager.
  51197. * @returns the current input manager
  51198. */
  51199. addMouseWheel(): ArcRotateCameraInputsManager;
  51200. /**
  51201. * Add pointers input support to the input manager.
  51202. * @returns the current input manager
  51203. */
  51204. addPointers(): ArcRotateCameraInputsManager;
  51205. /**
  51206. * Add keyboard input support to the input manager.
  51207. * @returns the current input manager
  51208. */
  51209. addKeyboard(): ArcRotateCameraInputsManager;
  51210. }
  51211. }
  51212. declare module "babylonjs/Cameras/arcRotateCamera" {
  51213. import { Observable } from "babylonjs/Misc/observable";
  51214. import { Nullable } from "babylonjs/types";
  51215. import { Scene } from "babylonjs/scene";
  51216. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  51217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51218. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51219. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51220. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  51221. import { Camera } from "babylonjs/Cameras/camera";
  51222. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  51223. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51224. import { Collider } from "babylonjs/Collisions/collider";
  51225. /**
  51226. * This represents an orbital type of camera.
  51227. *
  51228. * 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.
  51229. * 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.
  51230. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  51231. */
  51232. export class ArcRotateCamera extends TargetCamera {
  51233. /**
  51234. * Defines the rotation angle of the camera along the longitudinal axis.
  51235. */
  51236. alpha: number;
  51237. /**
  51238. * Defines the rotation angle of the camera along the latitudinal axis.
  51239. */
  51240. beta: number;
  51241. /**
  51242. * Defines the radius of the camera from it s target point.
  51243. */
  51244. radius: number;
  51245. protected _target: Vector3;
  51246. protected _targetHost: Nullable<AbstractMesh>;
  51247. /**
  51248. * Defines the target point of the camera.
  51249. * The camera looks towards it form the radius distance.
  51250. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  51251. */
  51252. get target(): Vector3;
  51253. set target(value: Vector3);
  51254. /**
  51255. * Define the current local position of the camera in the scene
  51256. */
  51257. get position(): Vector3;
  51258. set position(newPosition: Vector3);
  51259. protected _upToYMatrix: Matrix;
  51260. protected _YToUpMatrix: Matrix;
  51261. /**
  51262. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  51263. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  51264. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  51265. */
  51266. set upVector(vec: Vector3);
  51267. get upVector(): Vector3;
  51268. /**
  51269. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  51270. */
  51271. setMatUp(): void;
  51272. /**
  51273. * Current inertia value on the longitudinal axis.
  51274. * The bigger this number the longer it will take for the camera to stop.
  51275. */
  51276. inertialAlphaOffset: number;
  51277. /**
  51278. * Current inertia value on the latitudinal axis.
  51279. * The bigger this number the longer it will take for the camera to stop.
  51280. */
  51281. inertialBetaOffset: number;
  51282. /**
  51283. * Current inertia value on the radius axis.
  51284. * The bigger this number the longer it will take for the camera to stop.
  51285. */
  51286. inertialRadiusOffset: number;
  51287. /**
  51288. * Minimum allowed angle on the longitudinal axis.
  51289. * This can help limiting how the Camera is able to move in the scene.
  51290. */
  51291. lowerAlphaLimit: Nullable<number>;
  51292. /**
  51293. * Maximum allowed angle on the longitudinal axis.
  51294. * This can help limiting how the Camera is able to move in the scene.
  51295. */
  51296. upperAlphaLimit: Nullable<number>;
  51297. /**
  51298. * Minimum allowed angle on the latitudinal axis.
  51299. * This can help limiting how the Camera is able to move in the scene.
  51300. */
  51301. lowerBetaLimit: number;
  51302. /**
  51303. * Maximum allowed angle on the latitudinal axis.
  51304. * This can help limiting how the Camera is able to move in the scene.
  51305. */
  51306. upperBetaLimit: number;
  51307. /**
  51308. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  51309. * This can help limiting how the Camera is able to move in the scene.
  51310. */
  51311. lowerRadiusLimit: Nullable<number>;
  51312. /**
  51313. * Maximum allowed distance of the camera to the target (The camera can not get further).
  51314. * This can help limiting how the Camera is able to move in the scene.
  51315. */
  51316. upperRadiusLimit: Nullable<number>;
  51317. /**
  51318. * Defines the current inertia value used during panning of the camera along the X axis.
  51319. */
  51320. inertialPanningX: number;
  51321. /**
  51322. * Defines the current inertia value used during panning of the camera along the Y axis.
  51323. */
  51324. inertialPanningY: number;
  51325. /**
  51326. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  51327. * Basically if your fingers moves away from more than this distance you will be considered
  51328. * in pinch mode.
  51329. */
  51330. pinchToPanMaxDistance: number;
  51331. /**
  51332. * Defines the maximum distance the camera can pan.
  51333. * This could help keeping the cammera always in your scene.
  51334. */
  51335. panningDistanceLimit: Nullable<number>;
  51336. /**
  51337. * Defines the target of the camera before paning.
  51338. */
  51339. panningOriginTarget: Vector3;
  51340. /**
  51341. * Defines the value of the inertia used during panning.
  51342. * 0 would mean stop inertia and one would mean no decelleration at all.
  51343. */
  51344. panningInertia: number;
  51345. /**
  51346. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  51347. */
  51348. get angularSensibilityX(): number;
  51349. set angularSensibilityX(value: number);
  51350. /**
  51351. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  51352. */
  51353. get angularSensibilityY(): number;
  51354. set angularSensibilityY(value: number);
  51355. /**
  51356. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  51357. */
  51358. get pinchPrecision(): number;
  51359. set pinchPrecision(value: number);
  51360. /**
  51361. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  51362. * It will be used instead of pinchDeltaPrecision if different from 0.
  51363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51364. */
  51365. get pinchDeltaPercentage(): number;
  51366. set pinchDeltaPercentage(value: number);
  51367. /**
  51368. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  51369. * and pinch delta percentage.
  51370. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51371. * that any object in the plane at the camera's target point will scale
  51372. * perfectly with finger motion.
  51373. */
  51374. get useNaturalPinchZoom(): boolean;
  51375. set useNaturalPinchZoom(value: boolean);
  51376. /**
  51377. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  51378. */
  51379. get panningSensibility(): number;
  51380. set panningSensibility(value: number);
  51381. /**
  51382. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  51383. */
  51384. get keysUp(): number[];
  51385. set keysUp(value: number[]);
  51386. /**
  51387. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  51388. */
  51389. get keysDown(): number[];
  51390. set keysDown(value: number[]);
  51391. /**
  51392. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  51393. */
  51394. get keysLeft(): number[];
  51395. set keysLeft(value: number[]);
  51396. /**
  51397. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  51398. */
  51399. get keysRight(): number[];
  51400. set keysRight(value: number[]);
  51401. /**
  51402. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51403. */
  51404. get wheelPrecision(): number;
  51405. set wheelPrecision(value: number);
  51406. /**
  51407. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  51408. * It will be used instead of pinchDeltaPrecision if different from 0.
  51409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51410. */
  51411. get wheelDeltaPercentage(): number;
  51412. set wheelDeltaPercentage(value: number);
  51413. /**
  51414. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  51415. */
  51416. zoomOnFactor: number;
  51417. /**
  51418. * Defines a screen offset for the camera position.
  51419. */
  51420. targetScreenOffset: Vector2;
  51421. /**
  51422. * Allows the camera to be completely reversed.
  51423. * If false the camera can not arrive upside down.
  51424. */
  51425. allowUpsideDown: boolean;
  51426. /**
  51427. * Define if double tap/click is used to restore the previously saved state of the camera.
  51428. */
  51429. useInputToRestoreState: boolean;
  51430. /** @hidden */
  51431. _viewMatrix: Matrix;
  51432. /** @hidden */
  51433. _useCtrlForPanning: boolean;
  51434. /** @hidden */
  51435. _panningMouseButton: number;
  51436. /**
  51437. * Defines the input associated to the camera.
  51438. */
  51439. inputs: ArcRotateCameraInputsManager;
  51440. /** @hidden */
  51441. _reset: () => void;
  51442. /**
  51443. * Defines the allowed panning axis.
  51444. */
  51445. panningAxis: Vector3;
  51446. protected _transformedDirection: Vector3;
  51447. private _bouncingBehavior;
  51448. /**
  51449. * Gets the bouncing behavior of the camera if it has been enabled.
  51450. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51451. */
  51452. get bouncingBehavior(): Nullable<BouncingBehavior>;
  51453. /**
  51454. * Defines if the bouncing behavior of the camera is enabled on the camera.
  51455. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51456. */
  51457. get useBouncingBehavior(): boolean;
  51458. set useBouncingBehavior(value: boolean);
  51459. private _framingBehavior;
  51460. /**
  51461. * Gets the framing behavior of the camera if it has been enabled.
  51462. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51463. */
  51464. get framingBehavior(): Nullable<FramingBehavior>;
  51465. /**
  51466. * Defines if the framing behavior of the camera is enabled on the camera.
  51467. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51468. */
  51469. get useFramingBehavior(): boolean;
  51470. set useFramingBehavior(value: boolean);
  51471. private _autoRotationBehavior;
  51472. /**
  51473. * Gets the auto rotation behavior of the camera if it has been enabled.
  51474. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51475. */
  51476. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  51477. /**
  51478. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  51479. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51480. */
  51481. get useAutoRotationBehavior(): boolean;
  51482. set useAutoRotationBehavior(value: boolean);
  51483. /**
  51484. * Observable triggered when the mesh target has been changed on the camera.
  51485. */
  51486. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  51487. /**
  51488. * Event raised when the camera is colliding with a mesh.
  51489. */
  51490. onCollide: (collidedMesh: AbstractMesh) => void;
  51491. /**
  51492. * Defines whether the camera should check collision with the objects oh the scene.
  51493. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  51494. */
  51495. checkCollisions: boolean;
  51496. /**
  51497. * Defines the collision radius of the camera.
  51498. * This simulates a sphere around the camera.
  51499. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51500. */
  51501. collisionRadius: Vector3;
  51502. protected _collider: Collider;
  51503. protected _previousPosition: Vector3;
  51504. protected _collisionVelocity: Vector3;
  51505. protected _newPosition: Vector3;
  51506. protected _previousAlpha: number;
  51507. protected _previousBeta: number;
  51508. protected _previousRadius: number;
  51509. protected _collisionTriggered: boolean;
  51510. protected _targetBoundingCenter: Nullable<Vector3>;
  51511. private _computationVector;
  51512. /**
  51513. * Instantiates a new ArcRotateCamera in a given scene
  51514. * @param name Defines the name of the camera
  51515. * @param alpha Defines the camera rotation along the logitudinal axis
  51516. * @param beta Defines the camera rotation along the latitudinal axis
  51517. * @param radius Defines the camera distance from its target
  51518. * @param target Defines the camera target
  51519. * @param scene Defines the scene the camera belongs to
  51520. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  51521. */
  51522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51523. /** @hidden */
  51524. _initCache(): void;
  51525. /** @hidden */
  51526. _updateCache(ignoreParentClass?: boolean): void;
  51527. protected _getTargetPosition(): Vector3;
  51528. private _storedAlpha;
  51529. private _storedBeta;
  51530. private _storedRadius;
  51531. private _storedTarget;
  51532. private _storedTargetScreenOffset;
  51533. /**
  51534. * Stores the current state of the camera (alpha, beta, radius and target)
  51535. * @returns the camera itself
  51536. */
  51537. storeState(): Camera;
  51538. /**
  51539. * @hidden
  51540. * Restored camera state. You must call storeState() first
  51541. */
  51542. _restoreStateValues(): boolean;
  51543. /** @hidden */
  51544. _isSynchronizedViewMatrix(): boolean;
  51545. /**
  51546. * Attach the input controls to a specific dom element to get the input from.
  51547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51548. */
  51549. attachControl(noPreventDefault?: boolean): void;
  51550. /**
  51551. * Attach the input controls to a specific dom element to get the input from.
  51552. * @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
  51553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51554. */
  51555. attachControl(ignored: any, noPreventDefault?: boolean): void;
  51556. /**
  51557. * Attached controls to the current camera.
  51558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51559. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51560. */
  51561. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51562. /**
  51563. * Attached controls to the current camera.
  51564. * @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
  51565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51566. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51567. */
  51568. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51569. /**
  51570. * Attached controls to the current camera.
  51571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51572. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51573. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  51574. */
  51575. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  51576. /**
  51577. * Detach the current controls from the specified dom element.
  51578. */
  51579. detachControl(): void;
  51580. /**
  51581. * Detach the current controls from the specified dom element.
  51582. * @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
  51583. */
  51584. detachControl(ignored: any): void;
  51585. /** @hidden */
  51586. _checkInputs(): void;
  51587. protected _checkLimits(): void;
  51588. /**
  51589. * Rebuilds angles (alpha, beta) and radius from the give position and target
  51590. */
  51591. rebuildAnglesAndRadius(): void;
  51592. /**
  51593. * Use a position to define the current camera related information like alpha, beta and radius
  51594. * @param position Defines the position to set the camera at
  51595. */
  51596. setPosition(position: Vector3): void;
  51597. /**
  51598. * Defines the target the camera should look at.
  51599. * This will automatically adapt alpha beta and radius to fit within the new target.
  51600. * @param target Defines the new target as a Vector or a mesh
  51601. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  51602. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  51603. */
  51604. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  51605. /** @hidden */
  51606. _getViewMatrix(): Matrix;
  51607. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  51608. /**
  51609. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  51610. * @param meshes Defines the mesh to zoom on
  51611. * @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)
  51612. */
  51613. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  51614. /**
  51615. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  51616. * The target will be changed but the radius
  51617. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  51618. * @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)
  51619. */
  51620. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  51621. min: Vector3;
  51622. max: Vector3;
  51623. distance: number;
  51624. }, doNotUpdateMaxZ?: boolean): void;
  51625. /**
  51626. * @override
  51627. * Override Camera.createRigCamera
  51628. */
  51629. createRigCamera(name: string, cameraIndex: number): Camera;
  51630. /**
  51631. * @hidden
  51632. * @override
  51633. * Override Camera._updateRigCameras
  51634. */
  51635. _updateRigCameras(): void;
  51636. /**
  51637. * Destroy the camera and release the current resources hold by it.
  51638. */
  51639. dispose(): void;
  51640. /**
  51641. * Gets the current object class name.
  51642. * @return the class name
  51643. */
  51644. getClassName(): string;
  51645. }
  51646. }
  51647. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  51648. import { Behavior } from "babylonjs/Behaviors/behavior";
  51649. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51650. /**
  51651. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  51652. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51653. */
  51654. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  51655. /**
  51656. * Gets the name of the behavior.
  51657. */
  51658. get name(): string;
  51659. private _zoomStopsAnimation;
  51660. private _idleRotationSpeed;
  51661. private _idleRotationWaitTime;
  51662. private _idleRotationSpinupTime;
  51663. /**
  51664. * Sets the flag that indicates if user zooming should stop animation.
  51665. */
  51666. set zoomStopsAnimation(flag: boolean);
  51667. /**
  51668. * Gets the flag that indicates if user zooming should stop animation.
  51669. */
  51670. get zoomStopsAnimation(): boolean;
  51671. /**
  51672. * Sets the default speed at which the camera rotates around the model.
  51673. */
  51674. set idleRotationSpeed(speed: number);
  51675. /**
  51676. * Gets the default speed at which the camera rotates around the model.
  51677. */
  51678. get idleRotationSpeed(): number;
  51679. /**
  51680. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51681. */
  51682. set idleRotationWaitTime(time: number);
  51683. /**
  51684. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51685. */
  51686. get idleRotationWaitTime(): number;
  51687. /**
  51688. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51689. */
  51690. set idleRotationSpinupTime(time: number);
  51691. /**
  51692. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51693. */
  51694. get idleRotationSpinupTime(): number;
  51695. /**
  51696. * Gets a value indicating if the camera is currently rotating because of this behavior
  51697. */
  51698. get rotationInProgress(): boolean;
  51699. private _onPrePointerObservableObserver;
  51700. private _onAfterCheckInputsObserver;
  51701. private _attachedCamera;
  51702. private _isPointerDown;
  51703. private _lastFrameTime;
  51704. private _lastInteractionTime;
  51705. private _cameraRotationSpeed;
  51706. /**
  51707. * Initializes the behavior.
  51708. */
  51709. init(): void;
  51710. /**
  51711. * Attaches the behavior to its arc rotate camera.
  51712. * @param camera Defines the camera to attach the behavior to
  51713. */
  51714. attach(camera: ArcRotateCamera): void;
  51715. /**
  51716. * Detaches the behavior from its current arc rotate camera.
  51717. */
  51718. detach(): void;
  51719. /**
  51720. * Returns true if user is scrolling.
  51721. * @return true if user is scrolling.
  51722. */
  51723. private _userIsZooming;
  51724. private _lastFrameRadius;
  51725. private _shouldAnimationStopForInteraction;
  51726. /**
  51727. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51728. */
  51729. private _applyUserInteraction;
  51730. private _userIsMoving;
  51731. }
  51732. }
  51733. declare module "babylonjs/Behaviors/Cameras/index" {
  51734. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51735. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51736. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  51737. }
  51738. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  51739. import { Mesh } from "babylonjs/Meshes/mesh";
  51740. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51741. import { Behavior } from "babylonjs/Behaviors/behavior";
  51742. /**
  51743. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51744. */
  51745. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51746. private ui;
  51747. /**
  51748. * The name of the behavior
  51749. */
  51750. name: string;
  51751. /**
  51752. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51753. */
  51754. distanceAwayFromFace: number;
  51755. /**
  51756. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51757. */
  51758. distanceAwayFromBottomOfFace: number;
  51759. private _faceVectors;
  51760. private _target;
  51761. private _scene;
  51762. private _onRenderObserver;
  51763. private _tmpMatrix;
  51764. private _tmpVector;
  51765. /**
  51766. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51767. * @param ui The transform node that should be attched to the mesh
  51768. */
  51769. constructor(ui: TransformNode);
  51770. /**
  51771. * Initializes the behavior
  51772. */
  51773. init(): void;
  51774. private _closestFace;
  51775. private _zeroVector;
  51776. private _lookAtTmpMatrix;
  51777. private _lookAtToRef;
  51778. /**
  51779. * Attaches the AttachToBoxBehavior to the passed in mesh
  51780. * @param target The mesh that the specified node will be attached to
  51781. */
  51782. attach(target: Mesh): void;
  51783. /**
  51784. * Detaches the behavior from the mesh
  51785. */
  51786. detach(): void;
  51787. }
  51788. }
  51789. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  51790. import { Behavior } from "babylonjs/Behaviors/behavior";
  51791. import { Mesh } from "babylonjs/Meshes/mesh";
  51792. /**
  51793. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51794. */
  51795. export class FadeInOutBehavior implements Behavior<Mesh> {
  51796. /**
  51797. * Time in milliseconds to delay before fading in (Default: 0)
  51798. */
  51799. delay: number;
  51800. /**
  51801. * Time in milliseconds for the mesh to fade in (Default: 300)
  51802. */
  51803. fadeInTime: number;
  51804. private _millisecondsPerFrame;
  51805. private _hovered;
  51806. private _hoverValue;
  51807. private _ownerNode;
  51808. /**
  51809. * Instatiates the FadeInOutBehavior
  51810. */
  51811. constructor();
  51812. /**
  51813. * The name of the behavior
  51814. */
  51815. get name(): string;
  51816. /**
  51817. * Initializes the behavior
  51818. */
  51819. init(): void;
  51820. /**
  51821. * Attaches the fade behavior on the passed in mesh
  51822. * @param ownerNode The mesh that will be faded in/out once attached
  51823. */
  51824. attach(ownerNode: Mesh): void;
  51825. /**
  51826. * Detaches the behavior from the mesh
  51827. */
  51828. detach(): void;
  51829. /**
  51830. * Triggers the mesh to begin fading in or out
  51831. * @param value if the object should fade in or out (true to fade in)
  51832. */
  51833. fadeIn(value: boolean): void;
  51834. private _update;
  51835. private _setAllVisibility;
  51836. }
  51837. }
  51838. declare module "babylonjs/Misc/pivotTools" {
  51839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51840. /**
  51841. * Class containing a set of static utilities functions for managing Pivots
  51842. * @hidden
  51843. */
  51844. export class PivotTools {
  51845. private static _PivotCached;
  51846. private static _OldPivotPoint;
  51847. private static _PivotTranslation;
  51848. private static _PivotTmpVector;
  51849. private static _PivotPostMultiplyPivotMatrix;
  51850. /** @hidden */
  51851. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51852. /** @hidden */
  51853. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51854. }
  51855. }
  51856. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  51857. import { Scene } from "babylonjs/scene";
  51858. import { Vector4 } from "babylonjs/Maths/math.vector";
  51859. import { Mesh } from "babylonjs/Meshes/mesh";
  51860. import { Nullable } from "babylonjs/types";
  51861. import { Plane } from "babylonjs/Maths/math.plane";
  51862. /**
  51863. * Class containing static functions to help procedurally build meshes
  51864. */
  51865. export class PlaneBuilder {
  51866. /**
  51867. * Creates a plane mesh
  51868. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51869. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51870. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51874. * @param name defines the name of the mesh
  51875. * @param options defines the options used to create the mesh
  51876. * @param scene defines the hosting scene
  51877. * @returns the plane mesh
  51878. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51879. */
  51880. static CreatePlane(name: string, options: {
  51881. size?: number;
  51882. width?: number;
  51883. height?: number;
  51884. sideOrientation?: number;
  51885. frontUVs?: Vector4;
  51886. backUVs?: Vector4;
  51887. updatable?: boolean;
  51888. sourcePlane?: Plane;
  51889. }, scene?: Nullable<Scene>): Mesh;
  51890. }
  51891. }
  51892. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  51893. import { Behavior } from "babylonjs/Behaviors/behavior";
  51894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51895. import { Observable } from "babylonjs/Misc/observable";
  51896. import { Vector3 } from "babylonjs/Maths/math.vector";
  51897. import { Ray } from "babylonjs/Culling/ray";
  51898. import "babylonjs/Meshes/Builders/planeBuilder";
  51899. /**
  51900. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51901. */
  51902. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51903. private static _AnyMouseID;
  51904. /**
  51905. * Abstract mesh the behavior is set on
  51906. */
  51907. attachedNode: AbstractMesh;
  51908. private _dragPlane;
  51909. private _scene;
  51910. private _pointerObserver;
  51911. private _beforeRenderObserver;
  51912. private static _planeScene;
  51913. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51914. /**
  51915. * 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)
  51916. */
  51917. maxDragAngle: number;
  51918. /**
  51919. * @hidden
  51920. */
  51921. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51922. /**
  51923. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51924. */
  51925. currentDraggingPointerID: number;
  51926. /**
  51927. * The last position where the pointer hit the drag plane in world space
  51928. */
  51929. lastDragPosition: Vector3;
  51930. /**
  51931. * If the behavior is currently in a dragging state
  51932. */
  51933. dragging: boolean;
  51934. /**
  51935. * 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)
  51936. */
  51937. dragDeltaRatio: number;
  51938. /**
  51939. * If the drag plane orientation should be updated during the dragging (Default: true)
  51940. */
  51941. updateDragPlane: boolean;
  51942. private _debugMode;
  51943. private _moving;
  51944. /**
  51945. * Fires each time the attached mesh is dragged with the pointer
  51946. * * delta between last drag position and current drag position in world space
  51947. * * dragDistance along the drag axis
  51948. * * dragPlaneNormal normal of the current drag plane used during the drag
  51949. * * dragPlanePoint in world space where the drag intersects the drag plane
  51950. */
  51951. onDragObservable: Observable<{
  51952. delta: Vector3;
  51953. dragPlanePoint: Vector3;
  51954. dragPlaneNormal: Vector3;
  51955. dragDistance: number;
  51956. pointerId: number;
  51957. }>;
  51958. /**
  51959. * Fires each time a drag begins (eg. mouse down on mesh)
  51960. */
  51961. onDragStartObservable: Observable<{
  51962. dragPlanePoint: Vector3;
  51963. pointerId: number;
  51964. }>;
  51965. /**
  51966. * Fires each time a drag ends (eg. mouse release after drag)
  51967. */
  51968. onDragEndObservable: Observable<{
  51969. dragPlanePoint: Vector3;
  51970. pointerId: number;
  51971. }>;
  51972. /**
  51973. * If the attached mesh should be moved when dragged
  51974. */
  51975. moveAttached: boolean;
  51976. /**
  51977. * If the drag behavior will react to drag events (Default: true)
  51978. */
  51979. enabled: boolean;
  51980. /**
  51981. * If pointer events should start and release the drag (Default: true)
  51982. */
  51983. startAndReleaseDragOnPointerEvents: boolean;
  51984. /**
  51985. * If camera controls should be detached during the drag
  51986. */
  51987. detachCameraControls: boolean;
  51988. /**
  51989. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51990. */
  51991. useObjectOrientationForDragging: boolean;
  51992. private _options;
  51993. /**
  51994. * Gets the options used by the behavior
  51995. */
  51996. get options(): {
  51997. dragAxis?: Vector3;
  51998. dragPlaneNormal?: Vector3;
  51999. };
  52000. /**
  52001. * Sets the options used by the behavior
  52002. */
  52003. set options(options: {
  52004. dragAxis?: Vector3;
  52005. dragPlaneNormal?: Vector3;
  52006. });
  52007. /**
  52008. * Creates a pointer drag behavior that can be attached to a mesh
  52009. * @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)
  52010. */
  52011. constructor(options?: {
  52012. dragAxis?: Vector3;
  52013. dragPlaneNormal?: Vector3;
  52014. });
  52015. /**
  52016. * Predicate to determine if it is valid to move the object to a new position when it is moved
  52017. */
  52018. validateDrag: (targetPosition: Vector3) => boolean;
  52019. /**
  52020. * The name of the behavior
  52021. */
  52022. get name(): string;
  52023. /**
  52024. * Initializes the behavior
  52025. */
  52026. init(): void;
  52027. private _tmpVector;
  52028. private _alternatePickedPoint;
  52029. private _worldDragAxis;
  52030. private _targetPosition;
  52031. private _attachedToElement;
  52032. /**
  52033. * Attaches the drag behavior the passed in mesh
  52034. * @param ownerNode The mesh that will be dragged around once attached
  52035. * @param predicate Predicate to use for pick filtering
  52036. */
  52037. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  52038. /**
  52039. * Force relase the drag action by code.
  52040. */
  52041. releaseDrag(): void;
  52042. private _startDragRay;
  52043. private _lastPointerRay;
  52044. /**
  52045. * Simulates the start of a pointer drag event on the behavior
  52046. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  52047. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  52048. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  52049. */
  52050. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52051. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52052. private _dragDelta;
  52053. protected _moveDrag(ray: Ray): void;
  52054. private _pickWithRayOnDragPlane;
  52055. private _pointA;
  52056. private _pointC;
  52057. private _localAxis;
  52058. private _lookAt;
  52059. private _updateDragPlanePosition;
  52060. /**
  52061. * Detaches the behavior from the mesh
  52062. */
  52063. detach(): void;
  52064. }
  52065. }
  52066. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  52067. import { Mesh } from "babylonjs/Meshes/mesh";
  52068. import { Behavior } from "babylonjs/Behaviors/behavior";
  52069. /**
  52070. * A behavior that when attached to a mesh will allow the mesh to be scaled
  52071. */
  52072. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  52073. private _dragBehaviorA;
  52074. private _dragBehaviorB;
  52075. private _startDistance;
  52076. private _initialScale;
  52077. private _targetScale;
  52078. private _ownerNode;
  52079. private _sceneRenderObserver;
  52080. /**
  52081. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  52082. */
  52083. constructor();
  52084. /**
  52085. * The name of the behavior
  52086. */
  52087. get name(): string;
  52088. /**
  52089. * Initializes the behavior
  52090. */
  52091. init(): void;
  52092. private _getCurrentDistance;
  52093. /**
  52094. * Attaches the scale behavior the passed in mesh
  52095. * @param ownerNode The mesh that will be scaled around once attached
  52096. */
  52097. attach(ownerNode: Mesh): void;
  52098. /**
  52099. * Detaches the behavior from the mesh
  52100. */
  52101. detach(): void;
  52102. }
  52103. }
  52104. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  52105. import { Behavior } from "babylonjs/Behaviors/behavior";
  52106. import { Mesh } from "babylonjs/Meshes/mesh";
  52107. import { Observable } from "babylonjs/Misc/observable";
  52108. /**
  52109. * 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
  52110. */
  52111. export class SixDofDragBehavior implements Behavior<Mesh> {
  52112. private static _virtualScene;
  52113. private _ownerNode;
  52114. private _sceneRenderObserver;
  52115. private _scene;
  52116. private _targetPosition;
  52117. private _virtualOriginMesh;
  52118. private _virtualDragMesh;
  52119. private _pointerObserver;
  52120. private _moving;
  52121. private _startingOrientation;
  52122. private _attachedToElement;
  52123. /**
  52124. * 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)
  52125. */
  52126. private zDragFactor;
  52127. /**
  52128. * If the object should rotate to face the drag origin
  52129. */
  52130. rotateDraggedObject: boolean;
  52131. /**
  52132. * If the behavior is currently in a dragging state
  52133. */
  52134. dragging: boolean;
  52135. /**
  52136. * 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)
  52137. */
  52138. dragDeltaRatio: number;
  52139. /**
  52140. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  52141. */
  52142. currentDraggingPointerID: number;
  52143. /**
  52144. * If camera controls should be detached during the drag
  52145. */
  52146. detachCameraControls: boolean;
  52147. /**
  52148. * Fires each time a drag starts
  52149. */
  52150. onDragStartObservable: Observable<{}>;
  52151. /**
  52152. * Fires each time a drag happens
  52153. */
  52154. onDragObservable: Observable<void>;
  52155. /**
  52156. * Fires each time a drag ends (eg. mouse release after drag)
  52157. */
  52158. onDragEndObservable: Observable<{}>;
  52159. /**
  52160. * 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
  52161. */
  52162. constructor();
  52163. /**
  52164. * The name of the behavior
  52165. */
  52166. get name(): string;
  52167. /**
  52168. * Initializes the behavior
  52169. */
  52170. init(): void;
  52171. /**
  52172. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  52173. */
  52174. private get _pointerCamera();
  52175. /**
  52176. * Attaches the scale behavior the passed in mesh
  52177. * @param ownerNode The mesh that will be scaled around once attached
  52178. */
  52179. attach(ownerNode: Mesh): void;
  52180. /**
  52181. * Detaches the behavior from the mesh
  52182. */
  52183. detach(): void;
  52184. }
  52185. }
  52186. declare module "babylonjs/Behaviors/Meshes/index" {
  52187. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  52188. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  52189. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  52190. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52191. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  52192. }
  52193. declare module "babylonjs/Behaviors/index" {
  52194. export * from "babylonjs/Behaviors/behavior";
  52195. export * from "babylonjs/Behaviors/Cameras/index";
  52196. export * from "babylonjs/Behaviors/Meshes/index";
  52197. }
  52198. declare module "babylonjs/Bones/boneIKController" {
  52199. import { Bone } from "babylonjs/Bones/bone";
  52200. import { Vector3 } from "babylonjs/Maths/math.vector";
  52201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52202. import { Nullable } from "babylonjs/types";
  52203. /**
  52204. * Class used to apply inverse kinematics to bones
  52205. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  52206. */
  52207. export class BoneIKController {
  52208. private static _tmpVecs;
  52209. private static _tmpQuat;
  52210. private static _tmpMats;
  52211. /**
  52212. * Gets or sets the target mesh
  52213. */
  52214. targetMesh: AbstractMesh;
  52215. /** Gets or sets the mesh used as pole */
  52216. poleTargetMesh: AbstractMesh;
  52217. /**
  52218. * Gets or sets the bone used as pole
  52219. */
  52220. poleTargetBone: Nullable<Bone>;
  52221. /**
  52222. * Gets or sets the target position
  52223. */
  52224. targetPosition: Vector3;
  52225. /**
  52226. * Gets or sets the pole target position
  52227. */
  52228. poleTargetPosition: Vector3;
  52229. /**
  52230. * Gets or sets the pole target local offset
  52231. */
  52232. poleTargetLocalOffset: Vector3;
  52233. /**
  52234. * Gets or sets the pole angle
  52235. */
  52236. poleAngle: number;
  52237. /**
  52238. * Gets or sets the mesh associated with the controller
  52239. */
  52240. mesh: AbstractMesh;
  52241. /**
  52242. * 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)
  52243. */
  52244. slerpAmount: number;
  52245. private _bone1Quat;
  52246. private _bone1Mat;
  52247. private _bone2Ang;
  52248. private _bone1;
  52249. private _bone2;
  52250. private _bone1Length;
  52251. private _bone2Length;
  52252. private _maxAngle;
  52253. private _maxReach;
  52254. private _rightHandedSystem;
  52255. private _bendAxis;
  52256. private _slerping;
  52257. private _adjustRoll;
  52258. /**
  52259. * Gets or sets maximum allowed angle
  52260. */
  52261. get maxAngle(): number;
  52262. set maxAngle(value: number);
  52263. /**
  52264. * Creates a new BoneIKController
  52265. * @param mesh defines the mesh to control
  52266. * @param bone defines the bone to control
  52267. * @param options defines options to set up the controller
  52268. */
  52269. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  52270. targetMesh?: AbstractMesh;
  52271. poleTargetMesh?: AbstractMesh;
  52272. poleTargetBone?: Bone;
  52273. poleTargetLocalOffset?: Vector3;
  52274. poleAngle?: number;
  52275. bendAxis?: Vector3;
  52276. maxAngle?: number;
  52277. slerpAmount?: number;
  52278. });
  52279. private _setMaxAngle;
  52280. /**
  52281. * Force the controller to update the bones
  52282. */
  52283. update(): void;
  52284. }
  52285. }
  52286. declare module "babylonjs/Bones/boneLookController" {
  52287. import { Vector3 } from "babylonjs/Maths/math.vector";
  52288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52289. import { Bone } from "babylonjs/Bones/bone";
  52290. import { Space } from "babylonjs/Maths/math.axis";
  52291. /**
  52292. * Class used to make a bone look toward a point in space
  52293. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  52294. */
  52295. export class BoneLookController {
  52296. private static _tmpVecs;
  52297. private static _tmpQuat;
  52298. private static _tmpMats;
  52299. /**
  52300. * The target Vector3 that the bone will look at
  52301. */
  52302. target: Vector3;
  52303. /**
  52304. * The mesh that the bone is attached to
  52305. */
  52306. mesh: AbstractMesh;
  52307. /**
  52308. * The bone that will be looking to the target
  52309. */
  52310. bone: Bone;
  52311. /**
  52312. * The up axis of the coordinate system that is used when the bone is rotated
  52313. */
  52314. upAxis: Vector3;
  52315. /**
  52316. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  52317. */
  52318. upAxisSpace: Space;
  52319. /**
  52320. * Used to make an adjustment to the yaw of the bone
  52321. */
  52322. adjustYaw: number;
  52323. /**
  52324. * Used to make an adjustment to the pitch of the bone
  52325. */
  52326. adjustPitch: number;
  52327. /**
  52328. * Used to make an adjustment to the roll of the bone
  52329. */
  52330. adjustRoll: number;
  52331. /**
  52332. * 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)
  52333. */
  52334. slerpAmount: number;
  52335. private _minYaw;
  52336. private _maxYaw;
  52337. private _minPitch;
  52338. private _maxPitch;
  52339. private _minYawSin;
  52340. private _minYawCos;
  52341. private _maxYawSin;
  52342. private _maxYawCos;
  52343. private _midYawConstraint;
  52344. private _minPitchTan;
  52345. private _maxPitchTan;
  52346. private _boneQuat;
  52347. private _slerping;
  52348. private _transformYawPitch;
  52349. private _transformYawPitchInv;
  52350. private _firstFrameSkipped;
  52351. private _yawRange;
  52352. private _fowardAxis;
  52353. /**
  52354. * Gets or sets the minimum yaw angle that the bone can look to
  52355. */
  52356. get minYaw(): number;
  52357. set minYaw(value: number);
  52358. /**
  52359. * Gets or sets the maximum yaw angle that the bone can look to
  52360. */
  52361. get maxYaw(): number;
  52362. set maxYaw(value: number);
  52363. /**
  52364. * Gets or sets the minimum pitch angle that the bone can look to
  52365. */
  52366. get minPitch(): number;
  52367. set minPitch(value: number);
  52368. /**
  52369. * Gets or sets the maximum pitch angle that the bone can look to
  52370. */
  52371. get maxPitch(): number;
  52372. set maxPitch(value: number);
  52373. /**
  52374. * Create a BoneLookController
  52375. * @param mesh the mesh that the bone belongs to
  52376. * @param bone the bone that will be looking to the target
  52377. * @param target the target Vector3 to look at
  52378. * @param options optional settings:
  52379. * * maxYaw: the maximum angle the bone will yaw to
  52380. * * minYaw: the minimum angle the bone will yaw to
  52381. * * maxPitch: the maximum angle the bone will pitch to
  52382. * * minPitch: the minimum angle the bone will yaw to
  52383. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  52384. * * upAxis: the up axis of the coordinate system
  52385. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  52386. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  52387. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  52388. * * adjustYaw: used to make an adjustment to the yaw of the bone
  52389. * * adjustPitch: used to make an adjustment to the pitch of the bone
  52390. * * adjustRoll: used to make an adjustment to the roll of the bone
  52391. **/
  52392. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  52393. maxYaw?: number;
  52394. minYaw?: number;
  52395. maxPitch?: number;
  52396. minPitch?: number;
  52397. slerpAmount?: number;
  52398. upAxis?: Vector3;
  52399. upAxisSpace?: Space;
  52400. yawAxis?: Vector3;
  52401. pitchAxis?: Vector3;
  52402. adjustYaw?: number;
  52403. adjustPitch?: number;
  52404. adjustRoll?: number;
  52405. });
  52406. /**
  52407. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  52408. */
  52409. update(): void;
  52410. private _getAngleDiff;
  52411. private _getAngleBetween;
  52412. private _isAngleBetween;
  52413. }
  52414. }
  52415. declare module "babylonjs/Bones/index" {
  52416. export * from "babylonjs/Bones/bone";
  52417. export * from "babylonjs/Bones/boneIKController";
  52418. export * from "babylonjs/Bones/boneLookController";
  52419. export * from "babylonjs/Bones/skeleton";
  52420. }
  52421. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  52422. import { Nullable } from "babylonjs/types";
  52423. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52424. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52425. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  52426. /**
  52427. * Manage the gamepad inputs to control an arc rotate camera.
  52428. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52429. */
  52430. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  52431. /**
  52432. * Defines the camera the input is attached to.
  52433. */
  52434. camera: ArcRotateCamera;
  52435. /**
  52436. * Defines the gamepad the input is gathering event from.
  52437. */
  52438. gamepad: Nullable<Gamepad>;
  52439. /**
  52440. * Defines the gamepad rotation sensiblity.
  52441. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52442. */
  52443. gamepadRotationSensibility: number;
  52444. /**
  52445. * Defines the gamepad move sensiblity.
  52446. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52447. */
  52448. gamepadMoveSensibility: number;
  52449. private _yAxisScale;
  52450. /**
  52451. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52452. */
  52453. get invertYAxis(): boolean;
  52454. set invertYAxis(value: boolean);
  52455. private _onGamepadConnectedObserver;
  52456. private _onGamepadDisconnectedObserver;
  52457. /**
  52458. * Attach the input controls to a specific dom element to get the input from.
  52459. */
  52460. attachControl(): void;
  52461. /**
  52462. * Detach the current controls from the specified dom element.
  52463. */
  52464. detachControl(): void;
  52465. /**
  52466. * Update the current camera state depending on the inputs that have been used this frame.
  52467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52468. */
  52469. checkInputs(): void;
  52470. /**
  52471. * Gets the class name of the current intput.
  52472. * @returns the class name
  52473. */
  52474. getClassName(): string;
  52475. /**
  52476. * Get the friendly name associated with the input class.
  52477. * @returns the input friendly name
  52478. */
  52479. getSimpleName(): string;
  52480. }
  52481. }
  52482. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  52483. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52484. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52485. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  52486. interface ArcRotateCameraInputsManager {
  52487. /**
  52488. * Add orientation input support to the input manager.
  52489. * @returns the current input manager
  52490. */
  52491. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  52492. }
  52493. }
  52494. /**
  52495. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  52496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52497. */
  52498. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  52499. /**
  52500. * Defines the camera the input is attached to.
  52501. */
  52502. camera: ArcRotateCamera;
  52503. /**
  52504. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  52505. */
  52506. alphaCorrection: number;
  52507. /**
  52508. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  52509. */
  52510. gammaCorrection: number;
  52511. private _alpha;
  52512. private _gamma;
  52513. private _dirty;
  52514. private _deviceOrientationHandler;
  52515. /**
  52516. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  52517. */
  52518. constructor();
  52519. /**
  52520. * Attach the input controls to a specific dom element to get the input from.
  52521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52522. */
  52523. attachControl(noPreventDefault?: boolean): void;
  52524. /** @hidden */
  52525. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  52526. /**
  52527. * Update the current camera state depending on the inputs that have been used this frame.
  52528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52529. */
  52530. checkInputs(): void;
  52531. /**
  52532. * Detach the current controls from the specified dom element.
  52533. */
  52534. detachControl(): void;
  52535. /**
  52536. * Gets the class name of the current intput.
  52537. * @returns the class name
  52538. */
  52539. getClassName(): string;
  52540. /**
  52541. * Get the friendly name associated with the input class.
  52542. * @returns the input friendly name
  52543. */
  52544. getSimpleName(): string;
  52545. }
  52546. }
  52547. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  52548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52549. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52550. /**
  52551. * Listen to mouse events to control the camera.
  52552. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52553. */
  52554. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  52555. /**
  52556. * Defines the camera the input is attached to.
  52557. */
  52558. camera: FlyCamera;
  52559. /**
  52560. * Defines if touch is enabled. (Default is true.)
  52561. */
  52562. touchEnabled: boolean;
  52563. /**
  52564. * Defines the buttons associated with the input to handle camera rotation.
  52565. */
  52566. buttons: number[];
  52567. /**
  52568. * Assign buttons for Yaw control.
  52569. */
  52570. buttonsYaw: number[];
  52571. /**
  52572. * Assign buttons for Pitch control.
  52573. */
  52574. buttonsPitch: number[];
  52575. /**
  52576. * Assign buttons for Roll control.
  52577. */
  52578. buttonsRoll: number[];
  52579. /**
  52580. * Detect if any button is being pressed while mouse is moved.
  52581. * -1 = Mouse locked.
  52582. * 0 = Left button.
  52583. * 1 = Middle Button.
  52584. * 2 = Right Button.
  52585. */
  52586. activeButton: number;
  52587. /**
  52588. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  52589. * Higher values reduce its sensitivity.
  52590. */
  52591. angularSensibility: number;
  52592. private _observer;
  52593. private _rollObserver;
  52594. private previousPosition;
  52595. private noPreventDefault;
  52596. private element;
  52597. /**
  52598. * Listen to mouse events to control the camera.
  52599. * @param touchEnabled Define if touch is enabled. (Default is true.)
  52600. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52601. */
  52602. constructor(touchEnabled?: boolean);
  52603. /**
  52604. * Attach the mouse control to the HTML DOM element.
  52605. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  52606. */
  52607. attachControl(noPreventDefault?: boolean): void;
  52608. /**
  52609. * Detach the current controls from the specified dom element.
  52610. */
  52611. detachControl(): void;
  52612. /**
  52613. * Gets the class name of the current input.
  52614. * @returns the class name.
  52615. */
  52616. getClassName(): string;
  52617. /**
  52618. * Get the friendly name associated with the input class.
  52619. * @returns the input's friendly name.
  52620. */
  52621. getSimpleName(): string;
  52622. private _pointerInput;
  52623. private _onMouseMove;
  52624. /**
  52625. * Rotate camera by mouse offset.
  52626. */
  52627. private rotateCamera;
  52628. }
  52629. }
  52630. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  52631. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52632. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52633. /**
  52634. * Default Inputs manager for the FlyCamera.
  52635. * It groups all the default supported inputs for ease of use.
  52636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52637. */
  52638. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  52639. /**
  52640. * Instantiates a new FlyCameraInputsManager.
  52641. * @param camera Defines the camera the inputs belong to.
  52642. */
  52643. constructor(camera: FlyCamera);
  52644. /**
  52645. * Add keyboard input support to the input manager.
  52646. * @returns the new FlyCameraKeyboardMoveInput().
  52647. */
  52648. addKeyboard(): FlyCameraInputsManager;
  52649. /**
  52650. * Add mouse input support to the input manager.
  52651. * @param touchEnabled Enable touch screen support.
  52652. * @returns the new FlyCameraMouseInput().
  52653. */
  52654. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  52655. }
  52656. }
  52657. declare module "babylonjs/Cameras/flyCamera" {
  52658. import { Scene } from "babylonjs/scene";
  52659. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52661. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52662. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  52663. /**
  52664. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52665. * such as in a 3D Space Shooter or a Flight Simulator.
  52666. */
  52667. export class FlyCamera extends TargetCamera {
  52668. /**
  52669. * Define the collision ellipsoid of the camera.
  52670. * This is helpful for simulating a camera body, like a player's body.
  52671. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  52672. */
  52673. ellipsoid: Vector3;
  52674. /**
  52675. * Define an offset for the position of the ellipsoid around the camera.
  52676. * This can be helpful if the camera is attached away from the player's body center,
  52677. * such as at its head.
  52678. */
  52679. ellipsoidOffset: Vector3;
  52680. /**
  52681. * Enable or disable collisions of the camera with the rest of the scene objects.
  52682. */
  52683. checkCollisions: boolean;
  52684. /**
  52685. * Enable or disable gravity on the camera.
  52686. */
  52687. applyGravity: boolean;
  52688. /**
  52689. * Define the current direction the camera is moving to.
  52690. */
  52691. cameraDirection: Vector3;
  52692. /**
  52693. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  52694. * This overrides and empties cameraRotation.
  52695. */
  52696. rotationQuaternion: Quaternion;
  52697. /**
  52698. * Track Roll to maintain the wanted Rolling when looking around.
  52699. */
  52700. _trackRoll: number;
  52701. /**
  52702. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  52703. */
  52704. rollCorrect: number;
  52705. /**
  52706. * Mimic a banked turn, Rolling the camera when Yawing.
  52707. * It's recommended to use rollCorrect = 10 for faster banking correction.
  52708. */
  52709. bankedTurn: boolean;
  52710. /**
  52711. * Limit in radians for how much Roll banking will add. (Default: 90°)
  52712. */
  52713. bankedTurnLimit: number;
  52714. /**
  52715. * Value of 0 disables the banked Roll.
  52716. * Value of 1 is equal to the Yaw angle in radians.
  52717. */
  52718. bankedTurnMultiplier: number;
  52719. /**
  52720. * The inputs manager loads all the input sources, such as keyboard and mouse.
  52721. */
  52722. inputs: FlyCameraInputsManager;
  52723. /**
  52724. * Gets the input sensibility for mouse input.
  52725. * Higher values reduce sensitivity.
  52726. */
  52727. get angularSensibility(): number;
  52728. /**
  52729. * Sets the input sensibility for a mouse input.
  52730. * Higher values reduce sensitivity.
  52731. */
  52732. set angularSensibility(value: number);
  52733. /**
  52734. * Get the keys for camera movement forward.
  52735. */
  52736. get keysForward(): number[];
  52737. /**
  52738. * Set the keys for camera movement forward.
  52739. */
  52740. set keysForward(value: number[]);
  52741. /**
  52742. * Get the keys for camera movement backward.
  52743. */
  52744. get keysBackward(): number[];
  52745. set keysBackward(value: number[]);
  52746. /**
  52747. * Get the keys for camera movement up.
  52748. */
  52749. get keysUp(): number[];
  52750. /**
  52751. * Set the keys for camera movement up.
  52752. */
  52753. set keysUp(value: number[]);
  52754. /**
  52755. * Get the keys for camera movement down.
  52756. */
  52757. get keysDown(): number[];
  52758. /**
  52759. * Set the keys for camera movement down.
  52760. */
  52761. set keysDown(value: number[]);
  52762. /**
  52763. * Get the keys for camera movement left.
  52764. */
  52765. get keysLeft(): number[];
  52766. /**
  52767. * Set the keys for camera movement left.
  52768. */
  52769. set keysLeft(value: number[]);
  52770. /**
  52771. * Set the keys for camera movement right.
  52772. */
  52773. get keysRight(): number[];
  52774. /**
  52775. * Set the keys for camera movement right.
  52776. */
  52777. set keysRight(value: number[]);
  52778. /**
  52779. * Event raised when the camera collides with a mesh in the scene.
  52780. */
  52781. onCollide: (collidedMesh: AbstractMesh) => void;
  52782. private _collider;
  52783. private _needMoveForGravity;
  52784. private _oldPosition;
  52785. private _diffPosition;
  52786. private _newPosition;
  52787. /** @hidden */
  52788. _localDirection: Vector3;
  52789. /** @hidden */
  52790. _transformedDirection: Vector3;
  52791. /**
  52792. * Instantiates a FlyCamera.
  52793. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52794. * such as in a 3D Space Shooter or a Flight Simulator.
  52795. * @param name Define the name of the camera in the scene.
  52796. * @param position Define the starting position of the camera in the scene.
  52797. * @param scene Define the scene the camera belongs to.
  52798. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  52799. */
  52800. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52801. /**
  52802. * Attach the input controls to a specific dom element to get the input from.
  52803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52804. */
  52805. attachControl(noPreventDefault?: boolean): void;
  52806. /**
  52807. * Detach a control from the HTML DOM element.
  52808. * The camera will stop reacting to that input.
  52809. */
  52810. detachControl(): void;
  52811. private _collisionMask;
  52812. /**
  52813. * Get the mask that the camera ignores in collision events.
  52814. */
  52815. get collisionMask(): number;
  52816. /**
  52817. * Set the mask that the camera ignores in collision events.
  52818. */
  52819. set collisionMask(mask: number);
  52820. /** @hidden */
  52821. _collideWithWorld(displacement: Vector3): void;
  52822. /** @hidden */
  52823. private _onCollisionPositionChange;
  52824. /** @hidden */
  52825. _checkInputs(): void;
  52826. /** @hidden */
  52827. _decideIfNeedsToMove(): boolean;
  52828. /** @hidden */
  52829. _updatePosition(): void;
  52830. /**
  52831. * Restore the Roll to its target value at the rate specified.
  52832. * @param rate - Higher means slower restoring.
  52833. * @hidden
  52834. */
  52835. restoreRoll(rate: number): void;
  52836. /**
  52837. * Destroy the camera and release the current resources held by it.
  52838. */
  52839. dispose(): void;
  52840. /**
  52841. * Get the current object class name.
  52842. * @returns the class name.
  52843. */
  52844. getClassName(): string;
  52845. }
  52846. }
  52847. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  52848. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52849. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52850. /**
  52851. * Listen to keyboard events to control the camera.
  52852. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52853. */
  52854. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52855. /**
  52856. * Defines the camera the input is attached to.
  52857. */
  52858. camera: FlyCamera;
  52859. /**
  52860. * The list of keyboard keys used to control the forward move of the camera.
  52861. */
  52862. keysForward: number[];
  52863. /**
  52864. * The list of keyboard keys used to control the backward move of the camera.
  52865. */
  52866. keysBackward: number[];
  52867. /**
  52868. * The list of keyboard keys used to control the forward move of the camera.
  52869. */
  52870. keysUp: number[];
  52871. /**
  52872. * The list of keyboard keys used to control the backward move of the camera.
  52873. */
  52874. keysDown: number[];
  52875. /**
  52876. * The list of keyboard keys used to control the right strafe move of the camera.
  52877. */
  52878. keysRight: number[];
  52879. /**
  52880. * The list of keyboard keys used to control the left strafe move of the camera.
  52881. */
  52882. keysLeft: number[];
  52883. private _keys;
  52884. private _onCanvasBlurObserver;
  52885. private _onKeyboardObserver;
  52886. private _engine;
  52887. private _scene;
  52888. /**
  52889. * Attach the input controls to a specific dom element to get the input from.
  52890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52891. */
  52892. attachControl(noPreventDefault?: boolean): void;
  52893. /**
  52894. * Detach the current controls from the specified dom element.
  52895. */
  52896. detachControl(): void;
  52897. /**
  52898. * Gets the class name of the current intput.
  52899. * @returns the class name
  52900. */
  52901. getClassName(): string;
  52902. /** @hidden */
  52903. _onLostFocus(e: FocusEvent): void;
  52904. /**
  52905. * Get the friendly name associated with the input class.
  52906. * @returns the input friendly name
  52907. */
  52908. getSimpleName(): string;
  52909. /**
  52910. * Update the current camera state depending on the inputs that have been used this frame.
  52911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52912. */
  52913. checkInputs(): void;
  52914. }
  52915. }
  52916. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  52917. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52919. /**
  52920. * Manage the mouse wheel inputs to control a follow camera.
  52921. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52922. */
  52923. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52924. /**
  52925. * Defines the camera the input is attached to.
  52926. */
  52927. camera: FollowCamera;
  52928. /**
  52929. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52930. */
  52931. axisControlRadius: boolean;
  52932. /**
  52933. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52934. */
  52935. axisControlHeight: boolean;
  52936. /**
  52937. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52938. */
  52939. axisControlRotation: boolean;
  52940. /**
  52941. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52942. * relation to mouseWheel events.
  52943. */
  52944. wheelPrecision: number;
  52945. /**
  52946. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52947. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52948. */
  52949. wheelDeltaPercentage: number;
  52950. private _wheel;
  52951. private _observer;
  52952. /**
  52953. * Attach the input controls to a specific dom element to get the input from.
  52954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52955. */
  52956. attachControl(noPreventDefault?: boolean): void;
  52957. /**
  52958. * Detach the current controls from the specified dom element.
  52959. */
  52960. detachControl(): void;
  52961. /**
  52962. * Gets the class name of the current intput.
  52963. * @returns the class name
  52964. */
  52965. getClassName(): string;
  52966. /**
  52967. * Get the friendly name associated with the input class.
  52968. * @returns the input friendly name
  52969. */
  52970. getSimpleName(): string;
  52971. }
  52972. }
  52973. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  52974. import { Nullable } from "babylonjs/types";
  52975. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52976. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  52977. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  52978. /**
  52979. * Manage the pointers inputs to control an follow camera.
  52980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52981. */
  52982. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52983. /**
  52984. * Defines the camera the input is attached to.
  52985. */
  52986. camera: FollowCamera;
  52987. /**
  52988. * Gets the class name of the current input.
  52989. * @returns the class name
  52990. */
  52991. getClassName(): string;
  52992. /**
  52993. * Defines the pointer angular sensibility along the X axis or how fast is
  52994. * the camera rotating.
  52995. * A negative number will reverse the axis direction.
  52996. */
  52997. angularSensibilityX: number;
  52998. /**
  52999. * Defines the pointer angular sensibility along the Y axis or how fast is
  53000. * the camera rotating.
  53001. * A negative number will reverse the axis direction.
  53002. */
  53003. angularSensibilityY: number;
  53004. /**
  53005. * Defines the pointer pinch precision or how fast is the camera zooming.
  53006. * A negative number will reverse the axis direction.
  53007. */
  53008. pinchPrecision: number;
  53009. /**
  53010. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  53011. * from 0.
  53012. * It defines the percentage of current camera.radius to use as delta when
  53013. * pinch zoom is used.
  53014. */
  53015. pinchDeltaPercentage: number;
  53016. /**
  53017. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  53018. */
  53019. axisXControlRadius: boolean;
  53020. /**
  53021. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  53022. */
  53023. axisXControlHeight: boolean;
  53024. /**
  53025. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  53026. */
  53027. axisXControlRotation: boolean;
  53028. /**
  53029. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  53030. */
  53031. axisYControlRadius: boolean;
  53032. /**
  53033. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  53034. */
  53035. axisYControlHeight: boolean;
  53036. /**
  53037. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  53038. */
  53039. axisYControlRotation: boolean;
  53040. /**
  53041. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  53042. */
  53043. axisPinchControlRadius: boolean;
  53044. /**
  53045. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  53046. */
  53047. axisPinchControlHeight: boolean;
  53048. /**
  53049. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  53050. */
  53051. axisPinchControlRotation: boolean;
  53052. /**
  53053. * Log error messages if basic misconfiguration has occurred.
  53054. */
  53055. warningEnable: boolean;
  53056. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  53057. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  53058. private _warningCounter;
  53059. private _warning;
  53060. }
  53061. }
  53062. declare module "babylonjs/Cameras/followCameraInputsManager" {
  53063. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  53064. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53065. /**
  53066. * Default Inputs manager for the FollowCamera.
  53067. * It groups all the default supported inputs for ease of use.
  53068. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53069. */
  53070. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  53071. /**
  53072. * Instantiates a new FollowCameraInputsManager.
  53073. * @param camera Defines the camera the inputs belong to
  53074. */
  53075. constructor(camera: FollowCamera);
  53076. /**
  53077. * Add keyboard input support to the input manager.
  53078. * @returns the current input manager
  53079. */
  53080. addKeyboard(): FollowCameraInputsManager;
  53081. /**
  53082. * Add mouse wheel input support to the input manager.
  53083. * @returns the current input manager
  53084. */
  53085. addMouseWheel(): FollowCameraInputsManager;
  53086. /**
  53087. * Add pointers input support to the input manager.
  53088. * @returns the current input manager
  53089. */
  53090. addPointers(): FollowCameraInputsManager;
  53091. /**
  53092. * Add orientation input support to the input manager.
  53093. * @returns the current input manager
  53094. */
  53095. addVRDeviceOrientation(): FollowCameraInputsManager;
  53096. }
  53097. }
  53098. declare module "babylonjs/Cameras/followCamera" {
  53099. import { Nullable } from "babylonjs/types";
  53100. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  53101. import { Scene } from "babylonjs/scene";
  53102. import { Vector3 } from "babylonjs/Maths/math.vector";
  53103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53104. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  53105. /**
  53106. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  53107. * an arc rotate version arcFollowCamera are available.
  53108. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53109. */
  53110. export class FollowCamera extends TargetCamera {
  53111. /**
  53112. * Distance the follow camera should follow an object at
  53113. */
  53114. radius: number;
  53115. /**
  53116. * Minimum allowed distance of the camera to the axis of rotation
  53117. * (The camera can not get closer).
  53118. * This can help limiting how the Camera is able to move in the scene.
  53119. */
  53120. lowerRadiusLimit: Nullable<number>;
  53121. /**
  53122. * Maximum allowed distance of the camera to the axis of rotation
  53123. * (The camera can not get further).
  53124. * This can help limiting how the Camera is able to move in the scene.
  53125. */
  53126. upperRadiusLimit: Nullable<number>;
  53127. /**
  53128. * Define a rotation offset between the camera and the object it follows
  53129. */
  53130. rotationOffset: number;
  53131. /**
  53132. * Minimum allowed angle to camera position relative to target object.
  53133. * This can help limiting how the Camera is able to move in the scene.
  53134. */
  53135. lowerRotationOffsetLimit: Nullable<number>;
  53136. /**
  53137. * Maximum allowed angle to camera position relative to target object.
  53138. * This can help limiting how the Camera is able to move in the scene.
  53139. */
  53140. upperRotationOffsetLimit: Nullable<number>;
  53141. /**
  53142. * Define a height offset between the camera and the object it follows.
  53143. * It can help following an object from the top (like a car chaing a plane)
  53144. */
  53145. heightOffset: number;
  53146. /**
  53147. * Minimum allowed height of camera position relative to target object.
  53148. * This can help limiting how the Camera is able to move in the scene.
  53149. */
  53150. lowerHeightOffsetLimit: Nullable<number>;
  53151. /**
  53152. * Maximum allowed height of camera position relative to target object.
  53153. * This can help limiting how the Camera is able to move in the scene.
  53154. */
  53155. upperHeightOffsetLimit: Nullable<number>;
  53156. /**
  53157. * Define how fast the camera can accelerate to follow it s target.
  53158. */
  53159. cameraAcceleration: number;
  53160. /**
  53161. * Define the speed limit of the camera following an object.
  53162. */
  53163. maxCameraSpeed: number;
  53164. /**
  53165. * Define the target of the camera.
  53166. */
  53167. lockedTarget: Nullable<AbstractMesh>;
  53168. /**
  53169. * Defines the input associated with the camera.
  53170. */
  53171. inputs: FollowCameraInputsManager;
  53172. /**
  53173. * Instantiates the follow camera.
  53174. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53175. * @param name Define the name of the camera in the scene
  53176. * @param position Define the position of the camera
  53177. * @param scene Define the scene the camera belong to
  53178. * @param lockedTarget Define the target of the camera
  53179. */
  53180. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  53181. private _follow;
  53182. /**
  53183. * Attach the input controls to a specific dom element to get the input from.
  53184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53185. */
  53186. attachControl(noPreventDefault?: boolean): void;
  53187. /**
  53188. * Detach the current controls from the specified dom element.
  53189. */
  53190. detachControl(): void;
  53191. /** @hidden */
  53192. _checkInputs(): void;
  53193. private _checkLimits;
  53194. /**
  53195. * Gets the camera class name.
  53196. * @returns the class name
  53197. */
  53198. getClassName(): string;
  53199. }
  53200. /**
  53201. * Arc Rotate version of the follow camera.
  53202. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  53203. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53204. */
  53205. export class ArcFollowCamera extends TargetCamera {
  53206. /** The longitudinal angle of the camera */
  53207. alpha: number;
  53208. /** The latitudinal angle of the camera */
  53209. beta: number;
  53210. /** The radius of the camera from its target */
  53211. radius: number;
  53212. private _cartesianCoordinates;
  53213. /** Define the camera target (the mesh it should follow) */
  53214. private _meshTarget;
  53215. /**
  53216. * Instantiates a new ArcFollowCamera
  53217. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53218. * @param name Define the name of the camera
  53219. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  53220. * @param beta Define the rotation angle of the camera around the elevation axis
  53221. * @param radius Define the radius of the camera from its target point
  53222. * @param target Define the target of the camera
  53223. * @param scene Define the scene the camera belongs to
  53224. */
  53225. constructor(name: string,
  53226. /** The longitudinal angle of the camera */
  53227. alpha: number,
  53228. /** The latitudinal angle of the camera */
  53229. beta: number,
  53230. /** The radius of the camera from its target */
  53231. radius: number,
  53232. /** Define the camera target (the mesh it should follow) */
  53233. target: Nullable<AbstractMesh>, scene: Scene);
  53234. private _follow;
  53235. /** @hidden */
  53236. _checkInputs(): void;
  53237. /**
  53238. * Returns the class name of the object.
  53239. * It is mostly used internally for serialization purposes.
  53240. */
  53241. getClassName(): string;
  53242. }
  53243. }
  53244. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  53245. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53246. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53247. /**
  53248. * Manage the keyboard inputs to control the movement of a follow camera.
  53249. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53250. */
  53251. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  53252. /**
  53253. * Defines the camera the input is attached to.
  53254. */
  53255. camera: FollowCamera;
  53256. /**
  53257. * Defines the list of key codes associated with the up action (increase heightOffset)
  53258. */
  53259. keysHeightOffsetIncr: number[];
  53260. /**
  53261. * Defines the list of key codes associated with the down action (decrease heightOffset)
  53262. */
  53263. keysHeightOffsetDecr: number[];
  53264. /**
  53265. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  53266. */
  53267. keysHeightOffsetModifierAlt: boolean;
  53268. /**
  53269. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  53270. */
  53271. keysHeightOffsetModifierCtrl: boolean;
  53272. /**
  53273. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  53274. */
  53275. keysHeightOffsetModifierShift: boolean;
  53276. /**
  53277. * Defines the list of key codes associated with the left action (increase rotationOffset)
  53278. */
  53279. keysRotationOffsetIncr: number[];
  53280. /**
  53281. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  53282. */
  53283. keysRotationOffsetDecr: number[];
  53284. /**
  53285. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  53286. */
  53287. keysRotationOffsetModifierAlt: boolean;
  53288. /**
  53289. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  53290. */
  53291. keysRotationOffsetModifierCtrl: boolean;
  53292. /**
  53293. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  53294. */
  53295. keysRotationOffsetModifierShift: boolean;
  53296. /**
  53297. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  53298. */
  53299. keysRadiusIncr: number[];
  53300. /**
  53301. * Defines the list of key codes associated with the zoom-out action (increase radius)
  53302. */
  53303. keysRadiusDecr: number[];
  53304. /**
  53305. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  53306. */
  53307. keysRadiusModifierAlt: boolean;
  53308. /**
  53309. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  53310. */
  53311. keysRadiusModifierCtrl: boolean;
  53312. /**
  53313. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  53314. */
  53315. keysRadiusModifierShift: boolean;
  53316. /**
  53317. * Defines the rate of change of heightOffset.
  53318. */
  53319. heightSensibility: number;
  53320. /**
  53321. * Defines the rate of change of rotationOffset.
  53322. */
  53323. rotationSensibility: number;
  53324. /**
  53325. * Defines the rate of change of radius.
  53326. */
  53327. radiusSensibility: number;
  53328. private _keys;
  53329. private _ctrlPressed;
  53330. private _altPressed;
  53331. private _shiftPressed;
  53332. private _onCanvasBlurObserver;
  53333. private _onKeyboardObserver;
  53334. private _engine;
  53335. private _scene;
  53336. /**
  53337. * Attach the input controls to a specific dom element to get the input from.
  53338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53339. */
  53340. attachControl(noPreventDefault?: boolean): void;
  53341. /**
  53342. * Detach the current controls from the specified dom element.
  53343. */
  53344. detachControl(): void;
  53345. /**
  53346. * Update the current camera state depending on the inputs that have been used this frame.
  53347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53348. */
  53349. checkInputs(): void;
  53350. /**
  53351. * Gets the class name of the current input.
  53352. * @returns the class name
  53353. */
  53354. getClassName(): string;
  53355. /**
  53356. * Get the friendly name associated with the input class.
  53357. * @returns the input friendly name
  53358. */
  53359. getSimpleName(): string;
  53360. /**
  53361. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53362. * allow modification of the heightOffset value.
  53363. */
  53364. private _modifierHeightOffset;
  53365. /**
  53366. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53367. * allow modification of the rotationOffset value.
  53368. */
  53369. private _modifierRotationOffset;
  53370. /**
  53371. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53372. * allow modification of the radius value.
  53373. */
  53374. private _modifierRadius;
  53375. }
  53376. }
  53377. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  53378. import { Nullable } from "babylonjs/types";
  53379. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53381. import { Observable } from "babylonjs/Misc/observable";
  53382. module "babylonjs/Cameras/freeCameraInputsManager" {
  53383. interface FreeCameraInputsManager {
  53384. /**
  53385. * @hidden
  53386. */
  53387. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  53388. /**
  53389. * Add orientation input support to the input manager.
  53390. * @returns the current input manager
  53391. */
  53392. addDeviceOrientation(): FreeCameraInputsManager;
  53393. }
  53394. }
  53395. /**
  53396. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  53397. * Screen rotation is taken into account.
  53398. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53399. */
  53400. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  53401. private _camera;
  53402. private _screenOrientationAngle;
  53403. private _constantTranform;
  53404. private _screenQuaternion;
  53405. private _alpha;
  53406. private _beta;
  53407. private _gamma;
  53408. /**
  53409. * Can be used to detect if a device orientation sensor is available on a device
  53410. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  53411. * @returns a promise that will resolve on orientation change
  53412. */
  53413. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  53414. /**
  53415. * @hidden
  53416. */
  53417. _onDeviceOrientationChangedObservable: Observable<void>;
  53418. /**
  53419. * Instantiates a new input
  53420. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53421. */
  53422. constructor();
  53423. /**
  53424. * Define the camera controlled by the input.
  53425. */
  53426. get camera(): FreeCamera;
  53427. set camera(camera: FreeCamera);
  53428. /**
  53429. * Attach the input controls to a specific dom element to get the input from.
  53430. */
  53431. attachControl(): void;
  53432. private _orientationChanged;
  53433. private _deviceOrientation;
  53434. /**
  53435. * Detach the current controls from the specified dom element.
  53436. */
  53437. detachControl(): void;
  53438. /**
  53439. * Update the current camera state depending on the inputs that have been used this frame.
  53440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53441. */
  53442. checkInputs(): void;
  53443. /**
  53444. * Gets the class name of the current intput.
  53445. * @returns the class name
  53446. */
  53447. getClassName(): string;
  53448. /**
  53449. * Get the friendly name associated with the input class.
  53450. * @returns the input friendly name
  53451. */
  53452. getSimpleName(): string;
  53453. }
  53454. }
  53455. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  53456. import { Nullable } from "babylonjs/types";
  53457. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53458. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53459. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53460. /**
  53461. * Manage the gamepad inputs to control a free camera.
  53462. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53463. */
  53464. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  53465. /**
  53466. * Define the camera the input is attached to.
  53467. */
  53468. camera: FreeCamera;
  53469. /**
  53470. * Define the Gamepad controlling the input
  53471. */
  53472. gamepad: Nullable<Gamepad>;
  53473. /**
  53474. * Defines the gamepad rotation sensiblity.
  53475. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53476. */
  53477. gamepadAngularSensibility: number;
  53478. /**
  53479. * Defines the gamepad move sensiblity.
  53480. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53481. */
  53482. gamepadMoveSensibility: number;
  53483. private _yAxisScale;
  53484. /**
  53485. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  53486. */
  53487. get invertYAxis(): boolean;
  53488. set invertYAxis(value: boolean);
  53489. private _onGamepadConnectedObserver;
  53490. private _onGamepadDisconnectedObserver;
  53491. private _cameraTransform;
  53492. private _deltaTransform;
  53493. private _vector3;
  53494. private _vector2;
  53495. /**
  53496. * Attach the input controls to a specific dom element to get the input from.
  53497. */
  53498. attachControl(): void;
  53499. /**
  53500. * Detach the current controls from the specified dom element.
  53501. */
  53502. detachControl(): void;
  53503. /**
  53504. * Update the current camera state depending on the inputs that have been used this frame.
  53505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53506. */
  53507. checkInputs(): void;
  53508. /**
  53509. * Gets the class name of the current intput.
  53510. * @returns the class name
  53511. */
  53512. getClassName(): string;
  53513. /**
  53514. * Get the friendly name associated with the input class.
  53515. * @returns the input friendly name
  53516. */
  53517. getSimpleName(): string;
  53518. }
  53519. }
  53520. declare module "babylonjs/Misc/virtualJoystick" {
  53521. import { Nullable } from "babylonjs/types";
  53522. import { Vector3 } from "babylonjs/Maths/math.vector";
  53523. /**
  53524. * Defines the potential axis of a Joystick
  53525. */
  53526. export enum JoystickAxis {
  53527. /** X axis */
  53528. X = 0,
  53529. /** Y axis */
  53530. Y = 1,
  53531. /** Z axis */
  53532. Z = 2
  53533. }
  53534. /**
  53535. * Represents the different customization options available
  53536. * for VirtualJoystick
  53537. */
  53538. interface VirtualJoystickCustomizations {
  53539. /**
  53540. * Size of the joystick's puck
  53541. */
  53542. puckSize: number;
  53543. /**
  53544. * Size of the joystick's container
  53545. */
  53546. containerSize: number;
  53547. /**
  53548. * Color of the joystick && puck
  53549. */
  53550. color: string;
  53551. /**
  53552. * Image URL for the joystick's puck
  53553. */
  53554. puckImage?: string;
  53555. /**
  53556. * Image URL for the joystick's container
  53557. */
  53558. containerImage?: string;
  53559. /**
  53560. * Defines the unmoving position of the joystick container
  53561. */
  53562. position?: {
  53563. x: number;
  53564. y: number;
  53565. };
  53566. /**
  53567. * Defines whether or not the joystick container is always visible
  53568. */
  53569. alwaysVisible: boolean;
  53570. /**
  53571. * Defines whether or not to limit the movement of the puck to the joystick's container
  53572. */
  53573. limitToContainer: boolean;
  53574. }
  53575. /**
  53576. * Class used to define virtual joystick (used in touch mode)
  53577. */
  53578. export class VirtualJoystick {
  53579. /**
  53580. * Gets or sets a boolean indicating that left and right values must be inverted
  53581. */
  53582. reverseLeftRight: boolean;
  53583. /**
  53584. * Gets or sets a boolean indicating that up and down values must be inverted
  53585. */
  53586. reverseUpDown: boolean;
  53587. /**
  53588. * Gets the offset value for the position (ie. the change of the position value)
  53589. */
  53590. deltaPosition: Vector3;
  53591. /**
  53592. * Gets a boolean indicating if the virtual joystick was pressed
  53593. */
  53594. pressed: boolean;
  53595. /**
  53596. * Canvas the virtual joystick will render onto, default z-index of this is 5
  53597. */
  53598. static Canvas: Nullable<HTMLCanvasElement>;
  53599. /**
  53600. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  53601. */
  53602. limitToContainer: boolean;
  53603. private static _globalJoystickIndex;
  53604. private static _alwaysVisibleSticks;
  53605. private static vjCanvasContext;
  53606. private static vjCanvasWidth;
  53607. private static vjCanvasHeight;
  53608. private static halfWidth;
  53609. private static _GetDefaultOptions;
  53610. private _action;
  53611. private _axisTargetedByLeftAndRight;
  53612. private _axisTargetedByUpAndDown;
  53613. private _joystickSensibility;
  53614. private _inversedSensibility;
  53615. private _joystickPointerID;
  53616. private _joystickColor;
  53617. private _joystickPointerPos;
  53618. private _joystickPreviousPointerPos;
  53619. private _joystickPointerStartPos;
  53620. private _deltaJoystickVector;
  53621. private _leftJoystick;
  53622. private _touches;
  53623. private _joystickPosition;
  53624. private _alwaysVisible;
  53625. private _puckImage;
  53626. private _containerImage;
  53627. private _joystickPuckSize;
  53628. private _joystickContainerSize;
  53629. private _clearPuckSize;
  53630. private _clearContainerSize;
  53631. private _clearPuckSizeOffset;
  53632. private _clearContainerSizeOffset;
  53633. private _onPointerDownHandlerRef;
  53634. private _onPointerMoveHandlerRef;
  53635. private _onPointerUpHandlerRef;
  53636. private _onResize;
  53637. /**
  53638. * Creates a new virtual joystick
  53639. * @param leftJoystick defines that the joystick is for left hand (false by default)
  53640. * @param customizations Defines the options we want to customize the VirtualJoystick
  53641. */
  53642. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  53643. /**
  53644. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  53645. * @param newJoystickSensibility defines the new sensibility
  53646. */
  53647. setJoystickSensibility(newJoystickSensibility: number): void;
  53648. private _onPointerDown;
  53649. private _onPointerMove;
  53650. private _onPointerUp;
  53651. /**
  53652. * Change the color of the virtual joystick
  53653. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  53654. */
  53655. setJoystickColor(newColor: string): void;
  53656. /**
  53657. * Size of the joystick's container
  53658. */
  53659. set containerSize(newSize: number);
  53660. get containerSize(): number;
  53661. /**
  53662. * Size of the joystick's puck
  53663. */
  53664. set puckSize(newSize: number);
  53665. get puckSize(): number;
  53666. /**
  53667. * Clears the set position of the joystick
  53668. */
  53669. clearPosition(): void;
  53670. /**
  53671. * Defines whether or not the joystick container is always visible
  53672. */
  53673. set alwaysVisible(value: boolean);
  53674. get alwaysVisible(): boolean;
  53675. /**
  53676. * Sets the constant position of the Joystick container
  53677. * @param x X axis coordinate
  53678. * @param y Y axis coordinate
  53679. */
  53680. setPosition(x: number, y: number): void;
  53681. /**
  53682. * Defines a callback to call when the joystick is touched
  53683. * @param action defines the callback
  53684. */
  53685. setActionOnTouch(action: () => any): void;
  53686. /**
  53687. * Defines which axis you'd like to control for left & right
  53688. * @param axis defines the axis to use
  53689. */
  53690. setAxisForLeftRight(axis: JoystickAxis): void;
  53691. /**
  53692. * Defines which axis you'd like to control for up & down
  53693. * @param axis defines the axis to use
  53694. */
  53695. setAxisForUpDown(axis: JoystickAxis): void;
  53696. /**
  53697. * Clears the canvas from the previous puck / container draw
  53698. */
  53699. private _clearPreviousDraw;
  53700. /**
  53701. * Loads `urlPath` to be used for the container's image
  53702. * @param urlPath defines the urlPath of an image to use
  53703. */
  53704. setContainerImage(urlPath: string): void;
  53705. /**
  53706. * Loads `urlPath` to be used for the puck's image
  53707. * @param urlPath defines the urlPath of an image to use
  53708. */
  53709. setPuckImage(urlPath: string): void;
  53710. /**
  53711. * Draws the Virtual Joystick's container
  53712. */
  53713. private _drawContainer;
  53714. /**
  53715. * Draws the Virtual Joystick's puck
  53716. */
  53717. private _drawPuck;
  53718. private _drawVirtualJoystick;
  53719. /**
  53720. * Release internal HTML canvas
  53721. */
  53722. releaseCanvas(): void;
  53723. }
  53724. }
  53725. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  53726. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  53727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53729. module "babylonjs/Cameras/freeCameraInputsManager" {
  53730. interface FreeCameraInputsManager {
  53731. /**
  53732. * Add virtual joystick input support to the input manager.
  53733. * @returns the current input manager
  53734. */
  53735. addVirtualJoystick(): FreeCameraInputsManager;
  53736. }
  53737. }
  53738. /**
  53739. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  53740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53741. */
  53742. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  53743. /**
  53744. * Defines the camera the input is attached to.
  53745. */
  53746. camera: FreeCamera;
  53747. private _leftjoystick;
  53748. private _rightjoystick;
  53749. /**
  53750. * Gets the left stick of the virtual joystick.
  53751. * @returns The virtual Joystick
  53752. */
  53753. getLeftJoystick(): VirtualJoystick;
  53754. /**
  53755. * Gets the right stick of the virtual joystick.
  53756. * @returns The virtual Joystick
  53757. */
  53758. getRightJoystick(): VirtualJoystick;
  53759. /**
  53760. * Update the current camera state depending on the inputs that have been used this frame.
  53761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53762. */
  53763. checkInputs(): void;
  53764. /**
  53765. * Attach the input controls to a specific dom element to get the input from.
  53766. */
  53767. attachControl(): void;
  53768. /**
  53769. * Detach the current controls from the specified dom element.
  53770. */
  53771. detachControl(): void;
  53772. /**
  53773. * Gets the class name of the current intput.
  53774. * @returns the class name
  53775. */
  53776. getClassName(): string;
  53777. /**
  53778. * Get the friendly name associated with the input class.
  53779. * @returns the input friendly name
  53780. */
  53781. getSimpleName(): string;
  53782. }
  53783. }
  53784. declare module "babylonjs/Cameras/Inputs/index" {
  53785. export * from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  53786. export * from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  53787. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  53788. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  53789. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  53790. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  53791. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  53792. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  53793. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  53794. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  53795. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  53796. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  53797. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53798. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  53799. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  53800. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  53801. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  53802. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  53803. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  53804. }
  53805. declare module "babylonjs/Cameras/touchCamera" {
  53806. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53807. import { Scene } from "babylonjs/scene";
  53808. import { Vector3 } from "babylonjs/Maths/math.vector";
  53809. /**
  53810. * This represents a FPS type of camera controlled by touch.
  53811. * This is like a universal camera minus the Gamepad controls.
  53812. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53813. */
  53814. export class TouchCamera extends FreeCamera {
  53815. /**
  53816. * Defines the touch sensibility for rotation.
  53817. * The higher the faster.
  53818. */
  53819. get touchAngularSensibility(): number;
  53820. set touchAngularSensibility(value: number);
  53821. /**
  53822. * Defines the touch sensibility for move.
  53823. * The higher the faster.
  53824. */
  53825. get touchMoveSensibility(): number;
  53826. set touchMoveSensibility(value: number);
  53827. /**
  53828. * Instantiates a new touch camera.
  53829. * This represents a FPS type of camera controlled by touch.
  53830. * This is like a universal camera minus the Gamepad controls.
  53831. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53832. * @param name Define the name of the camera in the scene
  53833. * @param position Define the start position of the camera in the scene
  53834. * @param scene Define the scene the camera belongs to
  53835. */
  53836. constructor(name: string, position: Vector3, scene: Scene);
  53837. /**
  53838. * Gets the current object class name.
  53839. * @return the class name
  53840. */
  53841. getClassName(): string;
  53842. /** @hidden */
  53843. _setupInputs(): void;
  53844. }
  53845. }
  53846. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  53847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53848. import { Scene } from "babylonjs/scene";
  53849. import { Vector3 } from "babylonjs/Maths/math.vector";
  53850. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53851. import { Axis } from "babylonjs/Maths/math.axis";
  53852. /**
  53853. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53854. * being tilted forward or back and left or right.
  53855. */
  53856. export class DeviceOrientationCamera extends FreeCamera {
  53857. private _initialQuaternion;
  53858. private _quaternionCache;
  53859. private _tmpDragQuaternion;
  53860. private _disablePointerInputWhenUsingDeviceOrientation;
  53861. /**
  53862. * Creates a new device orientation camera
  53863. * @param name The name of the camera
  53864. * @param position The start position camera
  53865. * @param scene The scene the camera belongs to
  53866. */
  53867. constructor(name: string, position: Vector3, scene: Scene);
  53868. /**
  53869. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53870. */
  53871. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53872. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53873. private _dragFactor;
  53874. /**
  53875. * Enabled turning on the y axis when the orientation sensor is active
  53876. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53877. */
  53878. enableHorizontalDragging(dragFactor?: number): void;
  53879. /**
  53880. * Gets the current instance class name ("DeviceOrientationCamera").
  53881. * This helps avoiding instanceof at run time.
  53882. * @returns the class name
  53883. */
  53884. getClassName(): string;
  53885. /**
  53886. * @hidden
  53887. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53888. */
  53889. _checkInputs(): void;
  53890. /**
  53891. * Reset the camera to its default orientation on the specified axis only.
  53892. * @param axis The axis to reset
  53893. */
  53894. resetToCurrentRotation(axis?: Axis): void;
  53895. }
  53896. }
  53897. declare module "babylonjs/Gamepads/xboxGamepad" {
  53898. import { Observable } from "babylonjs/Misc/observable";
  53899. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53900. /**
  53901. * Defines supported buttons for XBox360 compatible gamepads
  53902. */
  53903. export enum Xbox360Button {
  53904. /** A */
  53905. A = 0,
  53906. /** B */
  53907. B = 1,
  53908. /** X */
  53909. X = 2,
  53910. /** Y */
  53911. Y = 3,
  53912. /** Left button */
  53913. LB = 4,
  53914. /** Right button */
  53915. RB = 5,
  53916. /** Back */
  53917. Back = 8,
  53918. /** Start */
  53919. Start = 9,
  53920. /** Left stick */
  53921. LeftStick = 10,
  53922. /** Right stick */
  53923. RightStick = 11
  53924. }
  53925. /** Defines values for XBox360 DPad */
  53926. export enum Xbox360Dpad {
  53927. /** Up */
  53928. Up = 12,
  53929. /** Down */
  53930. Down = 13,
  53931. /** Left */
  53932. Left = 14,
  53933. /** Right */
  53934. Right = 15
  53935. }
  53936. /**
  53937. * Defines a XBox360 gamepad
  53938. */
  53939. export class Xbox360Pad extends Gamepad {
  53940. private _leftTrigger;
  53941. private _rightTrigger;
  53942. private _onlefttriggerchanged;
  53943. private _onrighttriggerchanged;
  53944. private _onbuttondown;
  53945. private _onbuttonup;
  53946. private _ondpaddown;
  53947. private _ondpadup;
  53948. /** Observable raised when a button is pressed */
  53949. onButtonDownObservable: Observable<Xbox360Button>;
  53950. /** Observable raised when a button is released */
  53951. onButtonUpObservable: Observable<Xbox360Button>;
  53952. /** Observable raised when a pad is pressed */
  53953. onPadDownObservable: Observable<Xbox360Dpad>;
  53954. /** Observable raised when a pad is released */
  53955. onPadUpObservable: Observable<Xbox360Dpad>;
  53956. private _buttonA;
  53957. private _buttonB;
  53958. private _buttonX;
  53959. private _buttonY;
  53960. private _buttonBack;
  53961. private _buttonStart;
  53962. private _buttonLB;
  53963. private _buttonRB;
  53964. private _buttonLeftStick;
  53965. private _buttonRightStick;
  53966. private _dPadUp;
  53967. private _dPadDown;
  53968. private _dPadLeft;
  53969. private _dPadRight;
  53970. private _isXboxOnePad;
  53971. /**
  53972. * Creates a new XBox360 gamepad object
  53973. * @param id defines the id of this gamepad
  53974. * @param index defines its index
  53975. * @param gamepad defines the internal HTML gamepad object
  53976. * @param xboxOne defines if it is a XBox One gamepad
  53977. */
  53978. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53979. /**
  53980. * Defines the callback to call when left trigger is pressed
  53981. * @param callback defines the callback to use
  53982. */
  53983. onlefttriggerchanged(callback: (value: number) => void): void;
  53984. /**
  53985. * Defines the callback to call when right trigger is pressed
  53986. * @param callback defines the callback to use
  53987. */
  53988. onrighttriggerchanged(callback: (value: number) => void): void;
  53989. /**
  53990. * Gets the left trigger value
  53991. */
  53992. get leftTrigger(): number;
  53993. /**
  53994. * Sets the left trigger value
  53995. */
  53996. set leftTrigger(newValue: number);
  53997. /**
  53998. * Gets the right trigger value
  53999. */
  54000. get rightTrigger(): number;
  54001. /**
  54002. * Sets the right trigger value
  54003. */
  54004. set rightTrigger(newValue: number);
  54005. /**
  54006. * Defines the callback to call when a button is pressed
  54007. * @param callback defines the callback to use
  54008. */
  54009. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  54010. /**
  54011. * Defines the callback to call when a button is released
  54012. * @param callback defines the callback to use
  54013. */
  54014. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  54015. /**
  54016. * Defines the callback to call when a pad is pressed
  54017. * @param callback defines the callback to use
  54018. */
  54019. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  54020. /**
  54021. * Defines the callback to call when a pad is released
  54022. * @param callback defines the callback to use
  54023. */
  54024. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  54025. private _setButtonValue;
  54026. private _setDPadValue;
  54027. /**
  54028. * Gets the value of the `A` button
  54029. */
  54030. get buttonA(): number;
  54031. /**
  54032. * Sets the value of the `A` button
  54033. */
  54034. set buttonA(value: number);
  54035. /**
  54036. * Gets the value of the `B` button
  54037. */
  54038. get buttonB(): number;
  54039. /**
  54040. * Sets the value of the `B` button
  54041. */
  54042. set buttonB(value: number);
  54043. /**
  54044. * Gets the value of the `X` button
  54045. */
  54046. get buttonX(): number;
  54047. /**
  54048. * Sets the value of the `X` button
  54049. */
  54050. set buttonX(value: number);
  54051. /**
  54052. * Gets the value of the `Y` button
  54053. */
  54054. get buttonY(): number;
  54055. /**
  54056. * Sets the value of the `Y` button
  54057. */
  54058. set buttonY(value: number);
  54059. /**
  54060. * Gets the value of the `Start` button
  54061. */
  54062. get buttonStart(): number;
  54063. /**
  54064. * Sets the value of the `Start` button
  54065. */
  54066. set buttonStart(value: number);
  54067. /**
  54068. * Gets the value of the `Back` button
  54069. */
  54070. get buttonBack(): number;
  54071. /**
  54072. * Sets the value of the `Back` button
  54073. */
  54074. set buttonBack(value: number);
  54075. /**
  54076. * Gets the value of the `Left` button
  54077. */
  54078. get buttonLB(): number;
  54079. /**
  54080. * Sets the value of the `Left` button
  54081. */
  54082. set buttonLB(value: number);
  54083. /**
  54084. * Gets the value of the `Right` button
  54085. */
  54086. get buttonRB(): number;
  54087. /**
  54088. * Sets the value of the `Right` button
  54089. */
  54090. set buttonRB(value: number);
  54091. /**
  54092. * Gets the value of the Left joystick
  54093. */
  54094. get buttonLeftStick(): number;
  54095. /**
  54096. * Sets the value of the Left joystick
  54097. */
  54098. set buttonLeftStick(value: number);
  54099. /**
  54100. * Gets the value of the Right joystick
  54101. */
  54102. get buttonRightStick(): number;
  54103. /**
  54104. * Sets the value of the Right joystick
  54105. */
  54106. set buttonRightStick(value: number);
  54107. /**
  54108. * Gets the value of D-pad up
  54109. */
  54110. get dPadUp(): number;
  54111. /**
  54112. * Sets the value of D-pad up
  54113. */
  54114. set dPadUp(value: number);
  54115. /**
  54116. * Gets the value of D-pad down
  54117. */
  54118. get dPadDown(): number;
  54119. /**
  54120. * Sets the value of D-pad down
  54121. */
  54122. set dPadDown(value: number);
  54123. /**
  54124. * Gets the value of D-pad left
  54125. */
  54126. get dPadLeft(): number;
  54127. /**
  54128. * Sets the value of D-pad left
  54129. */
  54130. set dPadLeft(value: number);
  54131. /**
  54132. * Gets the value of D-pad right
  54133. */
  54134. get dPadRight(): number;
  54135. /**
  54136. * Sets the value of D-pad right
  54137. */
  54138. set dPadRight(value: number);
  54139. /**
  54140. * Force the gamepad to synchronize with device values
  54141. */
  54142. update(): void;
  54143. /**
  54144. * Disposes the gamepad
  54145. */
  54146. dispose(): void;
  54147. }
  54148. }
  54149. declare module "babylonjs/Gamepads/dualShockGamepad" {
  54150. import { Observable } from "babylonjs/Misc/observable";
  54151. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54152. /**
  54153. * Defines supported buttons for DualShock compatible gamepads
  54154. */
  54155. export enum DualShockButton {
  54156. /** Cross */
  54157. Cross = 0,
  54158. /** Circle */
  54159. Circle = 1,
  54160. /** Square */
  54161. Square = 2,
  54162. /** Triangle */
  54163. Triangle = 3,
  54164. /** L1 */
  54165. L1 = 4,
  54166. /** R1 */
  54167. R1 = 5,
  54168. /** Share */
  54169. Share = 8,
  54170. /** Options */
  54171. Options = 9,
  54172. /** Left stick */
  54173. LeftStick = 10,
  54174. /** Right stick */
  54175. RightStick = 11
  54176. }
  54177. /** Defines values for DualShock DPad */
  54178. export enum DualShockDpad {
  54179. /** Up */
  54180. Up = 12,
  54181. /** Down */
  54182. Down = 13,
  54183. /** Left */
  54184. Left = 14,
  54185. /** Right */
  54186. Right = 15
  54187. }
  54188. /**
  54189. * Defines a DualShock gamepad
  54190. */
  54191. export class DualShockPad extends Gamepad {
  54192. private _leftTrigger;
  54193. private _rightTrigger;
  54194. private _onlefttriggerchanged;
  54195. private _onrighttriggerchanged;
  54196. private _onbuttondown;
  54197. private _onbuttonup;
  54198. private _ondpaddown;
  54199. private _ondpadup;
  54200. /** Observable raised when a button is pressed */
  54201. onButtonDownObservable: Observable<DualShockButton>;
  54202. /** Observable raised when a button is released */
  54203. onButtonUpObservable: Observable<DualShockButton>;
  54204. /** Observable raised when a pad is pressed */
  54205. onPadDownObservable: Observable<DualShockDpad>;
  54206. /** Observable raised when a pad is released */
  54207. onPadUpObservable: Observable<DualShockDpad>;
  54208. private _buttonCross;
  54209. private _buttonCircle;
  54210. private _buttonSquare;
  54211. private _buttonTriangle;
  54212. private _buttonShare;
  54213. private _buttonOptions;
  54214. private _buttonL1;
  54215. private _buttonR1;
  54216. private _buttonLeftStick;
  54217. private _buttonRightStick;
  54218. private _dPadUp;
  54219. private _dPadDown;
  54220. private _dPadLeft;
  54221. private _dPadRight;
  54222. /**
  54223. * Creates a new DualShock gamepad object
  54224. * @param id defines the id of this gamepad
  54225. * @param index defines its index
  54226. * @param gamepad defines the internal HTML gamepad object
  54227. */
  54228. constructor(id: string, index: number, gamepad: any);
  54229. /**
  54230. * Defines the callback to call when left trigger is pressed
  54231. * @param callback defines the callback to use
  54232. */
  54233. onlefttriggerchanged(callback: (value: number) => void): void;
  54234. /**
  54235. * Defines the callback to call when right trigger is pressed
  54236. * @param callback defines the callback to use
  54237. */
  54238. onrighttriggerchanged(callback: (value: number) => void): void;
  54239. /**
  54240. * Gets the left trigger value
  54241. */
  54242. get leftTrigger(): number;
  54243. /**
  54244. * Sets the left trigger value
  54245. */
  54246. set leftTrigger(newValue: number);
  54247. /**
  54248. * Gets the right trigger value
  54249. */
  54250. get rightTrigger(): number;
  54251. /**
  54252. * Sets the right trigger value
  54253. */
  54254. set rightTrigger(newValue: number);
  54255. /**
  54256. * Defines the callback to call when a button is pressed
  54257. * @param callback defines the callback to use
  54258. */
  54259. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  54260. /**
  54261. * Defines the callback to call when a button is released
  54262. * @param callback defines the callback to use
  54263. */
  54264. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  54265. /**
  54266. * Defines the callback to call when a pad is pressed
  54267. * @param callback defines the callback to use
  54268. */
  54269. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  54270. /**
  54271. * Defines the callback to call when a pad is released
  54272. * @param callback defines the callback to use
  54273. */
  54274. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  54275. private _setButtonValue;
  54276. private _setDPadValue;
  54277. /**
  54278. * Gets the value of the `Cross` button
  54279. */
  54280. get buttonCross(): number;
  54281. /**
  54282. * Sets the value of the `Cross` button
  54283. */
  54284. set buttonCross(value: number);
  54285. /**
  54286. * Gets the value of the `Circle` button
  54287. */
  54288. get buttonCircle(): number;
  54289. /**
  54290. * Sets the value of the `Circle` button
  54291. */
  54292. set buttonCircle(value: number);
  54293. /**
  54294. * Gets the value of the `Square` button
  54295. */
  54296. get buttonSquare(): number;
  54297. /**
  54298. * Sets the value of the `Square` button
  54299. */
  54300. set buttonSquare(value: number);
  54301. /**
  54302. * Gets the value of the `Triangle` button
  54303. */
  54304. get buttonTriangle(): number;
  54305. /**
  54306. * Sets the value of the `Triangle` button
  54307. */
  54308. set buttonTriangle(value: number);
  54309. /**
  54310. * Gets the value of the `Options` button
  54311. */
  54312. get buttonOptions(): number;
  54313. /**
  54314. * Sets the value of the `Options` button
  54315. */
  54316. set buttonOptions(value: number);
  54317. /**
  54318. * Gets the value of the `Share` button
  54319. */
  54320. get buttonShare(): number;
  54321. /**
  54322. * Sets the value of the `Share` button
  54323. */
  54324. set buttonShare(value: number);
  54325. /**
  54326. * Gets the value of the `L1` button
  54327. */
  54328. get buttonL1(): number;
  54329. /**
  54330. * Sets the value of the `L1` button
  54331. */
  54332. set buttonL1(value: number);
  54333. /**
  54334. * Gets the value of the `R1` button
  54335. */
  54336. get buttonR1(): number;
  54337. /**
  54338. * Sets the value of the `R1` button
  54339. */
  54340. set buttonR1(value: number);
  54341. /**
  54342. * Gets the value of the Left joystick
  54343. */
  54344. get buttonLeftStick(): number;
  54345. /**
  54346. * Sets the value of the Left joystick
  54347. */
  54348. set buttonLeftStick(value: number);
  54349. /**
  54350. * Gets the value of the Right joystick
  54351. */
  54352. get buttonRightStick(): number;
  54353. /**
  54354. * Sets the value of the Right joystick
  54355. */
  54356. set buttonRightStick(value: number);
  54357. /**
  54358. * Gets the value of D-pad up
  54359. */
  54360. get dPadUp(): number;
  54361. /**
  54362. * Sets the value of D-pad up
  54363. */
  54364. set dPadUp(value: number);
  54365. /**
  54366. * Gets the value of D-pad down
  54367. */
  54368. get dPadDown(): number;
  54369. /**
  54370. * Sets the value of D-pad down
  54371. */
  54372. set dPadDown(value: number);
  54373. /**
  54374. * Gets the value of D-pad left
  54375. */
  54376. get dPadLeft(): number;
  54377. /**
  54378. * Sets the value of D-pad left
  54379. */
  54380. set dPadLeft(value: number);
  54381. /**
  54382. * Gets the value of D-pad right
  54383. */
  54384. get dPadRight(): number;
  54385. /**
  54386. * Sets the value of D-pad right
  54387. */
  54388. set dPadRight(value: number);
  54389. /**
  54390. * Force the gamepad to synchronize with device values
  54391. */
  54392. update(): void;
  54393. /**
  54394. * Disposes the gamepad
  54395. */
  54396. dispose(): void;
  54397. }
  54398. }
  54399. declare module "babylonjs/Gamepads/gamepadManager" {
  54400. import { Observable } from "babylonjs/Misc/observable";
  54401. import { Nullable } from "babylonjs/types";
  54402. import { Scene } from "babylonjs/scene";
  54403. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54404. /**
  54405. * Manager for handling gamepads
  54406. */
  54407. export class GamepadManager {
  54408. private _scene?;
  54409. private _babylonGamepads;
  54410. private _oneGamepadConnected;
  54411. /** @hidden */
  54412. _isMonitoring: boolean;
  54413. private _gamepadEventSupported;
  54414. private _gamepadSupport?;
  54415. /**
  54416. * observable to be triggered when the gamepad controller has been connected
  54417. */
  54418. onGamepadConnectedObservable: Observable<Gamepad>;
  54419. /**
  54420. * observable to be triggered when the gamepad controller has been disconnected
  54421. */
  54422. onGamepadDisconnectedObservable: Observable<Gamepad>;
  54423. private _onGamepadConnectedEvent;
  54424. private _onGamepadDisconnectedEvent;
  54425. /**
  54426. * Initializes the gamepad manager
  54427. * @param _scene BabylonJS scene
  54428. */
  54429. constructor(_scene?: Scene | undefined);
  54430. /**
  54431. * The gamepads in the game pad manager
  54432. */
  54433. get gamepads(): Gamepad[];
  54434. /**
  54435. * Get the gamepad controllers based on type
  54436. * @param type The type of gamepad controller
  54437. * @returns Nullable gamepad
  54438. */
  54439. getGamepadByType(type?: number): Nullable<Gamepad>;
  54440. /**
  54441. * Disposes the gamepad manager
  54442. */
  54443. dispose(): void;
  54444. private _addNewGamepad;
  54445. private _startMonitoringGamepads;
  54446. private _stopMonitoringGamepads;
  54447. /** @hidden */
  54448. _checkGamepadsStatus(): void;
  54449. private _updateGamepadObjects;
  54450. }
  54451. }
  54452. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  54453. import { Nullable } from "babylonjs/types";
  54454. import { Scene } from "babylonjs/scene";
  54455. import { ISceneComponent } from "babylonjs/sceneComponent";
  54456. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  54457. module "babylonjs/scene" {
  54458. interface Scene {
  54459. /** @hidden */
  54460. _gamepadManager: Nullable<GamepadManager>;
  54461. /**
  54462. * Gets the gamepad manager associated with the scene
  54463. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  54464. */
  54465. gamepadManager: GamepadManager;
  54466. }
  54467. }
  54468. module "babylonjs/Cameras/freeCameraInputsManager" {
  54469. /**
  54470. * Interface representing a free camera inputs manager
  54471. */
  54472. interface FreeCameraInputsManager {
  54473. /**
  54474. * Adds gamepad input support to the FreeCameraInputsManager.
  54475. * @returns the FreeCameraInputsManager
  54476. */
  54477. addGamepad(): FreeCameraInputsManager;
  54478. }
  54479. }
  54480. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  54481. /**
  54482. * Interface representing an arc rotate camera inputs manager
  54483. */
  54484. interface ArcRotateCameraInputsManager {
  54485. /**
  54486. * Adds gamepad input support to the ArcRotateCamera InputManager.
  54487. * @returns the camera inputs manager
  54488. */
  54489. addGamepad(): ArcRotateCameraInputsManager;
  54490. }
  54491. }
  54492. /**
  54493. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  54494. */
  54495. export class GamepadSystemSceneComponent implements ISceneComponent {
  54496. /**
  54497. * The component name helpfull to identify the component in the list of scene components.
  54498. */
  54499. readonly name: string;
  54500. /**
  54501. * The scene the component belongs to.
  54502. */
  54503. scene: Scene;
  54504. /**
  54505. * Creates a new instance of the component for the given scene
  54506. * @param scene Defines the scene to register the component in
  54507. */
  54508. constructor(scene: Scene);
  54509. /**
  54510. * Registers the component in a given scene
  54511. */
  54512. register(): void;
  54513. /**
  54514. * Rebuilds the elements related to this component in case of
  54515. * context lost for instance.
  54516. */
  54517. rebuild(): void;
  54518. /**
  54519. * Disposes the component and the associated ressources
  54520. */
  54521. dispose(): void;
  54522. private _beforeCameraUpdate;
  54523. }
  54524. }
  54525. declare module "babylonjs/Cameras/universalCamera" {
  54526. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  54527. import { Scene } from "babylonjs/scene";
  54528. import { Vector3 } from "babylonjs/Maths/math.vector";
  54529. import "babylonjs/Gamepads/gamepadSceneComponent";
  54530. /**
  54531. * 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,
  54532. * which still works and will still be found in many Playgrounds.
  54533. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54534. */
  54535. export class UniversalCamera extends TouchCamera {
  54536. /**
  54537. * Defines the gamepad rotation sensiblity.
  54538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  54539. */
  54540. get gamepadAngularSensibility(): number;
  54541. set gamepadAngularSensibility(value: number);
  54542. /**
  54543. * Defines the gamepad move sensiblity.
  54544. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  54545. */
  54546. get gamepadMoveSensibility(): number;
  54547. set gamepadMoveSensibility(value: number);
  54548. /**
  54549. * 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,
  54550. * which still works and will still be found in many Playgrounds.
  54551. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54552. * @param name Define the name of the camera in the scene
  54553. * @param position Define the start position of the camera in the scene
  54554. * @param scene Define the scene the camera belongs to
  54555. */
  54556. constructor(name: string, position: Vector3, scene: Scene);
  54557. /**
  54558. * Gets the current object class name.
  54559. * @return the class name
  54560. */
  54561. getClassName(): string;
  54562. }
  54563. }
  54564. declare module "babylonjs/Cameras/gamepadCamera" {
  54565. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54566. import { Scene } from "babylonjs/scene";
  54567. import { Vector3 } from "babylonjs/Maths/math.vector";
  54568. /**
  54569. * This represents a FPS type of camera. This is only here for back compat purpose.
  54570. * Please use the UniversalCamera instead as both are identical.
  54571. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54572. */
  54573. export class GamepadCamera extends UniversalCamera {
  54574. /**
  54575. * Instantiates a new Gamepad Camera
  54576. * This represents a FPS type of camera. This is only here for back compat purpose.
  54577. * Please use the UniversalCamera instead as both are identical.
  54578. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54579. * @param name Define the name of the camera in the scene
  54580. * @param position Define the start position of the camera in the scene
  54581. * @param scene Define the scene the camera belongs to
  54582. */
  54583. constructor(name: string, position: Vector3, scene: Scene);
  54584. /**
  54585. * Gets the current object class name.
  54586. * @return the class name
  54587. */
  54588. getClassName(): string;
  54589. }
  54590. }
  54591. declare module "babylonjs/Shaders/anaglyph.fragment" {
  54592. /** @hidden */
  54593. export var anaglyphPixelShader: {
  54594. name: string;
  54595. shader: string;
  54596. };
  54597. }
  54598. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  54599. import { Engine } from "babylonjs/Engines/engine";
  54600. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54601. import { Camera } from "babylonjs/Cameras/camera";
  54602. import "babylonjs/Shaders/anaglyph.fragment";
  54603. /**
  54604. * Postprocess used to generate anaglyphic rendering
  54605. */
  54606. export class AnaglyphPostProcess extends PostProcess {
  54607. private _passedProcess;
  54608. /**
  54609. * Gets a string identifying the name of the class
  54610. * @returns "AnaglyphPostProcess" string
  54611. */
  54612. getClassName(): string;
  54613. /**
  54614. * Creates a new AnaglyphPostProcess
  54615. * @param name defines postprocess name
  54616. * @param options defines creation options or target ratio scale
  54617. * @param rigCameras defines cameras using this postprocess
  54618. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  54619. * @param engine defines hosting engine
  54620. * @param reusable defines if the postprocess will be reused multiple times per frame
  54621. */
  54622. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  54623. }
  54624. }
  54625. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  54626. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  54627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54628. import { Scene } from "babylonjs/scene";
  54629. import { Vector3 } from "babylonjs/Maths/math.vector";
  54630. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54631. /**
  54632. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  54633. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54634. */
  54635. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  54636. /**
  54637. * Creates a new AnaglyphArcRotateCamera
  54638. * @param name defines camera name
  54639. * @param alpha defines alpha angle (in radians)
  54640. * @param beta defines beta angle (in radians)
  54641. * @param radius defines radius
  54642. * @param target defines camera target
  54643. * @param interaxialDistance defines distance between each color axis
  54644. * @param scene defines the hosting scene
  54645. */
  54646. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  54647. /**
  54648. * Gets camera class name
  54649. * @returns AnaglyphArcRotateCamera
  54650. */
  54651. getClassName(): string;
  54652. }
  54653. }
  54654. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  54655. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54656. import { Scene } from "babylonjs/scene";
  54657. import { Vector3 } from "babylonjs/Maths/math.vector";
  54658. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54659. /**
  54660. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  54661. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54662. */
  54663. export class AnaglyphFreeCamera extends FreeCamera {
  54664. /**
  54665. * Creates a new AnaglyphFreeCamera
  54666. * @param name defines camera name
  54667. * @param position defines initial position
  54668. * @param interaxialDistance defines distance between each color axis
  54669. * @param scene defines the hosting scene
  54670. */
  54671. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54672. /**
  54673. * Gets camera class name
  54674. * @returns AnaglyphFreeCamera
  54675. */
  54676. getClassName(): string;
  54677. }
  54678. }
  54679. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  54680. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54681. import { Scene } from "babylonjs/scene";
  54682. import { Vector3 } from "babylonjs/Maths/math.vector";
  54683. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54684. /**
  54685. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  54686. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54687. */
  54688. export class AnaglyphGamepadCamera extends GamepadCamera {
  54689. /**
  54690. * Creates a new AnaglyphGamepadCamera
  54691. * @param name defines camera name
  54692. * @param position defines initial position
  54693. * @param interaxialDistance defines distance between each color axis
  54694. * @param scene defines the hosting scene
  54695. */
  54696. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54697. /**
  54698. * Gets camera class name
  54699. * @returns AnaglyphGamepadCamera
  54700. */
  54701. getClassName(): string;
  54702. }
  54703. }
  54704. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  54705. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54706. import { Scene } from "babylonjs/scene";
  54707. import { Vector3 } from "babylonjs/Maths/math.vector";
  54708. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54709. /**
  54710. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  54711. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54712. */
  54713. export class AnaglyphUniversalCamera extends UniversalCamera {
  54714. /**
  54715. * Creates a new AnaglyphUniversalCamera
  54716. * @param name defines camera name
  54717. * @param position defines initial position
  54718. * @param interaxialDistance defines distance between each color axis
  54719. * @param scene defines the hosting scene
  54720. */
  54721. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54722. /**
  54723. * Gets camera class name
  54724. * @returns AnaglyphUniversalCamera
  54725. */
  54726. getClassName(): string;
  54727. }
  54728. }
  54729. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  54730. /** @hidden */
  54731. export var stereoscopicInterlacePixelShader: {
  54732. name: string;
  54733. shader: string;
  54734. };
  54735. }
  54736. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  54737. import { Camera } from "babylonjs/Cameras/camera";
  54738. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54739. import { Engine } from "babylonjs/Engines/engine";
  54740. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  54741. /**
  54742. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  54743. */
  54744. export class StereoscopicInterlacePostProcessI extends PostProcess {
  54745. private _stepSize;
  54746. private _passedProcess;
  54747. /**
  54748. * Gets a string identifying the name of the class
  54749. * @returns "StereoscopicInterlacePostProcessI" string
  54750. */
  54751. getClassName(): string;
  54752. /**
  54753. * Initializes a StereoscopicInterlacePostProcessI
  54754. * @param name The name of the effect.
  54755. * @param rigCameras The rig cameras to be appled to the post process
  54756. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  54757. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  54758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54759. * @param engine The engine which the post process will be applied. (default: current engine)
  54760. * @param reusable If the post process can be reused on the same frame. (default: false)
  54761. */
  54762. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54763. }
  54764. /**
  54765. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  54766. */
  54767. export class StereoscopicInterlacePostProcess extends PostProcess {
  54768. private _stepSize;
  54769. private _passedProcess;
  54770. /**
  54771. * Gets a string identifying the name of the class
  54772. * @returns "StereoscopicInterlacePostProcess" string
  54773. */
  54774. getClassName(): string;
  54775. /**
  54776. * Initializes a StereoscopicInterlacePostProcess
  54777. * @param name The name of the effect.
  54778. * @param rigCameras The rig cameras to be appled to the post process
  54779. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  54780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54781. * @param engine The engine which the post process will be applied. (default: current engine)
  54782. * @param reusable If the post process can be reused on the same frame. (default: false)
  54783. */
  54784. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54785. }
  54786. }
  54787. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  54788. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  54789. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54790. import { Scene } from "babylonjs/scene";
  54791. import { Vector3 } from "babylonjs/Maths/math.vector";
  54792. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54793. /**
  54794. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  54795. * @see https://doc.babylonjs.com/features/cameras
  54796. */
  54797. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  54798. /**
  54799. * Creates a new StereoscopicArcRotateCamera
  54800. * @param name defines camera name
  54801. * @param alpha defines alpha angle (in radians)
  54802. * @param beta defines beta angle (in radians)
  54803. * @param radius defines radius
  54804. * @param target defines camera target
  54805. * @param interaxialDistance defines distance between each color axis
  54806. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54807. * @param scene defines the hosting scene
  54808. */
  54809. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54810. /**
  54811. * Gets camera class name
  54812. * @returns StereoscopicArcRotateCamera
  54813. */
  54814. getClassName(): string;
  54815. }
  54816. }
  54817. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  54818. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54819. import { Scene } from "babylonjs/scene";
  54820. import { Vector3 } from "babylonjs/Maths/math.vector";
  54821. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54822. /**
  54823. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  54824. * @see https://doc.babylonjs.com/features/cameras
  54825. */
  54826. export class StereoscopicFreeCamera extends FreeCamera {
  54827. /**
  54828. * Creates a new StereoscopicFreeCamera
  54829. * @param name defines camera name
  54830. * @param position defines initial position
  54831. * @param interaxialDistance defines distance between each color axis
  54832. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54833. * @param scene defines the hosting scene
  54834. */
  54835. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54836. /**
  54837. * Gets camera class name
  54838. * @returns StereoscopicFreeCamera
  54839. */
  54840. getClassName(): string;
  54841. }
  54842. }
  54843. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  54844. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54845. import { Scene } from "babylonjs/scene";
  54846. import { Vector3 } from "babylonjs/Maths/math.vector";
  54847. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54848. /**
  54849. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  54850. * @see https://doc.babylonjs.com/features/cameras
  54851. */
  54852. export class StereoscopicGamepadCamera extends GamepadCamera {
  54853. /**
  54854. * Creates a new StereoscopicGamepadCamera
  54855. * @param name defines camera name
  54856. * @param position defines initial position
  54857. * @param interaxialDistance defines distance between each color axis
  54858. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54859. * @param scene defines the hosting scene
  54860. */
  54861. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54862. /**
  54863. * Gets camera class name
  54864. * @returns StereoscopicGamepadCamera
  54865. */
  54866. getClassName(): string;
  54867. }
  54868. }
  54869. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  54870. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54871. import { Scene } from "babylonjs/scene";
  54872. import { Vector3 } from "babylonjs/Maths/math.vector";
  54873. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54874. /**
  54875. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54876. * @see https://doc.babylonjs.com/features/cameras
  54877. */
  54878. export class StereoscopicUniversalCamera extends UniversalCamera {
  54879. /**
  54880. * Creates a new StereoscopicUniversalCamera
  54881. * @param name defines camera name
  54882. * @param position defines initial position
  54883. * @param interaxialDistance defines distance between each color axis
  54884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54885. * @param scene defines the hosting scene
  54886. */
  54887. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54888. /**
  54889. * Gets camera class name
  54890. * @returns StereoscopicUniversalCamera
  54891. */
  54892. getClassName(): string;
  54893. }
  54894. }
  54895. declare module "babylonjs/Cameras/Stereoscopic/index" {
  54896. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  54897. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  54898. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  54899. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  54900. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  54901. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  54902. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  54903. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  54904. }
  54905. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  54906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54907. import { Scene } from "babylonjs/scene";
  54908. import { Vector3 } from "babylonjs/Maths/math.vector";
  54909. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  54910. /**
  54911. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54912. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54913. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54914. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54915. */
  54916. export class VirtualJoysticksCamera extends FreeCamera {
  54917. /**
  54918. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54919. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54920. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54921. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54922. * @param name Define the name of the camera in the scene
  54923. * @param position Define the start position of the camera in the scene
  54924. * @param scene Define the scene the camera belongs to
  54925. */
  54926. constructor(name: string, position: Vector3, scene: Scene);
  54927. /**
  54928. * Gets the current object class name.
  54929. * @return the class name
  54930. */
  54931. getClassName(): string;
  54932. }
  54933. }
  54934. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  54935. import { Matrix } from "babylonjs/Maths/math.vector";
  54936. /**
  54937. * This represents all the required metrics to create a VR camera.
  54938. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54939. */
  54940. export class VRCameraMetrics {
  54941. /**
  54942. * Define the horizontal resolution off the screen.
  54943. */
  54944. hResolution: number;
  54945. /**
  54946. * Define the vertical resolution off the screen.
  54947. */
  54948. vResolution: number;
  54949. /**
  54950. * Define the horizontal screen size.
  54951. */
  54952. hScreenSize: number;
  54953. /**
  54954. * Define the vertical screen size.
  54955. */
  54956. vScreenSize: number;
  54957. /**
  54958. * Define the vertical screen center position.
  54959. */
  54960. vScreenCenter: number;
  54961. /**
  54962. * Define the distance of the eyes to the screen.
  54963. */
  54964. eyeToScreenDistance: number;
  54965. /**
  54966. * Define the distance between both lenses
  54967. */
  54968. lensSeparationDistance: number;
  54969. /**
  54970. * Define the distance between both viewer's eyes.
  54971. */
  54972. interpupillaryDistance: number;
  54973. /**
  54974. * Define the distortion factor of the VR postprocess.
  54975. * Please, touch with care.
  54976. */
  54977. distortionK: number[];
  54978. /**
  54979. * Define the chromatic aberration correction factors for the VR post process.
  54980. */
  54981. chromaAbCorrection: number[];
  54982. /**
  54983. * Define the scale factor of the post process.
  54984. * The smaller the better but the slower.
  54985. */
  54986. postProcessScaleFactor: number;
  54987. /**
  54988. * Define an offset for the lens center.
  54989. */
  54990. lensCenterOffset: number;
  54991. /**
  54992. * Define if the current vr camera should compensate the distortion of the lense or not.
  54993. */
  54994. compensateDistortion: boolean;
  54995. /**
  54996. * Defines if multiview should be enabled when rendering (Default: false)
  54997. */
  54998. multiviewEnabled: boolean;
  54999. /**
  55000. * Gets the rendering aspect ratio based on the provided resolutions.
  55001. */
  55002. get aspectRatio(): number;
  55003. /**
  55004. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  55005. */
  55006. get aspectRatioFov(): number;
  55007. /**
  55008. * @hidden
  55009. */
  55010. get leftHMatrix(): Matrix;
  55011. /**
  55012. * @hidden
  55013. */
  55014. get rightHMatrix(): Matrix;
  55015. /**
  55016. * @hidden
  55017. */
  55018. get leftPreViewMatrix(): Matrix;
  55019. /**
  55020. * @hidden
  55021. */
  55022. get rightPreViewMatrix(): Matrix;
  55023. /**
  55024. * Get the default VRMetrics based on the most generic setup.
  55025. * @returns the default vr metrics
  55026. */
  55027. static GetDefault(): VRCameraMetrics;
  55028. }
  55029. }
  55030. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  55031. /** @hidden */
  55032. export var vrDistortionCorrectionPixelShader: {
  55033. name: string;
  55034. shader: string;
  55035. };
  55036. }
  55037. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  55038. import { Camera } from "babylonjs/Cameras/camera";
  55039. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55041. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  55042. /**
  55043. * VRDistortionCorrectionPostProcess used for mobile VR
  55044. */
  55045. export class VRDistortionCorrectionPostProcess extends PostProcess {
  55046. private _isRightEye;
  55047. private _distortionFactors;
  55048. private _postProcessScaleFactor;
  55049. private _lensCenterOffset;
  55050. private _scaleIn;
  55051. private _scaleFactor;
  55052. private _lensCenter;
  55053. /**
  55054. * Gets a string identifying the name of the class
  55055. * @returns "VRDistortionCorrectionPostProcess" string
  55056. */
  55057. getClassName(): string;
  55058. /**
  55059. * Initializes the VRDistortionCorrectionPostProcess
  55060. * @param name The name of the effect.
  55061. * @param camera The camera to apply the render pass to.
  55062. * @param isRightEye If this is for the right eye distortion
  55063. * @param vrMetrics All the required metrics for the VR camera
  55064. */
  55065. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  55066. }
  55067. }
  55068. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  55069. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  55070. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  55071. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55072. import { Scene } from "babylonjs/scene";
  55073. import { Vector3 } from "babylonjs/Maths/math.vector";
  55074. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  55075. import "babylonjs/Cameras/RigModes/vrRigMode";
  55076. /**
  55077. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  55078. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55079. */
  55080. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  55081. /**
  55082. * Creates a new VRDeviceOrientationArcRotateCamera
  55083. * @param name defines camera name
  55084. * @param alpha defines the camera rotation along the logitudinal axis
  55085. * @param beta defines the camera rotation along the latitudinal axis
  55086. * @param radius defines the camera distance from its target
  55087. * @param target defines the camera target
  55088. * @param scene defines the scene the camera belongs to
  55089. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55090. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55091. */
  55092. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55093. /**
  55094. * Gets camera class name
  55095. * @returns VRDeviceOrientationArcRotateCamera
  55096. */
  55097. getClassName(): string;
  55098. }
  55099. }
  55100. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  55101. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55103. import { Scene } from "babylonjs/scene";
  55104. import { Vector3 } from "babylonjs/Maths/math.vector";
  55105. import "babylonjs/Cameras/RigModes/vrRigMode";
  55106. /**
  55107. * Camera used to simulate VR rendering (based on FreeCamera)
  55108. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55109. */
  55110. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  55111. /**
  55112. * Creates a new VRDeviceOrientationFreeCamera
  55113. * @param name defines camera name
  55114. * @param position defines the start position of the camera
  55115. * @param scene defines the scene the camera belongs to
  55116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55118. */
  55119. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55120. /**
  55121. * Gets camera class name
  55122. * @returns VRDeviceOrientationFreeCamera
  55123. */
  55124. getClassName(): string;
  55125. }
  55126. }
  55127. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  55128. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55129. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55130. import { Scene } from "babylonjs/scene";
  55131. import { Vector3 } from "babylonjs/Maths/math.vector";
  55132. import "babylonjs/Gamepads/gamepadSceneComponent";
  55133. /**
  55134. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  55135. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55136. */
  55137. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  55138. /**
  55139. * Creates a new VRDeviceOrientationGamepadCamera
  55140. * @param name defines camera name
  55141. * @param position defines the start position of the camera
  55142. * @param scene defines the scene the camera belongs to
  55143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55145. */
  55146. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55147. /**
  55148. * Gets camera class name
  55149. * @returns VRDeviceOrientationGamepadCamera
  55150. */
  55151. getClassName(): string;
  55152. }
  55153. }
  55154. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  55155. import { Scene } from "babylonjs/scene";
  55156. import { Texture } from "babylonjs/Materials/Textures/texture";
  55157. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55158. /**
  55159. * A class extending Texture allowing drawing on a texture
  55160. * @see https://doc.babylonjs.com/how_to/dynamictexture
  55161. */
  55162. export class DynamicTexture extends Texture {
  55163. private _generateMipMaps;
  55164. private _canvas;
  55165. private _context;
  55166. /**
  55167. * Creates a DynamicTexture
  55168. * @param name defines the name of the texture
  55169. * @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
  55170. * @param scene defines the scene where you want the texture
  55171. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55172. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55173. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55174. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  55175. */
  55176. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  55177. /**
  55178. * Get the current class name of the texture useful for serialization or dynamic coding.
  55179. * @returns "DynamicTexture"
  55180. */
  55181. getClassName(): string;
  55182. /**
  55183. * Gets the current state of canRescale
  55184. */
  55185. get canRescale(): boolean;
  55186. private _recreate;
  55187. /**
  55188. * Scales the texture
  55189. * @param ratio the scale factor to apply to both width and height
  55190. */
  55191. scale(ratio: number): void;
  55192. /**
  55193. * Resizes the texture
  55194. * @param width the new width
  55195. * @param height the new height
  55196. */
  55197. scaleTo(width: number, height: number): void;
  55198. /**
  55199. * Gets the context of the canvas used by the texture
  55200. * @returns the canvas context of the dynamic texture
  55201. */
  55202. getContext(): CanvasRenderingContext2D;
  55203. /**
  55204. * Clears the texture
  55205. */
  55206. clear(): void;
  55207. /**
  55208. * Updates the texture
  55209. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55210. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55211. */
  55212. update(invertY?: boolean, premulAlpha?: boolean): void;
  55213. /**
  55214. * Draws text onto the texture
  55215. * @param text defines the text to be drawn
  55216. * @param x defines the placement of the text from the left
  55217. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55218. * @param font defines the font to be used with font-style, font-size, font-name
  55219. * @param color defines the color used for the text
  55220. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55221. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55222. * @param update defines whether texture is immediately update (default is true)
  55223. */
  55224. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  55225. /**
  55226. * Clones the texture
  55227. * @returns the clone of the texture.
  55228. */
  55229. clone(): DynamicTexture;
  55230. /**
  55231. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55232. * @returns a serialized dynamic texture object
  55233. */
  55234. serialize(): any;
  55235. private _IsCanvasElement;
  55236. /** @hidden */
  55237. _rebuild(): void;
  55238. }
  55239. }
  55240. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  55241. import { Scene } from "babylonjs/scene";
  55242. import { Color3 } from "babylonjs/Maths/math.color";
  55243. import { Mesh } from "babylonjs/Meshes/mesh";
  55244. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55245. import { Nullable } from "babylonjs/types";
  55246. /**
  55247. * Class containing static functions to help procedurally build meshes
  55248. */
  55249. export class GroundBuilder {
  55250. /**
  55251. * Creates a ground mesh
  55252. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55253. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55255. * @param name defines the name of the mesh
  55256. * @param options defines the options used to create the mesh
  55257. * @param scene defines the hosting scene
  55258. * @returns the ground mesh
  55259. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55260. */
  55261. static CreateGround(name: string, options: {
  55262. width?: number;
  55263. height?: number;
  55264. subdivisions?: number;
  55265. subdivisionsX?: number;
  55266. subdivisionsY?: number;
  55267. updatable?: boolean;
  55268. }, scene: any): Mesh;
  55269. /**
  55270. * Creates a tiled ground mesh
  55271. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55272. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55273. * * 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
  55274. * * 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
  55275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55276. * @param name defines the name of the mesh
  55277. * @param options defines the options used to create the mesh
  55278. * @param scene defines the hosting scene
  55279. * @returns the tiled ground mesh
  55280. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55281. */
  55282. static CreateTiledGround(name: string, options: {
  55283. xmin: number;
  55284. zmin: number;
  55285. xmax: number;
  55286. zmax: number;
  55287. subdivisions?: {
  55288. w: number;
  55289. h: number;
  55290. };
  55291. precision?: {
  55292. w: number;
  55293. h: number;
  55294. };
  55295. updatable?: boolean;
  55296. }, scene?: Nullable<Scene>): Mesh;
  55297. /**
  55298. * Creates a ground mesh from a height map
  55299. * * The parameter `url` sets the URL of the height map image resource.
  55300. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55301. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55302. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55303. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55304. * * 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.
  55305. * * 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).
  55306. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55308. * @param name defines the name of the mesh
  55309. * @param url defines the url to the height map
  55310. * @param options defines the options used to create the mesh
  55311. * @param scene defines the hosting scene
  55312. * @returns the ground mesh
  55313. * @see https://doc.babylonjs.com/babylon101/height_map
  55314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55315. */
  55316. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55317. width?: number;
  55318. height?: number;
  55319. subdivisions?: number;
  55320. minHeight?: number;
  55321. maxHeight?: number;
  55322. colorFilter?: Color3;
  55323. alphaFilter?: number;
  55324. updatable?: boolean;
  55325. onReady?: (mesh: GroundMesh) => void;
  55326. }, scene?: Nullable<Scene>): GroundMesh;
  55327. }
  55328. }
  55329. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  55330. import { Vector4 } from "babylonjs/Maths/math.vector";
  55331. import { Mesh } from "babylonjs/Meshes/mesh";
  55332. /**
  55333. * Class containing static functions to help procedurally build meshes
  55334. */
  55335. export class TorusBuilder {
  55336. /**
  55337. * Creates a torus mesh
  55338. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55339. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55340. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55344. * @param name defines the name of the mesh
  55345. * @param options defines the options used to create the mesh
  55346. * @param scene defines the hosting scene
  55347. * @returns the torus mesh
  55348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55349. */
  55350. static CreateTorus(name: string, options: {
  55351. diameter?: number;
  55352. thickness?: number;
  55353. tessellation?: number;
  55354. updatable?: boolean;
  55355. sideOrientation?: number;
  55356. frontUVs?: Vector4;
  55357. backUVs?: Vector4;
  55358. }, scene: any): Mesh;
  55359. }
  55360. }
  55361. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  55362. import { Vector4 } from "babylonjs/Maths/math.vector";
  55363. import { Color4 } from "babylonjs/Maths/math.color";
  55364. import { Mesh } from "babylonjs/Meshes/mesh";
  55365. /**
  55366. * Class containing static functions to help procedurally build meshes
  55367. */
  55368. export class CylinderBuilder {
  55369. /**
  55370. * Creates a cylinder or a cone mesh
  55371. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55372. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55373. * * 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.
  55374. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55375. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55376. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55377. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55378. * * 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).
  55379. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55380. * * 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).
  55381. * * 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
  55382. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55383. * * 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
  55384. * * 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.
  55385. * * If `enclose` is false, a ring surface is one element.
  55386. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55387. * * 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
  55388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55391. * @param name defines the name of the mesh
  55392. * @param options defines the options used to create the mesh
  55393. * @param scene defines the hosting scene
  55394. * @returns the cylinder mesh
  55395. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55396. */
  55397. static CreateCylinder(name: string, options: {
  55398. height?: number;
  55399. diameterTop?: number;
  55400. diameterBottom?: number;
  55401. diameter?: number;
  55402. tessellation?: number;
  55403. subdivisions?: number;
  55404. arc?: number;
  55405. faceColors?: Color4[];
  55406. faceUV?: Vector4[];
  55407. updatable?: boolean;
  55408. hasRings?: boolean;
  55409. enclose?: boolean;
  55410. cap?: number;
  55411. sideOrientation?: number;
  55412. frontUVs?: Vector4;
  55413. backUVs?: Vector4;
  55414. }, scene: any): Mesh;
  55415. }
  55416. }
  55417. declare module "babylonjs/XR/webXRTypes" {
  55418. import { Nullable } from "babylonjs/types";
  55419. import { IDisposable } from "babylonjs/scene";
  55420. /**
  55421. * States of the webXR experience
  55422. */
  55423. export enum WebXRState {
  55424. /**
  55425. * Transitioning to being in XR mode
  55426. */
  55427. ENTERING_XR = 0,
  55428. /**
  55429. * Transitioning to non XR mode
  55430. */
  55431. EXITING_XR = 1,
  55432. /**
  55433. * In XR mode and presenting
  55434. */
  55435. IN_XR = 2,
  55436. /**
  55437. * Not entered XR mode
  55438. */
  55439. NOT_IN_XR = 3
  55440. }
  55441. /**
  55442. * The state of the XR camera's tracking
  55443. */
  55444. export enum WebXRTrackingState {
  55445. /**
  55446. * No transformation received, device is not being tracked
  55447. */
  55448. NOT_TRACKING = 0,
  55449. /**
  55450. * Tracking lost - using emulated position
  55451. */
  55452. TRACKING_LOST = 1,
  55453. /**
  55454. * Transformation tracking works normally
  55455. */
  55456. TRACKING = 2
  55457. }
  55458. /**
  55459. * Abstraction of the XR render target
  55460. */
  55461. export interface WebXRRenderTarget extends IDisposable {
  55462. /**
  55463. * xrpresent context of the canvas which can be used to display/mirror xr content
  55464. */
  55465. canvasContext: WebGLRenderingContext;
  55466. /**
  55467. * xr layer for the canvas
  55468. */
  55469. xrLayer: Nullable<XRWebGLLayer>;
  55470. /**
  55471. * Initializes the xr layer for the session
  55472. * @param xrSession xr session
  55473. * @returns a promise that will resolve once the XR Layer has been created
  55474. */
  55475. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55476. }
  55477. }
  55478. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  55479. import { Nullable } from "babylonjs/types";
  55480. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55481. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55482. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55483. import { Observable } from "babylonjs/Misc/observable";
  55484. /**
  55485. * COnfiguration object for WebXR output canvas
  55486. */
  55487. export class WebXRManagedOutputCanvasOptions {
  55488. /**
  55489. * An optional canvas in case you wish to create it yourself and provide it here.
  55490. * If not provided, a new canvas will be created
  55491. */
  55492. canvasElement?: HTMLCanvasElement;
  55493. /**
  55494. * Options for this XR Layer output
  55495. */
  55496. canvasOptions?: XRWebGLLayerInit;
  55497. /**
  55498. * CSS styling for a newly created canvas (if not provided)
  55499. */
  55500. newCanvasCssStyle?: string;
  55501. /**
  55502. * Get the default values of the configuration object
  55503. * @param engine defines the engine to use (can be null)
  55504. * @returns default values of this configuration object
  55505. */
  55506. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  55507. }
  55508. /**
  55509. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  55510. */
  55511. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  55512. private _options;
  55513. private _canvas;
  55514. private _engine;
  55515. private _originalCanvasSize;
  55516. /**
  55517. * Rendering context of the canvas which can be used to display/mirror xr content
  55518. */
  55519. canvasContext: WebGLRenderingContext;
  55520. /**
  55521. * xr layer for the canvas
  55522. */
  55523. xrLayer: Nullable<XRWebGLLayer>;
  55524. /**
  55525. * Obseervers registered here will be triggered when the xr layer was initialized
  55526. */
  55527. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  55528. /**
  55529. * Initializes the canvas to be added/removed upon entering/exiting xr
  55530. * @param _xrSessionManager The XR Session manager
  55531. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  55532. */
  55533. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  55534. /**
  55535. * Disposes of the object
  55536. */
  55537. dispose(): void;
  55538. /**
  55539. * Initializes the xr layer for the session
  55540. * @param xrSession xr session
  55541. * @returns a promise that will resolve once the XR Layer has been created
  55542. */
  55543. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55544. private _addCanvas;
  55545. private _removeCanvas;
  55546. private _setCanvasSize;
  55547. private _setManagedOutputCanvas;
  55548. }
  55549. }
  55550. declare module "babylonjs/XR/webXRSessionManager" {
  55551. import { Observable } from "babylonjs/Misc/observable";
  55552. import { Nullable } from "babylonjs/types";
  55553. import { IDisposable, Scene } from "babylonjs/scene";
  55554. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55555. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55556. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55557. /**
  55558. * Manages an XRSession to work with Babylon's engine
  55559. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  55560. */
  55561. export class WebXRSessionManager implements IDisposable {
  55562. /** The scene which the session should be created for */
  55563. scene: Scene;
  55564. private _referenceSpace;
  55565. private _rttProvider;
  55566. private _sessionEnded;
  55567. private _xrNavigator;
  55568. private baseLayer;
  55569. /**
  55570. * The base reference space from which the session started. good if you want to reset your
  55571. * reference space
  55572. */
  55573. baseReferenceSpace: XRReferenceSpace;
  55574. /**
  55575. * Current XR frame
  55576. */
  55577. currentFrame: Nullable<XRFrame>;
  55578. /** WebXR timestamp updated every frame */
  55579. currentTimestamp: number;
  55580. /**
  55581. * Used just in case of a failure to initialize an immersive session.
  55582. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  55583. */
  55584. defaultHeightCompensation: number;
  55585. /**
  55586. * Fires every time a new xrFrame arrives which can be used to update the camera
  55587. */
  55588. onXRFrameObservable: Observable<XRFrame>;
  55589. /**
  55590. * Fires when the reference space changed
  55591. */
  55592. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  55593. /**
  55594. * Fires when the xr session is ended either by the device or manually done
  55595. */
  55596. onXRSessionEnded: Observable<any>;
  55597. /**
  55598. * Fires when the xr session is ended either by the device or manually done
  55599. */
  55600. onXRSessionInit: Observable<XRSession>;
  55601. /**
  55602. * Underlying xr session
  55603. */
  55604. session: XRSession;
  55605. /**
  55606. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  55607. * or get the offset the player is currently at.
  55608. */
  55609. viewerReferenceSpace: XRReferenceSpace;
  55610. /**
  55611. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  55612. * @param scene The scene which the session should be created for
  55613. */
  55614. constructor(
  55615. /** The scene which the session should be created for */
  55616. scene: Scene);
  55617. /**
  55618. * The current reference space used in this session. This reference space can constantly change!
  55619. * It is mainly used to offset the camera's position.
  55620. */
  55621. get referenceSpace(): XRReferenceSpace;
  55622. /**
  55623. * Set a new reference space and triggers the observable
  55624. */
  55625. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  55626. /**
  55627. * Disposes of the session manager
  55628. */
  55629. dispose(): void;
  55630. /**
  55631. * Stops the xrSession and restores the render loop
  55632. * @returns Promise which resolves after it exits XR
  55633. */
  55634. exitXRAsync(): Promise<void>;
  55635. /**
  55636. * Gets the correct render target texture to be rendered this frame for this eye
  55637. * @param eye the eye for which to get the render target
  55638. * @returns the render target for the specified eye
  55639. */
  55640. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  55641. /**
  55642. * Creates a WebXRRenderTarget object for the XR session
  55643. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  55644. * @param options optional options to provide when creating a new render target
  55645. * @returns a WebXR render target to which the session can render
  55646. */
  55647. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  55648. /**
  55649. * Initializes the manager
  55650. * After initialization enterXR can be called to start an XR session
  55651. * @returns Promise which resolves after it is initialized
  55652. */
  55653. initializeAsync(): Promise<void>;
  55654. /**
  55655. * Initializes an xr session
  55656. * @param xrSessionMode mode to initialize
  55657. * @param xrSessionInit defines optional and required values to pass to the session builder
  55658. * @returns a promise which will resolve once the session has been initialized
  55659. */
  55660. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  55661. /**
  55662. * Checks if a session would be supported for the creation options specified
  55663. * @param sessionMode session mode to check if supported eg. immersive-vr
  55664. * @returns A Promise that resolves to true if supported and false if not
  55665. */
  55666. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55667. /**
  55668. * Resets the reference space to the one started the session
  55669. */
  55670. resetReferenceSpace(): void;
  55671. /**
  55672. * Starts rendering to the xr layer
  55673. */
  55674. runXRRenderLoop(): void;
  55675. /**
  55676. * Sets the reference space on the xr session
  55677. * @param referenceSpaceType space to set
  55678. * @returns a promise that will resolve once the reference space has been set
  55679. */
  55680. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  55681. /**
  55682. * Updates the render state of the session
  55683. * @param state state to set
  55684. * @returns a promise that resolves once the render state has been updated
  55685. */
  55686. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  55687. /**
  55688. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  55689. * @param sessionMode defines the session to test
  55690. * @returns a promise with boolean as final value
  55691. */
  55692. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55693. /**
  55694. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  55695. */
  55696. get isNative(): boolean;
  55697. private _createRenderTargetTexture;
  55698. }
  55699. }
  55700. declare module "babylonjs/XR/webXRCamera" {
  55701. import { Vector3 } from "babylonjs/Maths/math.vector";
  55702. import { Scene } from "babylonjs/scene";
  55703. import { Camera } from "babylonjs/Cameras/camera";
  55704. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55705. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55706. import { Observable } from "babylonjs/Misc/observable";
  55707. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  55708. /**
  55709. * WebXR Camera which holds the views for the xrSession
  55710. * @see https://doc.babylonjs.com/how_to/webxr_camera
  55711. */
  55712. export class WebXRCamera extends FreeCamera {
  55713. private _xrSessionManager;
  55714. private _firstFrame;
  55715. private _referenceQuaternion;
  55716. private _referencedPosition;
  55717. private _xrInvPositionCache;
  55718. private _xrInvQuaternionCache;
  55719. private _trackingState;
  55720. /**
  55721. * Observable raised before camera teleportation
  55722. */
  55723. onBeforeCameraTeleport: Observable<Vector3>;
  55724. /**
  55725. * Observable raised after camera teleportation
  55726. */
  55727. onAfterCameraTeleport: Observable<Vector3>;
  55728. /**
  55729. * Notifies when the camera's tracking state has changed.
  55730. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  55731. */
  55732. onTrackingStateChanged: Observable<WebXRTrackingState>;
  55733. /**
  55734. * Should position compensation execute on first frame.
  55735. * This is used when copying the position from a native (non XR) camera
  55736. */
  55737. compensateOnFirstFrame: boolean;
  55738. /**
  55739. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  55740. * @param name the name of the camera
  55741. * @param scene the scene to add the camera to
  55742. * @param _xrSessionManager a constructed xr session manager
  55743. */
  55744. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  55745. /**
  55746. * Get the current XR tracking state of the camera
  55747. */
  55748. get trackingState(): WebXRTrackingState;
  55749. private _setTrackingState;
  55750. /**
  55751. * Return the user's height, unrelated to the current ground.
  55752. * This will be the y position of this camera, when ground level is 0.
  55753. */
  55754. get realWorldHeight(): number;
  55755. /** @hidden */
  55756. _updateForDualEyeDebugging(): void;
  55757. /**
  55758. * Sets this camera's transformation based on a non-vr camera
  55759. * @param otherCamera the non-vr camera to copy the transformation from
  55760. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  55761. */
  55762. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  55763. /**
  55764. * Gets the current instance class name ("WebXRCamera").
  55765. * @returns the class name
  55766. */
  55767. getClassName(): string;
  55768. private _rotate180;
  55769. private _updateFromXRSession;
  55770. private _updateNumberOfRigCameras;
  55771. private _updateReferenceSpace;
  55772. private _updateReferenceSpaceOffset;
  55773. }
  55774. }
  55775. declare module "babylonjs/XR/webXRFeaturesManager" {
  55776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55777. import { IDisposable } from "babylonjs/scene";
  55778. /**
  55779. * Defining the interface required for a (webxr) feature
  55780. */
  55781. export interface IWebXRFeature extends IDisposable {
  55782. /**
  55783. * Is this feature attached
  55784. */
  55785. attached: boolean;
  55786. /**
  55787. * Should auto-attach be disabled?
  55788. */
  55789. disableAutoAttach: boolean;
  55790. /**
  55791. * Attach the feature to the session
  55792. * Will usually be called by the features manager
  55793. *
  55794. * @param force should attachment be forced (even when already attached)
  55795. * @returns true if successful.
  55796. */
  55797. attach(force?: boolean): boolean;
  55798. /**
  55799. * Detach the feature from the session
  55800. * Will usually be called by the features manager
  55801. *
  55802. * @returns true if successful.
  55803. */
  55804. detach(): boolean;
  55805. /**
  55806. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55807. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55808. *
  55809. * @returns whether or not the feature is compatible in this environment
  55810. */
  55811. isCompatible(): boolean;
  55812. /**
  55813. * Was this feature disposed;
  55814. */
  55815. isDisposed: boolean;
  55816. /**
  55817. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  55818. */
  55819. xrNativeFeatureName?: string;
  55820. /**
  55821. * A list of (Babylon WebXR) features this feature depends on
  55822. */
  55823. dependsOn?: string[];
  55824. /**
  55825. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  55826. */
  55827. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  55828. }
  55829. /**
  55830. * A list of the currently available features without referencing them
  55831. */
  55832. export class WebXRFeatureName {
  55833. /**
  55834. * The name of the anchor system feature
  55835. */
  55836. static readonly ANCHOR_SYSTEM: string;
  55837. /**
  55838. * The name of the background remover feature
  55839. */
  55840. static readonly BACKGROUND_REMOVER: string;
  55841. /**
  55842. * The name of the hit test feature
  55843. */
  55844. static readonly HIT_TEST: string;
  55845. /**
  55846. * The name of the mesh detection feature
  55847. */
  55848. static readonly MESH_DETECTION: string;
  55849. /**
  55850. * physics impostors for xr controllers feature
  55851. */
  55852. static readonly PHYSICS_CONTROLLERS: string;
  55853. /**
  55854. * The name of the plane detection feature
  55855. */
  55856. static readonly PLANE_DETECTION: string;
  55857. /**
  55858. * The name of the pointer selection feature
  55859. */
  55860. static readonly POINTER_SELECTION: string;
  55861. /**
  55862. * The name of the teleportation feature
  55863. */
  55864. static readonly TELEPORTATION: string;
  55865. /**
  55866. * The name of the feature points feature.
  55867. */
  55868. static readonly FEATURE_POINTS: string;
  55869. /**
  55870. * The name of the hand tracking feature.
  55871. */
  55872. static readonly HAND_TRACKING: string;
  55873. /**
  55874. * The name of the image tracking feature
  55875. */
  55876. static readonly IMAGE_TRACKING: string;
  55877. }
  55878. /**
  55879. * Defining the constructor of a feature. Used to register the modules.
  55880. */
  55881. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  55882. /**
  55883. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  55884. * It is mainly used in AR sessions.
  55885. *
  55886. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  55887. */
  55888. export class WebXRFeaturesManager implements IDisposable {
  55889. private _xrSessionManager;
  55890. private static readonly _AvailableFeatures;
  55891. private _features;
  55892. /**
  55893. * constructs a new features manages.
  55894. *
  55895. * @param _xrSessionManager an instance of WebXRSessionManager
  55896. */
  55897. constructor(_xrSessionManager: WebXRSessionManager);
  55898. /**
  55899. * Used to register a module. After calling this function a developer can use this feature in the scene.
  55900. * Mainly used internally.
  55901. *
  55902. * @param featureName the name of the feature to register
  55903. * @param constructorFunction the function used to construct the module
  55904. * @param version the (babylon) version of the module
  55905. * @param stable is that a stable version of this module
  55906. */
  55907. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  55908. /**
  55909. * Returns a constructor of a specific feature.
  55910. *
  55911. * @param featureName the name of the feature to construct
  55912. * @param version the version of the feature to load
  55913. * @param xrSessionManager the xrSessionManager. Used to construct the module
  55914. * @param options optional options provided to the module.
  55915. * @returns a function that, when called, will return a new instance of this feature
  55916. */
  55917. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  55918. /**
  55919. * Can be used to return the list of features currently registered
  55920. *
  55921. * @returns an Array of available features
  55922. */
  55923. static GetAvailableFeatures(): string[];
  55924. /**
  55925. * Gets the versions available for a specific feature
  55926. * @param featureName the name of the feature
  55927. * @returns an array with the available versions
  55928. */
  55929. static GetAvailableVersions(featureName: string): string[];
  55930. /**
  55931. * Return the latest unstable version of this feature
  55932. * @param featureName the name of the feature to search
  55933. * @returns the version number. if not found will return -1
  55934. */
  55935. static GetLatestVersionOfFeature(featureName: string): number;
  55936. /**
  55937. * Return the latest stable version of this feature
  55938. * @param featureName the name of the feature to search
  55939. * @returns the version number. if not found will return -1
  55940. */
  55941. static GetStableVersionOfFeature(featureName: string): number;
  55942. /**
  55943. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55944. * Can be used during a session to start a feature
  55945. * @param featureName the name of feature to attach
  55946. */
  55947. attachFeature(featureName: string): void;
  55948. /**
  55949. * Can be used inside a session or when the session ends to detach a specific feature
  55950. * @param featureName the name of the feature to detach
  55951. */
  55952. detachFeature(featureName: string): void;
  55953. /**
  55954. * Used to disable an already-enabled feature
  55955. * The feature will be disposed and will be recreated once enabled.
  55956. * @param featureName the feature to disable
  55957. * @returns true if disable was successful
  55958. */
  55959. disableFeature(featureName: string | {
  55960. Name: string;
  55961. }): boolean;
  55962. /**
  55963. * dispose this features manager
  55964. */
  55965. dispose(): void;
  55966. /**
  55967. * 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.
  55968. * 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.
  55969. *
  55970. * @param featureName the name of the feature to load or the class of the feature
  55971. * @param version optional version to load. if not provided the latest version will be enabled
  55972. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55973. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55974. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55975. * @returns a new constructed feature or throws an error if feature not found.
  55976. */
  55977. enableFeature(featureName: string | {
  55978. Name: string;
  55979. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55980. /**
  55981. * get the implementation of an enabled feature.
  55982. * @param featureName the name of the feature to load
  55983. * @returns the feature class, if found
  55984. */
  55985. getEnabledFeature(featureName: string): IWebXRFeature;
  55986. /**
  55987. * Get the list of enabled features
  55988. * @returns an array of enabled features
  55989. */
  55990. getEnabledFeatures(): string[];
  55991. /**
  55992. * This function will extend the session creation configuration object with enabled features.
  55993. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55994. * according to the defined "required" variable, provided during enableFeature call
  55995. * @param xrSessionInit the xr Session init object to extend
  55996. *
  55997. * @returns an extended XRSessionInit object
  55998. */
  55999. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  56000. }
  56001. }
  56002. declare module "babylonjs/XR/webXRExperienceHelper" {
  56003. import { Observable } from "babylonjs/Misc/observable";
  56004. import { IDisposable, Scene } from "babylonjs/scene";
  56005. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56006. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  56007. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  56008. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  56009. /**
  56010. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  56011. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  56012. */
  56013. export class WebXRExperienceHelper implements IDisposable {
  56014. private scene;
  56015. private _nonVRCamera;
  56016. private _originalSceneAutoClear;
  56017. private _supported;
  56018. /**
  56019. * Camera used to render xr content
  56020. */
  56021. camera: WebXRCamera;
  56022. /** A features manager for this xr session */
  56023. featuresManager: WebXRFeaturesManager;
  56024. /**
  56025. * Observers registered here will be triggered after the camera's initial transformation is set
  56026. * This can be used to set a different ground level or an extra rotation.
  56027. *
  56028. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  56029. * to the position set after this observable is done executing.
  56030. */
  56031. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  56032. /**
  56033. * Fires when the state of the experience helper has changed
  56034. */
  56035. onStateChangedObservable: Observable<WebXRState>;
  56036. /** Session manager used to keep track of xr session */
  56037. sessionManager: WebXRSessionManager;
  56038. /**
  56039. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  56040. */
  56041. state: WebXRState;
  56042. /**
  56043. * Creates a WebXRExperienceHelper
  56044. * @param scene The scene the helper should be created in
  56045. */
  56046. private constructor();
  56047. /**
  56048. * Creates the experience helper
  56049. * @param scene the scene to attach the experience helper to
  56050. * @returns a promise for the experience helper
  56051. */
  56052. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  56053. /**
  56054. * Disposes of the experience helper
  56055. */
  56056. dispose(): void;
  56057. /**
  56058. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  56059. * @param sessionMode options for the XR session
  56060. * @param referenceSpaceType frame of reference of the XR session
  56061. * @param renderTarget the output canvas that will be used to enter XR mode
  56062. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  56063. * @returns promise that resolves after xr mode has entered
  56064. */
  56065. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  56066. /**
  56067. * Exits XR mode and returns the scene to its original state
  56068. * @returns promise that resolves after xr mode has exited
  56069. */
  56070. exitXRAsync(): Promise<void>;
  56071. private _nonXRToXRCamera;
  56072. private _setState;
  56073. }
  56074. }
  56075. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  56076. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56077. import { Observable } from "babylonjs/Misc/observable";
  56078. import { IDisposable } from "babylonjs/scene";
  56079. /**
  56080. * X-Y values for axes in WebXR
  56081. */
  56082. export interface IWebXRMotionControllerAxesValue {
  56083. /**
  56084. * The value of the x axis
  56085. */
  56086. x: number;
  56087. /**
  56088. * The value of the y-axis
  56089. */
  56090. y: number;
  56091. }
  56092. /**
  56093. * changed / previous values for the values of this component
  56094. */
  56095. export interface IWebXRMotionControllerComponentChangesValues<T> {
  56096. /**
  56097. * current (this frame) value
  56098. */
  56099. current: T;
  56100. /**
  56101. * previous (last change) value
  56102. */
  56103. previous: T;
  56104. }
  56105. /**
  56106. * Represents changes in the component between current frame and last values recorded
  56107. */
  56108. export interface IWebXRMotionControllerComponentChanges {
  56109. /**
  56110. * will be populated with previous and current values if axes changed
  56111. */
  56112. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  56113. /**
  56114. * will be populated with previous and current values if pressed changed
  56115. */
  56116. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56117. /**
  56118. * will be populated with previous and current values if touched changed
  56119. */
  56120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56121. /**
  56122. * will be populated with previous and current values if value changed
  56123. */
  56124. value?: IWebXRMotionControllerComponentChangesValues<number>;
  56125. }
  56126. /**
  56127. * This class represents a single component (for example button or thumbstick) of a motion controller
  56128. */
  56129. export class WebXRControllerComponent implements IDisposable {
  56130. /**
  56131. * the id of this component
  56132. */
  56133. id: string;
  56134. /**
  56135. * the type of the component
  56136. */
  56137. type: MotionControllerComponentType;
  56138. private _buttonIndex;
  56139. private _axesIndices;
  56140. private _axes;
  56141. private _changes;
  56142. private _currentValue;
  56143. private _hasChanges;
  56144. private _pressed;
  56145. private _touched;
  56146. /**
  56147. * button component type
  56148. */
  56149. static BUTTON_TYPE: MotionControllerComponentType;
  56150. /**
  56151. * squeeze component type
  56152. */
  56153. static SQUEEZE_TYPE: MotionControllerComponentType;
  56154. /**
  56155. * Thumbstick component type
  56156. */
  56157. static THUMBSTICK_TYPE: MotionControllerComponentType;
  56158. /**
  56159. * Touchpad component type
  56160. */
  56161. static TOUCHPAD_TYPE: MotionControllerComponentType;
  56162. /**
  56163. * trigger component type
  56164. */
  56165. static TRIGGER_TYPE: MotionControllerComponentType;
  56166. /**
  56167. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  56168. * the axes data changes
  56169. */
  56170. onAxisValueChangedObservable: Observable<{
  56171. x: number;
  56172. y: number;
  56173. }>;
  56174. /**
  56175. * Observers registered here will be triggered when the state of a button changes
  56176. * State change is either pressed / touched / value
  56177. */
  56178. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  56179. /**
  56180. * Creates a new component for a motion controller.
  56181. * It is created by the motion controller itself
  56182. *
  56183. * @param id the id of this component
  56184. * @param type the type of the component
  56185. * @param _buttonIndex index in the buttons array of the gamepad
  56186. * @param _axesIndices indices of the values in the axes array of the gamepad
  56187. */
  56188. constructor(
  56189. /**
  56190. * the id of this component
  56191. */
  56192. id: string,
  56193. /**
  56194. * the type of the component
  56195. */
  56196. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  56197. /**
  56198. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  56199. */
  56200. get axes(): IWebXRMotionControllerAxesValue;
  56201. /**
  56202. * Get the changes. Elements will be populated only if they changed with their previous and current value
  56203. */
  56204. get changes(): IWebXRMotionControllerComponentChanges;
  56205. /**
  56206. * Return whether or not the component changed the last frame
  56207. */
  56208. get hasChanges(): boolean;
  56209. /**
  56210. * is the button currently pressed
  56211. */
  56212. get pressed(): boolean;
  56213. /**
  56214. * is the button currently touched
  56215. */
  56216. get touched(): boolean;
  56217. /**
  56218. * Get the current value of this component
  56219. */
  56220. get value(): number;
  56221. /**
  56222. * Dispose this component
  56223. */
  56224. dispose(): void;
  56225. /**
  56226. * Are there axes correlating to this component
  56227. * @return true is axes data is available
  56228. */
  56229. isAxes(): boolean;
  56230. /**
  56231. * Is this component a button (hence - pressable)
  56232. * @returns true if can be pressed
  56233. */
  56234. isButton(): boolean;
  56235. /**
  56236. * update this component using the gamepad object it is in. Called on every frame
  56237. * @param nativeController the native gamepad controller object
  56238. */
  56239. update(nativeController: IMinimalMotionControllerObject): void;
  56240. }
  56241. }
  56242. declare module "babylonjs/Loading/sceneLoader" {
  56243. import { Observable } from "babylonjs/Misc/observable";
  56244. import { Nullable } from "babylonjs/types";
  56245. import { Scene } from "babylonjs/scene";
  56246. import { Engine } from "babylonjs/Engines/engine";
  56247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56248. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56249. import { AssetContainer } from "babylonjs/assetContainer";
  56250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56251. import { Skeleton } from "babylonjs/Bones/skeleton";
  56252. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  56253. import { WebRequest } from "babylonjs/Misc/webRequest";
  56254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56255. import { Geometry } from "babylonjs/Meshes/geometry";
  56256. import { Light } from "babylonjs/Lights/light";
  56257. /**
  56258. * Type used for the success callback of ImportMesh
  56259. */
  56260. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  56261. /**
  56262. * Interface used for the result of ImportMeshAsync
  56263. */
  56264. export interface ISceneLoaderAsyncResult {
  56265. /**
  56266. * The array of loaded meshes
  56267. */
  56268. readonly meshes: AbstractMesh[];
  56269. /**
  56270. * The array of loaded particle systems
  56271. */
  56272. readonly particleSystems: IParticleSystem[];
  56273. /**
  56274. * The array of loaded skeletons
  56275. */
  56276. readonly skeletons: Skeleton[];
  56277. /**
  56278. * The array of loaded animation groups
  56279. */
  56280. readonly animationGroups: AnimationGroup[];
  56281. /**
  56282. * The array of loaded transform nodes
  56283. */
  56284. readonly transformNodes: TransformNode[];
  56285. /**
  56286. * The array of loaded geometries
  56287. */
  56288. readonly geometries: Geometry[];
  56289. /**
  56290. * The array of loaded lights
  56291. */
  56292. readonly lights: Light[];
  56293. }
  56294. /**
  56295. * Interface used to represent data loading progression
  56296. */
  56297. export interface ISceneLoaderProgressEvent {
  56298. /**
  56299. * Defines if data length to load can be evaluated
  56300. */
  56301. readonly lengthComputable: boolean;
  56302. /**
  56303. * Defines the loaded data length
  56304. */
  56305. readonly loaded: number;
  56306. /**
  56307. * Defines the data length to load
  56308. */
  56309. readonly total: number;
  56310. }
  56311. /**
  56312. * Interface used by SceneLoader plugins to define supported file extensions
  56313. */
  56314. export interface ISceneLoaderPluginExtensions {
  56315. /**
  56316. * Defines the list of supported extensions
  56317. */
  56318. [extension: string]: {
  56319. isBinary: boolean;
  56320. };
  56321. }
  56322. /**
  56323. * Interface used by SceneLoader plugin factory
  56324. */
  56325. export interface ISceneLoaderPluginFactory {
  56326. /**
  56327. * Defines the name of the factory
  56328. */
  56329. name: string;
  56330. /**
  56331. * Function called to create a new plugin
  56332. * @return the new plugin
  56333. */
  56334. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56335. /**
  56336. * The callback that returns true if the data can be directly loaded.
  56337. * @param data string containing the file data
  56338. * @returns if the data can be loaded directly
  56339. */
  56340. canDirectLoad?(data: string): boolean;
  56341. }
  56342. /**
  56343. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  56344. */
  56345. export interface ISceneLoaderPluginBase {
  56346. /**
  56347. * The friendly name of this plugin.
  56348. */
  56349. name: string;
  56350. /**
  56351. * The file extensions supported by this plugin.
  56352. */
  56353. extensions: string | ISceneLoaderPluginExtensions;
  56354. /**
  56355. * The callback called when loading from a url.
  56356. * @param scene scene loading this url
  56357. * @param url url to load
  56358. * @param onSuccess callback called when the file successfully loads
  56359. * @param onProgress callback called while file is loading (if the server supports this mode)
  56360. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  56361. * @param onError callback called when the file fails to load
  56362. * @returns a file request object
  56363. */
  56364. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56365. /**
  56366. * The callback called when loading from a file object.
  56367. * @param scene scene loading this file
  56368. * @param file defines the file to load
  56369. * @param onSuccess defines the callback to call when data is loaded
  56370. * @param onProgress defines the callback to call during loading process
  56371. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  56372. * @param onError defines the callback to call when an error occurs
  56373. * @returns a file request object
  56374. */
  56375. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56376. /**
  56377. * The callback that returns true if the data can be directly loaded.
  56378. * @param data string containing the file data
  56379. * @returns if the data can be loaded directly
  56380. */
  56381. canDirectLoad?(data: string): boolean;
  56382. /**
  56383. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  56384. * @param scene scene loading this data
  56385. * @param data string containing the data
  56386. * @returns data to pass to the plugin
  56387. */
  56388. directLoad?(scene: Scene, data: string): any;
  56389. /**
  56390. * The callback that allows custom handling of the root url based on the response url.
  56391. * @param rootUrl the original root url
  56392. * @param responseURL the response url if available
  56393. * @returns the new root url
  56394. */
  56395. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  56396. }
  56397. /**
  56398. * Interface used to define a SceneLoader plugin
  56399. */
  56400. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  56401. /**
  56402. * Import meshes into a scene.
  56403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56404. * @param scene The scene to import into
  56405. * @param data The data to import
  56406. * @param rootUrl The root url for scene and resources
  56407. * @param meshes The meshes array to import into
  56408. * @param particleSystems The particle systems array to import into
  56409. * @param skeletons The skeletons array to import into
  56410. * @param onError The callback when import fails
  56411. * @returns True if successful or false otherwise
  56412. */
  56413. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  56414. /**
  56415. * Load into a scene.
  56416. * @param scene The scene to load into
  56417. * @param data The data to import
  56418. * @param rootUrl The root url for scene and resources
  56419. * @param onError The callback when import fails
  56420. * @returns True if successful or false otherwise
  56421. */
  56422. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  56423. /**
  56424. * Load into an asset container.
  56425. * @param scene The scene to load into
  56426. * @param data The data to import
  56427. * @param rootUrl The root url for scene and resources
  56428. * @param onError The callback when import fails
  56429. * @returns The loaded asset container
  56430. */
  56431. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  56432. }
  56433. /**
  56434. * Interface used to define an async SceneLoader plugin
  56435. */
  56436. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  56437. /**
  56438. * Import meshes into a scene.
  56439. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56440. * @param scene The scene to import into
  56441. * @param data The data to import
  56442. * @param rootUrl The root url for scene and resources
  56443. * @param onProgress The callback when the load progresses
  56444. * @param fileName Defines the name of the file to load
  56445. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  56446. */
  56447. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  56448. /**
  56449. * Load into a scene.
  56450. * @param scene The scene to load into
  56451. * @param data The data to import
  56452. * @param rootUrl The root url for scene and resources
  56453. * @param onProgress The callback when the load progresses
  56454. * @param fileName Defines the name of the file to load
  56455. * @returns Nothing
  56456. */
  56457. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56458. /**
  56459. * Load into an asset container.
  56460. * @param scene The scene to load into
  56461. * @param data The data to import
  56462. * @param rootUrl The root url for scene and resources
  56463. * @param onProgress The callback when the load progresses
  56464. * @param fileName Defines the name of the file to load
  56465. * @returns The loaded asset container
  56466. */
  56467. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56468. }
  56469. /**
  56470. * Mode that determines how to handle old animation groups before loading new ones.
  56471. */
  56472. export enum SceneLoaderAnimationGroupLoadingMode {
  56473. /**
  56474. * Reset all old animations to initial state then dispose them.
  56475. */
  56476. Clean = 0,
  56477. /**
  56478. * Stop all old animations.
  56479. */
  56480. Stop = 1,
  56481. /**
  56482. * Restart old animations from first frame.
  56483. */
  56484. Sync = 2,
  56485. /**
  56486. * Old animations remains untouched.
  56487. */
  56488. NoSync = 3
  56489. }
  56490. /**
  56491. * Defines a plugin registered by the SceneLoader
  56492. */
  56493. interface IRegisteredPlugin {
  56494. /**
  56495. * Defines the plugin to use
  56496. */
  56497. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56498. /**
  56499. * Defines if the plugin supports binary data
  56500. */
  56501. isBinary: boolean;
  56502. }
  56503. /**
  56504. * Class used to load scene from various file formats using registered plugins
  56505. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  56506. */
  56507. export class SceneLoader {
  56508. /**
  56509. * No logging while loading
  56510. */
  56511. static readonly NO_LOGGING: number;
  56512. /**
  56513. * Minimal logging while loading
  56514. */
  56515. static readonly MINIMAL_LOGGING: number;
  56516. /**
  56517. * Summary logging while loading
  56518. */
  56519. static readonly SUMMARY_LOGGING: number;
  56520. /**
  56521. * Detailled logging while loading
  56522. */
  56523. static readonly DETAILED_LOGGING: number;
  56524. /**
  56525. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  56526. */
  56527. static get ForceFullSceneLoadingForIncremental(): boolean;
  56528. static set ForceFullSceneLoadingForIncremental(value: boolean);
  56529. /**
  56530. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  56531. */
  56532. static get ShowLoadingScreen(): boolean;
  56533. static set ShowLoadingScreen(value: boolean);
  56534. /**
  56535. * Defines the current logging level (while loading the scene)
  56536. * @ignorenaming
  56537. */
  56538. static get loggingLevel(): number;
  56539. static set loggingLevel(value: number);
  56540. /**
  56541. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  56542. */
  56543. static get CleanBoneMatrixWeights(): boolean;
  56544. static set CleanBoneMatrixWeights(value: boolean);
  56545. /**
  56546. * Event raised when a plugin is used to load a scene
  56547. */
  56548. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56549. private static _registeredPlugins;
  56550. private static _showingLoadingScreen;
  56551. /**
  56552. * Gets the default plugin (used to load Babylon files)
  56553. * @returns the .babylon plugin
  56554. */
  56555. static GetDefaultPlugin(): IRegisteredPlugin;
  56556. private static _GetPluginForExtension;
  56557. private static _GetPluginForDirectLoad;
  56558. private static _GetPluginForFilename;
  56559. private static _GetDirectLoad;
  56560. private static _LoadData;
  56561. private static _GetFileInfo;
  56562. /**
  56563. * Gets a plugin that can load the given extension
  56564. * @param extension defines the extension to load
  56565. * @returns a plugin or null if none works
  56566. */
  56567. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56568. /**
  56569. * Gets a boolean indicating that the given extension can be loaded
  56570. * @param extension defines the extension to load
  56571. * @returns true if the extension is supported
  56572. */
  56573. static IsPluginForExtensionAvailable(extension: string): boolean;
  56574. /**
  56575. * Adds a new plugin to the list of registered plugins
  56576. * @param plugin defines the plugin to add
  56577. */
  56578. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  56579. /**
  56580. * Import meshes into a scene
  56581. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56582. * @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)
  56583. * @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)
  56584. * @param scene the instance of BABYLON.Scene to append to
  56585. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  56586. * @param onProgress a callback with a progress event for each file being loaded
  56587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56588. * @param pluginExtension the extension used to determine the plugin
  56589. * @returns The loaded plugin
  56590. */
  56591. 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>;
  56592. /**
  56593. * Import meshes into a scene
  56594. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56595. * @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)
  56596. * @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)
  56597. * @param scene the instance of BABYLON.Scene to append to
  56598. * @param onProgress a callback with a progress event for each file being loaded
  56599. * @param pluginExtension the extension used to determine the plugin
  56600. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  56601. */
  56602. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  56603. /**
  56604. * Load a scene
  56605. * @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)
  56606. * @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)
  56607. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56608. * @param onSuccess a callback with the scene when import succeeds
  56609. * @param onProgress a callback with a progress event for each file being loaded
  56610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56611. * @param pluginExtension the extension used to determine the plugin
  56612. * @returns The loaded plugin
  56613. */
  56614. 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>;
  56615. /**
  56616. * Load a scene
  56617. * @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)
  56618. * @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)
  56619. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56620. * @param onProgress a callback with a progress event for each file being loaded
  56621. * @param pluginExtension the extension used to determine the plugin
  56622. * @returns The loaded scene
  56623. */
  56624. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56625. /**
  56626. * Append a scene
  56627. * @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)
  56628. * @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)
  56629. * @param scene is the instance of BABYLON.Scene to append to
  56630. * @param onSuccess a callback with the scene when import succeeds
  56631. * @param onProgress a callback with a progress event for each file being loaded
  56632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56633. * @param pluginExtension the extension used to determine the plugin
  56634. * @returns The loaded plugin
  56635. */
  56636. 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>;
  56637. /**
  56638. * Append a scene
  56639. * @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)
  56640. * @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)
  56641. * @param scene is the instance of BABYLON.Scene to append to
  56642. * @param onProgress a callback with a progress event for each file being loaded
  56643. * @param pluginExtension the extension used to determine the plugin
  56644. * @returns The given scene
  56645. */
  56646. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56647. /**
  56648. * Load a scene into an asset container
  56649. * @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)
  56650. * @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)
  56651. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56652. * @param onSuccess a callback with the scene when import succeeds
  56653. * @param onProgress a callback with a progress event for each file being loaded
  56654. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56655. * @param pluginExtension the extension used to determine the plugin
  56656. * @returns The loaded plugin
  56657. */
  56658. 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>;
  56659. /**
  56660. * Load a scene into an asset container
  56661. * @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)
  56662. * @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)
  56663. * @param scene is the instance of Scene to append to
  56664. * @param onProgress a callback with a progress event for each file being loaded
  56665. * @param pluginExtension the extension used to determine the plugin
  56666. * @returns The loaded asset container
  56667. */
  56668. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  56669. /**
  56670. * Import animations from a file into a scene
  56671. * @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)
  56672. * @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)
  56673. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56674. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56675. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56676. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56677. * @param onSuccess a callback with the scene when import succeeds
  56678. * @param onProgress a callback with a progress event for each file being loaded
  56679. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56680. * @param pluginExtension the extension used to determine the plugin
  56681. */
  56682. 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;
  56683. /**
  56684. * Import animations from a file into a scene
  56685. * @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)
  56686. * @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)
  56687. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56688. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56689. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56690. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56691. * @param onSuccess a callback with the scene when import succeeds
  56692. * @param onProgress a callback with a progress event for each file being loaded
  56693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56694. * @param pluginExtension the extension used to determine the plugin
  56695. * @returns the updated scene with imported animations
  56696. */
  56697. 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>;
  56698. }
  56699. }
  56700. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  56701. import { IDisposable, Scene } from "babylonjs/scene";
  56702. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  56703. import { Observable } from "babylonjs/Misc/observable";
  56704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56705. import { Nullable } from "babylonjs/types";
  56706. /**
  56707. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  56708. */
  56709. export type MotionControllerHandedness = "none" | "left" | "right";
  56710. /**
  56711. * The type of components available in motion controllers.
  56712. * This is not the name of the component.
  56713. */
  56714. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  56715. /**
  56716. * The state of a controller component
  56717. */
  56718. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  56719. /**
  56720. * The schema of motion controller layout.
  56721. * No object will be initialized using this interface
  56722. * This is used just to define the profile.
  56723. */
  56724. export interface IMotionControllerLayout {
  56725. /**
  56726. * Path to load the assets. Usually relative to the base path
  56727. */
  56728. assetPath: string;
  56729. /**
  56730. * Available components (unsorted)
  56731. */
  56732. components: {
  56733. /**
  56734. * A map of component Ids
  56735. */
  56736. [componentId: string]: {
  56737. /**
  56738. * The type of input the component outputs
  56739. */
  56740. type: MotionControllerComponentType;
  56741. /**
  56742. * The indices of this component in the gamepad object
  56743. */
  56744. gamepadIndices: {
  56745. /**
  56746. * Index of button
  56747. */
  56748. button?: number;
  56749. /**
  56750. * If available, index of x-axis
  56751. */
  56752. xAxis?: number;
  56753. /**
  56754. * If available, index of y-axis
  56755. */
  56756. yAxis?: number;
  56757. };
  56758. /**
  56759. * The mesh's root node name
  56760. */
  56761. rootNodeName: string;
  56762. /**
  56763. * Animation definitions for this model
  56764. */
  56765. visualResponses: {
  56766. [stateKey: string]: {
  56767. /**
  56768. * What property will be animated
  56769. */
  56770. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  56771. /**
  56772. * What states influence this visual response
  56773. */
  56774. states: MotionControllerComponentStateType[];
  56775. /**
  56776. * Type of animation - movement or visibility
  56777. */
  56778. valueNodeProperty: "transform" | "visibility";
  56779. /**
  56780. * Base node name to move. Its position will be calculated according to the min and max nodes
  56781. */
  56782. valueNodeName?: string;
  56783. /**
  56784. * Minimum movement node
  56785. */
  56786. minNodeName?: string;
  56787. /**
  56788. * Max movement node
  56789. */
  56790. maxNodeName?: string;
  56791. };
  56792. };
  56793. /**
  56794. * If touch enabled, what is the name of node to display user feedback
  56795. */
  56796. touchPointNodeName?: string;
  56797. };
  56798. };
  56799. /**
  56800. * Is it xr standard mapping or not
  56801. */
  56802. gamepadMapping: "" | "xr-standard";
  56803. /**
  56804. * Base root node of this entire model
  56805. */
  56806. rootNodeName: string;
  56807. /**
  56808. * Defines the main button component id
  56809. */
  56810. selectComponentId: string;
  56811. }
  56812. /**
  56813. * A definition for the layout map in the input profile
  56814. */
  56815. export interface IMotionControllerLayoutMap {
  56816. /**
  56817. * Layouts with handedness type as a key
  56818. */
  56819. [handedness: string]: IMotionControllerLayout;
  56820. }
  56821. /**
  56822. * The XR Input profile schema
  56823. * Profiles can be found here:
  56824. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  56825. */
  56826. export interface IMotionControllerProfile {
  56827. /**
  56828. * fallback profiles for this profileId
  56829. */
  56830. fallbackProfileIds: string[];
  56831. /**
  56832. * The layout map, with handedness as key
  56833. */
  56834. layouts: IMotionControllerLayoutMap;
  56835. /**
  56836. * The id of this profile
  56837. * correlates to the profile(s) in the xrInput.profiles array
  56838. */
  56839. profileId: string;
  56840. }
  56841. /**
  56842. * A helper-interface for the 3 meshes needed for controller button animation
  56843. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  56844. */
  56845. export interface IMotionControllerButtonMeshMap {
  56846. /**
  56847. * the mesh that defines the pressed value mesh position.
  56848. * This is used to find the max-position of this button
  56849. */
  56850. pressedMesh: AbstractMesh;
  56851. /**
  56852. * the mesh that defines the unpressed value mesh position.
  56853. * This is used to find the min (or initial) position of this button
  56854. */
  56855. unpressedMesh: AbstractMesh;
  56856. /**
  56857. * The mesh that will be changed when value changes
  56858. */
  56859. valueMesh: AbstractMesh;
  56860. }
  56861. /**
  56862. * A helper-interface for the 3 meshes needed for controller axis animation.
  56863. * This will be expanded when touchpad animations are fully supported
  56864. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  56865. */
  56866. export interface IMotionControllerMeshMap {
  56867. /**
  56868. * the mesh that defines the maximum value mesh position.
  56869. */
  56870. maxMesh?: AbstractMesh;
  56871. /**
  56872. * the mesh that defines the minimum value mesh position.
  56873. */
  56874. minMesh?: AbstractMesh;
  56875. /**
  56876. * The mesh that will be changed when axis value changes
  56877. */
  56878. valueMesh?: AbstractMesh;
  56879. }
  56880. /**
  56881. * The elements needed for change-detection of the gamepad objects in motion controllers
  56882. */
  56883. export interface IMinimalMotionControllerObject {
  56884. /**
  56885. * Available axes of this controller
  56886. */
  56887. axes: number[];
  56888. /**
  56889. * An array of available buttons
  56890. */
  56891. buttons: Array<{
  56892. /**
  56893. * Value of the button/trigger
  56894. */
  56895. value: number;
  56896. /**
  56897. * If the button/trigger is currently touched
  56898. */
  56899. touched: boolean;
  56900. /**
  56901. * If the button/trigger is currently pressed
  56902. */
  56903. pressed: boolean;
  56904. }>;
  56905. /**
  56906. * EXPERIMENTAL haptic support.
  56907. */
  56908. hapticActuators?: Array<{
  56909. pulse: (value: number, duration: number) => Promise<boolean>;
  56910. }>;
  56911. }
  56912. /**
  56913. * An Abstract Motion controller
  56914. * This class receives an xrInput and a profile layout and uses those to initialize the components
  56915. * Each component has an observable to check for changes in value and state
  56916. */
  56917. export abstract class WebXRAbstractMotionController implements IDisposable {
  56918. protected scene: Scene;
  56919. protected layout: IMotionControllerLayout;
  56920. /**
  56921. * The gamepad object correlating to this controller
  56922. */
  56923. gamepadObject: IMinimalMotionControllerObject;
  56924. /**
  56925. * handedness (left/right/none) of this controller
  56926. */
  56927. handedness: MotionControllerHandedness;
  56928. private _initComponent;
  56929. private _modelReady;
  56930. /**
  56931. * A map of components (WebXRControllerComponent) in this motion controller
  56932. * Components have a ComponentType and can also have both button and axis definitions
  56933. */
  56934. readonly components: {
  56935. [id: string]: WebXRControllerComponent;
  56936. };
  56937. /**
  56938. * Disable the model's animation. Can be set at any time.
  56939. */
  56940. disableAnimation: boolean;
  56941. /**
  56942. * Observers registered here will be triggered when the model of this controller is done loading
  56943. */
  56944. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  56945. /**
  56946. * The profile id of this motion controller
  56947. */
  56948. abstract profileId: string;
  56949. /**
  56950. * The root mesh of the model. It is null if the model was not yet initialized
  56951. */
  56952. rootMesh: Nullable<AbstractMesh>;
  56953. /**
  56954. * constructs a new abstract motion controller
  56955. * @param scene the scene to which the model of the controller will be added
  56956. * @param layout The profile layout to load
  56957. * @param gamepadObject The gamepad object correlating to this controller
  56958. * @param handedness handedness (left/right/none) of this controller
  56959. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  56960. */
  56961. constructor(scene: Scene, layout: IMotionControllerLayout,
  56962. /**
  56963. * The gamepad object correlating to this controller
  56964. */
  56965. gamepadObject: IMinimalMotionControllerObject,
  56966. /**
  56967. * handedness (left/right/none) of this controller
  56968. */
  56969. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56970. /**
  56971. * Dispose this controller, the model mesh and all its components
  56972. */
  56973. dispose(): void;
  56974. /**
  56975. * Returns all components of specific type
  56976. * @param type the type to search for
  56977. * @return an array of components with this type
  56978. */
  56979. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56980. /**
  56981. * get a component based an its component id as defined in layout.components
  56982. * @param id the id of the component
  56983. * @returns the component correlates to the id or undefined if not found
  56984. */
  56985. getComponent(id: string): WebXRControllerComponent;
  56986. /**
  56987. * Get the list of components available in this motion controller
  56988. * @returns an array of strings correlating to available components
  56989. */
  56990. getComponentIds(): string[];
  56991. /**
  56992. * Get the first component of specific type
  56993. * @param type type of component to find
  56994. * @return a controller component or null if not found
  56995. */
  56996. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56997. /**
  56998. * Get the main (Select) component of this controller as defined in the layout
  56999. * @returns the main component of this controller
  57000. */
  57001. getMainComponent(): WebXRControllerComponent;
  57002. /**
  57003. * Loads the model correlating to this controller
  57004. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  57005. * @returns A promise fulfilled with the result of the model loading
  57006. */
  57007. loadModel(): Promise<boolean>;
  57008. /**
  57009. * Update this model using the current XRFrame
  57010. * @param xrFrame the current xr frame to use and update the model
  57011. */
  57012. updateFromXRFrame(xrFrame: XRFrame): void;
  57013. /**
  57014. * Backwards compatibility due to a deeply-integrated typo
  57015. */
  57016. get handness(): XREye;
  57017. /**
  57018. * Pulse (vibrate) this controller
  57019. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  57020. * Consecutive calls to this function will cancel the last pulse call
  57021. *
  57022. * @param value the strength of the pulse in 0.0...1.0 range
  57023. * @param duration Duration of the pulse in milliseconds
  57024. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  57025. * @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
  57026. */
  57027. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  57028. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57029. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57030. /**
  57031. * Moves the axis on the controller mesh based on its current state
  57032. * @param axis the index of the axis
  57033. * @param axisValue the value of the axis which determines the meshes new position
  57034. * @hidden
  57035. */
  57036. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  57037. /**
  57038. * Update the model itself with the current frame data
  57039. * @param xrFrame the frame to use for updating the model mesh
  57040. */
  57041. protected updateModel(xrFrame: XRFrame): void;
  57042. /**
  57043. * Get the filename and path for this controller's model
  57044. * @returns a map of filename and path
  57045. */
  57046. protected abstract _getFilenameAndPath(): {
  57047. filename: string;
  57048. path: string;
  57049. };
  57050. /**
  57051. * This function is called before the mesh is loaded. It checks for loading constraints.
  57052. * For example, this function can check if the GLB loader is available
  57053. * If this function returns false, the generic controller will be loaded instead
  57054. * @returns Is the client ready to load the mesh
  57055. */
  57056. protected abstract _getModelLoadingConstraints(): boolean;
  57057. /**
  57058. * This function will be called after the model was successfully loaded and can be used
  57059. * for mesh transformations before it is available for the user
  57060. * @param meshes the loaded meshes
  57061. */
  57062. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  57063. /**
  57064. * Set the root mesh for this controller. Important for the WebXR controller class
  57065. * @param meshes the loaded meshes
  57066. */
  57067. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  57068. /**
  57069. * A function executed each frame that updates the mesh (if needed)
  57070. * @param xrFrame the current xrFrame
  57071. */
  57072. protected abstract _updateModel(xrFrame: XRFrame): void;
  57073. private _getGenericFilenameAndPath;
  57074. private _getGenericParentMesh;
  57075. }
  57076. }
  57077. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  57078. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57080. import { Scene } from "babylonjs/scene";
  57081. /**
  57082. * A generic trigger-only motion controller for WebXR
  57083. */
  57084. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  57085. /**
  57086. * Static version of the profile id of this controller
  57087. */
  57088. static ProfileId: string;
  57089. profileId: string;
  57090. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  57091. protected _getFilenameAndPath(): {
  57092. filename: string;
  57093. path: string;
  57094. };
  57095. protected _getModelLoadingConstraints(): boolean;
  57096. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  57097. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57098. protected _updateModel(): void;
  57099. }
  57100. }
  57101. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  57102. import { Vector4 } from "babylonjs/Maths/math.vector";
  57103. import { Mesh } from "babylonjs/Meshes/mesh";
  57104. import { Scene } from "babylonjs/scene";
  57105. import { Nullable } from "babylonjs/types";
  57106. /**
  57107. * Class containing static functions to help procedurally build meshes
  57108. */
  57109. export class SphereBuilder {
  57110. /**
  57111. * Creates a sphere mesh
  57112. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57113. * * 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`)
  57114. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57115. * * 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
  57116. * * 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)
  57117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57120. * @param name defines the name of the mesh
  57121. * @param options defines the options used to create the mesh
  57122. * @param scene defines the hosting scene
  57123. * @returns the sphere mesh
  57124. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57125. */
  57126. static CreateSphere(name: string, options: {
  57127. segments?: number;
  57128. diameter?: number;
  57129. diameterX?: number;
  57130. diameterY?: number;
  57131. diameterZ?: number;
  57132. arc?: number;
  57133. slice?: number;
  57134. sideOrientation?: number;
  57135. frontUVs?: Vector4;
  57136. backUVs?: Vector4;
  57137. updatable?: boolean;
  57138. }, scene?: Nullable<Scene>): Mesh;
  57139. }
  57140. }
  57141. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  57142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57143. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57144. import { Scene } from "babylonjs/scene";
  57145. /**
  57146. * A profiled motion controller has its profile loaded from an online repository.
  57147. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  57148. */
  57149. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  57150. private _repositoryUrl;
  57151. private _buttonMeshMapping;
  57152. private _touchDots;
  57153. /**
  57154. * The profile ID of this controller. Will be populated when the controller initializes.
  57155. */
  57156. profileId: string;
  57157. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  57158. dispose(): void;
  57159. protected _getFilenameAndPath(): {
  57160. filename: string;
  57161. path: string;
  57162. };
  57163. protected _getModelLoadingConstraints(): boolean;
  57164. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  57165. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57166. protected _updateModel(_xrFrame: XRFrame): void;
  57167. }
  57168. }
  57169. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  57170. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57171. import { Scene } from "babylonjs/scene";
  57172. /**
  57173. * A construction function type to create a new controller based on an xrInput object
  57174. */
  57175. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  57176. /**
  57177. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  57178. *
  57179. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  57180. * it should be replaced with auto-loaded controllers.
  57181. *
  57182. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  57183. */
  57184. export class WebXRMotionControllerManager {
  57185. private static _AvailableControllers;
  57186. private static _Fallbacks;
  57187. private static _ProfileLoadingPromises;
  57188. private static _ProfilesList;
  57189. /**
  57190. * The base URL of the online controller repository. Can be changed at any time.
  57191. */
  57192. static BaseRepositoryUrl: string;
  57193. /**
  57194. * Which repository gets priority - local or online
  57195. */
  57196. static PrioritizeOnlineRepository: boolean;
  57197. /**
  57198. * Use the online repository, or use only locally-defined controllers
  57199. */
  57200. static UseOnlineRepository: boolean;
  57201. /**
  57202. * Clear the cache used for profile loading and reload when requested again
  57203. */
  57204. static ClearProfilesCache(): void;
  57205. /**
  57206. * Register the default fallbacks.
  57207. * This function is called automatically when this file is imported.
  57208. */
  57209. static DefaultFallbacks(): void;
  57210. /**
  57211. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  57212. * @param profileId the profile to which a fallback needs to be found
  57213. * @return an array with corresponding fallback profiles
  57214. */
  57215. static FindFallbackWithProfileId(profileId: string): string[];
  57216. /**
  57217. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  57218. * The order of search:
  57219. *
  57220. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  57221. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  57222. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  57223. * 4) return the generic trigger controller if none were found
  57224. *
  57225. * @param xrInput the xrInput to which a new controller is initialized
  57226. * @param scene the scene to which the model will be added
  57227. * @param forceProfile force a certain profile for this controller
  57228. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  57229. */
  57230. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  57231. /**
  57232. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  57233. *
  57234. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  57235. *
  57236. * @param type the profile type to register
  57237. * @param constructFunction the function to be called when loading this profile
  57238. */
  57239. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  57240. /**
  57241. * Register a fallback to a specific profile.
  57242. * @param profileId the profileId that will receive the fallbacks
  57243. * @param fallbacks A list of fallback profiles
  57244. */
  57245. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  57246. /**
  57247. * Will update the list of profiles available in the repository
  57248. * @return a promise that resolves to a map of profiles available online
  57249. */
  57250. static UpdateProfilesList(): Promise<{
  57251. [profile: string]: string;
  57252. }>;
  57253. private static _LoadProfileFromRepository;
  57254. private static _LoadProfilesFromAvailableControllers;
  57255. }
  57256. }
  57257. declare module "babylonjs/XR/webXRInputSource" {
  57258. import { Observable } from "babylonjs/Misc/observable";
  57259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57260. import { Ray } from "babylonjs/Culling/ray";
  57261. import { Scene } from "babylonjs/scene";
  57262. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57263. /**
  57264. * Configuration options for the WebXR controller creation
  57265. */
  57266. export interface IWebXRControllerOptions {
  57267. /**
  57268. * Should the controller mesh be animated when a user interacts with it
  57269. * The pressed buttons / thumbstick and touchpad animations will be disabled
  57270. */
  57271. disableMotionControllerAnimation?: boolean;
  57272. /**
  57273. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  57274. */
  57275. doNotLoadControllerMesh?: boolean;
  57276. /**
  57277. * Force a specific controller type for this controller.
  57278. * This can be used when creating your own profile or when testing different controllers
  57279. */
  57280. forceControllerProfile?: string;
  57281. /**
  57282. * Defines a rendering group ID for meshes that will be loaded.
  57283. * This is for the default controllers only.
  57284. */
  57285. renderingGroupId?: number;
  57286. }
  57287. /**
  57288. * Represents an XR controller
  57289. */
  57290. export class WebXRInputSource {
  57291. private _scene;
  57292. /** The underlying input source for the controller */
  57293. inputSource: XRInputSource;
  57294. private _options;
  57295. private _tmpVector;
  57296. private _uniqueId;
  57297. private _disposed;
  57298. /**
  57299. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  57300. */
  57301. grip?: AbstractMesh;
  57302. /**
  57303. * If available, this is the gamepad object related to this controller.
  57304. * Using this object it is possible to get click events and trackpad changes of the
  57305. * webxr controller that is currently being used.
  57306. */
  57307. motionController?: WebXRAbstractMotionController;
  57308. /**
  57309. * Event that fires when the controller is removed/disposed.
  57310. * The object provided as event data is this controller, after associated assets were disposed.
  57311. * uniqueId is still available.
  57312. */
  57313. onDisposeObservable: Observable<WebXRInputSource>;
  57314. /**
  57315. * Will be triggered when the mesh associated with the motion controller is done loading.
  57316. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  57317. * A shortened version of controller -> motion controller -> on mesh loaded.
  57318. */
  57319. onMeshLoadedObservable: Observable<AbstractMesh>;
  57320. /**
  57321. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  57322. */
  57323. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  57324. /**
  57325. * Pointer which can be used to select objects or attach a visible laser to
  57326. */
  57327. pointer: AbstractMesh;
  57328. /**
  57329. * Creates the input source object
  57330. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  57331. * @param _scene the scene which the controller should be associated to
  57332. * @param inputSource the underlying input source for the controller
  57333. * @param _options options for this controller creation
  57334. */
  57335. constructor(_scene: Scene,
  57336. /** The underlying input source for the controller */
  57337. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  57338. /**
  57339. * Get this controllers unique id
  57340. */
  57341. get uniqueId(): string;
  57342. /**
  57343. * Disposes of the object
  57344. */
  57345. dispose(): void;
  57346. /**
  57347. * Gets a world space ray coming from the pointer or grip
  57348. * @param result the resulting ray
  57349. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  57350. */
  57351. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  57352. /**
  57353. * Updates the controller pose based on the given XRFrame
  57354. * @param xrFrame xr frame to update the pose with
  57355. * @param referenceSpace reference space to use
  57356. */
  57357. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  57358. }
  57359. }
  57360. declare module "babylonjs/XR/webXRInput" {
  57361. import { Observable } from "babylonjs/Misc/observable";
  57362. import { IDisposable } from "babylonjs/scene";
  57363. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  57364. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57365. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57366. /**
  57367. * The schema for initialization options of the XR Input class
  57368. */
  57369. export interface IWebXRInputOptions {
  57370. /**
  57371. * If set to true no model will be automatically loaded
  57372. */
  57373. doNotLoadControllerMeshes?: boolean;
  57374. /**
  57375. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  57376. * If not found, the xr input profile data will be used.
  57377. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  57378. */
  57379. forceInputProfile?: string;
  57380. /**
  57381. * Do not send a request to the controller repository to load the profile.
  57382. *
  57383. * Instead, use the controllers available in babylon itself.
  57384. */
  57385. disableOnlineControllerRepository?: boolean;
  57386. /**
  57387. * A custom URL for the controllers repository
  57388. */
  57389. customControllersRepositoryURL?: string;
  57390. /**
  57391. * Should the controller model's components not move according to the user input
  57392. */
  57393. disableControllerAnimation?: boolean;
  57394. /**
  57395. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  57396. */
  57397. controllerOptions?: IWebXRControllerOptions;
  57398. }
  57399. /**
  57400. * XR input used to track XR inputs such as controllers/rays
  57401. */
  57402. export class WebXRInput implements IDisposable {
  57403. /**
  57404. * the xr session manager for this session
  57405. */
  57406. xrSessionManager: WebXRSessionManager;
  57407. /**
  57408. * the WebXR camera for this session. Mainly used for teleportation
  57409. */
  57410. xrCamera: WebXRCamera;
  57411. private readonly options;
  57412. /**
  57413. * XR controllers being tracked
  57414. */
  57415. controllers: Array<WebXRInputSource>;
  57416. private _frameObserver;
  57417. private _sessionEndedObserver;
  57418. private _sessionInitObserver;
  57419. /**
  57420. * Event when a controller has been connected/added
  57421. */
  57422. onControllerAddedObservable: Observable<WebXRInputSource>;
  57423. /**
  57424. * Event when a controller has been removed/disconnected
  57425. */
  57426. onControllerRemovedObservable: Observable<WebXRInputSource>;
  57427. /**
  57428. * Initializes the WebXRInput
  57429. * @param xrSessionManager the xr session manager for this session
  57430. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  57431. * @param options = initialization options for this xr input
  57432. */
  57433. constructor(
  57434. /**
  57435. * the xr session manager for this session
  57436. */
  57437. xrSessionManager: WebXRSessionManager,
  57438. /**
  57439. * the WebXR camera for this session. Mainly used for teleportation
  57440. */
  57441. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  57442. private _onInputSourcesChange;
  57443. private _addAndRemoveControllers;
  57444. /**
  57445. * Disposes of the object
  57446. */
  57447. dispose(): void;
  57448. }
  57449. }
  57450. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  57451. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57452. import { Observable, EventState } from "babylonjs/Misc/observable";
  57453. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57454. /**
  57455. * This is the base class for all WebXR features.
  57456. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  57457. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  57458. */
  57459. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  57460. protected _xrSessionManager: WebXRSessionManager;
  57461. private _attached;
  57462. private _removeOnDetach;
  57463. /**
  57464. * Is this feature disposed?
  57465. */
  57466. isDisposed: boolean;
  57467. /**
  57468. * Should auto-attach be disabled?
  57469. */
  57470. disableAutoAttach: boolean;
  57471. /**
  57472. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  57473. */
  57474. xrNativeFeatureName: string;
  57475. /**
  57476. * Construct a new (abstract) WebXR feature
  57477. * @param _xrSessionManager the xr session manager for this feature
  57478. */
  57479. constructor(_xrSessionManager: WebXRSessionManager);
  57480. /**
  57481. * Is this feature attached
  57482. */
  57483. get attached(): boolean;
  57484. /**
  57485. * attach this feature
  57486. *
  57487. * @param force should attachment be forced (even when already attached)
  57488. * @returns true if successful, false is failed or already attached
  57489. */
  57490. attach(force?: boolean): boolean;
  57491. /**
  57492. * detach this feature.
  57493. *
  57494. * @returns true if successful, false if failed or already detached
  57495. */
  57496. detach(): boolean;
  57497. /**
  57498. * Dispose this feature and all of the resources attached
  57499. */
  57500. dispose(): void;
  57501. /**
  57502. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  57503. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  57504. *
  57505. * @returns whether or not the feature is compatible in this environment
  57506. */
  57507. isCompatible(): boolean;
  57508. /**
  57509. * This is used to register callbacks that will automatically be removed when detach is called.
  57510. * @param observable the observable to which the observer will be attached
  57511. * @param callback the callback to register
  57512. */
  57513. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  57514. /**
  57515. * Code in this function will be executed on each xrFrame received from the browser.
  57516. * This function will not execute after the feature is detached.
  57517. * @param _xrFrame the current frame
  57518. */
  57519. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  57520. }
  57521. }
  57522. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  57523. import { IDisposable, Scene } from "babylonjs/scene";
  57524. import { Nullable } from "babylonjs/types";
  57525. import { Observable } from "babylonjs/Misc/observable";
  57526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57527. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  57528. import { Camera } from "babylonjs/Cameras/camera";
  57529. /**
  57530. * Renders a layer on top of an existing scene
  57531. */
  57532. export class UtilityLayerRenderer implements IDisposable {
  57533. /** the original scene that will be rendered on top of */
  57534. originalScene: Scene;
  57535. private _pointerCaptures;
  57536. private _lastPointerEvents;
  57537. private static _DefaultUtilityLayer;
  57538. private static _DefaultKeepDepthUtilityLayer;
  57539. private _sharedGizmoLight;
  57540. private _renderCamera;
  57541. /**
  57542. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  57543. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  57544. * @returns the camera that is used when rendering the utility layer
  57545. */
  57546. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  57547. /**
  57548. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  57549. * @param cam the camera that should be used when rendering the utility layer
  57550. */
  57551. setRenderCamera(cam: Nullable<Camera>): void;
  57552. /**
  57553. * @hidden
  57554. * Light which used by gizmos to get light shading
  57555. */
  57556. _getSharedGizmoLight(): HemisphericLight;
  57557. /**
  57558. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  57559. */
  57560. pickUtilitySceneFirst: boolean;
  57561. /**
  57562. * 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)
  57563. */
  57564. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  57565. /**
  57566. * 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)
  57567. */
  57568. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  57569. /**
  57570. * The scene that is rendered on top of the original scene
  57571. */
  57572. utilityLayerScene: Scene;
  57573. /**
  57574. * If the utility layer should automatically be rendered on top of existing scene
  57575. */
  57576. shouldRender: boolean;
  57577. /**
  57578. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  57579. */
  57580. onlyCheckPointerDownEvents: boolean;
  57581. /**
  57582. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  57583. */
  57584. processAllEvents: boolean;
  57585. /**
  57586. * Observable raised when the pointer move from the utility layer scene to the main scene
  57587. */
  57588. onPointerOutObservable: Observable<number>;
  57589. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  57590. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  57591. private _afterRenderObserver;
  57592. private _sceneDisposeObserver;
  57593. private _originalPointerObserver;
  57594. /**
  57595. * Instantiates a UtilityLayerRenderer
  57596. * @param originalScene the original scene that will be rendered on top of
  57597. * @param handleEvents boolean indicating if the utility layer should handle events
  57598. */
  57599. constructor(
  57600. /** the original scene that will be rendered on top of */
  57601. originalScene: Scene, handleEvents?: boolean);
  57602. private _notifyObservers;
  57603. /**
  57604. * Renders the utility layers scene on top of the original scene
  57605. */
  57606. render(): void;
  57607. /**
  57608. * Disposes of the renderer
  57609. */
  57610. dispose(): void;
  57611. private _updateCamera;
  57612. }
  57613. }
  57614. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  57615. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57617. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57618. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  57619. import { Scene } from "babylonjs/scene";
  57620. import { Nullable } from "babylonjs/types";
  57621. import { Color3 } from "babylonjs/Maths/math.color";
  57622. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57623. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57624. /**
  57625. * Options interface for the pointer selection module
  57626. */
  57627. export interface IWebXRControllerPointerSelectionOptions {
  57628. /**
  57629. * if provided, this scene will be used to render meshes.
  57630. */
  57631. customUtilityLayerScene?: Scene;
  57632. /**
  57633. * 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)
  57634. * If not disabled, the last picked point will be used to execute a pointer up event
  57635. * If disabled, pointer up event will be triggered right after the pointer down event.
  57636. * Used in screen and gaze target ray mode only
  57637. */
  57638. disablePointerUpOnTouchOut: boolean;
  57639. /**
  57640. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  57641. */
  57642. forceGazeMode: boolean;
  57643. /**
  57644. * 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
  57645. * to start a new countdown to the pointer down event.
  57646. * Defaults to 1.
  57647. */
  57648. gazeModePointerMovedFactor?: number;
  57649. /**
  57650. * Different button type to use instead of the main component
  57651. */
  57652. overrideButtonId?: string;
  57653. /**
  57654. * use this rendering group id for the meshes (optional)
  57655. */
  57656. renderingGroupId?: number;
  57657. /**
  57658. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  57659. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  57660. * 3000 means 3 seconds between pointing at something and selecting it
  57661. */
  57662. timeToSelect?: number;
  57663. /**
  57664. * Should meshes created here be added to a utility layer or the main scene
  57665. */
  57666. useUtilityLayer?: boolean;
  57667. /**
  57668. * Optional WebXR camera to be used for gaze selection
  57669. */
  57670. gazeCamera?: WebXRCamera;
  57671. /**
  57672. * the xr input to use with this pointer selection
  57673. */
  57674. xrInput: WebXRInput;
  57675. /**
  57676. * Should the scene pointerX and pointerY update be disabled
  57677. * This is required for fullscreen AR GUI, but might slow down other experiences.
  57678. * Disable in VR, if not needed.
  57679. * The first rig camera (left eye) will be used to calculate the projection
  57680. */
  57681. disableScenePointerVectorUpdate: boolean;
  57682. /**
  57683. * Enable pointer selection on all controllers instead of switching between them
  57684. */
  57685. enablePointerSelectionOnAllControllers?: boolean;
  57686. /**
  57687. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  57688. * If switch is enabled, it will still allow the user to switch between the different controllers
  57689. */
  57690. preferredHandedness?: XRHandedness;
  57691. /**
  57692. * Disable switching the pointer selection from one controller to the other.
  57693. * 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
  57694. */
  57695. disableSwitchOnClick?: boolean;
  57696. /**
  57697. * The maximum distance of the pointer selection feature. Defaults to 100.
  57698. */
  57699. maxPointerDistance?: number;
  57700. }
  57701. /**
  57702. * A module that will enable pointer selection for motion controllers of XR Input Sources
  57703. */
  57704. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  57705. private readonly _options;
  57706. private static _idCounter;
  57707. private _attachController;
  57708. private _controllers;
  57709. private _scene;
  57710. private _tmpVectorForPickCompare;
  57711. private _attachedController;
  57712. /**
  57713. * The module's name
  57714. */
  57715. static readonly Name: string;
  57716. /**
  57717. * The (Babylon) version of this module.
  57718. * This is an integer representing the implementation version.
  57719. * This number does not correspond to the WebXR specs version
  57720. */
  57721. static readonly Version: number;
  57722. /**
  57723. * Disable lighting on the laser pointer (so it will always be visible)
  57724. */
  57725. disablePointerLighting: boolean;
  57726. /**
  57727. * Disable lighting on the selection mesh (so it will always be visible)
  57728. */
  57729. disableSelectionMeshLighting: boolean;
  57730. /**
  57731. * Should the laser pointer be displayed
  57732. */
  57733. displayLaserPointer: boolean;
  57734. /**
  57735. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  57736. */
  57737. displaySelectionMesh: boolean;
  57738. /**
  57739. * This color will be set to the laser pointer when selection is triggered
  57740. */
  57741. laserPointerPickedColor: Color3;
  57742. /**
  57743. * Default color of the laser pointer
  57744. */
  57745. laserPointerDefaultColor: Color3;
  57746. /**
  57747. * default color of the selection ring
  57748. */
  57749. selectionMeshDefaultColor: Color3;
  57750. /**
  57751. * This color will be applied to the selection ring when selection is triggered
  57752. */
  57753. selectionMeshPickedColor: Color3;
  57754. /**
  57755. * Optional filter to be used for ray selection. This predicate shares behavior with
  57756. * scene.pointerMovePredicate which takes priority if it is also assigned.
  57757. */
  57758. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57759. /**
  57760. * constructs a new background remover module
  57761. * @param _xrSessionManager the session manager for this module
  57762. * @param _options read-only options to be used in this module
  57763. */
  57764. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  57765. /**
  57766. * attach this feature
  57767. * Will usually be called by the features manager
  57768. *
  57769. * @returns true if successful.
  57770. */
  57771. attach(): boolean;
  57772. /**
  57773. * detach this feature.
  57774. * Will usually be called by the features manager
  57775. *
  57776. * @returns true if successful.
  57777. */
  57778. detach(): boolean;
  57779. /**
  57780. * Will get the mesh under a specific pointer.
  57781. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  57782. * @param controllerId the controllerId to check
  57783. * @returns The mesh under pointer or null if no mesh is under the pointer
  57784. */
  57785. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  57786. /**
  57787. * Get the xr controller that correlates to the pointer id in the pointer event
  57788. *
  57789. * @param id the pointer id to search for
  57790. * @returns the controller that correlates to this id or null if not found
  57791. */
  57792. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  57793. private _identityMatrix;
  57794. private _screenCoordinatesRef;
  57795. private _viewportRef;
  57796. protected _onXRFrame(_xrFrame: XRFrame): void;
  57797. private _attachGazeMode;
  57798. private _attachScreenRayMode;
  57799. private _attachTrackedPointerRayMode;
  57800. private _convertNormalToDirectionOfRay;
  57801. private _detachController;
  57802. private _generateNewMeshPair;
  57803. private _pickingMoved;
  57804. private _updatePointerDistance;
  57805. /** @hidden */
  57806. get lasterPointerDefaultColor(): Color3;
  57807. }
  57808. }
  57809. declare module "babylonjs/XR/webXREnterExitUI" {
  57810. import { Nullable } from "babylonjs/types";
  57811. import { Observable } from "babylonjs/Misc/observable";
  57812. import { IDisposable, Scene } from "babylonjs/scene";
  57813. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  57814. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  57815. /**
  57816. * Button which can be used to enter a different mode of XR
  57817. */
  57818. export class WebXREnterExitUIButton {
  57819. /** button element */
  57820. element: HTMLElement;
  57821. /** XR initialization options for the button */
  57822. sessionMode: XRSessionMode;
  57823. /** Reference space type */
  57824. referenceSpaceType: XRReferenceSpaceType;
  57825. /**
  57826. * Creates a WebXREnterExitUIButton
  57827. * @param element button element
  57828. * @param sessionMode XR initialization session mode
  57829. * @param referenceSpaceType the type of reference space to be used
  57830. */
  57831. constructor(
  57832. /** button element */
  57833. element: HTMLElement,
  57834. /** XR initialization options for the button */
  57835. sessionMode: XRSessionMode,
  57836. /** Reference space type */
  57837. referenceSpaceType: XRReferenceSpaceType);
  57838. /**
  57839. * Extendable function which can be used to update the button's visuals when the state changes
  57840. * @param activeButton the current active button in the UI
  57841. */
  57842. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  57843. }
  57844. /**
  57845. * Options to create the webXR UI
  57846. */
  57847. export class WebXREnterExitUIOptions {
  57848. /**
  57849. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  57850. */
  57851. customButtons?: Array<WebXREnterExitUIButton>;
  57852. /**
  57853. * A reference space type to use when creating the default button.
  57854. * Default is local-floor
  57855. */
  57856. referenceSpaceType?: XRReferenceSpaceType;
  57857. /**
  57858. * Context to enter xr with
  57859. */
  57860. renderTarget?: Nullable<WebXRRenderTarget>;
  57861. /**
  57862. * A session mode to use when creating the default button.
  57863. * Default is immersive-vr
  57864. */
  57865. sessionMode?: XRSessionMode;
  57866. /**
  57867. * A list of optional features to init the session with
  57868. */
  57869. optionalFeatures?: string[];
  57870. /**
  57871. * A list of optional features to init the session with
  57872. */
  57873. requiredFeatures?: string[];
  57874. /**
  57875. * If defined, this function will be executed if the UI encounters an error when entering XR
  57876. */
  57877. onError?: (error: any) => void;
  57878. }
  57879. /**
  57880. * UI to allow the user to enter/exit XR mode
  57881. */
  57882. export class WebXREnterExitUI implements IDisposable {
  57883. private scene;
  57884. /** version of the options passed to this UI */
  57885. options: WebXREnterExitUIOptions;
  57886. private _activeButton;
  57887. private _buttons;
  57888. /**
  57889. * The HTML Div Element to which buttons are added.
  57890. */
  57891. readonly overlay: HTMLDivElement;
  57892. /**
  57893. * Fired every time the active button is changed.
  57894. *
  57895. * When xr is entered via a button that launches xr that button will be the callback parameter
  57896. *
  57897. * When exiting xr the callback parameter will be null)
  57898. */
  57899. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  57900. /**
  57901. *
  57902. * @param scene babylon scene object to use
  57903. * @param options (read-only) version of the options passed to this UI
  57904. */
  57905. private constructor();
  57906. /**
  57907. * Creates UI to allow the user to enter/exit XR mode
  57908. * @param scene the scene to add the ui to
  57909. * @param helper the xr experience helper to enter/exit xr with
  57910. * @param options options to configure the UI
  57911. * @returns the created ui
  57912. */
  57913. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  57914. /**
  57915. * Disposes of the XR UI component
  57916. */
  57917. dispose(): void;
  57918. private _updateButtons;
  57919. }
  57920. }
  57921. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  57922. import { Vector3 } from "babylonjs/Maths/math.vector";
  57923. import { Color4 } from "babylonjs/Maths/math.color";
  57924. import { Nullable } from "babylonjs/types";
  57925. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57926. import { Scene } from "babylonjs/scene";
  57927. /**
  57928. * Class containing static functions to help procedurally build meshes
  57929. */
  57930. export class LinesBuilder {
  57931. /**
  57932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57933. * * 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
  57934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57939. * * 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
  57940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57943. * @param name defines the name of the new line system
  57944. * @param options defines the options used to create the line system
  57945. * @param scene defines the hosting scene
  57946. * @returns a new line system mesh
  57947. */
  57948. static CreateLineSystem(name: string, options: {
  57949. lines: Vector3[][];
  57950. updatable?: boolean;
  57951. instance?: Nullable<LinesMesh>;
  57952. colors?: Nullable<Color4[][]>;
  57953. useVertexAlpha?: boolean;
  57954. }, scene: Nullable<Scene>): LinesMesh;
  57955. /**
  57956. * Creates a line mesh
  57957. * 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
  57958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57959. * * The parameter `points` is an array successive Vector3
  57960. * * 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
  57961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57963. * * When updating an instance, remember that only point positions can change, not the number of points
  57964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57966. * @param name defines the name of the new line system
  57967. * @param options defines the options used to create the line system
  57968. * @param scene defines the hosting scene
  57969. * @returns a new line mesh
  57970. */
  57971. static CreateLines(name: string, options: {
  57972. points: Vector3[];
  57973. updatable?: boolean;
  57974. instance?: Nullable<LinesMesh>;
  57975. colors?: Color4[];
  57976. useVertexAlpha?: boolean;
  57977. }, scene?: Nullable<Scene>): LinesMesh;
  57978. /**
  57979. * Creates a dashed line mesh
  57980. * * 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
  57981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57982. * * The parameter `points` is an array successive Vector3
  57983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57986. * * 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
  57987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57988. * * When updating an instance, remember that only point positions can change, not the number of points
  57989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57990. * @param name defines the name of the mesh
  57991. * @param options defines the options used to create the mesh
  57992. * @param scene defines the hosting scene
  57993. * @returns the dashed line mesh
  57994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57995. */
  57996. static CreateDashedLines(name: string, options: {
  57997. points: Vector3[];
  57998. dashSize?: number;
  57999. gapSize?: number;
  58000. dashNb?: number;
  58001. updatable?: boolean;
  58002. instance?: LinesMesh;
  58003. useVertexAlpha?: boolean;
  58004. }, scene?: Nullable<Scene>): LinesMesh;
  58005. }
  58006. }
  58007. declare module "babylonjs/Misc/timer" {
  58008. import { Observable, Observer } from "babylonjs/Misc/observable";
  58009. import { Nullable } from "babylonjs/types";
  58010. import { IDisposable } from "babylonjs/scene";
  58011. /**
  58012. * Construction options for a timer
  58013. */
  58014. export interface ITimerOptions<T> {
  58015. /**
  58016. * Time-to-end
  58017. */
  58018. timeout: number;
  58019. /**
  58020. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  58021. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  58022. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  58023. */
  58024. contextObservable: Observable<T>;
  58025. /**
  58026. * Optional parameters when adding an observer to the observable
  58027. */
  58028. observableParameters?: {
  58029. mask?: number;
  58030. insertFirst?: boolean;
  58031. scope?: any;
  58032. };
  58033. /**
  58034. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  58035. */
  58036. breakCondition?: (data?: ITimerData<T>) => boolean;
  58037. /**
  58038. * Will be triggered when the time condition has met
  58039. */
  58040. onEnded?: (data: ITimerData<any>) => void;
  58041. /**
  58042. * Will be triggered when the break condition has met (prematurely ended)
  58043. */
  58044. onAborted?: (data: ITimerData<any>) => void;
  58045. /**
  58046. * Optional function to execute on each tick (or count)
  58047. */
  58048. onTick?: (data: ITimerData<any>) => void;
  58049. }
  58050. /**
  58051. * An interface defining the data sent by the timer
  58052. */
  58053. export interface ITimerData<T> {
  58054. /**
  58055. * When did it start
  58056. */
  58057. startTime: number;
  58058. /**
  58059. * Time now
  58060. */
  58061. currentTime: number;
  58062. /**
  58063. * Time passed since started
  58064. */
  58065. deltaTime: number;
  58066. /**
  58067. * How much is completed, in [0.0...1.0].
  58068. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  58069. */
  58070. completeRate: number;
  58071. /**
  58072. * What the registered observable sent in the last count
  58073. */
  58074. payload: T;
  58075. }
  58076. /**
  58077. * The current state of the timer
  58078. */
  58079. export enum TimerState {
  58080. /**
  58081. * Timer initialized, not yet started
  58082. */
  58083. INIT = 0,
  58084. /**
  58085. * Timer started and counting
  58086. */
  58087. STARTED = 1,
  58088. /**
  58089. * Timer ended (whether aborted or time reached)
  58090. */
  58091. ENDED = 2
  58092. }
  58093. /**
  58094. * A simple version of the timer. Will take options and start the timer immediately after calling it
  58095. *
  58096. * @param options options with which to initialize this timer
  58097. */
  58098. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  58099. /**
  58100. * An advanced implementation of a timer class
  58101. */
  58102. export class AdvancedTimer<T = any> implements IDisposable {
  58103. /**
  58104. * Will notify each time the timer calculates the remaining time
  58105. */
  58106. onEachCountObservable: Observable<ITimerData<T>>;
  58107. /**
  58108. * Will trigger when the timer was aborted due to the break condition
  58109. */
  58110. onTimerAbortedObservable: Observable<ITimerData<T>>;
  58111. /**
  58112. * Will trigger when the timer ended successfully
  58113. */
  58114. onTimerEndedObservable: Observable<ITimerData<T>>;
  58115. /**
  58116. * Will trigger when the timer state has changed
  58117. */
  58118. onStateChangedObservable: Observable<TimerState>;
  58119. private _observer;
  58120. private _contextObservable;
  58121. private _observableParameters;
  58122. private _startTime;
  58123. private _timer;
  58124. private _state;
  58125. private _breakCondition;
  58126. private _timeToEnd;
  58127. private _breakOnNextTick;
  58128. /**
  58129. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  58130. * @param options construction options for this advanced timer
  58131. */
  58132. constructor(options: ITimerOptions<T>);
  58133. /**
  58134. * set a breaking condition for this timer. Default is to never break during count
  58135. * @param predicate the new break condition. Returns true to break, false otherwise
  58136. */
  58137. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  58138. /**
  58139. * Reset ALL associated observables in this advanced timer
  58140. */
  58141. clearObservables(): void;
  58142. /**
  58143. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  58144. *
  58145. * @param timeToEnd how much time to measure until timer ended
  58146. */
  58147. start(timeToEnd?: number): void;
  58148. /**
  58149. * Will force a stop on the next tick.
  58150. */
  58151. stop(): void;
  58152. /**
  58153. * Dispose this timer, clearing all resources
  58154. */
  58155. dispose(): void;
  58156. private _setState;
  58157. private _tick;
  58158. private _stop;
  58159. }
  58160. }
  58161. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  58162. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  58163. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  58164. import { Nullable } from "babylonjs/types";
  58165. import { WebXRInput } from "babylonjs/XR/webXRInput";
  58166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58167. import { Vector3 } from "babylonjs/Maths/math.vector";
  58168. import { Material } from "babylonjs/Materials/material";
  58169. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  58170. import { Scene } from "babylonjs/scene";
  58171. /**
  58172. * The options container for the teleportation module
  58173. */
  58174. export interface IWebXRTeleportationOptions {
  58175. /**
  58176. * if provided, this scene will be used to render meshes.
  58177. */
  58178. customUtilityLayerScene?: Scene;
  58179. /**
  58180. * Values to configure the default target mesh
  58181. */
  58182. defaultTargetMeshOptions?: {
  58183. /**
  58184. * Fill color of the teleportation area
  58185. */
  58186. teleportationFillColor?: string;
  58187. /**
  58188. * Border color for the teleportation area
  58189. */
  58190. teleportationBorderColor?: string;
  58191. /**
  58192. * Disable the mesh's animation sequence
  58193. */
  58194. disableAnimation?: boolean;
  58195. /**
  58196. * Disable lighting on the material or the ring and arrow
  58197. */
  58198. disableLighting?: boolean;
  58199. /**
  58200. * Override the default material of the torus and arrow
  58201. */
  58202. torusArrowMaterial?: Material;
  58203. };
  58204. /**
  58205. * A list of meshes to use as floor meshes.
  58206. * Meshes can be added and removed after initializing the feature using the
  58207. * addFloorMesh and removeFloorMesh functions
  58208. * If empty, rotation will still work
  58209. */
  58210. floorMeshes?: AbstractMesh[];
  58211. /**
  58212. * use this rendering group id for the meshes (optional)
  58213. */
  58214. renderingGroupId?: number;
  58215. /**
  58216. * Should teleportation move only to snap points
  58217. */
  58218. snapPointsOnly?: boolean;
  58219. /**
  58220. * An array of points to which the teleportation will snap to.
  58221. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  58222. */
  58223. snapPositions?: Vector3[];
  58224. /**
  58225. * How close should the teleportation ray be in order to snap to position.
  58226. * Default to 0.8 units (meters)
  58227. */
  58228. snapToPositionRadius?: number;
  58229. /**
  58230. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  58231. * If you want to support rotation, make sure your mesh has a direction indicator.
  58232. *
  58233. * When left untouched, the default mesh will be initialized.
  58234. */
  58235. teleportationTargetMesh?: AbstractMesh;
  58236. /**
  58237. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  58238. */
  58239. timeToTeleport?: number;
  58240. /**
  58241. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  58242. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  58243. */
  58244. useMainComponentOnly?: boolean;
  58245. /**
  58246. * Should meshes created here be added to a utility layer or the main scene
  58247. */
  58248. useUtilityLayer?: boolean;
  58249. /**
  58250. * Babylon XR Input class for controller
  58251. */
  58252. xrInput: WebXRInput;
  58253. /**
  58254. * Meshes that the teleportation ray cannot go through
  58255. */
  58256. pickBlockerMeshes?: AbstractMesh[];
  58257. /**
  58258. * Should teleport work only on a specific hand?
  58259. */
  58260. forceHandedness?: XRHandedness;
  58261. /**
  58262. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  58263. */
  58264. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  58265. }
  58266. /**
  58267. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  58268. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  58269. * the input of the attached controllers.
  58270. */
  58271. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  58272. private _options;
  58273. private _controllers;
  58274. private _currentTeleportationControllerId;
  58275. private _floorMeshes;
  58276. private _quadraticBezierCurve;
  58277. private _selectionFeature;
  58278. private _snapToPositions;
  58279. private _snappedToPoint;
  58280. private _teleportationRingMaterial?;
  58281. private _tmpRay;
  58282. private _tmpVector;
  58283. private _tmpQuaternion;
  58284. /**
  58285. * The module's name
  58286. */
  58287. static readonly Name: string;
  58288. /**
  58289. * The (Babylon) version of this module.
  58290. * This is an integer representing the implementation version.
  58291. * This number does not correspond to the webxr specs version
  58292. */
  58293. static readonly Version: number;
  58294. /**
  58295. * Is movement backwards enabled
  58296. */
  58297. backwardsMovementEnabled: boolean;
  58298. /**
  58299. * Distance to travel when moving backwards
  58300. */
  58301. backwardsTeleportationDistance: number;
  58302. /**
  58303. * The distance from the user to the inspection point in the direction of the controller
  58304. * A higher number will allow the user to move further
  58305. * defaults to 5 (meters, in xr units)
  58306. */
  58307. parabolicCheckRadius: number;
  58308. /**
  58309. * Should the module support parabolic ray on top of direct ray
  58310. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  58311. * Very helpful when moving between floors / different heights
  58312. */
  58313. parabolicRayEnabled: boolean;
  58314. /**
  58315. * The second type of ray - straight line.
  58316. * Should it be enabled or should the parabolic line be the only one.
  58317. */
  58318. straightRayEnabled: boolean;
  58319. /**
  58320. * How much rotation should be applied when rotating right and left
  58321. */
  58322. rotationAngle: number;
  58323. private _rotationEnabled;
  58324. /**
  58325. * Is rotation enabled when moving forward?
  58326. * Disabling this feature will prevent the user from deciding the direction when teleporting
  58327. */
  58328. get rotationEnabled(): boolean;
  58329. /**
  58330. * Sets wether rotation is enabled or not
  58331. * @param enabled is rotation enabled when teleportation is shown
  58332. */
  58333. set rotationEnabled(enabled: boolean);
  58334. /**
  58335. * Exposes the currently set teleportation target mesh.
  58336. */
  58337. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  58338. /**
  58339. * constructs a new anchor system
  58340. * @param _xrSessionManager an instance of WebXRSessionManager
  58341. * @param _options configuration object for this feature
  58342. */
  58343. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  58344. /**
  58345. * Get the snapPointsOnly flag
  58346. */
  58347. get snapPointsOnly(): boolean;
  58348. /**
  58349. * Sets the snapPointsOnly flag
  58350. * @param snapToPoints should teleportation be exclusively to snap points
  58351. */
  58352. set snapPointsOnly(snapToPoints: boolean);
  58353. /**
  58354. * Add a new mesh to the floor meshes array
  58355. * @param mesh the mesh to use as floor mesh
  58356. */
  58357. addFloorMesh(mesh: AbstractMesh): void;
  58358. /**
  58359. * Add a new snap-to point to fix teleportation to this position
  58360. * @param newSnapPoint The new Snap-To point
  58361. */
  58362. addSnapPoint(newSnapPoint: Vector3): void;
  58363. attach(): boolean;
  58364. detach(): boolean;
  58365. dispose(): void;
  58366. /**
  58367. * Remove a mesh from the floor meshes array
  58368. * @param mesh the mesh to remove
  58369. */
  58370. removeFloorMesh(mesh: AbstractMesh): void;
  58371. /**
  58372. * Remove a mesh from the floor meshes array using its name
  58373. * @param name the mesh name to remove
  58374. */
  58375. removeFloorMeshByName(name: string): void;
  58376. /**
  58377. * 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
  58378. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  58379. * @returns was the point found and removed or not
  58380. */
  58381. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  58382. /**
  58383. * This function sets a selection feature that will be disabled when
  58384. * the forward ray is shown and will be reattached when hidden.
  58385. * This is used to remove the selection rays when moving.
  58386. * @param selectionFeature the feature to disable when forward movement is enabled
  58387. */
  58388. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  58389. protected _onXRFrame(_xrFrame: XRFrame): void;
  58390. private _attachController;
  58391. private _createDefaultTargetMesh;
  58392. private _detachController;
  58393. private _findClosestSnapPointWithRadius;
  58394. private _setTargetMeshPosition;
  58395. private _setTargetMeshVisibility;
  58396. private _showParabolicPath;
  58397. private _teleportForward;
  58398. }
  58399. }
  58400. declare module "babylonjs/XR/webXRDefaultExperience" {
  58401. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58402. import { Scene } from "babylonjs/scene";
  58403. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  58404. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  58405. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58406. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  58407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58408. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  58409. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  58410. /**
  58411. * Options for the default xr helper
  58412. */
  58413. export class WebXRDefaultExperienceOptions {
  58414. /**
  58415. * Enable or disable default UI to enter XR
  58416. */
  58417. disableDefaultUI?: boolean;
  58418. /**
  58419. * Should teleportation not initialize. defaults to false.
  58420. */
  58421. disableTeleportation?: boolean;
  58422. /**
  58423. * Floor meshes that will be used for teleport
  58424. */
  58425. floorMeshes?: Array<AbstractMesh>;
  58426. /**
  58427. * If set to true, the first frame will not be used to reset position
  58428. * The first frame is mainly used when copying transformation from the old camera
  58429. * Mainly used in AR
  58430. */
  58431. ignoreNativeCameraTransformation?: boolean;
  58432. /**
  58433. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  58434. */
  58435. inputOptions?: IWebXRInputOptions;
  58436. /**
  58437. * optional configuration for the output canvas
  58438. */
  58439. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  58440. /**
  58441. * optional UI options. This can be used among other to change session mode and reference space type
  58442. */
  58443. uiOptions?: WebXREnterExitUIOptions;
  58444. /**
  58445. * When loading teleportation and pointer select, use stable versions instead of latest.
  58446. */
  58447. useStablePlugins?: boolean;
  58448. /**
  58449. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  58450. */
  58451. renderingGroupId?: number;
  58452. /**
  58453. * A list of optional features to init the session with
  58454. * If set to true, all features we support will be added
  58455. */
  58456. optionalFeatures?: boolean | string[];
  58457. }
  58458. /**
  58459. * Default experience which provides a similar setup to the previous webVRExperience
  58460. */
  58461. export class WebXRDefaultExperience {
  58462. /**
  58463. * Base experience
  58464. */
  58465. baseExperience: WebXRExperienceHelper;
  58466. /**
  58467. * Enables ui for entering/exiting xr
  58468. */
  58469. enterExitUI: WebXREnterExitUI;
  58470. /**
  58471. * Input experience extension
  58472. */
  58473. input: WebXRInput;
  58474. /**
  58475. * Enables laser pointer and selection
  58476. */
  58477. pointerSelection: WebXRControllerPointerSelection;
  58478. /**
  58479. * Default target xr should render to
  58480. */
  58481. renderTarget: WebXRRenderTarget;
  58482. /**
  58483. * Enables teleportation
  58484. */
  58485. teleportation: WebXRMotionControllerTeleportation;
  58486. private constructor();
  58487. /**
  58488. * Creates the default xr experience
  58489. * @param scene scene
  58490. * @param options options for basic configuration
  58491. * @returns resulting WebXRDefaultExperience
  58492. */
  58493. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58494. /**
  58495. * DIsposes of the experience helper
  58496. */
  58497. dispose(): void;
  58498. }
  58499. }
  58500. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  58501. import { Observable } from "babylonjs/Misc/observable";
  58502. import { Nullable } from "babylonjs/types";
  58503. import { Camera } from "babylonjs/Cameras/camera";
  58504. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  58505. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58506. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  58507. import { Scene } from "babylonjs/scene";
  58508. import { Vector3 } from "babylonjs/Maths/math.vector";
  58509. import { Color3 } from "babylonjs/Maths/math.color";
  58510. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58512. import { Mesh } from "babylonjs/Meshes/mesh";
  58513. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  58514. import { EasingFunction } from "babylonjs/Animations/easing";
  58515. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  58516. import "babylonjs/Meshes/Builders/groundBuilder";
  58517. import "babylonjs/Meshes/Builders/torusBuilder";
  58518. import "babylonjs/Meshes/Builders/cylinderBuilder";
  58519. import "babylonjs/Gamepads/gamepadSceneComponent";
  58520. import "babylonjs/Animations/animatable";
  58521. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  58522. /**
  58523. * Options to modify the vr teleportation behavior.
  58524. */
  58525. export interface VRTeleportationOptions {
  58526. /**
  58527. * The name of the mesh which should be used as the teleportation floor. (default: null)
  58528. */
  58529. floorMeshName?: string;
  58530. /**
  58531. * A list of meshes to be used as the teleportation floor. (default: empty)
  58532. */
  58533. floorMeshes?: Mesh[];
  58534. /**
  58535. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  58536. */
  58537. teleportationMode?: number;
  58538. /**
  58539. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  58540. */
  58541. teleportationTime?: number;
  58542. /**
  58543. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  58544. */
  58545. teleportationSpeed?: number;
  58546. /**
  58547. * The easing function used in the animation or null for Linear. (default CircleEase)
  58548. */
  58549. easingFunction?: EasingFunction;
  58550. }
  58551. /**
  58552. * Options to modify the vr experience helper's behavior.
  58553. */
  58554. export interface VRExperienceHelperOptions extends WebVROptions {
  58555. /**
  58556. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  58557. */
  58558. createDeviceOrientationCamera?: boolean;
  58559. /**
  58560. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  58561. */
  58562. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  58563. /**
  58564. * Uses the main button on the controller to toggle the laser casted. (default: true)
  58565. */
  58566. laserToggle?: boolean;
  58567. /**
  58568. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  58569. */
  58570. floorMeshes?: Mesh[];
  58571. /**
  58572. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  58573. */
  58574. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  58575. /**
  58576. * Defines if WebXR should be used instead of WebVR (if available)
  58577. */
  58578. useXR?: boolean;
  58579. }
  58580. /**
  58581. * Event containing information after VR has been entered
  58582. */
  58583. export class OnAfterEnteringVRObservableEvent {
  58584. /**
  58585. * If entering vr was successful
  58586. */
  58587. success: boolean;
  58588. }
  58589. /**
  58590. * Helps to quickly add VR support to an existing scene.
  58591. * See https://doc.babylonjs.com/how_to/webvr_helper
  58592. */
  58593. export class VRExperienceHelper {
  58594. /** Options to modify the vr experience helper's behavior. */
  58595. webVROptions: VRExperienceHelperOptions;
  58596. private _scene;
  58597. private _position;
  58598. private _btnVR;
  58599. private _btnVRDisplayed;
  58600. private _webVRsupported;
  58601. private _webVRready;
  58602. private _webVRrequesting;
  58603. private _webVRpresenting;
  58604. private _hasEnteredVR;
  58605. private _fullscreenVRpresenting;
  58606. private _inputElement;
  58607. private _webVRCamera;
  58608. private _vrDeviceOrientationCamera;
  58609. private _deviceOrientationCamera;
  58610. private _existingCamera;
  58611. private _onKeyDown;
  58612. private _onVrDisplayPresentChange;
  58613. private _onVRDisplayChanged;
  58614. private _onVRRequestPresentStart;
  58615. private _onVRRequestPresentComplete;
  58616. /**
  58617. * 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)
  58618. */
  58619. enableGazeEvenWhenNoPointerLock: boolean;
  58620. /**
  58621. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  58622. */
  58623. exitVROnDoubleTap: boolean;
  58624. /**
  58625. * Observable raised right before entering VR.
  58626. */
  58627. onEnteringVRObservable: Observable<VRExperienceHelper>;
  58628. /**
  58629. * Observable raised when entering VR has completed.
  58630. */
  58631. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  58632. /**
  58633. * Observable raised when exiting VR.
  58634. */
  58635. onExitingVRObservable: Observable<VRExperienceHelper>;
  58636. /**
  58637. * Observable raised when controller mesh is loaded.
  58638. */
  58639. onControllerMeshLoadedObservable: Observable<WebVRController>;
  58640. /** Return this.onEnteringVRObservable
  58641. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  58642. */
  58643. get onEnteringVR(): Observable<VRExperienceHelper>;
  58644. /** Return this.onExitingVRObservable
  58645. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  58646. */
  58647. get onExitingVR(): Observable<VRExperienceHelper>;
  58648. /** Return this.onControllerMeshLoadedObservable
  58649. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  58650. */
  58651. get onControllerMeshLoaded(): Observable<WebVRController>;
  58652. private _rayLength;
  58653. private _useCustomVRButton;
  58654. private _teleportationRequested;
  58655. private _teleportActive;
  58656. private _floorMeshName;
  58657. private _floorMeshesCollection;
  58658. private _teleportationMode;
  58659. private _teleportationTime;
  58660. private _teleportationSpeed;
  58661. private _teleportationEasing;
  58662. private _rotationAllowed;
  58663. private _teleportBackwardsVector;
  58664. private _teleportationTarget;
  58665. private _isDefaultTeleportationTarget;
  58666. private _postProcessMove;
  58667. private _teleportationFillColor;
  58668. private _teleportationBorderColor;
  58669. private _rotationAngle;
  58670. private _haloCenter;
  58671. private _cameraGazer;
  58672. private _padSensibilityUp;
  58673. private _padSensibilityDown;
  58674. private _leftController;
  58675. private _rightController;
  58676. private _gazeColor;
  58677. private _laserColor;
  58678. private _pickedLaserColor;
  58679. private _pickedGazeColor;
  58680. /**
  58681. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  58682. */
  58683. onNewMeshSelected: Observable<AbstractMesh>;
  58684. /**
  58685. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  58686. * This observable will provide the mesh and the controller used to select the mesh
  58687. */
  58688. onMeshSelectedWithController: Observable<{
  58689. mesh: AbstractMesh;
  58690. controller: WebVRController;
  58691. }>;
  58692. /**
  58693. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  58694. */
  58695. onNewMeshPicked: Observable<PickingInfo>;
  58696. private _circleEase;
  58697. /**
  58698. * Observable raised before camera teleportation
  58699. */
  58700. onBeforeCameraTeleport: Observable<Vector3>;
  58701. /**
  58702. * Observable raised after camera teleportation
  58703. */
  58704. onAfterCameraTeleport: Observable<Vector3>;
  58705. /**
  58706. * Observable raised when current selected mesh gets unselected
  58707. */
  58708. onSelectedMeshUnselected: Observable<AbstractMesh>;
  58709. private _raySelectionPredicate;
  58710. /**
  58711. * To be optionaly changed by user to define custom ray selection
  58712. */
  58713. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  58714. /**
  58715. * To be optionaly changed by user to define custom selection logic (after ray selection)
  58716. */
  58717. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58718. /**
  58719. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  58720. */
  58721. teleportationEnabled: boolean;
  58722. private _defaultHeight;
  58723. private _teleportationInitialized;
  58724. private _interactionsEnabled;
  58725. private _interactionsRequested;
  58726. private _displayGaze;
  58727. private _displayLaserPointer;
  58728. /**
  58729. * The mesh used to display where the user is going to teleport.
  58730. */
  58731. get teleportationTarget(): Mesh;
  58732. /**
  58733. * Sets the mesh to be used to display where the user is going to teleport.
  58734. */
  58735. set teleportationTarget(value: Mesh);
  58736. /**
  58737. * 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
  58738. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  58739. * See https://doc.babylonjs.com/resources/baking_transformations
  58740. */
  58741. get gazeTrackerMesh(): Mesh;
  58742. set gazeTrackerMesh(value: Mesh);
  58743. /**
  58744. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  58745. */
  58746. updateGazeTrackerScale: boolean;
  58747. /**
  58748. * If the gaze trackers color should be updated when selecting meshes
  58749. */
  58750. updateGazeTrackerColor: boolean;
  58751. /**
  58752. * If the controller laser color should be updated when selecting meshes
  58753. */
  58754. updateControllerLaserColor: boolean;
  58755. /**
  58756. * The gaze tracking mesh corresponding to the left controller
  58757. */
  58758. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  58759. /**
  58760. * The gaze tracking mesh corresponding to the right controller
  58761. */
  58762. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  58763. /**
  58764. * If the ray of the gaze should be displayed.
  58765. */
  58766. get displayGaze(): boolean;
  58767. /**
  58768. * Sets if the ray of the gaze should be displayed.
  58769. */
  58770. set displayGaze(value: boolean);
  58771. /**
  58772. * If the ray of the LaserPointer should be displayed.
  58773. */
  58774. get displayLaserPointer(): boolean;
  58775. /**
  58776. * Sets if the ray of the LaserPointer should be displayed.
  58777. */
  58778. set displayLaserPointer(value: boolean);
  58779. /**
  58780. * The deviceOrientationCamera used as the camera when not in VR.
  58781. */
  58782. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  58783. /**
  58784. * Based on the current WebVR support, returns the current VR camera used.
  58785. */
  58786. get currentVRCamera(): Nullable<Camera>;
  58787. /**
  58788. * The webVRCamera which is used when in VR.
  58789. */
  58790. get webVRCamera(): WebVRFreeCamera;
  58791. /**
  58792. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  58793. */
  58794. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  58795. /**
  58796. * The html button that is used to trigger entering into VR.
  58797. */
  58798. get vrButton(): Nullable<HTMLButtonElement>;
  58799. private get _teleportationRequestInitiated();
  58800. /**
  58801. * Defines whether or not Pointer lock should be requested when switching to
  58802. * full screen.
  58803. */
  58804. requestPointerLockOnFullScreen: boolean;
  58805. /**
  58806. * If asking to force XR, this will be populated with the default xr experience
  58807. */
  58808. xr: WebXRDefaultExperience;
  58809. /**
  58810. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  58811. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  58812. */
  58813. xrTestDone: boolean;
  58814. /**
  58815. * Instantiates a VRExperienceHelper.
  58816. * Helps to quickly add VR support to an existing scene.
  58817. * @param scene The scene the VRExperienceHelper belongs to.
  58818. * @param webVROptions Options to modify the vr experience helper's behavior.
  58819. */
  58820. constructor(scene: Scene,
  58821. /** Options to modify the vr experience helper's behavior. */
  58822. webVROptions?: VRExperienceHelperOptions);
  58823. private completeVRInit;
  58824. private _onDefaultMeshLoaded;
  58825. private _onResize;
  58826. private _onFullscreenChange;
  58827. /**
  58828. * Gets a value indicating if we are currently in VR mode.
  58829. */
  58830. get isInVRMode(): boolean;
  58831. private onVrDisplayPresentChange;
  58832. private onVRDisplayChanged;
  58833. private moveButtonToBottomRight;
  58834. private displayVRButton;
  58835. private updateButtonVisibility;
  58836. private _cachedAngularSensibility;
  58837. /**
  58838. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  58839. * Otherwise, will use the fullscreen API.
  58840. */
  58841. enterVR(): void;
  58842. /**
  58843. * Attempt to exit VR, or fullscreen.
  58844. */
  58845. exitVR(): void;
  58846. /**
  58847. * The position of the vr experience helper.
  58848. */
  58849. get position(): Vector3;
  58850. /**
  58851. * Sets the position of the vr experience helper.
  58852. */
  58853. set position(value: Vector3);
  58854. /**
  58855. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  58856. */
  58857. enableInteractions(): void;
  58858. private get _noControllerIsActive();
  58859. private beforeRender;
  58860. private _isTeleportationFloor;
  58861. /**
  58862. * Adds a floor mesh to be used for teleportation.
  58863. * @param floorMesh the mesh to be used for teleportation.
  58864. */
  58865. addFloorMesh(floorMesh: Mesh): void;
  58866. /**
  58867. * Removes a floor mesh from being used for teleportation.
  58868. * @param floorMesh the mesh to be removed.
  58869. */
  58870. removeFloorMesh(floorMesh: Mesh): void;
  58871. /**
  58872. * Enables interactions and teleportation using the VR controllers and gaze.
  58873. * @param vrTeleportationOptions options to modify teleportation behavior.
  58874. */
  58875. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  58876. private _onNewGamepadConnected;
  58877. private _tryEnableInteractionOnController;
  58878. private _onNewGamepadDisconnected;
  58879. private _enableInteractionOnController;
  58880. private _checkTeleportWithRay;
  58881. private _checkRotate;
  58882. private _checkTeleportBackwards;
  58883. private _enableTeleportationOnController;
  58884. private _createTeleportationCircles;
  58885. private _displayTeleportationTarget;
  58886. private _hideTeleportationTarget;
  58887. private _rotateCamera;
  58888. private _moveTeleportationSelectorTo;
  58889. private _workingVector;
  58890. private _workingQuaternion;
  58891. private _workingMatrix;
  58892. /**
  58893. * Time Constant Teleportation Mode
  58894. */
  58895. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  58896. /**
  58897. * Speed Constant Teleportation Mode
  58898. */
  58899. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  58900. /**
  58901. * Teleports the users feet to the desired location
  58902. * @param location The location where the user's feet should be placed
  58903. */
  58904. teleportCamera(location: Vector3): void;
  58905. private _convertNormalToDirectionOfRay;
  58906. private _castRayAndSelectObject;
  58907. private _notifySelectedMeshUnselected;
  58908. /**
  58909. * Permanently set new colors for the laser pointer
  58910. * @param color the new laser color
  58911. * @param pickedColor the new laser color when picked mesh detected
  58912. */
  58913. setLaserColor(color: Color3, pickedColor?: Color3): void;
  58914. /**
  58915. * Set lighting enabled / disabled on the laser pointer of both controllers
  58916. * @param enabled should the lighting be enabled on the laser pointer
  58917. */
  58918. setLaserLightingState(enabled?: boolean): void;
  58919. /**
  58920. * Permanently set new colors for the gaze pointer
  58921. * @param color the new gaze color
  58922. * @param pickedColor the new gaze color when picked mesh detected
  58923. */
  58924. setGazeColor(color: Color3, pickedColor?: Color3): void;
  58925. /**
  58926. * Sets the color of the laser ray from the vr controllers.
  58927. * @param color new color for the ray.
  58928. */
  58929. changeLaserColor(color: Color3): void;
  58930. /**
  58931. * Sets the color of the ray from the vr headsets gaze.
  58932. * @param color new color for the ray.
  58933. */
  58934. changeGazeColor(color: Color3): void;
  58935. /**
  58936. * Exits VR and disposes of the vr experience helper
  58937. */
  58938. dispose(): void;
  58939. /**
  58940. * Gets the name of the VRExperienceHelper class
  58941. * @returns "VRExperienceHelper"
  58942. */
  58943. getClassName(): string;
  58944. }
  58945. }
  58946. declare module "babylonjs/Cameras/VR/index" {
  58947. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  58948. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  58949. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58950. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  58951. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  58952. export * from "babylonjs/Cameras/VR/webVRCamera";
  58953. }
  58954. declare module "babylonjs/Cameras/RigModes/index" {
  58955. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  58956. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  58957. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  58958. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  58959. }
  58960. declare module "babylonjs/Cameras/index" {
  58961. export * from "babylonjs/Cameras/Inputs/index";
  58962. export * from "babylonjs/Cameras/cameraInputsManager";
  58963. export * from "babylonjs/Cameras/camera";
  58964. export * from "babylonjs/Cameras/targetCamera";
  58965. export * from "babylonjs/Cameras/freeCamera";
  58966. export * from "babylonjs/Cameras/freeCameraInputsManager";
  58967. export * from "babylonjs/Cameras/touchCamera";
  58968. export * from "babylonjs/Cameras/arcRotateCamera";
  58969. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  58970. export * from "babylonjs/Cameras/deviceOrientationCamera";
  58971. export * from "babylonjs/Cameras/flyCamera";
  58972. export * from "babylonjs/Cameras/flyCameraInputsManager";
  58973. export * from "babylonjs/Cameras/followCamera";
  58974. export * from "babylonjs/Cameras/followCameraInputsManager";
  58975. export * from "babylonjs/Cameras/gamepadCamera";
  58976. export * from "babylonjs/Cameras/Stereoscopic/index";
  58977. export * from "babylonjs/Cameras/universalCamera";
  58978. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  58979. export * from "babylonjs/Cameras/VR/index";
  58980. export * from "babylonjs/Cameras/RigModes/index";
  58981. }
  58982. declare module "babylonjs/Collisions/index" {
  58983. export * from "babylonjs/Collisions/collider";
  58984. export * from "babylonjs/Collisions/collisionCoordinator";
  58985. export * from "babylonjs/Collisions/pickingInfo";
  58986. export * from "babylonjs/Collisions/intersectionInfo";
  58987. export * from "babylonjs/Collisions/meshCollisionData";
  58988. }
  58989. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  58990. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  58991. import { Vector3 } from "babylonjs/Maths/math.vector";
  58992. import { Ray } from "babylonjs/Culling/ray";
  58993. import { Plane } from "babylonjs/Maths/math.plane";
  58994. /**
  58995. * Contains an array of blocks representing the octree
  58996. */
  58997. export interface IOctreeContainer<T> {
  58998. /**
  58999. * Blocks within the octree
  59000. */
  59001. blocks: Array<OctreeBlock<T>>;
  59002. }
  59003. /**
  59004. * Class used to store a cell in an octree
  59005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59006. */
  59007. export class OctreeBlock<T> {
  59008. /**
  59009. * Gets the content of the current block
  59010. */
  59011. entries: T[];
  59012. /**
  59013. * Gets the list of block children
  59014. */
  59015. blocks: Array<OctreeBlock<T>>;
  59016. private _depth;
  59017. private _maxDepth;
  59018. private _capacity;
  59019. private _minPoint;
  59020. private _maxPoint;
  59021. private _boundingVectors;
  59022. private _creationFunc;
  59023. /**
  59024. * Creates a new block
  59025. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  59026. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  59027. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59028. * @param depth defines the current depth of this block in the octree
  59029. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  59030. * @param creationFunc defines a callback to call when an element is added to the block
  59031. */
  59032. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  59033. /**
  59034. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59035. */
  59036. get capacity(): number;
  59037. /**
  59038. * Gets the minimum vector (in world space) of the block's bounding box
  59039. */
  59040. get minPoint(): Vector3;
  59041. /**
  59042. * Gets the maximum vector (in world space) of the block's bounding box
  59043. */
  59044. get maxPoint(): Vector3;
  59045. /**
  59046. * Add a new element to this block
  59047. * @param entry defines the element to add
  59048. */
  59049. addEntry(entry: T): void;
  59050. /**
  59051. * Remove an element from this block
  59052. * @param entry defines the element to remove
  59053. */
  59054. removeEntry(entry: T): void;
  59055. /**
  59056. * Add an array of elements to this block
  59057. * @param entries defines the array of elements to add
  59058. */
  59059. addEntries(entries: T[]): void;
  59060. /**
  59061. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  59062. * @param frustumPlanes defines the frustum planes to test
  59063. * @param selection defines the array to store current content if selection is positive
  59064. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59065. */
  59066. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59067. /**
  59068. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  59069. * @param sphereCenter defines the bounding sphere center
  59070. * @param sphereRadius defines the bounding sphere radius
  59071. * @param selection defines the array to store current content if selection is positive
  59072. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59073. */
  59074. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59075. /**
  59076. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  59077. * @param ray defines the ray to test with
  59078. * @param selection defines the array to store current content if selection is positive
  59079. */
  59080. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  59081. /**
  59082. * Subdivide the content into child blocks (this block will then be empty)
  59083. */
  59084. createInnerBlocks(): void;
  59085. /**
  59086. * @hidden
  59087. */
  59088. 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;
  59089. }
  59090. }
  59091. declare module "babylonjs/Culling/Octrees/octree" {
  59092. import { SmartArray } from "babylonjs/Misc/smartArray";
  59093. import { Vector3 } from "babylonjs/Maths/math.vector";
  59094. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59096. import { Ray } from "babylonjs/Culling/ray";
  59097. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  59098. import { Plane } from "babylonjs/Maths/math.plane";
  59099. /**
  59100. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  59101. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59102. */
  59103. export class Octree<T> {
  59104. /** 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.) */
  59105. maxDepth: number;
  59106. /**
  59107. * Blocks within the octree containing objects
  59108. */
  59109. blocks: Array<OctreeBlock<T>>;
  59110. /**
  59111. * Content stored in the octree
  59112. */
  59113. dynamicContent: T[];
  59114. private _maxBlockCapacity;
  59115. private _selectionContent;
  59116. private _creationFunc;
  59117. /**
  59118. * Creates a octree
  59119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59120. * @param creationFunc function to be used to instatiate the octree
  59121. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  59122. * @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.)
  59123. */
  59124. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  59125. /** 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.) */
  59126. maxDepth?: number);
  59127. /**
  59128. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  59129. * @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);
  59130. * @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);
  59131. * @param entries meshes to be added to the octree blocks
  59132. */
  59133. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  59134. /**
  59135. * Adds a mesh to the octree
  59136. * @param entry Mesh to add to the octree
  59137. */
  59138. addMesh(entry: T): void;
  59139. /**
  59140. * Remove an element from the octree
  59141. * @param entry defines the element to remove
  59142. */
  59143. removeMesh(entry: T): void;
  59144. /**
  59145. * Selects an array of meshes within the frustum
  59146. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  59147. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  59148. * @returns array of meshes within the frustum
  59149. */
  59150. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  59151. /**
  59152. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  59153. * @param sphereCenter defines the bounding sphere center
  59154. * @param sphereRadius defines the bounding sphere radius
  59155. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59156. * @returns an array of objects that intersect the sphere
  59157. */
  59158. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  59159. /**
  59160. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  59161. * @param ray defines the ray to test with
  59162. * @returns array of intersected objects
  59163. */
  59164. intersectsRay(ray: Ray): SmartArray<T>;
  59165. /**
  59166. * Adds a mesh into the octree block if it intersects the block
  59167. */
  59168. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  59169. /**
  59170. * Adds a submesh into the octree block if it intersects the block
  59171. */
  59172. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  59173. }
  59174. }
  59175. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  59176. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  59177. import { Scene } from "babylonjs/scene";
  59178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59180. import { Ray } from "babylonjs/Culling/ray";
  59181. import { Octree } from "babylonjs/Culling/Octrees/octree";
  59182. import { Collider } from "babylonjs/Collisions/collider";
  59183. module "babylonjs/scene" {
  59184. interface Scene {
  59185. /**
  59186. * @hidden
  59187. * Backing Filed
  59188. */
  59189. _selectionOctree: Octree<AbstractMesh>;
  59190. /**
  59191. * Gets the octree used to boost mesh selection (picking)
  59192. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59193. */
  59194. selectionOctree: Octree<AbstractMesh>;
  59195. /**
  59196. * Creates or updates the octree used to boost selection (picking)
  59197. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59198. * @param maxCapacity defines the maximum capacity per leaf
  59199. * @param maxDepth defines the maximum depth of the octree
  59200. * @returns an octree of AbstractMesh
  59201. */
  59202. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  59203. }
  59204. }
  59205. module "babylonjs/Meshes/abstractMesh" {
  59206. interface AbstractMesh {
  59207. /**
  59208. * @hidden
  59209. * Backing Field
  59210. */
  59211. _submeshesOctree: Octree<SubMesh>;
  59212. /**
  59213. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  59214. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  59215. * @param maxCapacity defines the maximum size of each block (64 by default)
  59216. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  59217. * @returns the new octree
  59218. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  59219. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59220. */
  59221. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  59222. }
  59223. }
  59224. /**
  59225. * Defines the octree scene component responsible to manage any octrees
  59226. * in a given scene.
  59227. */
  59228. export class OctreeSceneComponent {
  59229. /**
  59230. * The component name help to identify the component in the list of scene components.
  59231. */
  59232. readonly name: string;
  59233. /**
  59234. * The scene the component belongs to.
  59235. */
  59236. scene: Scene;
  59237. /**
  59238. * Indicates if the meshes have been checked to make sure they are isEnabled()
  59239. */
  59240. readonly checksIsEnabled: boolean;
  59241. /**
  59242. * Creates a new instance of the component for the given scene
  59243. * @param scene Defines the scene to register the component in
  59244. */
  59245. constructor(scene: Scene);
  59246. /**
  59247. * Registers the component in a given scene
  59248. */
  59249. register(): void;
  59250. /**
  59251. * Return the list of active meshes
  59252. * @returns the list of active meshes
  59253. */
  59254. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  59255. /**
  59256. * Return the list of active sub meshes
  59257. * @param mesh The mesh to get the candidates sub meshes from
  59258. * @returns the list of active sub meshes
  59259. */
  59260. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  59261. private _tempRay;
  59262. /**
  59263. * Return the list of sub meshes intersecting with a given local ray
  59264. * @param mesh defines the mesh to find the submesh for
  59265. * @param localRay defines the ray in local space
  59266. * @returns the list of intersecting sub meshes
  59267. */
  59268. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  59269. /**
  59270. * Return the list of sub meshes colliding with a collider
  59271. * @param mesh defines the mesh to find the submesh for
  59272. * @param collider defines the collider to evaluate the collision against
  59273. * @returns the list of colliding sub meshes
  59274. */
  59275. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  59276. /**
  59277. * Rebuilds the elements related to this component in case of
  59278. * context lost for instance.
  59279. */
  59280. rebuild(): void;
  59281. /**
  59282. * Disposes the component and the associated ressources.
  59283. */
  59284. dispose(): void;
  59285. }
  59286. }
  59287. declare module "babylonjs/Culling/Octrees/index" {
  59288. export * from "babylonjs/Culling/Octrees/octree";
  59289. export * from "babylonjs/Culling/Octrees/octreeBlock";
  59290. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  59291. }
  59292. declare module "babylonjs/Culling/index" {
  59293. export * from "babylonjs/Culling/boundingBox";
  59294. export * from "babylonjs/Culling/boundingInfo";
  59295. export * from "babylonjs/Culling/boundingSphere";
  59296. export * from "babylonjs/Culling/Octrees/index";
  59297. export * from "babylonjs/Culling/ray";
  59298. }
  59299. declare module "babylonjs/Gizmos/gizmo" {
  59300. import { Observer } from "babylonjs/Misc/observable";
  59301. import { Nullable } from "babylonjs/types";
  59302. import { IDisposable } from "babylonjs/scene";
  59303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59304. import { Mesh } from "babylonjs/Meshes/mesh";
  59305. import { Node } from "babylonjs/node";
  59306. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59307. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59308. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  59309. /**
  59310. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  59311. */
  59312. export interface GizmoAxisCache {
  59313. /** Mesh used to runder the Gizmo */
  59314. gizmoMeshes: Mesh[];
  59315. /** Mesh used to detect user interaction with Gizmo */
  59316. colliderMeshes: Mesh[];
  59317. /** Material used to inicate color of gizmo mesh */
  59318. material: StandardMaterial;
  59319. /** Material used to inicate hover state of the Gizmo */
  59320. hoverMaterial: StandardMaterial;
  59321. /** Material used to inicate disabled state of the Gizmo */
  59322. disableMaterial: StandardMaterial;
  59323. /** Used to indicate Active state of the Gizmo */
  59324. active: boolean;
  59325. }
  59326. /**
  59327. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  59328. */
  59329. export class Gizmo implements IDisposable {
  59330. /** The utility layer the gizmo will be added to */
  59331. gizmoLayer: UtilityLayerRenderer;
  59332. /**
  59333. * The root mesh of the gizmo
  59334. */
  59335. _rootMesh: Mesh;
  59336. private _attachedMesh;
  59337. private _attachedNode;
  59338. /**
  59339. * Ratio for the scale of the gizmo (Default: 1)
  59340. */
  59341. protected _scaleRatio: number;
  59342. /**
  59343. * boolean updated by pointermove when a gizmo mesh is hovered
  59344. */
  59345. protected _isHovered: boolean;
  59346. /**
  59347. * Ratio for the scale of the gizmo (Default: 1)
  59348. */
  59349. set scaleRatio(value: number);
  59350. get scaleRatio(): number;
  59351. /**
  59352. * True when the mouse pointer is hovered a gizmo mesh
  59353. */
  59354. get isHovered(): boolean;
  59355. /**
  59356. * If a custom mesh has been set (Default: false)
  59357. */
  59358. protected _customMeshSet: boolean;
  59359. /**
  59360. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  59361. * * When set, interactions will be enabled
  59362. */
  59363. get attachedMesh(): Nullable<AbstractMesh>;
  59364. set attachedMesh(value: Nullable<AbstractMesh>);
  59365. /**
  59366. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  59367. * * When set, interactions will be enabled
  59368. */
  59369. get attachedNode(): Nullable<Node>;
  59370. set attachedNode(value: Nullable<Node>);
  59371. /**
  59372. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59373. * @param mesh The mesh to replace the default mesh of the gizmo
  59374. */
  59375. setCustomMesh(mesh: Mesh): void;
  59376. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  59377. /**
  59378. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  59379. */
  59380. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59381. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59382. /**
  59383. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  59384. */
  59385. updateGizmoPositionToMatchAttachedMesh: boolean;
  59386. /**
  59387. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  59388. */
  59389. updateScale: boolean;
  59390. protected _interactionsEnabled: boolean;
  59391. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59392. private _beforeRenderObserver;
  59393. private _tempQuaternion;
  59394. private _tempVector;
  59395. private _tempVector2;
  59396. private _tempMatrix1;
  59397. private _tempMatrix2;
  59398. private _rightHandtoLeftHandMatrix;
  59399. /**
  59400. * Creates a gizmo
  59401. * @param gizmoLayer The utility layer the gizmo will be added to
  59402. */
  59403. constructor(
  59404. /** The utility layer the gizmo will be added to */
  59405. gizmoLayer?: UtilityLayerRenderer);
  59406. /**
  59407. * Updates the gizmo to match the attached mesh's position/rotation
  59408. */
  59409. protected _update(): void;
  59410. /**
  59411. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  59412. * @param value Node, TransformNode or mesh
  59413. */
  59414. protected _matrixChanged(): void;
  59415. /**
  59416. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  59417. * @param gizmoLayer The utility layer the gizmo will be added to
  59418. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59419. * @returns {Observer<PointerInfo>} pointerObserver
  59420. */
  59421. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  59422. /**
  59423. * Disposes of the gizmo
  59424. */
  59425. dispose(): void;
  59426. }
  59427. }
  59428. declare module "babylonjs/Gizmos/planeDragGizmo" {
  59429. import { Observable } from "babylonjs/Misc/observable";
  59430. import { Nullable } from "babylonjs/types";
  59431. import { Vector3 } from "babylonjs/Maths/math.vector";
  59432. import { Color3 } from "babylonjs/Maths/math.color";
  59433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59434. import { Node } from "babylonjs/node";
  59435. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59436. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59437. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59438. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59439. import { Scene } from "babylonjs/scene";
  59440. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59441. /**
  59442. * Single plane drag gizmo
  59443. */
  59444. export class PlaneDragGizmo extends Gizmo {
  59445. /**
  59446. * Drag behavior responsible for the gizmos dragging interactions
  59447. */
  59448. dragBehavior: PointerDragBehavior;
  59449. private _pointerObserver;
  59450. /**
  59451. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59452. */
  59453. snapDistance: number;
  59454. /**
  59455. * Event that fires each time the gizmo snaps to a new location.
  59456. * * snapDistance is the the change in distance
  59457. */
  59458. onSnapObservable: Observable<{
  59459. snapDistance: number;
  59460. }>;
  59461. private _gizmoMesh;
  59462. private _coloredMaterial;
  59463. private _hoverMaterial;
  59464. private _disableMaterial;
  59465. private _isEnabled;
  59466. private _parent;
  59467. private _dragging;
  59468. /** @hidden */
  59469. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  59470. /**
  59471. * Creates a PlaneDragGizmo
  59472. * @param gizmoLayer The utility layer the gizmo will be added to
  59473. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  59474. * @param color The color of the gizmo
  59475. */
  59476. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  59477. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59478. /**
  59479. * If the gizmo is enabled
  59480. */
  59481. set isEnabled(value: boolean);
  59482. get isEnabled(): boolean;
  59483. /**
  59484. * Disposes of the gizmo
  59485. */
  59486. dispose(): void;
  59487. }
  59488. }
  59489. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59490. import { Observable } from "babylonjs/Misc/observable";
  59491. import { Nullable } from "babylonjs/types";
  59492. import { Vector3 } from "babylonjs/Maths/math.vector";
  59493. import { Color3 } from "babylonjs/Maths/math.color";
  59494. import "babylonjs/Meshes/Builders/linesBuilder";
  59495. import { Node } from "babylonjs/node";
  59496. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59497. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59498. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59499. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59500. /**
  59501. * Single plane rotation gizmo
  59502. */
  59503. export class PlaneRotationGizmo extends Gizmo {
  59504. /**
  59505. * Drag behavior responsible for the gizmos dragging interactions
  59506. */
  59507. dragBehavior: PointerDragBehavior;
  59508. private _pointerObserver;
  59509. /**
  59510. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59511. */
  59512. snapDistance: number;
  59513. /**
  59514. * Event that fires each time the gizmo snaps to a new location.
  59515. * * snapDistance is the the change in distance
  59516. */
  59517. onSnapObservable: Observable<{
  59518. snapDistance: number;
  59519. }>;
  59520. private _isEnabled;
  59521. private _parent;
  59522. private _coloredMaterial;
  59523. private _hoverMaterial;
  59524. private _disableMaterial;
  59525. private _gizmoMesh;
  59526. private _rotationCircle;
  59527. private _dragging;
  59528. private static _CircleConstants;
  59529. /**
  59530. * Creates a PlaneRotationGizmo
  59531. * @param gizmoLayer The utility layer the gizmo will be added to
  59532. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59533. * @param color The color of the gizmo
  59534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59536. * @param thickness display gizmo axis thickness
  59537. */
  59538. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59539. /** Create Geometry for Gizmo */
  59540. private _createGizmoMesh;
  59541. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59542. private setupRotationCircle;
  59543. private updateRotationPath;
  59544. private updateRotationCircle;
  59545. /**
  59546. * If the gizmo is enabled
  59547. */
  59548. set isEnabled(value: boolean);
  59549. get isEnabled(): boolean;
  59550. /**
  59551. * Disposes of the gizmo
  59552. */
  59553. dispose(): void;
  59554. }
  59555. }
  59556. declare module "babylonjs/Gizmos/rotationGizmo" {
  59557. import { Observable } from "babylonjs/Misc/observable";
  59558. import { Nullable } from "babylonjs/types";
  59559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59560. import { Mesh } from "babylonjs/Meshes/mesh";
  59561. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59562. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59563. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59564. import { Node } from "babylonjs/node";
  59565. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59566. /**
  59567. * Gizmo that enables rotating a mesh along 3 axis
  59568. */
  59569. export class RotationGizmo extends Gizmo {
  59570. /**
  59571. * Internal gizmo used for interactions on the x axis
  59572. */
  59573. xGizmo: PlaneRotationGizmo;
  59574. /**
  59575. * Internal gizmo used for interactions on the y axis
  59576. */
  59577. yGizmo: PlaneRotationGizmo;
  59578. /**
  59579. * Internal gizmo used for interactions on the z axis
  59580. */
  59581. zGizmo: PlaneRotationGizmo;
  59582. /** Fires an event when any of it's sub gizmos are dragged */
  59583. onDragStartObservable: Observable<unknown>;
  59584. /** Fires an event when any of it's sub gizmos are released from dragging */
  59585. onDragEndObservable: Observable<unknown>;
  59586. private _meshAttached;
  59587. private _nodeAttached;
  59588. private _observables;
  59589. /** Node Caching for quick lookup */
  59590. private _gizmoAxisCache;
  59591. get attachedMesh(): Nullable<AbstractMesh>;
  59592. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59593. get attachedNode(): Nullable<Node>;
  59594. set attachedNode(node: Nullable<Node>);
  59595. protected _checkBillboardTransform(): void;
  59596. /**
  59597. * True when the mouse pointer is hovering a gizmo mesh
  59598. */
  59599. get isHovered(): boolean;
  59600. /**
  59601. * Creates a RotationGizmo
  59602. * @param gizmoLayer The utility layer the gizmo will be added to
  59603. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59604. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59605. * @param thickness display gizmo axis thickness
  59606. */
  59607. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  59608. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59609. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59610. /**
  59611. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59612. */
  59613. set snapDistance(value: number);
  59614. get snapDistance(): number;
  59615. /**
  59616. * Ratio for the scale of the gizmo (Default: 1)
  59617. */
  59618. set scaleRatio(value: number);
  59619. get scaleRatio(): number;
  59620. /**
  59621. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59622. * @param mesh Axis gizmo mesh
  59623. * @param cache Gizmo axis definition used for reactive gizmo UI
  59624. */
  59625. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59626. /**
  59627. * Disposes of the gizmo
  59628. */
  59629. dispose(): void;
  59630. /**
  59631. * CustomMeshes are not supported by this gizmo
  59632. * @param mesh The mesh to replace the default mesh of the gizmo
  59633. */
  59634. setCustomMesh(mesh: Mesh): void;
  59635. }
  59636. }
  59637. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59638. import { Scene } from "babylonjs/scene";
  59639. import { Vector4 } from "babylonjs/Maths/math.vector";
  59640. import { Color4 } from "babylonjs/Maths/math.color";
  59641. import { Mesh } from "babylonjs/Meshes/mesh";
  59642. import { Nullable } from "babylonjs/types";
  59643. /**
  59644. * Class containing static functions to help procedurally build meshes
  59645. */
  59646. export class PolyhedronBuilder {
  59647. /**
  59648. * Creates a polyhedron mesh
  59649. * * 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
  59650. * * The parameter `size` (positive float, default 1) sets the polygon size
  59651. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59652. * * 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`
  59653. * * 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
  59654. * * 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)`)
  59655. * * 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
  59656. * * 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
  59657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59660. * @param name defines the name of the mesh
  59661. * @param options defines the options used to create the mesh
  59662. * @param scene defines the hosting scene
  59663. * @returns the polyhedron mesh
  59664. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59665. */
  59666. static CreatePolyhedron(name: string, options: {
  59667. type?: number;
  59668. size?: number;
  59669. sizeX?: number;
  59670. sizeY?: number;
  59671. sizeZ?: number;
  59672. custom?: any;
  59673. faceUV?: Vector4[];
  59674. faceColors?: Color4[];
  59675. flat?: boolean;
  59676. updatable?: boolean;
  59677. sideOrientation?: number;
  59678. frontUVs?: Vector4;
  59679. backUVs?: Vector4;
  59680. }, scene?: Nullable<Scene>): Mesh;
  59681. }
  59682. }
  59683. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  59684. import { Nullable } from "babylonjs/types";
  59685. import { Scene } from "babylonjs/scene";
  59686. import { Vector4 } from "babylonjs/Maths/math.vector";
  59687. import { Color4 } from "babylonjs/Maths/math.color";
  59688. import { Mesh } from "babylonjs/Meshes/mesh";
  59689. /**
  59690. * Class containing static functions to help procedurally build meshes
  59691. */
  59692. export class BoxBuilder {
  59693. /**
  59694. * Creates a box mesh
  59695. * * The parameter `size` sets the size (float) of each box side (default 1)
  59696. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59697. * * 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)
  59698. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59702. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59703. * @param name defines the name of the mesh
  59704. * @param options defines the options used to create the mesh
  59705. * @param scene defines the hosting scene
  59706. * @returns the box mesh
  59707. */
  59708. static CreateBox(name: string, options: {
  59709. size?: number;
  59710. width?: number;
  59711. height?: number;
  59712. depth?: number;
  59713. faceUV?: Vector4[];
  59714. faceColors?: Color4[];
  59715. sideOrientation?: number;
  59716. frontUVs?: Vector4;
  59717. backUVs?: Vector4;
  59718. wrap?: boolean;
  59719. topBaseAt?: number;
  59720. bottomBaseAt?: number;
  59721. updatable?: boolean;
  59722. }, scene?: Nullable<Scene>): Mesh;
  59723. }
  59724. }
  59725. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59726. import { Observable } from "babylonjs/Misc/observable";
  59727. import { Nullable } from "babylonjs/types";
  59728. import { Vector3 } from "babylonjs/Maths/math.vector";
  59729. import { Node } from "babylonjs/node";
  59730. import { Mesh } from "babylonjs/Meshes/mesh";
  59731. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59732. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59733. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59734. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59735. import { Color3 } from "babylonjs/Maths/math.color";
  59736. /**
  59737. * Single axis scale gizmo
  59738. */
  59739. export class AxisScaleGizmo extends Gizmo {
  59740. /**
  59741. * Drag behavior responsible for the gizmos dragging interactions
  59742. */
  59743. dragBehavior: PointerDragBehavior;
  59744. private _pointerObserver;
  59745. /**
  59746. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59747. */
  59748. snapDistance: number;
  59749. /**
  59750. * Event that fires each time the gizmo snaps to a new location.
  59751. * * snapDistance is the the change in distance
  59752. */
  59753. onSnapObservable: Observable<{
  59754. snapDistance: number;
  59755. }>;
  59756. /**
  59757. * If the scaling operation should be done on all axis (default: false)
  59758. */
  59759. uniformScaling: boolean;
  59760. /**
  59761. * Custom sensitivity value for the drag strength
  59762. */
  59763. sensitivity: number;
  59764. private _isEnabled;
  59765. private _parent;
  59766. private _gizmoMesh;
  59767. private _coloredMaterial;
  59768. private _hoverMaterial;
  59769. private _disableMaterial;
  59770. private _dragging;
  59771. private _tmpVector;
  59772. private _tmpMatrix;
  59773. private _tmpMatrix2;
  59774. /**
  59775. * Creates an AxisScaleGizmo
  59776. * @param gizmoLayer The utility layer the gizmo will be added to
  59777. * @param dragAxis The axis which the gizmo will be able to scale on
  59778. * @param color The color of the gizmo
  59779. * @param thickness display gizmo axis thickness
  59780. */
  59781. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59782. /** Create Geometry for Gizmo */
  59783. private _createGizmoMesh;
  59784. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59785. /**
  59786. * If the gizmo is enabled
  59787. */
  59788. set isEnabled(value: boolean);
  59789. get isEnabled(): boolean;
  59790. /**
  59791. * Disposes of the gizmo
  59792. */
  59793. dispose(): void;
  59794. /**
  59795. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59796. * @param mesh The mesh to replace the default mesh of the gizmo
  59797. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59798. */
  59799. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59800. }
  59801. }
  59802. declare module "babylonjs/Gizmos/scaleGizmo" {
  59803. import { Observable } from "babylonjs/Misc/observable";
  59804. import { Nullable } from "babylonjs/types";
  59805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59806. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59807. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59808. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59809. import { Mesh } from "babylonjs/Meshes/mesh";
  59810. import { Node } from "babylonjs/node";
  59811. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59812. /**
  59813. * Gizmo that enables scaling a mesh along 3 axis
  59814. */
  59815. export class ScaleGizmo extends Gizmo {
  59816. /**
  59817. * Internal gizmo used for interactions on the x axis
  59818. */
  59819. xGizmo: AxisScaleGizmo;
  59820. /**
  59821. * Internal gizmo used for interactions on the y axis
  59822. */
  59823. yGizmo: AxisScaleGizmo;
  59824. /**
  59825. * Internal gizmo used for interactions on the z axis
  59826. */
  59827. zGizmo: AxisScaleGizmo;
  59828. /**
  59829. * Internal gizmo used to scale all axis equally
  59830. */
  59831. uniformScaleGizmo: AxisScaleGizmo;
  59832. private _meshAttached;
  59833. private _nodeAttached;
  59834. private _snapDistance;
  59835. private _uniformScalingMesh;
  59836. private _octahedron;
  59837. private _sensitivity;
  59838. private _coloredMaterial;
  59839. private _hoverMaterial;
  59840. private _disableMaterial;
  59841. private _observables;
  59842. /** Node Caching for quick lookup */
  59843. private _gizmoAxisCache;
  59844. /** Fires an event when any of it's sub gizmos are dragged */
  59845. onDragStartObservable: Observable<unknown>;
  59846. /** Fires an event when any of it's sub gizmos are released from dragging */
  59847. onDragEndObservable: Observable<unknown>;
  59848. get attachedMesh(): Nullable<AbstractMesh>;
  59849. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59850. get attachedNode(): Nullable<Node>;
  59851. set attachedNode(node: Nullable<Node>);
  59852. /**
  59853. * True when the mouse pointer is hovering a gizmo mesh
  59854. */
  59855. get isHovered(): boolean;
  59856. /**
  59857. * Creates a ScaleGizmo
  59858. * @param gizmoLayer The utility layer the gizmo will be added to
  59859. * @param thickness display gizmo axis thickness
  59860. */
  59861. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59862. /** Create Geometry for Gizmo */
  59863. private _createUniformScaleMesh;
  59864. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59865. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59866. /**
  59867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59868. */
  59869. set snapDistance(value: number);
  59870. get snapDistance(): number;
  59871. /**
  59872. * Ratio for the scale of the gizmo (Default: 1)
  59873. */
  59874. set scaleRatio(value: number);
  59875. get scaleRatio(): number;
  59876. /**
  59877. * Sensitivity factor for dragging (Default: 1)
  59878. */
  59879. set sensitivity(value: number);
  59880. get sensitivity(): number;
  59881. /**
  59882. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59883. * @param mesh Axis gizmo mesh
  59884. * @param cache Gizmo axis definition used for reactive gizmo UI
  59885. */
  59886. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59887. /**
  59888. * Disposes of the gizmo
  59889. */
  59890. dispose(): void;
  59891. }
  59892. }
  59893. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59894. import { Observable } from "babylonjs/Misc/observable";
  59895. import { Nullable } from "babylonjs/types";
  59896. import { Vector3 } from "babylonjs/Maths/math.vector";
  59897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59898. import { Mesh } from "babylonjs/Meshes/mesh";
  59899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59901. import { Color3 } from "babylonjs/Maths/math.color";
  59902. import "babylonjs/Meshes/Builders/boxBuilder";
  59903. /**
  59904. * Bounding box gizmo
  59905. */
  59906. export class BoundingBoxGizmo extends Gizmo {
  59907. private _lineBoundingBox;
  59908. private _rotateSpheresParent;
  59909. private _scaleBoxesParent;
  59910. private _boundingDimensions;
  59911. private _renderObserver;
  59912. private _pointerObserver;
  59913. private _scaleDragSpeed;
  59914. private _tmpQuaternion;
  59915. private _tmpVector;
  59916. private _tmpRotationMatrix;
  59917. /**
  59918. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  59919. */
  59920. ignoreChildren: boolean;
  59921. /**
  59922. * 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)
  59923. */
  59924. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59925. /**
  59926. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59927. */
  59928. rotationSphereSize: number;
  59929. /**
  59930. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59931. */
  59932. scaleBoxSize: number;
  59933. /**
  59934. * 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)
  59935. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59936. */
  59937. fixedDragMeshScreenSize: boolean;
  59938. /**
  59939. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  59940. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59941. */
  59942. fixedDragMeshBoundsSize: boolean;
  59943. /**
  59944. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59945. */
  59946. fixedDragMeshScreenSizeDistanceFactor: number;
  59947. /**
  59948. * Fired when a rotation sphere or scale box is dragged
  59949. */
  59950. onDragStartObservable: Observable<{}>;
  59951. /**
  59952. * Fired when a scale box is dragged
  59953. */
  59954. onScaleBoxDragObservable: Observable<{}>;
  59955. /**
  59956. * Fired when a scale box drag is ended
  59957. */
  59958. onScaleBoxDragEndObservable: Observable<{}>;
  59959. /**
  59960. * Fired when a rotation sphere is dragged
  59961. */
  59962. onRotationSphereDragObservable: Observable<{}>;
  59963. /**
  59964. * Fired when a rotation sphere drag is ended
  59965. */
  59966. onRotationSphereDragEndObservable: Observable<{}>;
  59967. /**
  59968. * 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)
  59969. */
  59970. scalePivot: Nullable<Vector3>;
  59971. /**
  59972. * Mesh used as a pivot to rotate the attached node
  59973. */
  59974. private _anchorMesh;
  59975. private _existingMeshScale;
  59976. private _dragMesh;
  59977. private pointerDragBehavior;
  59978. private coloredMaterial;
  59979. private hoverColoredMaterial;
  59980. /**
  59981. * Sets the color of the bounding box gizmo
  59982. * @param color the color to set
  59983. */
  59984. setColor(color: Color3): void;
  59985. /**
  59986. * Creates an BoundingBoxGizmo
  59987. * @param gizmoLayer The utility layer the gizmo will be added to
  59988. * @param color The color of the gizmo
  59989. */
  59990. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59991. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59992. private _selectNode;
  59993. /**
  59994. * Updates the bounding box information for the Gizmo
  59995. */
  59996. updateBoundingBox(): void;
  59997. private _updateRotationSpheres;
  59998. private _updateScaleBoxes;
  59999. /**
  60000. * Enables rotation on the specified axis and disables rotation on the others
  60001. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  60002. */
  60003. setEnabledRotationAxis(axis: string): void;
  60004. /**
  60005. * Enables/disables scaling
  60006. * @param enable if scaling should be enabled
  60007. * @param homogeneousScaling defines if scaling should only be homogeneous
  60008. */
  60009. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  60010. private _updateDummy;
  60011. /**
  60012. * Enables a pointer drag behavior on the bounding box of the gizmo
  60013. */
  60014. enableDragBehavior(): void;
  60015. /**
  60016. * Disposes of the gizmo
  60017. */
  60018. dispose(): void;
  60019. /**
  60020. * 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)
  60021. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  60022. * @returns the bounding box mesh with the passed in mesh as a child
  60023. */
  60024. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  60025. /**
  60026. * CustomMeshes are not supported by this gizmo
  60027. * @param mesh The mesh to replace the default mesh of the gizmo
  60028. */
  60029. setCustomMesh(mesh: Mesh): void;
  60030. }
  60031. }
  60032. declare module "babylonjs/Gizmos/gizmoManager" {
  60033. import { Observable } from "babylonjs/Misc/observable";
  60034. import { Nullable } from "babylonjs/types";
  60035. import { Scene, IDisposable } from "babylonjs/scene";
  60036. import { Node } from "babylonjs/node";
  60037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60038. import { Mesh } from "babylonjs/Meshes/mesh";
  60039. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60040. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  60041. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60042. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  60043. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60044. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  60045. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  60046. /**
  60047. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  60048. */
  60049. export class GizmoManager implements IDisposable {
  60050. private scene;
  60051. /**
  60052. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  60053. */
  60054. gizmos: {
  60055. positionGizmo: Nullable<PositionGizmo>;
  60056. rotationGizmo: Nullable<RotationGizmo>;
  60057. scaleGizmo: Nullable<ScaleGizmo>;
  60058. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  60059. };
  60060. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  60061. clearGizmoOnEmptyPointerEvent: boolean;
  60062. /** Fires an event when the manager is attached to a mesh */
  60063. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  60064. /** Fires an event when the manager is attached to a node */
  60065. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  60066. private _gizmosEnabled;
  60067. private _pointerObservers;
  60068. private _attachedMesh;
  60069. private _attachedNode;
  60070. private _boundingBoxColor;
  60071. private _defaultUtilityLayer;
  60072. private _defaultKeepDepthUtilityLayer;
  60073. private _thickness;
  60074. /** Node Caching for quick lookup */
  60075. private _gizmoAxisCache;
  60076. /**
  60077. * When bounding box gizmo is enabled, this can be used to track drag/end events
  60078. */
  60079. boundingBoxDragBehavior: SixDofDragBehavior;
  60080. /**
  60081. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  60082. */
  60083. attachableMeshes: Nullable<Array<AbstractMesh>>;
  60084. /**
  60085. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  60086. */
  60087. attachableNodes: Nullable<Array<Node>>;
  60088. /**
  60089. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  60090. */
  60091. usePointerToAttachGizmos: boolean;
  60092. /**
  60093. * Utility layer that the bounding box gizmo belongs to
  60094. */
  60095. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  60096. /**
  60097. * Utility layer that all gizmos besides bounding box belong to
  60098. */
  60099. get utilityLayer(): UtilityLayerRenderer;
  60100. /**
  60101. * True when the mouse pointer is hovering a gizmo mesh
  60102. */
  60103. get isHovered(): boolean;
  60104. /**
  60105. * Instatiates a gizmo manager
  60106. * @param scene the scene to overlay the gizmos on top of
  60107. * @param thickness display gizmo axis thickness
  60108. * @param utilityLayer the layer where gizmos are rendered
  60109. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  60110. */
  60111. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  60112. /**
  60113. * Subscribes to pointer down events, for attaching and detaching mesh
  60114. * @param scene The sceme layer the observer will be added to
  60115. */
  60116. private _attachToMeshPointerObserver;
  60117. /**
  60118. * Attaches a set of gizmos to the specified mesh
  60119. * @param mesh The mesh the gizmo's should be attached to
  60120. */
  60121. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60122. /**
  60123. * Attaches a set of gizmos to the specified node
  60124. * @param node The node the gizmo's should be attached to
  60125. */
  60126. attachToNode(node: Nullable<Node>): void;
  60127. /**
  60128. * If the position gizmo is enabled
  60129. */
  60130. set positionGizmoEnabled(value: boolean);
  60131. get positionGizmoEnabled(): boolean;
  60132. /**
  60133. * If the rotation gizmo is enabled
  60134. */
  60135. set rotationGizmoEnabled(value: boolean);
  60136. get rotationGizmoEnabled(): boolean;
  60137. /**
  60138. * If the scale gizmo is enabled
  60139. */
  60140. set scaleGizmoEnabled(value: boolean);
  60141. get scaleGizmoEnabled(): boolean;
  60142. /**
  60143. * If the boundingBox gizmo is enabled
  60144. */
  60145. set boundingBoxGizmoEnabled(value: boolean);
  60146. get boundingBoxGizmoEnabled(): boolean;
  60147. /**
  60148. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60149. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  60150. */
  60151. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  60152. /**
  60153. * Disposes of the gizmo manager
  60154. */
  60155. dispose(): void;
  60156. }
  60157. }
  60158. declare module "babylonjs/Gizmos/positionGizmo" {
  60159. import { Observable } from "babylonjs/Misc/observable";
  60160. import { Nullable } from "babylonjs/types";
  60161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60162. import { Node } from "babylonjs/node";
  60163. import { Mesh } from "babylonjs/Meshes/mesh";
  60164. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60165. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  60166. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  60167. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60168. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  60169. /**
  60170. * Gizmo that enables dragging a mesh along 3 axis
  60171. */
  60172. export class PositionGizmo extends Gizmo {
  60173. /**
  60174. * Internal gizmo used for interactions on the x axis
  60175. */
  60176. xGizmo: AxisDragGizmo;
  60177. /**
  60178. * Internal gizmo used for interactions on the y axis
  60179. */
  60180. yGizmo: AxisDragGizmo;
  60181. /**
  60182. * Internal gizmo used for interactions on the z axis
  60183. */
  60184. zGizmo: AxisDragGizmo;
  60185. /**
  60186. * Internal gizmo used for interactions on the yz plane
  60187. */
  60188. xPlaneGizmo: PlaneDragGizmo;
  60189. /**
  60190. * Internal gizmo used for interactions on the xz plane
  60191. */
  60192. yPlaneGizmo: PlaneDragGizmo;
  60193. /**
  60194. * Internal gizmo used for interactions on the xy plane
  60195. */
  60196. zPlaneGizmo: PlaneDragGizmo;
  60197. /**
  60198. * private variables
  60199. */
  60200. private _meshAttached;
  60201. private _nodeAttached;
  60202. private _snapDistance;
  60203. private _observables;
  60204. /** Node Caching for quick lookup */
  60205. private _gizmoAxisCache;
  60206. /** Fires an event when any of it's sub gizmos are dragged */
  60207. onDragStartObservable: Observable<unknown>;
  60208. /** Fires an event when any of it's sub gizmos are released from dragging */
  60209. onDragEndObservable: Observable<unknown>;
  60210. /**
  60211. * If set to true, planar drag is enabled
  60212. */
  60213. private _planarGizmoEnabled;
  60214. get attachedMesh(): Nullable<AbstractMesh>;
  60215. set attachedMesh(mesh: Nullable<AbstractMesh>);
  60216. get attachedNode(): Nullable<Node>;
  60217. set attachedNode(node: Nullable<Node>);
  60218. /**
  60219. * True when the mouse pointer is hovering a gizmo mesh
  60220. */
  60221. get isHovered(): boolean;
  60222. /**
  60223. * Creates a PositionGizmo
  60224. * @param gizmoLayer The utility layer the gizmo will be added to
  60225. @param thickness display gizmo axis thickness
  60226. */
  60227. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  60228. /**
  60229. * If the planar drag gizmo is enabled
  60230. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  60231. */
  60232. set planarGizmoEnabled(value: boolean);
  60233. get planarGizmoEnabled(): boolean;
  60234. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60235. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60236. /**
  60237. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60238. */
  60239. set snapDistance(value: number);
  60240. get snapDistance(): number;
  60241. /**
  60242. * Ratio for the scale of the gizmo (Default: 1)
  60243. */
  60244. set scaleRatio(value: number);
  60245. get scaleRatio(): number;
  60246. /**
  60247. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60248. * @param mesh Axis gizmo mesh
  60249. * @param cache Gizmo axis definition used for reactive gizmo UI
  60250. */
  60251. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60252. /**
  60253. * Disposes of the gizmo
  60254. */
  60255. dispose(): void;
  60256. /**
  60257. * CustomMeshes are not supported by this gizmo
  60258. * @param mesh The mesh to replace the default mesh of the gizmo
  60259. */
  60260. setCustomMesh(mesh: Mesh): void;
  60261. }
  60262. }
  60263. declare module "babylonjs/Gizmos/axisDragGizmo" {
  60264. import { Observable } from "babylonjs/Misc/observable";
  60265. import { Nullable } from "babylonjs/types";
  60266. import { Vector3 } from "babylonjs/Maths/math.vector";
  60267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60268. import { Node } from "babylonjs/node";
  60269. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60270. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60271. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60272. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60273. import { Scene } from "babylonjs/scene";
  60274. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60275. import { Color3 } from "babylonjs/Maths/math.color";
  60276. /**
  60277. * Single axis drag gizmo
  60278. */
  60279. export class AxisDragGizmo extends Gizmo {
  60280. /**
  60281. * Drag behavior responsible for the gizmos dragging interactions
  60282. */
  60283. dragBehavior: PointerDragBehavior;
  60284. private _pointerObserver;
  60285. /**
  60286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60287. */
  60288. snapDistance: number;
  60289. /**
  60290. * Event that fires each time the gizmo snaps to a new location.
  60291. * * snapDistance is the the change in distance
  60292. */
  60293. onSnapObservable: Observable<{
  60294. snapDistance: number;
  60295. }>;
  60296. private _isEnabled;
  60297. private _parent;
  60298. private _gizmoMesh;
  60299. private _coloredMaterial;
  60300. private _hoverMaterial;
  60301. private _disableMaterial;
  60302. private _dragging;
  60303. /** @hidden */
  60304. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  60305. /** @hidden */
  60306. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  60307. /**
  60308. * Creates an AxisDragGizmo
  60309. * @param gizmoLayer The utility layer the gizmo will be added to
  60310. * @param dragAxis The axis which the gizmo will be able to drag on
  60311. * @param color The color of the gizmo
  60312. * @param thickness display gizmo axis thickness
  60313. */
  60314. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  60315. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60316. /**
  60317. * If the gizmo is enabled
  60318. */
  60319. set isEnabled(value: boolean);
  60320. get isEnabled(): boolean;
  60321. /**
  60322. * Disposes of the gizmo
  60323. */
  60324. dispose(): void;
  60325. }
  60326. }
  60327. declare module "babylonjs/Debug/axesViewer" {
  60328. import { Vector3 } from "babylonjs/Maths/math.vector";
  60329. import { Nullable } from "babylonjs/types";
  60330. import { Scene } from "babylonjs/scene";
  60331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60332. /**
  60333. * The Axes viewer will show 3 axes in a specific point in space
  60334. */
  60335. export class AxesViewer {
  60336. private _xAxis;
  60337. private _yAxis;
  60338. private _zAxis;
  60339. private _scaleLinesFactor;
  60340. private _instanced;
  60341. /**
  60342. * Gets the hosting scene
  60343. */
  60344. scene: Nullable<Scene>;
  60345. /**
  60346. * Gets or sets a number used to scale line length
  60347. */
  60348. scaleLines: number;
  60349. /** Gets the node hierarchy used to render x-axis */
  60350. get xAxis(): TransformNode;
  60351. /** Gets the node hierarchy used to render y-axis */
  60352. get yAxis(): TransformNode;
  60353. /** Gets the node hierarchy used to render z-axis */
  60354. get zAxis(): TransformNode;
  60355. /**
  60356. * Creates a new AxesViewer
  60357. * @param scene defines the hosting scene
  60358. * @param scaleLines defines a number used to scale line length (1 by default)
  60359. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  60360. * @param xAxis defines the node hierarchy used to render the x-axis
  60361. * @param yAxis defines the node hierarchy used to render the y-axis
  60362. * @param zAxis defines the node hierarchy used to render the z-axis
  60363. */
  60364. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  60365. /**
  60366. * Force the viewer to update
  60367. * @param position defines the position of the viewer
  60368. * @param xaxis defines the x axis of the viewer
  60369. * @param yaxis defines the y axis of the viewer
  60370. * @param zaxis defines the z axis of the viewer
  60371. */
  60372. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  60373. /**
  60374. * Creates an instance of this axes viewer.
  60375. * @returns a new axes viewer with instanced meshes
  60376. */
  60377. createInstance(): AxesViewer;
  60378. /** Releases resources */
  60379. dispose(): void;
  60380. private static _SetRenderingGroupId;
  60381. }
  60382. }
  60383. declare module "babylonjs/Debug/boneAxesViewer" {
  60384. import { Nullable } from "babylonjs/types";
  60385. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  60386. import { Vector3 } from "babylonjs/Maths/math.vector";
  60387. import { Mesh } from "babylonjs/Meshes/mesh";
  60388. import { Bone } from "babylonjs/Bones/bone";
  60389. import { Scene } from "babylonjs/scene";
  60390. /**
  60391. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  60392. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  60393. */
  60394. export class BoneAxesViewer extends AxesViewer {
  60395. /**
  60396. * Gets or sets the target mesh where to display the axes viewer
  60397. */
  60398. mesh: Nullable<Mesh>;
  60399. /**
  60400. * Gets or sets the target bone where to display the axes viewer
  60401. */
  60402. bone: Nullable<Bone>;
  60403. /** Gets current position */
  60404. pos: Vector3;
  60405. /** Gets direction of X axis */
  60406. xaxis: Vector3;
  60407. /** Gets direction of Y axis */
  60408. yaxis: Vector3;
  60409. /** Gets direction of Z axis */
  60410. zaxis: Vector3;
  60411. /**
  60412. * Creates a new BoneAxesViewer
  60413. * @param scene defines the hosting scene
  60414. * @param bone defines the target bone
  60415. * @param mesh defines the target mesh
  60416. * @param scaleLines defines a scaling factor for line length (1 by default)
  60417. */
  60418. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  60419. /**
  60420. * Force the viewer to update
  60421. */
  60422. update(): void;
  60423. /** Releases resources */
  60424. dispose(): void;
  60425. }
  60426. }
  60427. declare module "babylonjs/Debug/debugLayer" {
  60428. import { Scene } from "babylonjs/scene";
  60429. /**
  60430. * Interface used to define scene explorer extensibility option
  60431. */
  60432. export interface IExplorerExtensibilityOption {
  60433. /**
  60434. * Define the option label
  60435. */
  60436. label: string;
  60437. /**
  60438. * Defines the action to execute on click
  60439. */
  60440. action: (entity: any) => void;
  60441. }
  60442. /**
  60443. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  60444. */
  60445. export interface IExplorerExtensibilityGroup {
  60446. /**
  60447. * Defines a predicate to test if a given type mut be extended
  60448. */
  60449. predicate: (entity: any) => boolean;
  60450. /**
  60451. * Gets the list of options added to a type
  60452. */
  60453. entries: IExplorerExtensibilityOption[];
  60454. }
  60455. /**
  60456. * Interface used to define the options to use to create the Inspector
  60457. */
  60458. export interface IInspectorOptions {
  60459. /**
  60460. * Display in overlay mode (default: false)
  60461. */
  60462. overlay?: boolean;
  60463. /**
  60464. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  60465. */
  60466. globalRoot?: HTMLElement;
  60467. /**
  60468. * Display the Scene explorer
  60469. */
  60470. showExplorer?: boolean;
  60471. /**
  60472. * Display the property inspector
  60473. */
  60474. showInspector?: boolean;
  60475. /**
  60476. * Display in embed mode (both panes on the right)
  60477. */
  60478. embedMode?: boolean;
  60479. /**
  60480. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  60481. */
  60482. handleResize?: boolean;
  60483. /**
  60484. * Allow the panes to popup (default: true)
  60485. */
  60486. enablePopup?: boolean;
  60487. /**
  60488. * Allow the panes to be closed by users (default: true)
  60489. */
  60490. enableClose?: boolean;
  60491. /**
  60492. * Optional list of extensibility entries
  60493. */
  60494. explorerExtensibility?: IExplorerExtensibilityGroup[];
  60495. /**
  60496. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  60497. */
  60498. inspectorURL?: string;
  60499. /**
  60500. * Optional initial tab (default to DebugLayerTab.Properties)
  60501. */
  60502. initialTab?: DebugLayerTab;
  60503. }
  60504. module "babylonjs/scene" {
  60505. interface Scene {
  60506. /**
  60507. * @hidden
  60508. * Backing field
  60509. */
  60510. _debugLayer: DebugLayer;
  60511. /**
  60512. * Gets the debug layer (aka Inspector) associated with the scene
  60513. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60514. */
  60515. debugLayer: DebugLayer;
  60516. }
  60517. }
  60518. /**
  60519. * Enum of inspector action tab
  60520. */
  60521. export enum DebugLayerTab {
  60522. /**
  60523. * Properties tag (default)
  60524. */
  60525. Properties = 0,
  60526. /**
  60527. * Debug tab
  60528. */
  60529. Debug = 1,
  60530. /**
  60531. * Statistics tab
  60532. */
  60533. Statistics = 2,
  60534. /**
  60535. * Tools tab
  60536. */
  60537. Tools = 3,
  60538. /**
  60539. * Settings tab
  60540. */
  60541. Settings = 4
  60542. }
  60543. /**
  60544. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60545. * what is happening in your scene
  60546. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60547. */
  60548. export class DebugLayer {
  60549. /**
  60550. * Define the url to get the inspector script from.
  60551. * By default it uses the babylonjs CDN.
  60552. * @ignoreNaming
  60553. */
  60554. static InspectorURL: string;
  60555. private _scene;
  60556. private BJSINSPECTOR;
  60557. private _onPropertyChangedObservable?;
  60558. /**
  60559. * Observable triggered when a property is changed through the inspector.
  60560. */
  60561. get onPropertyChangedObservable(): any;
  60562. /**
  60563. * Instantiates a new debug layer.
  60564. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60565. * what is happening in your scene
  60566. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60567. * @param scene Defines the scene to inspect
  60568. */
  60569. constructor(scene: Scene);
  60570. /** Creates the inspector window. */
  60571. private _createInspector;
  60572. /**
  60573. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  60574. * @param entity defines the entity to select
  60575. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  60576. */
  60577. select(entity: any, lineContainerTitles?: string | string[]): void;
  60578. /** Get the inspector from bundle or global */
  60579. private _getGlobalInspector;
  60580. /**
  60581. * Get if the inspector is visible or not.
  60582. * @returns true if visible otherwise, false
  60583. */
  60584. isVisible(): boolean;
  60585. /**
  60586. * Hide the inspector and close its window.
  60587. */
  60588. hide(): void;
  60589. /**
  60590. * Update the scene in the inspector
  60591. */
  60592. setAsActiveScene(): void;
  60593. /**
  60594. * Launch the debugLayer.
  60595. * @param config Define the configuration of the inspector
  60596. * @return a promise fulfilled when the debug layer is visible
  60597. */
  60598. show(config?: IInspectorOptions): Promise<DebugLayer>;
  60599. }
  60600. }
  60601. declare module "babylonjs/Debug/physicsViewer" {
  60602. import { Nullable } from "babylonjs/types";
  60603. import { Scene } from "babylonjs/scene";
  60604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60605. import { Mesh } from "babylonjs/Meshes/mesh";
  60606. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60607. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60608. /**
  60609. * Used to show the physics impostor around the specific mesh
  60610. */
  60611. export class PhysicsViewer {
  60612. /** @hidden */
  60613. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  60614. /** @hidden */
  60615. protected _meshes: Array<Nullable<AbstractMesh>>;
  60616. /** @hidden */
  60617. protected _scene: Nullable<Scene>;
  60618. /** @hidden */
  60619. protected _numMeshes: number;
  60620. /** @hidden */
  60621. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  60622. private _renderFunction;
  60623. private _utilityLayer;
  60624. private _debugBoxMesh;
  60625. private _debugSphereMesh;
  60626. private _debugCylinderMesh;
  60627. private _debugMaterial;
  60628. private _debugMeshMeshes;
  60629. /**
  60630. * Creates a new PhysicsViewer
  60631. * @param scene defines the hosting scene
  60632. */
  60633. constructor(scene: Scene);
  60634. /** @hidden */
  60635. protected _updateDebugMeshes(): void;
  60636. /**
  60637. * Renders a specified physic impostor
  60638. * @param impostor defines the impostor to render
  60639. * @param targetMesh defines the mesh represented by the impostor
  60640. * @returns the new debug mesh used to render the impostor
  60641. */
  60642. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  60643. /**
  60644. * Hides a specified physic impostor
  60645. * @param impostor defines the impostor to hide
  60646. */
  60647. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  60648. private _getDebugMaterial;
  60649. private _getDebugBoxMesh;
  60650. private _getDebugSphereMesh;
  60651. private _getDebugCylinderMesh;
  60652. private _getDebugMeshMesh;
  60653. private _getDebugMesh;
  60654. /** Releases all resources */
  60655. dispose(): void;
  60656. }
  60657. }
  60658. declare module "babylonjs/Debug/rayHelper" {
  60659. import { Nullable } from "babylonjs/types";
  60660. import { Ray } from "babylonjs/Culling/ray";
  60661. import { Vector3 } from "babylonjs/Maths/math.vector";
  60662. import { Color3 } from "babylonjs/Maths/math.color";
  60663. import { Scene } from "babylonjs/scene";
  60664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60665. import "babylonjs/Meshes/Builders/linesBuilder";
  60666. /**
  60667. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60668. * in order to better appreciate the issue one might have.
  60669. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60670. */
  60671. export class RayHelper {
  60672. /**
  60673. * Defines the ray we are currently tryin to visualize.
  60674. */
  60675. ray: Nullable<Ray>;
  60676. private _renderPoints;
  60677. private _renderLine;
  60678. private _renderFunction;
  60679. private _scene;
  60680. private _onAfterRenderObserver;
  60681. private _onAfterStepObserver;
  60682. private _attachedToMesh;
  60683. private _meshSpaceDirection;
  60684. private _meshSpaceOrigin;
  60685. /**
  60686. * Helper function to create a colored helper in a scene in one line.
  60687. * @param ray Defines the ray we are currently tryin to visualize
  60688. * @param scene Defines the scene the ray is used in
  60689. * @param color Defines the color we want to see the ray in
  60690. * @returns The newly created ray helper.
  60691. */
  60692. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  60693. /**
  60694. * Instantiate a new ray helper.
  60695. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60696. * in order to better appreciate the issue one might have.
  60697. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60698. * @param ray Defines the ray we are currently tryin to visualize
  60699. */
  60700. constructor(ray: Ray);
  60701. /**
  60702. * Shows the ray we are willing to debug.
  60703. * @param scene Defines the scene the ray needs to be rendered in
  60704. * @param color Defines the color the ray needs to be rendered in
  60705. */
  60706. show(scene: Scene, color?: Color3): void;
  60707. /**
  60708. * Hides the ray we are debugging.
  60709. */
  60710. hide(): void;
  60711. private _render;
  60712. /**
  60713. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  60714. * @param mesh Defines the mesh we want the helper attached to
  60715. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  60716. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  60717. * @param length Defines the length of the ray
  60718. */
  60719. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  60720. /**
  60721. * Detach the ray helper from the mesh it has previously been attached to.
  60722. */
  60723. detachFromMesh(): void;
  60724. private _updateToMesh;
  60725. /**
  60726. * Dispose the helper and release its associated resources.
  60727. */
  60728. dispose(): void;
  60729. }
  60730. }
  60731. declare module "babylonjs/Debug/ISkeletonViewer" {
  60732. import { Skeleton } from "babylonjs/Bones/skeleton";
  60733. import { Color3 } from "babylonjs/Maths/math.color";
  60734. /**
  60735. * Defines the options associated with the creation of a SkeletonViewer.
  60736. */
  60737. export interface ISkeletonViewerOptions {
  60738. /** Should the system pause animations before building the Viewer? */
  60739. pauseAnimations: boolean;
  60740. /** Should the system return the skeleton to rest before building? */
  60741. returnToRest: boolean;
  60742. /** public Display Mode of the Viewer */
  60743. displayMode: number;
  60744. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60745. displayOptions: ISkeletonViewerDisplayOptions;
  60746. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60747. computeBonesUsingShaders: boolean;
  60748. /** Flag ignore non weighted bones */
  60749. useAllBones: boolean;
  60750. }
  60751. /**
  60752. * Defines how to display the various bone meshes for the viewer.
  60753. */
  60754. export interface ISkeletonViewerDisplayOptions {
  60755. /** How far down to start tapering the bone spurs */
  60756. midStep?: number;
  60757. /** How big is the midStep? */
  60758. midStepFactor?: number;
  60759. /** Base for the Sphere Size */
  60760. sphereBaseSize?: number;
  60761. /** The ratio of the sphere to the longest bone in units */
  60762. sphereScaleUnit?: number;
  60763. /** Ratio for the Sphere Size */
  60764. sphereFactor?: number;
  60765. /** Whether a spur should attach its far end to the child bone position */
  60766. spurFollowsChild?: boolean;
  60767. /** Whether to show local axes or not */
  60768. showLocalAxes?: boolean;
  60769. /** Length of each local axis */
  60770. localAxesSize?: number;
  60771. }
  60772. /**
  60773. * Defines the constructor options for the BoneWeight Shader.
  60774. */
  60775. export interface IBoneWeightShaderOptions {
  60776. /** Skeleton to Map */
  60777. skeleton: Skeleton;
  60778. /** Colors for Uninfluenced bones */
  60779. colorBase?: Color3;
  60780. /** Colors for 0.0-0.25 Weight bones */
  60781. colorZero?: Color3;
  60782. /** Color for 0.25-0.5 Weight Influence */
  60783. colorQuarter?: Color3;
  60784. /** Color for 0.5-0.75 Weight Influence */
  60785. colorHalf?: Color3;
  60786. /** Color for 0.75-1 Weight Influence */
  60787. colorFull?: Color3;
  60788. /** Color for Zero Weight Influence */
  60789. targetBoneIndex?: number;
  60790. }
  60791. /**
  60792. * Simple structure of the gradient steps for the Color Map.
  60793. */
  60794. export interface ISkeletonMapShaderColorMapKnot {
  60795. /** Color of the Knot */
  60796. color: Color3;
  60797. /** Location of the Knot */
  60798. location: number;
  60799. }
  60800. /**
  60801. * Defines the constructor options for the SkeletonMap Shader.
  60802. */
  60803. export interface ISkeletonMapShaderOptions {
  60804. /** Skeleton to Map */
  60805. skeleton: Skeleton;
  60806. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  60807. colorMap?: ISkeletonMapShaderColorMapKnot[];
  60808. }
  60809. }
  60810. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  60811. import { Nullable } from "babylonjs/types";
  60812. import { Scene } from "babylonjs/scene";
  60813. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  60814. import { Color4 } from "babylonjs/Maths/math.color";
  60815. import { Mesh } from "babylonjs/Meshes/mesh";
  60816. /**
  60817. * Class containing static functions to help procedurally build meshes
  60818. */
  60819. export class RibbonBuilder {
  60820. /**
  60821. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60822. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60823. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60824. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60825. * * 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
  60826. * * 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
  60827. * * 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
  60828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60831. * * 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
  60832. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60833. * * 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
  60834. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60836. * @param name defines the name of the mesh
  60837. * @param options defines the options used to create the mesh
  60838. * @param scene defines the hosting scene
  60839. * @returns the ribbon mesh
  60840. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60842. */
  60843. static CreateRibbon(name: string, options: {
  60844. pathArray: Vector3[][];
  60845. closeArray?: boolean;
  60846. closePath?: boolean;
  60847. offset?: number;
  60848. updatable?: boolean;
  60849. sideOrientation?: number;
  60850. frontUVs?: Vector4;
  60851. backUVs?: Vector4;
  60852. instance?: Mesh;
  60853. invertUV?: boolean;
  60854. uvs?: Vector2[];
  60855. colors?: Color4[];
  60856. }, scene?: Nullable<Scene>): Mesh;
  60857. }
  60858. }
  60859. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  60860. import { Nullable } from "babylonjs/types";
  60861. import { Scene } from "babylonjs/scene";
  60862. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60863. import { Mesh } from "babylonjs/Meshes/mesh";
  60864. /**
  60865. * Class containing static functions to help procedurally build meshes
  60866. */
  60867. export class ShapeBuilder {
  60868. /**
  60869. * 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.
  60870. * * 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.
  60871. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60872. * * 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.
  60873. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60874. * * 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
  60875. * * 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
  60876. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60879. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60881. * @param name defines the name of the mesh
  60882. * @param options defines the options used to create the mesh
  60883. * @param scene defines the hosting scene
  60884. * @returns the extruded shape mesh
  60885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60887. */
  60888. static ExtrudeShape(name: string, options: {
  60889. shape: Vector3[];
  60890. path: Vector3[];
  60891. scale?: number;
  60892. rotation?: number;
  60893. cap?: number;
  60894. updatable?: boolean;
  60895. sideOrientation?: number;
  60896. frontUVs?: Vector4;
  60897. backUVs?: Vector4;
  60898. instance?: Mesh;
  60899. invertUV?: boolean;
  60900. }, scene?: Nullable<Scene>): Mesh;
  60901. /**
  60902. * Creates an custom extruded shape mesh.
  60903. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60904. * * 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.
  60905. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60906. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  60907. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60908. * * 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
  60909. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60910. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60911. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60912. * * 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
  60913. * * 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
  60914. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60919. * @param name defines the name of the mesh
  60920. * @param options defines the options used to create the mesh
  60921. * @param scene defines the hosting scene
  60922. * @returns the custom extruded shape mesh
  60923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60924. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60926. */
  60927. static ExtrudeShapeCustom(name: string, options: {
  60928. shape: Vector3[];
  60929. path: Vector3[];
  60930. scaleFunction?: any;
  60931. rotationFunction?: any;
  60932. ribbonCloseArray?: boolean;
  60933. ribbonClosePath?: boolean;
  60934. cap?: number;
  60935. updatable?: boolean;
  60936. sideOrientation?: number;
  60937. frontUVs?: Vector4;
  60938. backUVs?: Vector4;
  60939. instance?: Mesh;
  60940. invertUV?: boolean;
  60941. }, scene?: Nullable<Scene>): Mesh;
  60942. private static _ExtrudeShapeGeneric;
  60943. }
  60944. }
  60945. declare module "babylonjs/Debug/skeletonViewer" {
  60946. import { Color3 } from "babylonjs/Maths/math.color";
  60947. import { Scene } from "babylonjs/scene";
  60948. import { Nullable } from "babylonjs/types";
  60949. import { Skeleton } from "babylonjs/Bones/skeleton";
  60950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60951. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60952. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60953. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  60954. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  60955. /**
  60956. * Class used to render a debug view of a given skeleton
  60957. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  60958. */
  60959. export class SkeletonViewer {
  60960. /** defines the skeleton to render */
  60961. skeleton: Skeleton;
  60962. /** defines the mesh attached to the skeleton */
  60963. mesh: AbstractMesh;
  60964. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  60965. autoUpdateBonesMatrices: boolean;
  60966. /** defines the rendering group id to use with the viewer */
  60967. renderingGroupId: number;
  60968. /** is the options for the viewer */
  60969. options: Partial<ISkeletonViewerOptions>;
  60970. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  60971. static readonly DISPLAY_LINES: number;
  60972. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  60973. static readonly DISPLAY_SPHERES: number;
  60974. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  60975. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  60976. /** public static method to create a BoneWeight Shader
  60977. * @param options The constructor options
  60978. * @param scene The scene that the shader is scoped to
  60979. * @returns The created ShaderMaterial
  60980. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  60981. */
  60982. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  60983. /** public static method to create a BoneWeight Shader
  60984. * @param options The constructor options
  60985. * @param scene The scene that the shader is scoped to
  60986. * @returns The created ShaderMaterial
  60987. */
  60988. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  60989. /** private static method to create a BoneWeight Shader
  60990. * @param size The size of the buffer to create (usually the bone count)
  60991. * @param colorMap The gradient data to generate
  60992. * @param scene The scene that the shader is scoped to
  60993. * @returns an Array of floats from the color gradient values
  60994. */
  60995. private static _CreateBoneMapColorBuffer;
  60996. /** If SkeletonViewer scene scope. */
  60997. private _scene;
  60998. /** Gets or sets the color used to render the skeleton */
  60999. color: Color3;
  61000. /** Array of the points of the skeleton fo the line view. */
  61001. private _debugLines;
  61002. /** The SkeletonViewers Mesh. */
  61003. private _debugMesh;
  61004. /** The local axes Meshes. */
  61005. private _localAxes;
  61006. /** If SkeletonViewer is enabled. */
  61007. private _isEnabled;
  61008. /** If SkeletonViewer is ready. */
  61009. private _ready;
  61010. /** SkeletonViewer render observable. */
  61011. private _obs;
  61012. /** The Utility Layer to render the gizmos in. */
  61013. private _utilityLayer;
  61014. private _boneIndices;
  61015. /** Gets the Scene. */
  61016. get scene(): Scene;
  61017. /** Gets the utilityLayer. */
  61018. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  61019. /** Checks Ready Status. */
  61020. get isReady(): Boolean;
  61021. /** Sets Ready Status. */
  61022. set ready(value: boolean);
  61023. /** Gets the debugMesh */
  61024. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  61025. /** Sets the debugMesh */
  61026. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  61027. /** Gets the displayMode */
  61028. get displayMode(): number;
  61029. /** Sets the displayMode */
  61030. set displayMode(value: number);
  61031. /**
  61032. * Creates a new SkeletonViewer
  61033. * @param skeleton defines the skeleton to render
  61034. * @param mesh defines the mesh attached to the skeleton
  61035. * @param scene defines the hosting scene
  61036. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  61037. * @param renderingGroupId defines the rendering group id to use with the viewer
  61038. * @param options All of the extra constructor options for the SkeletonViewer
  61039. */
  61040. constructor(
  61041. /** defines the skeleton to render */
  61042. skeleton: Skeleton,
  61043. /** defines the mesh attached to the skeleton */
  61044. mesh: AbstractMesh,
  61045. /** The Scene scope*/
  61046. scene: Scene,
  61047. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  61048. autoUpdateBonesMatrices?: boolean,
  61049. /** defines the rendering group id to use with the viewer */
  61050. renderingGroupId?: number,
  61051. /** is the options for the viewer */
  61052. options?: Partial<ISkeletonViewerOptions>);
  61053. /** The Dynamic bindings for the update functions */
  61054. private _bindObs;
  61055. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  61056. update(): void;
  61057. /** Gets or sets a boolean indicating if the viewer is enabled */
  61058. set isEnabled(value: boolean);
  61059. get isEnabled(): boolean;
  61060. private _getBonePosition;
  61061. private _getLinesForBonesWithLength;
  61062. private _getLinesForBonesNoLength;
  61063. /** function to revert the mesh and scene back to the initial state. */
  61064. private _revert;
  61065. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  61066. private _getAbsoluteBindPoseToRef;
  61067. /** function to build and bind sphere joint points and spur bone representations. */
  61068. private _buildSpheresAndSpurs;
  61069. private _buildLocalAxes;
  61070. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  61071. private _displayLinesUpdate;
  61072. /** Changes the displayMode of the skeleton viewer
  61073. * @param mode The displayMode numerical value
  61074. */
  61075. changeDisplayMode(mode: number): void;
  61076. /** Sets a display option of the skeleton viewer
  61077. *
  61078. * | Option | Type | Default | Description |
  61079. * | ---------------- | ------- | ------- | ----------- |
  61080. * | 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`. |
  61081. * | 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`. |
  61082. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61083. * | 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`. |
  61084. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  61085. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  61086. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  61087. *
  61088. * @param option String of the option name
  61089. * @param value The numerical option value
  61090. */
  61091. changeDisplayOptions(option: string, value: number): void;
  61092. /** Release associated resources */
  61093. dispose(): void;
  61094. }
  61095. }
  61096. declare module "babylonjs/Debug/index" {
  61097. export * from "babylonjs/Debug/axesViewer";
  61098. export * from "babylonjs/Debug/boneAxesViewer";
  61099. export * from "babylonjs/Debug/debugLayer";
  61100. export * from "babylonjs/Debug/physicsViewer";
  61101. export * from "babylonjs/Debug/rayHelper";
  61102. export * from "babylonjs/Debug/skeletonViewer";
  61103. export * from "babylonjs/Debug/ISkeletonViewer";
  61104. }
  61105. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  61106. /**
  61107. * Enum for Device Types
  61108. */
  61109. export enum DeviceType {
  61110. /** Generic */
  61111. Generic = 0,
  61112. /** Keyboard */
  61113. Keyboard = 1,
  61114. /** Mouse */
  61115. Mouse = 2,
  61116. /** Touch Pointers */
  61117. Touch = 3,
  61118. /** PS4 Dual Shock */
  61119. DualShock = 4,
  61120. /** Xbox */
  61121. Xbox = 5,
  61122. /** Switch Controller */
  61123. Switch = 6
  61124. }
  61125. /**
  61126. * Enum for All Pointers (Touch/Mouse)
  61127. */
  61128. export enum PointerInput {
  61129. /** Horizontal Axis */
  61130. Horizontal = 0,
  61131. /** Vertical Axis */
  61132. Vertical = 1,
  61133. /** Left Click or Touch */
  61134. LeftClick = 2,
  61135. /** Middle Click */
  61136. MiddleClick = 3,
  61137. /** Right Click */
  61138. RightClick = 4,
  61139. /** Browser Back */
  61140. BrowserBack = 5,
  61141. /** Browser Forward */
  61142. BrowserForward = 6
  61143. }
  61144. /**
  61145. * Enum for Dual Shock Gamepad
  61146. */
  61147. export enum DualShockInput {
  61148. /** Cross */
  61149. Cross = 0,
  61150. /** Circle */
  61151. Circle = 1,
  61152. /** Square */
  61153. Square = 2,
  61154. /** Triangle */
  61155. Triangle = 3,
  61156. /** L1 */
  61157. L1 = 4,
  61158. /** R1 */
  61159. R1 = 5,
  61160. /** L2 */
  61161. L2 = 6,
  61162. /** R2 */
  61163. R2 = 7,
  61164. /** Share */
  61165. Share = 8,
  61166. /** Options */
  61167. Options = 9,
  61168. /** L3 */
  61169. L3 = 10,
  61170. /** R3 */
  61171. R3 = 11,
  61172. /** DPadUp */
  61173. DPadUp = 12,
  61174. /** DPadDown */
  61175. DPadDown = 13,
  61176. /** DPadLeft */
  61177. DPadLeft = 14,
  61178. /** DRight */
  61179. DPadRight = 15,
  61180. /** Home */
  61181. Home = 16,
  61182. /** TouchPad */
  61183. TouchPad = 17,
  61184. /** LStickXAxis */
  61185. LStickXAxis = 18,
  61186. /** LStickYAxis */
  61187. LStickYAxis = 19,
  61188. /** RStickXAxis */
  61189. RStickXAxis = 20,
  61190. /** RStickYAxis */
  61191. RStickYAxis = 21
  61192. }
  61193. /**
  61194. * Enum for Xbox Gamepad
  61195. */
  61196. export enum XboxInput {
  61197. /** A */
  61198. A = 0,
  61199. /** B */
  61200. B = 1,
  61201. /** X */
  61202. X = 2,
  61203. /** Y */
  61204. Y = 3,
  61205. /** LB */
  61206. LB = 4,
  61207. /** RB */
  61208. RB = 5,
  61209. /** LT */
  61210. LT = 6,
  61211. /** RT */
  61212. RT = 7,
  61213. /** Back */
  61214. Back = 8,
  61215. /** Start */
  61216. Start = 9,
  61217. /** LS */
  61218. LS = 10,
  61219. /** RS */
  61220. RS = 11,
  61221. /** DPadUp */
  61222. DPadUp = 12,
  61223. /** DPadDown */
  61224. DPadDown = 13,
  61225. /** DPadLeft */
  61226. DPadLeft = 14,
  61227. /** DRight */
  61228. DPadRight = 15,
  61229. /** Home */
  61230. Home = 16,
  61231. /** LStickXAxis */
  61232. LStickXAxis = 17,
  61233. /** LStickYAxis */
  61234. LStickYAxis = 18,
  61235. /** RStickXAxis */
  61236. RStickXAxis = 19,
  61237. /** RStickYAxis */
  61238. RStickYAxis = 20
  61239. }
  61240. /**
  61241. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  61242. */
  61243. export enum SwitchInput {
  61244. /** B */
  61245. B = 0,
  61246. /** A */
  61247. A = 1,
  61248. /** Y */
  61249. Y = 2,
  61250. /** X */
  61251. X = 3,
  61252. /** L */
  61253. L = 4,
  61254. /** R */
  61255. R = 5,
  61256. /** ZL */
  61257. ZL = 6,
  61258. /** ZR */
  61259. ZR = 7,
  61260. /** Minus */
  61261. Minus = 8,
  61262. /** Plus */
  61263. Plus = 9,
  61264. /** LS */
  61265. LS = 10,
  61266. /** RS */
  61267. RS = 11,
  61268. /** DPadUp */
  61269. DPadUp = 12,
  61270. /** DPadDown */
  61271. DPadDown = 13,
  61272. /** DPadLeft */
  61273. DPadLeft = 14,
  61274. /** DRight */
  61275. DPadRight = 15,
  61276. /** Home */
  61277. Home = 16,
  61278. /** Capture */
  61279. Capture = 17,
  61280. /** LStickXAxis */
  61281. LStickXAxis = 18,
  61282. /** LStickYAxis */
  61283. LStickYAxis = 19,
  61284. /** RStickXAxis */
  61285. RStickXAxis = 20,
  61286. /** RStickYAxis */
  61287. RStickYAxis = 21
  61288. }
  61289. }
  61290. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  61291. import { Engine } from "babylonjs/Engines/engine";
  61292. import { IDisposable } from "babylonjs/scene";
  61293. import { Nullable } from "babylonjs/types";
  61294. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61295. /**
  61296. * This class will take all inputs from Keyboard, Pointer, and
  61297. * any Gamepads and provide a polling system that all devices
  61298. * will use. This class assumes that there will only be one
  61299. * pointer device and one keyboard.
  61300. */
  61301. export class DeviceInputSystem implements IDisposable {
  61302. /**
  61303. * Returns onDeviceConnected callback property
  61304. * @returns Callback with function to execute when a device is connected
  61305. */
  61306. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  61307. /**
  61308. * Sets callback function when a device is connected and executes against all connected devices
  61309. * @param callback Function to execute when a device is connected
  61310. */
  61311. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  61312. /**
  61313. * Callback to be triggered when a device is disconnected
  61314. */
  61315. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  61316. /**
  61317. * Callback to be triggered when event driven input is updated
  61318. */
  61319. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  61320. private _inputs;
  61321. private _gamepads;
  61322. private _keyboardActive;
  61323. private _pointerActive;
  61324. private _elementToAttachTo;
  61325. private _keyboardDownEvent;
  61326. private _keyboardUpEvent;
  61327. private _pointerMoveEvent;
  61328. private _pointerDownEvent;
  61329. private _pointerUpEvent;
  61330. private _gamepadConnectedEvent;
  61331. private _gamepadDisconnectedEvent;
  61332. private _onDeviceConnected;
  61333. private static _MAX_KEYCODES;
  61334. private static _MAX_POINTER_INPUTS;
  61335. private constructor();
  61336. /**
  61337. * Creates a new DeviceInputSystem instance
  61338. * @param engine Engine to pull input element from
  61339. * @returns The new instance
  61340. */
  61341. static Create(engine: Engine): DeviceInputSystem;
  61342. /**
  61343. * Checks for current device input value, given an id and input index
  61344. * @param deviceName Id of connected device
  61345. * @param inputIndex Index of device input
  61346. * @returns Current value of input
  61347. */
  61348. /**
  61349. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  61350. * @param deviceType Enum specifiying device type
  61351. * @param deviceSlot "Slot" or index that device is referenced in
  61352. * @param inputIndex Id of input to be checked
  61353. * @returns Current value of input
  61354. */
  61355. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  61356. /**
  61357. * Dispose of all the eventlisteners
  61358. */
  61359. dispose(): void;
  61360. /**
  61361. * Checks for existing connections to devices and register them, if necessary
  61362. * Currently handles gamepads and mouse
  61363. */
  61364. private _checkForConnectedDevices;
  61365. /**
  61366. * Add a gamepad to the DeviceInputSystem
  61367. * @param gamepad A single DOM Gamepad object
  61368. */
  61369. private _addGamePad;
  61370. /**
  61371. * Add pointer device to DeviceInputSystem
  61372. * @param deviceType Type of Pointer to add
  61373. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  61374. * @param currentX Current X at point of adding
  61375. * @param currentY Current Y at point of adding
  61376. */
  61377. private _addPointerDevice;
  61378. /**
  61379. * Add device and inputs to device array
  61380. * @param deviceType Enum specifiying device type
  61381. * @param deviceSlot "Slot" or index that device is referenced in
  61382. * @param numberOfInputs Number of input entries to create for given device
  61383. */
  61384. private _registerDevice;
  61385. /**
  61386. * Given a specific device name, remove that device from the device map
  61387. * @param deviceType Enum specifiying device type
  61388. * @param deviceSlot "Slot" or index that device is referenced in
  61389. */
  61390. private _unregisterDevice;
  61391. /**
  61392. * Handle all actions that come from keyboard interaction
  61393. */
  61394. private _handleKeyActions;
  61395. /**
  61396. * Handle all actions that come from pointer interaction
  61397. */
  61398. private _handlePointerActions;
  61399. /**
  61400. * Handle all actions that come from gamepad interaction
  61401. */
  61402. private _handleGamepadActions;
  61403. /**
  61404. * Update all non-event based devices with each frame
  61405. * @param deviceType Enum specifiying device type
  61406. * @param deviceSlot "Slot" or index that device is referenced in
  61407. * @param inputIndex Id of input to be checked
  61408. */
  61409. private _updateDevice;
  61410. /**
  61411. * Gets DeviceType from the device name
  61412. * @param deviceName Name of Device from DeviceInputSystem
  61413. * @returns DeviceType enum value
  61414. */
  61415. private _getGamepadDeviceType;
  61416. }
  61417. }
  61418. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  61419. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61420. /**
  61421. * Type to handle enforcement of inputs
  61422. */
  61423. 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;
  61424. }
  61425. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  61426. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  61427. import { Engine } from "babylonjs/Engines/engine";
  61428. import { IDisposable } from "babylonjs/scene";
  61429. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61430. import { Nullable } from "babylonjs/types";
  61431. import { Observable } from "babylonjs/Misc/observable";
  61432. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61433. /**
  61434. * Class that handles all input for a specific device
  61435. */
  61436. export class DeviceSource<T extends DeviceType> {
  61437. /** Type of device */
  61438. readonly deviceType: DeviceType;
  61439. /** "Slot" or index that device is referenced in */
  61440. readonly deviceSlot: number;
  61441. /**
  61442. * Observable to handle device input changes per device
  61443. */
  61444. readonly onInputChangedObservable: Observable<{
  61445. inputIndex: DeviceInput<T>;
  61446. previousState: Nullable<number>;
  61447. currentState: Nullable<number>;
  61448. }>;
  61449. private readonly _deviceInputSystem;
  61450. /**
  61451. * Default Constructor
  61452. * @param deviceInputSystem Reference to DeviceInputSystem
  61453. * @param deviceType Type of device
  61454. * @param deviceSlot "Slot" or index that device is referenced in
  61455. */
  61456. constructor(deviceInputSystem: DeviceInputSystem,
  61457. /** Type of device */
  61458. deviceType: DeviceType,
  61459. /** "Slot" or index that device is referenced in */
  61460. deviceSlot?: number);
  61461. /**
  61462. * Get input for specific input
  61463. * @param inputIndex index of specific input on device
  61464. * @returns Input value from DeviceInputSystem
  61465. */
  61466. getInput(inputIndex: DeviceInput<T>): number;
  61467. }
  61468. /**
  61469. * Class to keep track of devices
  61470. */
  61471. export class DeviceSourceManager implements IDisposable {
  61472. /**
  61473. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  61474. */
  61475. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  61476. /**
  61477. * Observable to be triggered when after a device is disconnected
  61478. */
  61479. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  61480. private readonly _devices;
  61481. private readonly _firstDevice;
  61482. private readonly _deviceInputSystem;
  61483. /**
  61484. * Default Constructor
  61485. * @param engine engine to pull input element from
  61486. */
  61487. constructor(engine: Engine);
  61488. /**
  61489. * Gets a DeviceSource, given a type and slot
  61490. * @param deviceType Enum specifying device type
  61491. * @param deviceSlot "Slot" or index that device is referenced in
  61492. * @returns DeviceSource object
  61493. */
  61494. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  61495. /**
  61496. * Gets an array of DeviceSource objects for a given device type
  61497. * @param deviceType Enum specifying device type
  61498. * @returns Array of DeviceSource objects
  61499. */
  61500. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  61501. /**
  61502. * Returns a read-only list of all available devices
  61503. * @returns Read-only array with active devices
  61504. */
  61505. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  61506. /**
  61507. * Dispose of DeviceInputSystem and other parts
  61508. */
  61509. dispose(): void;
  61510. /**
  61511. * Function to add device name to device list
  61512. * @param deviceType Enum specifying device type
  61513. * @param deviceSlot "Slot" or index that device is referenced in
  61514. */
  61515. private _addDevice;
  61516. /**
  61517. * Function to remove device name to device list
  61518. * @param deviceType Enum specifying device type
  61519. * @param deviceSlot "Slot" or index that device is referenced in
  61520. */
  61521. private _removeDevice;
  61522. /**
  61523. * Updates array storing first connected device of each type
  61524. * @param type Type of Device
  61525. */
  61526. private _updateFirstDevices;
  61527. }
  61528. }
  61529. declare module "babylonjs/DeviceInput/index" {
  61530. export * from "babylonjs/DeviceInput/deviceInputSystem";
  61531. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61532. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61533. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61534. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61535. }
  61536. declare module "babylonjs/Engines/nullEngine" {
  61537. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  61538. import { Engine } from "babylonjs/Engines/engine";
  61539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  61540. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  61541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61542. import { Effect } from "babylonjs/Materials/effect";
  61543. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  61544. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61545. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  61546. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  61547. /**
  61548. * Options to create the null engine
  61549. */
  61550. export class NullEngineOptions {
  61551. /**
  61552. * Render width (Default: 512)
  61553. */
  61554. renderWidth: number;
  61555. /**
  61556. * Render height (Default: 256)
  61557. */
  61558. renderHeight: number;
  61559. /**
  61560. * Texture size (Default: 512)
  61561. */
  61562. textureSize: number;
  61563. /**
  61564. * If delta time between frames should be constant
  61565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61566. */
  61567. deterministicLockstep: boolean;
  61568. /**
  61569. * Maximum about of steps between frames (Default: 4)
  61570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61571. */
  61572. lockstepMaxSteps: number;
  61573. /**
  61574. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  61575. */
  61576. useHighPrecisionMatrix?: boolean;
  61577. }
  61578. /**
  61579. * The null engine class provides support for headless version of babylon.js.
  61580. * This can be used in server side scenario or for testing purposes
  61581. */
  61582. export class NullEngine extends Engine {
  61583. private _options;
  61584. /**
  61585. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  61586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61587. * @returns true if engine is in deterministic lock step mode
  61588. */
  61589. isDeterministicLockStep(): boolean;
  61590. /**
  61591. * Gets the max steps when engine is running in deterministic lock step
  61592. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61593. * @returns the max steps
  61594. */
  61595. getLockstepMaxSteps(): number;
  61596. /**
  61597. * Gets the current hardware scaling level.
  61598. * By default the hardware scaling level is computed from the window device ratio.
  61599. * 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.
  61600. * @returns a number indicating the current hardware scaling level
  61601. */
  61602. getHardwareScalingLevel(): number;
  61603. constructor(options?: NullEngineOptions);
  61604. /**
  61605. * Creates a vertex buffer
  61606. * @param vertices the data for the vertex buffer
  61607. * @returns the new WebGL static buffer
  61608. */
  61609. createVertexBuffer(vertices: FloatArray): DataBuffer;
  61610. /**
  61611. * Creates a new index buffer
  61612. * @param indices defines the content of the index buffer
  61613. * @param updatable defines if the index buffer must be updatable
  61614. * @returns a new webGL buffer
  61615. */
  61616. createIndexBuffer(indices: IndicesArray): DataBuffer;
  61617. /**
  61618. * Clear the current render buffer or the current render target (if any is set up)
  61619. * @param color defines the color to use
  61620. * @param backBuffer defines if the back buffer must be cleared
  61621. * @param depth defines if the depth buffer must be cleared
  61622. * @param stencil defines if the stencil buffer must be cleared
  61623. */
  61624. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  61625. /**
  61626. * Gets the current render width
  61627. * @param useScreen defines if screen size must be used (or the current render target if any)
  61628. * @returns a number defining the current render width
  61629. */
  61630. getRenderWidth(useScreen?: boolean): number;
  61631. /**
  61632. * Gets the current render height
  61633. * @param useScreen defines if screen size must be used (or the current render target if any)
  61634. * @returns a number defining the current render height
  61635. */
  61636. getRenderHeight(useScreen?: boolean): number;
  61637. /**
  61638. * Set the WebGL's viewport
  61639. * @param viewport defines the viewport element to be used
  61640. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  61641. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  61642. */
  61643. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61644. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  61645. /**
  61646. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  61647. * @param pipelineContext defines the pipeline context to use
  61648. * @param uniformsNames defines the list of uniform names
  61649. * @returns an array of webGL uniform locations
  61650. */
  61651. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  61652. /**
  61653. * Gets the lsit of active attributes for a given webGL program
  61654. * @param pipelineContext defines the pipeline context to use
  61655. * @param attributesNames defines the list of attribute names to get
  61656. * @returns an array of indices indicating the offset of each attribute
  61657. */
  61658. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61659. /**
  61660. * Binds an effect to the webGL context
  61661. * @param effect defines the effect to bind
  61662. */
  61663. bindSamplers(effect: Effect): void;
  61664. /**
  61665. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  61666. * @param effect defines the effect to activate
  61667. */
  61668. enableEffect(effect: Effect): void;
  61669. /**
  61670. * Set various states to the webGL context
  61671. * @param culling defines backface culling state
  61672. * @param zOffset defines the value to apply to zOffset (0 by default)
  61673. * @param force defines if states must be applied even if cache is up to date
  61674. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  61675. */
  61676. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61677. /**
  61678. * Set the value of an uniform to an array of int32
  61679. * @param uniform defines the webGL uniform location where to store the value
  61680. * @param array defines the array of int32 to store
  61681. * @returns true if value was set
  61682. */
  61683. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61684. /**
  61685. * Set the value of an uniform to an array of int32 (stored as vec2)
  61686. * @param uniform defines the webGL uniform location where to store the value
  61687. * @param array defines the array of int32 to store
  61688. * @returns true if value was set
  61689. */
  61690. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61691. /**
  61692. * Set the value of an uniform to an array of int32 (stored as vec3)
  61693. * @param uniform defines the webGL uniform location where to store the value
  61694. * @param array defines the array of int32 to store
  61695. * @returns true if value was set
  61696. */
  61697. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61698. /**
  61699. * Set the value of an uniform to an array of int32 (stored as vec4)
  61700. * @param uniform defines the webGL uniform location where to store the value
  61701. * @param array defines the array of int32 to store
  61702. * @returns true if value was set
  61703. */
  61704. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61705. /**
  61706. * Set the value of an uniform to an array of float32
  61707. * @param uniform defines the webGL uniform location where to store the value
  61708. * @param array defines the array of float32 to store
  61709. * @returns true if value was set
  61710. */
  61711. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61712. /**
  61713. * Set the value of an uniform to an array of float32 (stored as vec2)
  61714. * @param uniform defines the webGL uniform location where to store the value
  61715. * @param array defines the array of float32 to store
  61716. * @returns true if value was set
  61717. */
  61718. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61719. /**
  61720. * Set the value of an uniform to an array of float32 (stored as vec3)
  61721. * @param uniform defines the webGL uniform location where to store the value
  61722. * @param array defines the array of float32 to store
  61723. * @returns true if value was set
  61724. */
  61725. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61726. /**
  61727. * Set the value of an uniform to an array of float32 (stored as vec4)
  61728. * @param uniform defines the webGL uniform location where to store the value
  61729. * @param array defines the array of float32 to store
  61730. * @returns true if value was set
  61731. */
  61732. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61733. /**
  61734. * Set the value of an uniform to an array of number
  61735. * @param uniform defines the webGL uniform location where to store the value
  61736. * @param array defines the array of number to store
  61737. * @returns true if value was set
  61738. */
  61739. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61740. /**
  61741. * Set the value of an uniform to an array of number (stored as vec2)
  61742. * @param uniform defines the webGL uniform location where to store the value
  61743. * @param array defines the array of number to store
  61744. * @returns true if value was set
  61745. */
  61746. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61747. /**
  61748. * Set the value of an uniform to an array of number (stored as vec3)
  61749. * @param uniform defines the webGL uniform location where to store the value
  61750. * @param array defines the array of number to store
  61751. * @returns true if value was set
  61752. */
  61753. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61754. /**
  61755. * Set the value of an uniform to an array of number (stored as vec4)
  61756. * @param uniform defines the webGL uniform location where to store the value
  61757. * @param array defines the array of number to store
  61758. * @returns true if value was set
  61759. */
  61760. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61761. /**
  61762. * Set the value of an uniform to an array of float32 (stored as matrices)
  61763. * @param uniform defines the webGL uniform location where to store the value
  61764. * @param matrices defines the array of float32 to store
  61765. * @returns true if value was set
  61766. */
  61767. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61768. /**
  61769. * Set the value of an uniform to a matrix (3x3)
  61770. * @param uniform defines the webGL uniform location where to store the value
  61771. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  61772. * @returns true if value was set
  61773. */
  61774. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61775. /**
  61776. * Set the value of an uniform to a matrix (2x2)
  61777. * @param uniform defines the webGL uniform location where to store the value
  61778. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  61779. * @returns true if value was set
  61780. */
  61781. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61782. /**
  61783. * Set the value of an uniform to a number (float)
  61784. * @param uniform defines the webGL uniform location where to store the value
  61785. * @param value defines the float number to store
  61786. * @returns true if value was set
  61787. */
  61788. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61789. /**
  61790. * Set the value of an uniform to a vec2
  61791. * @param uniform defines the webGL uniform location where to store the value
  61792. * @param x defines the 1st component of the value
  61793. * @param y defines the 2nd component of the value
  61794. * @returns true if value was set
  61795. */
  61796. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61797. /**
  61798. * Set the value of an uniform to a vec3
  61799. * @param uniform defines the webGL uniform location where to store the value
  61800. * @param x defines the 1st component of the value
  61801. * @param y defines the 2nd component of the value
  61802. * @param z defines the 3rd component of the value
  61803. * @returns true if value was set
  61804. */
  61805. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61806. /**
  61807. * Set the value of an uniform to a boolean
  61808. * @param uniform defines the webGL uniform location where to store the value
  61809. * @param bool defines the boolean to store
  61810. * @returns true if value was set
  61811. */
  61812. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  61813. /**
  61814. * Set the value of an uniform to a vec4
  61815. * @param uniform defines the webGL uniform location where to store the value
  61816. * @param x defines the 1st component of the value
  61817. * @param y defines the 2nd component of the value
  61818. * @param z defines the 3rd component of the value
  61819. * @param w defines the 4th component of the value
  61820. * @returns true if value was set
  61821. */
  61822. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61823. /**
  61824. * Sets the current alpha mode
  61825. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  61826. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61827. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61828. */
  61829. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61830. /**
  61831. * Bind webGl buffers directly to the webGL context
  61832. * @param vertexBuffers defines the vertex buffer to bind
  61833. * @param indexBuffer defines the index buffer to bind
  61834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  61835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  61836. * @param effect defines the effect associated with the vertex buffer
  61837. */
  61838. bindBuffers(vertexBuffers: {
  61839. [key: string]: VertexBuffer;
  61840. }, indexBuffer: DataBuffer, effect: Effect): void;
  61841. /**
  61842. * Force the entire cache to be cleared
  61843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  61844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  61845. */
  61846. wipeCaches(bruteForce?: boolean): void;
  61847. /**
  61848. * Send a draw order
  61849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  61850. * @param indexStart defines the starting index
  61851. * @param indexCount defines the number of index to draw
  61852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61853. */
  61854. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  61855. /**
  61856. * Draw a list of indexed primitives
  61857. * @param fillMode defines the primitive to use
  61858. * @param indexStart defines the starting index
  61859. * @param indexCount defines the number of index to draw
  61860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61861. */
  61862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61863. /**
  61864. * Draw a list of unindexed primitives
  61865. * @param fillMode defines the primitive to use
  61866. * @param verticesStart defines the index of first vertex to draw
  61867. * @param verticesCount defines the count of vertices to draw
  61868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61869. */
  61870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61871. /** @hidden */
  61872. protected _createTexture(): WebGLTexture;
  61873. /** @hidden */
  61874. _releaseTexture(texture: InternalTexture): void;
  61875. /**
  61876. * Usually called from Texture.ts.
  61877. * Passed information to create a WebGLTexture
  61878. * @param urlArg defines a value which contains one of the following:
  61879. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61880. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61881. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61883. * @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)
  61884. * @param scene needed for loading to the correct scene
  61885. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61886. * @param onLoad optional callback to be called upon successful completion
  61887. * @param onError optional callback to be called upon failure
  61888. * @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
  61889. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  61890. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  61891. * @param forcedExtension defines the extension to use to pick the right loader
  61892. * @param mimeType defines an optional mime type
  61893. * @returns a InternalTexture for assignment back into BABYLON.Texture
  61894. */
  61895. 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;
  61896. /**
  61897. * Creates a new render target texture
  61898. * @param size defines the size of the texture
  61899. * @param options defines the options used to create the texture
  61900. * @returns a new render target texture stored in an InternalTexture
  61901. */
  61902. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  61903. /**
  61904. * Update the sampling mode of a given texture
  61905. * @param samplingMode defines the required sampling mode
  61906. * @param texture defines the texture to update
  61907. */
  61908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  61909. /**
  61910. * Binds the frame buffer to the specified texture.
  61911. * @param texture The texture to render to or null for the default canvas
  61912. * @param faceIndex The face of the texture to render to in case of cube texture
  61913. * @param requiredWidth The width of the target to render to
  61914. * @param requiredHeight The height of the target to render to
  61915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  61916. * @param lodLevel defines le lod level to bind to the frame buffer
  61917. */
  61918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  61919. /**
  61920. * Unbind the current render target texture from the webGL context
  61921. * @param texture defines the render target texture to unbind
  61922. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  61923. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  61924. */
  61925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  61926. /**
  61927. * Creates a dynamic vertex buffer
  61928. * @param vertices the data for the dynamic vertex buffer
  61929. * @returns the new WebGL dynamic buffer
  61930. */
  61931. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  61932. /**
  61933. * Update the content of a dynamic texture
  61934. * @param texture defines the texture to update
  61935. * @param canvas defines the canvas containing the source
  61936. * @param invertY defines if data must be stored with Y axis inverted
  61937. * @param premulAlpha defines if alpha is stored as premultiplied
  61938. * @param format defines the format of the data
  61939. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  61940. */
  61941. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  61942. /**
  61943. * Gets a boolean indicating if all created effects are ready
  61944. * @returns true if all effects are ready
  61945. */
  61946. areAllEffectsReady(): boolean;
  61947. /**
  61948. * @hidden
  61949. * Get the current error code of the webGL context
  61950. * @returns the error code
  61951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  61952. */
  61953. getError(): number;
  61954. /** @hidden */
  61955. _getUnpackAlignement(): number;
  61956. /** @hidden */
  61957. _unpackFlipY(value: boolean): void;
  61958. /**
  61959. * Update a dynamic index buffer
  61960. * @param indexBuffer defines the target index buffer
  61961. * @param indices defines the data to update
  61962. * @param offset defines the offset in the target index buffer where update should start
  61963. */
  61964. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  61965. /**
  61966. * Updates a dynamic vertex buffer.
  61967. * @param vertexBuffer the vertex buffer to update
  61968. * @param vertices the data used to update the vertex buffer
  61969. * @param byteOffset the byte offset of the data (optional)
  61970. * @param byteLength the byte length of the data (optional)
  61971. */
  61972. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  61973. /** @hidden */
  61974. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  61975. /** @hidden */
  61976. _bindTexture(channel: number, texture: InternalTexture): void;
  61977. protected _deleteBuffer(buffer: WebGLBuffer): void;
  61978. /**
  61979. * 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
  61980. */
  61981. releaseEffects(): void;
  61982. displayLoadingUI(): void;
  61983. hideLoadingUI(): void;
  61984. /** @hidden */
  61985. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61986. /** @hidden */
  61987. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61988. /** @hidden */
  61989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61990. /** @hidden */
  61991. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  61992. }
  61993. }
  61994. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  61995. import { Nullable, int } from "babylonjs/types";
  61996. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  61997. /** @hidden */
  61998. export class _OcclusionDataStorage {
  61999. /** @hidden */
  62000. occlusionInternalRetryCounter: number;
  62001. /** @hidden */
  62002. isOcclusionQueryInProgress: boolean;
  62003. /** @hidden */
  62004. isOccluded: boolean;
  62005. /** @hidden */
  62006. occlusionRetryCount: number;
  62007. /** @hidden */
  62008. occlusionType: number;
  62009. /** @hidden */
  62010. occlusionQueryAlgorithmType: number;
  62011. }
  62012. module "babylonjs/Engines/engine" {
  62013. interface Engine {
  62014. /**
  62015. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  62016. * @return the new query
  62017. */
  62018. createQuery(): WebGLQuery;
  62019. /**
  62020. * Delete and release a webGL query
  62021. * @param query defines the query to delete
  62022. * @return the current engine
  62023. */
  62024. deleteQuery(query: WebGLQuery): Engine;
  62025. /**
  62026. * Check if a given query has resolved and got its value
  62027. * @param query defines the query to check
  62028. * @returns true if the query got its value
  62029. */
  62030. isQueryResultAvailable(query: WebGLQuery): boolean;
  62031. /**
  62032. * Gets the value of a given query
  62033. * @param query defines the query to check
  62034. * @returns the value of the query
  62035. */
  62036. getQueryResult(query: WebGLQuery): number;
  62037. /**
  62038. * Initiates an occlusion query
  62039. * @param algorithmType defines the algorithm to use
  62040. * @param query defines the query to use
  62041. * @returns the current engine
  62042. * @see https://doc.babylonjs.com/features/occlusionquery
  62043. */
  62044. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  62045. /**
  62046. * Ends an occlusion query
  62047. * @see https://doc.babylonjs.com/features/occlusionquery
  62048. * @param algorithmType defines the algorithm to use
  62049. * @returns the current engine
  62050. */
  62051. endOcclusionQuery(algorithmType: number): Engine;
  62052. /**
  62053. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  62054. * Please note that only one query can be issued at a time
  62055. * @returns a time token used to track the time span
  62056. */
  62057. startTimeQuery(): Nullable<_TimeToken>;
  62058. /**
  62059. * Ends a time query
  62060. * @param token defines the token used to measure the time span
  62061. * @returns the time spent (in ns)
  62062. */
  62063. endTimeQuery(token: _TimeToken): int;
  62064. /** @hidden */
  62065. _currentNonTimestampToken: Nullable<_TimeToken>;
  62066. /** @hidden */
  62067. _createTimeQuery(): WebGLQuery;
  62068. /** @hidden */
  62069. _deleteTimeQuery(query: WebGLQuery): void;
  62070. /** @hidden */
  62071. _getGlAlgorithmType(algorithmType: number): number;
  62072. /** @hidden */
  62073. _getTimeQueryResult(query: WebGLQuery): any;
  62074. /** @hidden */
  62075. _getTimeQueryAvailability(query: WebGLQuery): any;
  62076. }
  62077. }
  62078. module "babylonjs/Meshes/abstractMesh" {
  62079. interface AbstractMesh {
  62080. /**
  62081. * Backing filed
  62082. * @hidden
  62083. */
  62084. __occlusionDataStorage: _OcclusionDataStorage;
  62085. /**
  62086. * Access property
  62087. * @hidden
  62088. */
  62089. _occlusionDataStorage: _OcclusionDataStorage;
  62090. /**
  62091. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  62092. * The default value is -1 which means don't break the query and wait till the result
  62093. * @see https://doc.babylonjs.com/features/occlusionquery
  62094. */
  62095. occlusionRetryCount: number;
  62096. /**
  62097. * 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:
  62098. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  62099. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  62100. * * 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.
  62101. * @see https://doc.babylonjs.com/features/occlusionquery
  62102. */
  62103. occlusionType: number;
  62104. /**
  62105. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  62106. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  62107. * * 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.
  62108. * @see https://doc.babylonjs.com/features/occlusionquery
  62109. */
  62110. occlusionQueryAlgorithmType: number;
  62111. /**
  62112. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  62113. * @see https://doc.babylonjs.com/features/occlusionquery
  62114. */
  62115. isOccluded: boolean;
  62116. /**
  62117. * Flag to check the progress status of the query
  62118. * @see https://doc.babylonjs.com/features/occlusionquery
  62119. */
  62120. isOcclusionQueryInProgress: boolean;
  62121. }
  62122. }
  62123. }
  62124. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  62125. import { Nullable } from "babylonjs/types";
  62126. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62127. /** @hidden */
  62128. export var _forceTransformFeedbackToBundle: boolean;
  62129. module "babylonjs/Engines/engine" {
  62130. interface Engine {
  62131. /**
  62132. * Creates a webGL transform feedback object
  62133. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  62134. * @returns the webGL transform feedback object
  62135. */
  62136. createTransformFeedback(): WebGLTransformFeedback;
  62137. /**
  62138. * Delete a webGL transform feedback object
  62139. * @param value defines the webGL transform feedback object to delete
  62140. */
  62141. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  62142. /**
  62143. * Bind a webGL transform feedback object to the webgl context
  62144. * @param value defines the webGL transform feedback object to bind
  62145. */
  62146. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  62147. /**
  62148. * Begins a transform feedback operation
  62149. * @param usePoints defines if points or triangles must be used
  62150. */
  62151. beginTransformFeedback(usePoints: boolean): void;
  62152. /**
  62153. * Ends a transform feedback operation
  62154. */
  62155. endTransformFeedback(): void;
  62156. /**
  62157. * Specify the varyings to use with transform feedback
  62158. * @param program defines the associated webGL program
  62159. * @param value defines the list of strings representing the varying names
  62160. */
  62161. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  62162. /**
  62163. * Bind a webGL buffer for a transform feedback operation
  62164. * @param value defines the webGL buffer to bind
  62165. */
  62166. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  62167. }
  62168. }
  62169. }
  62170. declare module "babylonjs/Engines/Extensions/engine.views" {
  62171. import { Camera } from "babylonjs/Cameras/camera";
  62172. import { Nullable } from "babylonjs/types";
  62173. /**
  62174. * Class used to define an additional view for the engine
  62175. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62176. */
  62177. export class EngineView {
  62178. /** Defines the canvas where to render the view */
  62179. target: HTMLCanvasElement;
  62180. /** Defines an optional camera used to render the view (will use active camera else) */
  62181. camera?: Camera;
  62182. }
  62183. module "babylonjs/Engines/engine" {
  62184. interface Engine {
  62185. /**
  62186. * Gets or sets the HTML element to use for attaching events
  62187. */
  62188. inputElement: Nullable<HTMLElement>;
  62189. /**
  62190. * Gets the current engine view
  62191. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62192. */
  62193. activeView: Nullable<EngineView>;
  62194. /** Gets or sets the list of views */
  62195. views: EngineView[];
  62196. /**
  62197. * Register a new child canvas
  62198. * @param canvas defines the canvas to register
  62199. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  62200. * @returns the associated view
  62201. */
  62202. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  62203. /**
  62204. * Remove a registered child canvas
  62205. * @param canvas defines the canvas to remove
  62206. * @returns the current engine
  62207. */
  62208. unRegisterView(canvas: HTMLCanvasElement): Engine;
  62209. }
  62210. }
  62211. }
  62212. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  62213. import { Nullable } from "babylonjs/types";
  62214. module "babylonjs/Engines/engine" {
  62215. interface Engine {
  62216. /** @hidden */
  62217. _excludedCompressedTextures: string[];
  62218. /** @hidden */
  62219. _textureFormatInUse: string;
  62220. /**
  62221. * Gets the list of texture formats supported
  62222. */
  62223. readonly texturesSupported: Array<string>;
  62224. /**
  62225. * Gets the texture format in use
  62226. */
  62227. readonly textureFormatInUse: Nullable<string>;
  62228. /**
  62229. * Set the compressed texture extensions or file names to skip.
  62230. *
  62231. * @param skippedFiles defines the list of those texture files you want to skip
  62232. * Example: [".dds", ".env", "myfile.png"]
  62233. */
  62234. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  62235. /**
  62236. * Set the compressed texture format to use, based on the formats you have, and the formats
  62237. * supported by the hardware / browser.
  62238. *
  62239. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  62240. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  62241. * to API arguments needed to compressed textures. This puts the burden on the container
  62242. * generator to house the arcane code for determining these for current & future formats.
  62243. *
  62244. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62245. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62246. *
  62247. * Note: The result of this call is not taken into account when a texture is base64.
  62248. *
  62249. * @param formatsAvailable defines the list of those format families you have created
  62250. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  62251. *
  62252. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  62253. * @returns The extension selected.
  62254. */
  62255. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  62256. }
  62257. }
  62258. }
  62259. declare module "babylonjs/Engines/Extensions/index" {
  62260. export * from "babylonjs/Engines/Extensions/engine.alpha";
  62261. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  62262. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  62263. export * from "babylonjs/Engines/Extensions/engine.multiview";
  62264. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  62265. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62266. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  62267. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  62268. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  62269. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  62270. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62271. export * from "babylonjs/Engines/Extensions/engine.webVR";
  62272. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  62273. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  62274. export * from "babylonjs/Engines/Extensions/engine.views";
  62275. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  62276. import "babylonjs/Engines/Extensions/engine.textureSelector";
  62277. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  62278. }
  62279. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  62280. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62281. /** @hidden */
  62282. export var rgbdEncodePixelShader: {
  62283. name: string;
  62284. shader: string;
  62285. };
  62286. }
  62287. declare module "babylonjs/Misc/environmentTextureTools" {
  62288. import { Nullable } from "babylonjs/types";
  62289. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  62290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62292. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62293. import "babylonjs/Engines/Extensions/engine.readTexture";
  62294. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62295. import "babylonjs/Shaders/rgbdEncode.fragment";
  62296. import "babylonjs/Shaders/rgbdDecode.fragment";
  62297. /**
  62298. * Raw texture data and descriptor sufficient for WebGL texture upload
  62299. */
  62300. export interface EnvironmentTextureInfo {
  62301. /**
  62302. * Version of the environment map
  62303. */
  62304. version: number;
  62305. /**
  62306. * Width of image
  62307. */
  62308. width: number;
  62309. /**
  62310. * Irradiance information stored in the file.
  62311. */
  62312. irradiance: any;
  62313. /**
  62314. * Specular information stored in the file.
  62315. */
  62316. specular: any;
  62317. }
  62318. /**
  62319. * Defines One Image in the file. It requires only the position in the file
  62320. * as well as the length.
  62321. */
  62322. interface BufferImageData {
  62323. /**
  62324. * Length of the image data.
  62325. */
  62326. length: number;
  62327. /**
  62328. * Position of the data from the null terminator delimiting the end of the JSON.
  62329. */
  62330. position: number;
  62331. }
  62332. /**
  62333. * Defines the specular data enclosed in the file.
  62334. * This corresponds to the version 1 of the data.
  62335. */
  62336. export interface EnvironmentTextureSpecularInfoV1 {
  62337. /**
  62338. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  62339. */
  62340. specularDataPosition?: number;
  62341. /**
  62342. * This contains all the images data needed to reconstruct the cubemap.
  62343. */
  62344. mipmaps: Array<BufferImageData>;
  62345. /**
  62346. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  62347. */
  62348. lodGenerationScale: number;
  62349. }
  62350. /**
  62351. * Sets of helpers addressing the serialization and deserialization of environment texture
  62352. * stored in a BabylonJS env file.
  62353. * Those files are usually stored as .env files.
  62354. */
  62355. export class EnvironmentTextureTools {
  62356. /**
  62357. * Magic number identifying the env file.
  62358. */
  62359. private static _MagicBytes;
  62360. /**
  62361. * Gets the environment info from an env file.
  62362. * @param data The array buffer containing the .env bytes.
  62363. * @returns the environment file info (the json header) if successfully parsed.
  62364. */
  62365. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  62366. /**
  62367. * Creates an environment texture from a loaded cube texture.
  62368. * @param texture defines the cube texture to convert in env file
  62369. * @return a promise containing the environment data if succesfull.
  62370. */
  62371. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  62372. /**
  62373. * Creates a JSON representation of the spherical data.
  62374. * @param texture defines the texture containing the polynomials
  62375. * @return the JSON representation of the spherical info
  62376. */
  62377. private static _CreateEnvTextureIrradiance;
  62378. /**
  62379. * Creates the ArrayBufferViews used for initializing environment texture image data.
  62380. * @param data the image data
  62381. * @param info parameters that determine what views will be created for accessing the underlying buffer
  62382. * @return the views described by info providing access to the underlying buffer
  62383. */
  62384. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  62385. /**
  62386. * Uploads the texture info contained in the env file to the GPU.
  62387. * @param texture defines the internal texture to upload to
  62388. * @param data defines the data to load
  62389. * @param info defines the texture info retrieved through the GetEnvInfo method
  62390. * @returns a promise
  62391. */
  62392. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  62393. private static _OnImageReadyAsync;
  62394. /**
  62395. * Uploads the levels of image data to the GPU.
  62396. * @param texture defines the internal texture to upload to
  62397. * @param imageData defines the array buffer views of image data [mipmap][face]
  62398. * @returns a promise
  62399. */
  62400. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  62401. /**
  62402. * Uploads spherical polynomials information to the texture.
  62403. * @param texture defines the texture we are trying to upload the information to
  62404. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  62405. */
  62406. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  62407. /** @hidden */
  62408. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62409. }
  62410. }
  62411. declare module "babylonjs/Engines/nativeEngine" {
  62412. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  62413. import { Engine } from "babylonjs/Engines/engine";
  62414. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  62415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62417. import { Effect } from "babylonjs/Materials/effect";
  62418. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62419. import { Scene } from "babylonjs/scene";
  62420. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  62421. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  62422. import { IMatrixLike, IColor3Like, IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  62423. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  62424. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  62425. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  62426. /**
  62427. * Container for accessors for natively-stored mesh data buffers.
  62428. */
  62429. class NativeDataBuffer extends DataBuffer {
  62430. /**
  62431. * Accessor value used to identify/retrieve a natively-stored index buffer.
  62432. */
  62433. nativeIndexBuffer?: any;
  62434. /**
  62435. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  62436. */
  62437. nativeVertexBuffer?: any;
  62438. }
  62439. /** @hidden */
  62440. class NativeTexture extends InternalTexture {
  62441. getInternalTexture(): InternalTexture;
  62442. getViewCount(): number;
  62443. }
  62444. /** @hidden */
  62445. export class NativeEngine extends Engine {
  62446. private readonly _native;
  62447. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  62448. private readonly INVALID_HANDLE;
  62449. private _boundBuffersVertexArray;
  62450. private _currentDepthTest;
  62451. getHardwareScalingLevel(): number;
  62452. constructor();
  62453. dispose(): void;
  62454. /**
  62455. * Can be used to override the current requestAnimationFrame requester.
  62456. * @hidden
  62457. */
  62458. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  62459. /**
  62460. * Override default engine behavior.
  62461. * @param color
  62462. * @param backBuffer
  62463. * @param depth
  62464. * @param stencil
  62465. */
  62466. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  62467. /**
  62468. * Gets host document
  62469. * @returns the host document object
  62470. */
  62471. getHostDocument(): Nullable<Document>;
  62472. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  62473. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  62474. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  62475. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  62476. [key: string]: VertexBuffer;
  62477. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62478. bindBuffers(vertexBuffers: {
  62479. [key: string]: VertexBuffer;
  62480. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62481. recordVertexArrayObject(vertexBuffers: {
  62482. [key: string]: VertexBuffer;
  62483. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  62484. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62485. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62486. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  62487. /**
  62488. * Draw a list of indexed primitives
  62489. * @param fillMode defines the primitive to use
  62490. * @param indexStart defines the starting index
  62491. * @param indexCount defines the number of index to draw
  62492. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62493. */
  62494. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  62495. /**
  62496. * Draw a list of unindexed primitives
  62497. * @param fillMode defines the primitive to use
  62498. * @param verticesStart defines the index of first vertex to draw
  62499. * @param verticesCount defines the count of vertices to draw
  62500. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62501. */
  62502. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  62503. createPipelineContext(): IPipelineContext;
  62504. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  62505. /** @hidden */
  62506. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  62507. /** @hidden */
  62508. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  62509. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62510. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62511. protected _setProgram(program: WebGLProgram): void;
  62512. _releaseEffect(effect: Effect): void;
  62513. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  62514. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  62515. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  62516. bindSamplers(effect: Effect): void;
  62517. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  62518. getRenderWidth(useScreen?: boolean): number;
  62519. getRenderHeight(useScreen?: boolean): number;
  62520. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  62521. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  62522. /**
  62523. * Set the z offset to apply to current rendering
  62524. * @param value defines the offset to apply
  62525. */
  62526. setZOffset(value: number): void;
  62527. /**
  62528. * Gets the current value of the zOffset
  62529. * @returns the current zOffset state
  62530. */
  62531. getZOffset(): number;
  62532. /**
  62533. * Enable or disable depth buffering
  62534. * @param enable defines the state to set
  62535. */
  62536. setDepthBuffer(enable: boolean): void;
  62537. /**
  62538. * Gets a boolean indicating if depth writing is enabled
  62539. * @returns the current depth writing state
  62540. */
  62541. getDepthWrite(): boolean;
  62542. setDepthFunctionToGreater(): void;
  62543. setDepthFunctionToGreaterOrEqual(): void;
  62544. setDepthFunctionToLess(): void;
  62545. setDepthFunctionToLessOrEqual(): void;
  62546. /**
  62547. * Enable or disable depth writing
  62548. * @param enable defines the state to set
  62549. */
  62550. setDepthWrite(enable: boolean): void;
  62551. /**
  62552. * Enable or disable color writing
  62553. * @param enable defines the state to set
  62554. */
  62555. setColorWrite(enable: boolean): void;
  62556. /**
  62557. * Gets a boolean indicating if color writing is enabled
  62558. * @returns the current color writing state
  62559. */
  62560. getColorWrite(): boolean;
  62561. /**
  62562. * Sets alpha constants used by some alpha blending modes
  62563. * @param r defines the red component
  62564. * @param g defines the green component
  62565. * @param b defines the blue component
  62566. * @param a defines the alpha component
  62567. */
  62568. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  62569. /**
  62570. * Sets the current alpha mode
  62571. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  62572. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  62573. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62574. */
  62575. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  62576. /**
  62577. * Gets the current alpha mode
  62578. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62579. * @returns the current alpha mode
  62580. */
  62581. getAlphaMode(): number;
  62582. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  62583. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62584. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62585. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62586. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62587. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62588. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62589. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62590. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62591. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  62592. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  62593. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  62594. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  62595. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  62596. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62597. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62598. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  62599. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  62600. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  62601. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  62602. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  62603. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  62604. wipeCaches(bruteForce?: boolean): void;
  62605. protected _createTexture(): WebGLTexture;
  62606. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  62607. /**
  62608. * Update the content of a dynamic texture
  62609. * @param texture defines the texture to update
  62610. * @param canvas defines the canvas containing the source
  62611. * @param invertY defines if data must be stored with Y axis inverted
  62612. * @param premulAlpha defines if alpha is stored as premultiplied
  62613. * @param format defines the format of the data
  62614. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62615. */
  62616. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62617. /**
  62618. * Usually called from Texture.ts.
  62619. * Passed information to create a WebGLTexture
  62620. * @param url defines a value which contains one of the following:
  62621. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  62622. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  62623. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  62624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  62625. * @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)
  62626. * @param scene needed for loading to the correct scene
  62627. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  62628. * @param onLoad optional callback to be called upon successful completion
  62629. * @param onError optional callback to be called upon failure
  62630. * @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
  62631. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62632. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62633. * @param forcedExtension defines the extension to use to pick the right loader
  62634. * @param mimeType defines an optional mime type
  62635. * @param loaderOptions options to be passed to the loader
  62636. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62637. */
  62638. 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;
  62639. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  62640. _releaseFramebufferObjects(texture: InternalTexture): void;
  62641. /**
  62642. * Creates a cube texture
  62643. * @param rootUrl defines the url where the files to load is located
  62644. * @param scene defines the current scene
  62645. * @param files defines the list of files to load (1 per face)
  62646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  62647. * @param onLoad defines an optional callback raised when the texture is loaded
  62648. * @param onError defines an optional callback raised if there is an issue to load the texture
  62649. * @param format defines the format of the data
  62650. * @param forcedExtension defines the extension to use to pick the right loader
  62651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  62652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  62655. * @returns the cube texture as an InternalTexture
  62656. */
  62657. 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;
  62658. createRenderTargetTexture(size: number | {
  62659. width: number;
  62660. height: number;
  62661. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  62662. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62663. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62664. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62665. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  62666. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  62667. /**
  62668. * Updates a dynamic vertex buffer.
  62669. * @param vertexBuffer the vertex buffer to update
  62670. * @param data the data used to update the vertex buffer
  62671. * @param byteOffset the byte offset of the data (optional)
  62672. * @param byteLength the byte length of the data (optional)
  62673. */
  62674. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  62675. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  62676. private _updateAnisotropicLevel;
  62677. private _getAddressMode;
  62678. /** @hidden */
  62679. _bindTexture(channel: number, texture: InternalTexture): void;
  62680. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  62681. releaseEffects(): void;
  62682. /** @hidden */
  62683. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62684. /** @hidden */
  62685. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62686. /** @hidden */
  62687. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62688. /** @hidden */
  62689. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62690. private _getNativeSamplingMode;
  62691. private _getNativeTextureFormat;
  62692. private _getNativeAlphaMode;
  62693. private _getNativeAttribType;
  62694. }
  62695. }
  62696. declare module "babylonjs/Engines/engineFactory" {
  62697. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62698. /**
  62699. * Helper class to create the best engine depending on the current hardware
  62700. */
  62701. export class EngineFactory {
  62702. /**
  62703. * Creates an engine based on the capabilities of the underlying hardware
  62704. * @param canvas Defines the canvas to use to display the result
  62705. * @param options Defines the options passed to the engine to create the context dependencies
  62706. * @returns a promise that resolves with the created engine
  62707. */
  62708. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  62709. }
  62710. }
  62711. declare module "babylonjs/Engines/index" {
  62712. export * from "babylonjs/Engines/constants";
  62713. export * from "babylonjs/Engines/engineCapabilities";
  62714. export * from "babylonjs/Engines/instancingAttributeInfo";
  62715. export * from "babylonjs/Engines/thinEngine";
  62716. export * from "babylonjs/Engines/engine";
  62717. export * from "babylonjs/Engines/engineStore";
  62718. export * from "babylonjs/Engines/nullEngine";
  62719. export * from "babylonjs/Engines/Extensions/index";
  62720. export * from "babylonjs/Engines/IPipelineContext";
  62721. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  62722. export * from "babylonjs/Engines/WebGPU/webgpuConstants";
  62723. export * from "babylonjs/Engines/webgpuEngine";
  62724. export * from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  62725. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  62726. export * from "babylonjs/Engines/nativeEngine";
  62727. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  62728. export * from "babylonjs/Engines/performanceConfigurator";
  62729. export * from "babylonjs/Engines/engineFeatures";
  62730. export * from "babylonjs/Engines/engineFactory";
  62731. }
  62732. declare module "babylonjs/Events/clipboardEvents" {
  62733. /**
  62734. * Gather the list of clipboard event types as constants.
  62735. */
  62736. export class ClipboardEventTypes {
  62737. /**
  62738. * The clipboard event is fired when a copy command is active (pressed).
  62739. */
  62740. static readonly COPY: number;
  62741. /**
  62742. * The clipboard event is fired when a cut command is active (pressed).
  62743. */
  62744. static readonly CUT: number;
  62745. /**
  62746. * The clipboard event is fired when a paste command is active (pressed).
  62747. */
  62748. static readonly PASTE: number;
  62749. }
  62750. /**
  62751. * This class is used to store clipboard related info for the onClipboardObservable event.
  62752. */
  62753. export class ClipboardInfo {
  62754. /**
  62755. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62756. */
  62757. type: number;
  62758. /**
  62759. * Defines the related dom event
  62760. */
  62761. event: ClipboardEvent;
  62762. /**
  62763. *Creates an instance of ClipboardInfo.
  62764. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  62765. * @param event Defines the related dom event
  62766. */
  62767. constructor(
  62768. /**
  62769. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62770. */
  62771. type: number,
  62772. /**
  62773. * Defines the related dom event
  62774. */
  62775. event: ClipboardEvent);
  62776. /**
  62777. * Get the clipboard event's type from the keycode.
  62778. * @param keyCode Defines the keyCode for the current keyboard event.
  62779. * @return {number}
  62780. */
  62781. static GetTypeFromCharacter(keyCode: number): number;
  62782. }
  62783. }
  62784. declare module "babylonjs/Events/index" {
  62785. export * from "babylonjs/Events/keyboardEvents";
  62786. export * from "babylonjs/Events/pointerEvents";
  62787. export * from "babylonjs/Events/clipboardEvents";
  62788. }
  62789. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  62790. import { Scene } from "babylonjs/scene";
  62791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62792. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62793. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62794. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62795. /**
  62796. * Google Daydream controller
  62797. */
  62798. export class DaydreamController extends WebVRController {
  62799. /**
  62800. * Base Url for the controller model.
  62801. */
  62802. static MODEL_BASE_URL: string;
  62803. /**
  62804. * File name for the controller model.
  62805. */
  62806. static MODEL_FILENAME: string;
  62807. /**
  62808. * Gamepad Id prefix used to identify Daydream Controller.
  62809. */
  62810. static readonly GAMEPAD_ID_PREFIX: string;
  62811. /**
  62812. * Creates a new DaydreamController from a gamepad
  62813. * @param vrGamepad the gamepad that the controller should be created from
  62814. */
  62815. constructor(vrGamepad: any);
  62816. /**
  62817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62818. * @param scene scene in which to add meshes
  62819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62820. */
  62821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62822. /**
  62823. * Called once for each button that changed state since the last frame
  62824. * @param buttonIdx Which button index changed
  62825. * @param state New state of the button
  62826. * @param changes Which properties on the state changed since last frame
  62827. */
  62828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62829. }
  62830. }
  62831. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  62832. import { Scene } from "babylonjs/scene";
  62833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62834. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62835. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62836. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62837. /**
  62838. * Gear VR Controller
  62839. */
  62840. export class GearVRController extends WebVRController {
  62841. /**
  62842. * Base Url for the controller model.
  62843. */
  62844. static MODEL_BASE_URL: string;
  62845. /**
  62846. * File name for the controller model.
  62847. */
  62848. static MODEL_FILENAME: string;
  62849. /**
  62850. * Gamepad Id prefix used to identify this controller.
  62851. */
  62852. static readonly GAMEPAD_ID_PREFIX: string;
  62853. private readonly _buttonIndexToObservableNameMap;
  62854. /**
  62855. * Creates a new GearVRController from a gamepad
  62856. * @param vrGamepad the gamepad that the controller should be created from
  62857. */
  62858. constructor(vrGamepad: any);
  62859. /**
  62860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62861. * @param scene scene in which to add meshes
  62862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62863. */
  62864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62865. /**
  62866. * Called once for each button that changed state since the last frame
  62867. * @param buttonIdx Which button index changed
  62868. * @param state New state of the button
  62869. * @param changes Which properties on the state changed since last frame
  62870. */
  62871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62872. }
  62873. }
  62874. declare module "babylonjs/Gamepads/Controllers/genericController" {
  62875. import { Scene } from "babylonjs/scene";
  62876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62877. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62878. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62879. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62880. /**
  62881. * Generic Controller
  62882. */
  62883. export class GenericController extends WebVRController {
  62884. /**
  62885. * Base Url for the controller model.
  62886. */
  62887. static readonly MODEL_BASE_URL: string;
  62888. /**
  62889. * File name for the controller model.
  62890. */
  62891. static readonly MODEL_FILENAME: string;
  62892. /**
  62893. * Creates a new GenericController from a gamepad
  62894. * @param vrGamepad the gamepad that the controller should be created from
  62895. */
  62896. constructor(vrGamepad: any);
  62897. /**
  62898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62899. * @param scene scene in which to add meshes
  62900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62901. */
  62902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62903. /**
  62904. * Called once for each button that changed state since the last frame
  62905. * @param buttonIdx Which button index changed
  62906. * @param state New state of the button
  62907. * @param changes Which properties on the state changed since last frame
  62908. */
  62909. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62910. }
  62911. }
  62912. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  62913. import { Observable } from "babylonjs/Misc/observable";
  62914. import { Scene } from "babylonjs/scene";
  62915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62916. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62917. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62918. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62919. /**
  62920. * Oculus Touch Controller
  62921. */
  62922. export class OculusTouchController extends WebVRController {
  62923. /**
  62924. * Base Url for the controller model.
  62925. */
  62926. static MODEL_BASE_URL: string;
  62927. /**
  62928. * File name for the left controller model.
  62929. */
  62930. static MODEL_LEFT_FILENAME: string;
  62931. /**
  62932. * File name for the right controller model.
  62933. */
  62934. static MODEL_RIGHT_FILENAME: string;
  62935. /**
  62936. * Base Url for the Quest controller model.
  62937. */
  62938. static QUEST_MODEL_BASE_URL: string;
  62939. /**
  62940. * @hidden
  62941. * If the controllers are running on a device that needs the updated Quest controller models
  62942. */
  62943. static _IsQuest: boolean;
  62944. /**
  62945. * Fired when the secondary trigger on this controller is modified
  62946. */
  62947. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  62948. /**
  62949. * Fired when the thumb rest on this controller is modified
  62950. */
  62951. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  62952. /**
  62953. * Creates a new OculusTouchController from a gamepad
  62954. * @param vrGamepad the gamepad that the controller should be created from
  62955. */
  62956. constructor(vrGamepad: any);
  62957. /**
  62958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62959. * @param scene scene in which to add meshes
  62960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62961. */
  62962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62963. /**
  62964. * Fired when the A button on this controller is modified
  62965. */
  62966. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62967. /**
  62968. * Fired when the B button on this controller is modified
  62969. */
  62970. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62971. /**
  62972. * Fired when the X button on this controller is modified
  62973. */
  62974. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62975. /**
  62976. * Fired when the Y button on this controller is modified
  62977. */
  62978. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62979. /**
  62980. * Called once for each button that changed state since the last frame
  62981. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  62982. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  62983. * 2) secondary trigger (same)
  62984. * 3) A (right) X (left), touch, pressed = value
  62985. * 4) B / Y
  62986. * 5) thumb rest
  62987. * @param buttonIdx Which button index changed
  62988. * @param state New state of the button
  62989. * @param changes Which properties on the state changed since last frame
  62990. */
  62991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62992. }
  62993. }
  62994. declare module "babylonjs/Gamepads/Controllers/viveController" {
  62995. import { Scene } from "babylonjs/scene";
  62996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62997. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62998. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62999. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63000. import { Observable } from "babylonjs/Misc/observable";
  63001. /**
  63002. * Vive Controller
  63003. */
  63004. export class ViveController extends WebVRController {
  63005. /**
  63006. * Base Url for the controller model.
  63007. */
  63008. static MODEL_BASE_URL: string;
  63009. /**
  63010. * File name for the controller model.
  63011. */
  63012. static MODEL_FILENAME: string;
  63013. /**
  63014. * Creates a new ViveController from a gamepad
  63015. * @param vrGamepad the gamepad that the controller should be created from
  63016. */
  63017. constructor(vrGamepad: any);
  63018. /**
  63019. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63020. * @param scene scene in which to add meshes
  63021. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63022. */
  63023. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63024. /**
  63025. * Fired when the left button on this controller is modified
  63026. */
  63027. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63028. /**
  63029. * Fired when the right button on this controller is modified
  63030. */
  63031. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63032. /**
  63033. * Fired when the menu button on this controller is modified
  63034. */
  63035. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63036. /**
  63037. * Called once for each button that changed state since the last frame
  63038. * Vive mapping:
  63039. * 0: touchpad
  63040. * 1: trigger
  63041. * 2: left AND right buttons
  63042. * 3: menu button
  63043. * @param buttonIdx Which button index changed
  63044. * @param state New state of the button
  63045. * @param changes Which properties on the state changed since last frame
  63046. */
  63047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63048. }
  63049. }
  63050. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  63051. import { Observable } from "babylonjs/Misc/observable";
  63052. import { Scene } from "babylonjs/scene";
  63053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63054. import { Ray } from "babylonjs/Culling/ray";
  63055. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63056. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63057. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63058. /**
  63059. * Defines the WindowsMotionController object that the state of the windows motion controller
  63060. */
  63061. export class WindowsMotionController extends WebVRController {
  63062. /**
  63063. * The base url used to load the left and right controller models
  63064. */
  63065. static MODEL_BASE_URL: string;
  63066. /**
  63067. * The name of the left controller model file
  63068. */
  63069. static MODEL_LEFT_FILENAME: string;
  63070. /**
  63071. * The name of the right controller model file
  63072. */
  63073. static MODEL_RIGHT_FILENAME: string;
  63074. /**
  63075. * The controller name prefix for this controller type
  63076. */
  63077. static readonly GAMEPAD_ID_PREFIX: string;
  63078. /**
  63079. * The controller id pattern for this controller type
  63080. */
  63081. private static readonly GAMEPAD_ID_PATTERN;
  63082. private _loadedMeshInfo;
  63083. protected readonly _mapping: {
  63084. buttons: string[];
  63085. buttonMeshNames: {
  63086. trigger: string;
  63087. menu: string;
  63088. grip: string;
  63089. thumbstick: string;
  63090. trackpad: string;
  63091. };
  63092. buttonObservableNames: {
  63093. trigger: string;
  63094. menu: string;
  63095. grip: string;
  63096. thumbstick: string;
  63097. trackpad: string;
  63098. };
  63099. axisMeshNames: string[];
  63100. pointingPoseMeshName: string;
  63101. };
  63102. /**
  63103. * Fired when the trackpad on this controller is clicked
  63104. */
  63105. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63106. /**
  63107. * Fired when the trackpad on this controller is modified
  63108. */
  63109. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63110. /**
  63111. * The current x and y values of this controller's trackpad
  63112. */
  63113. trackpad: StickValues;
  63114. /**
  63115. * Creates a new WindowsMotionController from a gamepad
  63116. * @param vrGamepad the gamepad that the controller should be created from
  63117. */
  63118. constructor(vrGamepad: any);
  63119. /**
  63120. * Fired when the trigger on this controller is modified
  63121. */
  63122. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63123. /**
  63124. * Fired when the menu button on this controller is modified
  63125. */
  63126. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63127. /**
  63128. * Fired when the grip button on this controller is modified
  63129. */
  63130. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63131. /**
  63132. * Fired when the thumbstick button on this controller is modified
  63133. */
  63134. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63135. /**
  63136. * Fired when the touchpad button on this controller is modified
  63137. */
  63138. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63139. /**
  63140. * Fired when the touchpad values on this controller are modified
  63141. */
  63142. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  63143. protected _updateTrackpad(): void;
  63144. /**
  63145. * Called once per frame by the engine.
  63146. */
  63147. update(): void;
  63148. /**
  63149. * Called once for each button that changed state since the last frame
  63150. * @param buttonIdx Which button index changed
  63151. * @param state New state of the button
  63152. * @param changes Which properties on the state changed since last frame
  63153. */
  63154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63155. /**
  63156. * Moves the buttons on the controller mesh based on their current state
  63157. * @param buttonName the name of the button to move
  63158. * @param buttonValue the value of the button which determines the buttons new position
  63159. */
  63160. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  63161. /**
  63162. * Moves the axis on the controller mesh based on its current state
  63163. * @param axis the index of the axis
  63164. * @param axisValue the value of the axis which determines the meshes new position
  63165. * @hidden
  63166. */
  63167. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  63168. /**
  63169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63170. * @param scene scene in which to add meshes
  63171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63172. */
  63173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  63174. /**
  63175. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  63176. * can be transformed by button presses and axes values, based on this._mapping.
  63177. *
  63178. * @param scene scene in which the meshes exist
  63179. * @param meshes list of meshes that make up the controller model to process
  63180. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  63181. */
  63182. private processModel;
  63183. private createMeshInfo;
  63184. /**
  63185. * Gets the ray of the controller in the direction the controller is pointing
  63186. * @param length the length the resulting ray should be
  63187. * @returns a ray in the direction the controller is pointing
  63188. */
  63189. getForwardRay(length?: number): Ray;
  63190. /**
  63191. * Disposes of the controller
  63192. */
  63193. dispose(): void;
  63194. }
  63195. /**
  63196. * This class represents a new windows motion controller in XR.
  63197. */
  63198. export class XRWindowsMotionController extends WindowsMotionController {
  63199. /**
  63200. * Changing the original WIndowsMotionController mapping to fir the new mapping
  63201. */
  63202. protected readonly _mapping: {
  63203. buttons: string[];
  63204. buttonMeshNames: {
  63205. trigger: string;
  63206. menu: string;
  63207. grip: string;
  63208. thumbstick: string;
  63209. trackpad: string;
  63210. };
  63211. buttonObservableNames: {
  63212. trigger: string;
  63213. menu: string;
  63214. grip: string;
  63215. thumbstick: string;
  63216. trackpad: string;
  63217. };
  63218. axisMeshNames: string[];
  63219. pointingPoseMeshName: string;
  63220. };
  63221. /**
  63222. * Construct a new XR-Based windows motion controller
  63223. *
  63224. * @param gamepadInfo the gamepad object from the browser
  63225. */
  63226. constructor(gamepadInfo: any);
  63227. /**
  63228. * holds the thumbstick values (X,Y)
  63229. */
  63230. thumbstickValues: StickValues;
  63231. /**
  63232. * Fired when the thumbstick on this controller is clicked
  63233. */
  63234. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  63235. /**
  63236. * Fired when the thumbstick on this controller is modified
  63237. */
  63238. onThumbstickValuesChangedObservable: Observable<StickValues>;
  63239. /**
  63240. * Fired when the touchpad button on this controller is modified
  63241. */
  63242. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63243. /**
  63244. * Fired when the touchpad values on this controller are modified
  63245. */
  63246. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63247. /**
  63248. * Fired when the thumbstick button on this controller is modified
  63249. * here to prevent breaking changes
  63250. */
  63251. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63252. /**
  63253. * updating the thumbstick(!) and not the trackpad.
  63254. * This is named this way due to the difference between WebVR and XR and to avoid
  63255. * changing the parent class.
  63256. */
  63257. protected _updateTrackpad(): void;
  63258. /**
  63259. * Disposes the class with joy
  63260. */
  63261. dispose(): void;
  63262. }
  63263. }
  63264. declare module "babylonjs/Gamepads/Controllers/index" {
  63265. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  63266. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  63267. export * from "babylonjs/Gamepads/Controllers/genericController";
  63268. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  63269. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63270. export * from "babylonjs/Gamepads/Controllers/viveController";
  63271. export * from "babylonjs/Gamepads/Controllers/webVRController";
  63272. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  63273. }
  63274. declare module "babylonjs/Gamepads/index" {
  63275. export * from "babylonjs/Gamepads/Controllers/index";
  63276. export * from "babylonjs/Gamepads/gamepad";
  63277. export * from "babylonjs/Gamepads/gamepadManager";
  63278. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  63279. export * from "babylonjs/Gamepads/xboxGamepad";
  63280. export * from "babylonjs/Gamepads/dualShockGamepad";
  63281. }
  63282. declare module "babylonjs/Lights/directionalLight" {
  63283. import { Camera } from "babylonjs/Cameras/camera";
  63284. import { Scene } from "babylonjs/scene";
  63285. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63287. import { Light } from "babylonjs/Lights/light";
  63288. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63289. import { Effect } from "babylonjs/Materials/effect";
  63290. /**
  63291. * A directional light is defined by a direction (what a surprise!).
  63292. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  63293. * 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.
  63294. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63295. */
  63296. export class DirectionalLight extends ShadowLight {
  63297. private _shadowFrustumSize;
  63298. /**
  63299. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  63300. */
  63301. get shadowFrustumSize(): number;
  63302. /**
  63303. * Specifies a fix frustum size for the shadow generation.
  63304. */
  63305. set shadowFrustumSize(value: number);
  63306. private _shadowOrthoScale;
  63307. /**
  63308. * Gets the shadow projection scale against the optimal computed one.
  63309. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63310. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63311. */
  63312. get shadowOrthoScale(): number;
  63313. /**
  63314. * Sets the shadow projection scale against the optimal computed one.
  63315. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63316. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63317. */
  63318. set shadowOrthoScale(value: number);
  63319. /**
  63320. * Automatically compute the projection matrix to best fit (including all the casters)
  63321. * on each frame.
  63322. */
  63323. autoUpdateExtends: boolean;
  63324. /**
  63325. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  63326. * on each frame. autoUpdateExtends must be set to true for this to work
  63327. */
  63328. autoCalcShadowZBounds: boolean;
  63329. private _orthoLeft;
  63330. private _orthoRight;
  63331. private _orthoTop;
  63332. private _orthoBottom;
  63333. /**
  63334. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  63335. * The directional light is emitted from everywhere in the given direction.
  63336. * It can cast shadows.
  63337. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63338. * @param name The friendly name of the light
  63339. * @param direction The direction of the light
  63340. * @param scene The scene the light belongs to
  63341. */
  63342. constructor(name: string, direction: Vector3, scene: Scene);
  63343. /**
  63344. * Returns the string "DirectionalLight".
  63345. * @return The class name
  63346. */
  63347. getClassName(): string;
  63348. /**
  63349. * Returns the integer 1.
  63350. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63351. */
  63352. getTypeID(): number;
  63353. /**
  63354. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  63355. * Returns the DirectionalLight Shadow projection matrix.
  63356. */
  63357. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63358. /**
  63359. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  63360. * Returns the DirectionalLight Shadow projection matrix.
  63361. */
  63362. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  63363. /**
  63364. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  63365. * Returns the DirectionalLight Shadow projection matrix.
  63366. */
  63367. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63368. protected _buildUniformLayout(): void;
  63369. /**
  63370. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  63371. * @param effect The effect to update
  63372. * @param lightIndex The index of the light in the effect to update
  63373. * @returns The directional light
  63374. */
  63375. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  63376. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  63377. /**
  63378. * Gets the minZ used for shadow according to both the scene and the light.
  63379. *
  63380. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63381. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63382. * @param activeCamera The camera we are returning the min for
  63383. * @returns the depth min z
  63384. */
  63385. getDepthMinZ(activeCamera: Camera): number;
  63386. /**
  63387. * Gets the maxZ used for shadow according to both the scene and the light.
  63388. *
  63389. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63390. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63391. * @param activeCamera The camera we are returning the max for
  63392. * @returns the depth max z
  63393. */
  63394. getDepthMaxZ(activeCamera: Camera): number;
  63395. /**
  63396. * Prepares the list of defines specific to the light type.
  63397. * @param defines the list of defines
  63398. * @param lightIndex defines the index of the light for the effect
  63399. */
  63400. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63401. }
  63402. }
  63403. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  63404. import { Mesh } from "babylonjs/Meshes/mesh";
  63405. /**
  63406. * Class containing static functions to help procedurally build meshes
  63407. */
  63408. export class HemisphereBuilder {
  63409. /**
  63410. * Creates a hemisphere mesh
  63411. * @param name defines the name of the mesh
  63412. * @param options defines the options used to create the mesh
  63413. * @param scene defines the hosting scene
  63414. * @returns the hemisphere mesh
  63415. */
  63416. static CreateHemisphere(name: string, options: {
  63417. segments?: number;
  63418. diameter?: number;
  63419. sideOrientation?: number;
  63420. }, scene: any): Mesh;
  63421. }
  63422. }
  63423. declare module "babylonjs/Lights/spotLight" {
  63424. import { Nullable } from "babylonjs/types";
  63425. import { Scene } from "babylonjs/scene";
  63426. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63428. import { Effect } from "babylonjs/Materials/effect";
  63429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63430. import { Light } from "babylonjs/Lights/light";
  63431. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63432. /**
  63433. * A spot light is defined by a position, a direction, an angle, and an exponent.
  63434. * These values define a cone of light starting from the position, emitting toward the direction.
  63435. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  63436. * and the exponent defines the speed of the decay of the light with distance (reach).
  63437. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63438. */
  63439. export class SpotLight extends ShadowLight {
  63440. private _angle;
  63441. private _innerAngle;
  63442. private _cosHalfAngle;
  63443. private _lightAngleScale;
  63444. private _lightAngleOffset;
  63445. /**
  63446. * Gets the cone angle of the spot light in Radians.
  63447. */
  63448. get angle(): number;
  63449. /**
  63450. * Sets the cone angle of the spot light in Radians.
  63451. */
  63452. set angle(value: number);
  63453. /**
  63454. * Only used in gltf falloff mode, this defines the angle where
  63455. * the directional falloff will start before cutting at angle which could be seen
  63456. * as outer angle.
  63457. */
  63458. get innerAngle(): number;
  63459. /**
  63460. * Only used in gltf falloff mode, this defines the angle where
  63461. * the directional falloff will start before cutting at angle which could be seen
  63462. * as outer angle.
  63463. */
  63464. set innerAngle(value: number);
  63465. private _shadowAngleScale;
  63466. /**
  63467. * Allows scaling the angle of the light for shadow generation only.
  63468. */
  63469. get shadowAngleScale(): number;
  63470. /**
  63471. * Allows scaling the angle of the light for shadow generation only.
  63472. */
  63473. set shadowAngleScale(value: number);
  63474. /**
  63475. * The light decay speed with the distance from the emission spot.
  63476. */
  63477. exponent: number;
  63478. private _projectionTextureMatrix;
  63479. /**
  63480. * Allows reading the projecton texture
  63481. */
  63482. get projectionTextureMatrix(): Matrix;
  63483. protected _projectionTextureLightNear: number;
  63484. /**
  63485. * Gets the near clip of the Spotlight for texture projection.
  63486. */
  63487. get projectionTextureLightNear(): number;
  63488. /**
  63489. * Sets the near clip of the Spotlight for texture projection.
  63490. */
  63491. set projectionTextureLightNear(value: number);
  63492. protected _projectionTextureLightFar: number;
  63493. /**
  63494. * Gets the far clip of the Spotlight for texture projection.
  63495. */
  63496. get projectionTextureLightFar(): number;
  63497. /**
  63498. * Sets the far clip of the Spotlight for texture projection.
  63499. */
  63500. set projectionTextureLightFar(value: number);
  63501. protected _projectionTextureUpDirection: Vector3;
  63502. /**
  63503. * Gets the Up vector of the Spotlight for texture projection.
  63504. */
  63505. get projectionTextureUpDirection(): Vector3;
  63506. /**
  63507. * Sets the Up vector of the Spotlight for texture projection.
  63508. */
  63509. set projectionTextureUpDirection(value: Vector3);
  63510. private _projectionTexture;
  63511. /**
  63512. * Gets the projection texture of the light.
  63513. */
  63514. get projectionTexture(): Nullable<BaseTexture>;
  63515. /**
  63516. * Sets the projection texture of the light.
  63517. */
  63518. set projectionTexture(value: Nullable<BaseTexture>);
  63519. private static _IsProceduralTexture;
  63520. private static _IsTexture;
  63521. private _projectionTextureViewLightDirty;
  63522. private _projectionTextureProjectionLightDirty;
  63523. private _projectionTextureDirty;
  63524. private _projectionTextureViewTargetVector;
  63525. private _projectionTextureViewLightMatrix;
  63526. private _projectionTextureProjectionLightMatrix;
  63527. private _projectionTextureScalingMatrix;
  63528. /**
  63529. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  63530. * It can cast shadows.
  63531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63532. * @param name The light friendly name
  63533. * @param position The position of the spot light in the scene
  63534. * @param direction The direction of the light in the scene
  63535. * @param angle The cone angle of the light in Radians
  63536. * @param exponent The light decay speed with the distance from the emission spot
  63537. * @param scene The scene the lights belongs to
  63538. */
  63539. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  63540. /**
  63541. * Returns the string "SpotLight".
  63542. * @returns the class name
  63543. */
  63544. getClassName(): string;
  63545. /**
  63546. * Returns the integer 2.
  63547. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63548. */
  63549. getTypeID(): number;
  63550. /**
  63551. * Overrides the direction setter to recompute the projection texture view light Matrix.
  63552. */
  63553. protected _setDirection(value: Vector3): void;
  63554. /**
  63555. * Overrides the position setter to recompute the projection texture view light Matrix.
  63556. */
  63557. protected _setPosition(value: Vector3): void;
  63558. /**
  63559. * 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.
  63560. * Returns the SpotLight.
  63561. */
  63562. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63563. protected _computeProjectionTextureViewLightMatrix(): void;
  63564. protected _computeProjectionTextureProjectionLightMatrix(): void;
  63565. /**
  63566. * Main function for light texture projection matrix computing.
  63567. */
  63568. protected _computeProjectionTextureMatrix(): void;
  63569. protected _buildUniformLayout(): void;
  63570. private _computeAngleValues;
  63571. /**
  63572. * Sets the passed Effect "effect" with the Light textures.
  63573. * @param effect The effect to update
  63574. * @param lightIndex The index of the light in the effect to update
  63575. * @returns The light
  63576. */
  63577. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  63578. /**
  63579. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  63580. * @param effect The effect to update
  63581. * @param lightIndex The index of the light in the effect to update
  63582. * @returns The spot light
  63583. */
  63584. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  63585. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63586. /**
  63587. * Disposes the light and the associated resources.
  63588. */
  63589. dispose(): void;
  63590. /**
  63591. * Prepares the list of defines specific to the light type.
  63592. * @param defines the list of defines
  63593. * @param lightIndex defines the index of the light for the effect
  63594. */
  63595. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63596. }
  63597. }
  63598. declare module "babylonjs/Gizmos/lightGizmo" {
  63599. import { Nullable } from "babylonjs/types";
  63600. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63601. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63602. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63603. import { Light } from "babylonjs/Lights/light";
  63604. import { Observable } from "babylonjs/Misc/observable";
  63605. /**
  63606. * Gizmo that enables viewing a light
  63607. */
  63608. export class LightGizmo extends Gizmo {
  63609. private _lightMesh;
  63610. private _material;
  63611. private _cachedPosition;
  63612. private _cachedForward;
  63613. private _attachedMeshParent;
  63614. private _pointerObserver;
  63615. /**
  63616. * Event that fires each time the gizmo is clicked
  63617. */
  63618. onClickedObservable: Observable<Light>;
  63619. /**
  63620. * Creates a LightGizmo
  63621. * @param gizmoLayer The utility layer the gizmo will be added to
  63622. */
  63623. constructor(gizmoLayer?: UtilityLayerRenderer);
  63624. private _light;
  63625. /**
  63626. * The light that the gizmo is attached to
  63627. */
  63628. set light(light: Nullable<Light>);
  63629. get light(): Nullable<Light>;
  63630. /**
  63631. * Gets the material used to render the light gizmo
  63632. */
  63633. get material(): StandardMaterial;
  63634. /**
  63635. * @hidden
  63636. * Updates the gizmo to match the attached mesh's position/rotation
  63637. */
  63638. protected _update(): void;
  63639. private static _Scale;
  63640. /**
  63641. * Creates the lines for a light mesh
  63642. */
  63643. private static _CreateLightLines;
  63644. /**
  63645. * Disposes of the light gizmo
  63646. */
  63647. dispose(): void;
  63648. private static _CreateHemisphericLightMesh;
  63649. private static _CreatePointLightMesh;
  63650. private static _CreateSpotLightMesh;
  63651. private static _CreateDirectionalLightMesh;
  63652. }
  63653. }
  63654. declare module "babylonjs/Gizmos/cameraGizmo" {
  63655. import { Nullable } from "babylonjs/types";
  63656. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63657. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63658. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63659. import { Camera } from "babylonjs/Cameras/camera";
  63660. import { Observable } from "babylonjs/Misc/observable";
  63661. /**
  63662. * Gizmo that enables viewing a camera
  63663. */
  63664. export class CameraGizmo extends Gizmo {
  63665. private _cameraMesh;
  63666. private _cameraLinesMesh;
  63667. private _material;
  63668. private _pointerObserver;
  63669. /**
  63670. * Event that fires each time the gizmo is clicked
  63671. */
  63672. onClickedObservable: Observable<Camera>;
  63673. /**
  63674. * Creates a CameraGizmo
  63675. * @param gizmoLayer The utility layer the gizmo will be added to
  63676. */
  63677. constructor(gizmoLayer?: UtilityLayerRenderer);
  63678. private _camera;
  63679. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  63680. get displayFrustum(): boolean;
  63681. set displayFrustum(value: boolean);
  63682. /**
  63683. * The camera that the gizmo is attached to
  63684. */
  63685. set camera(camera: Nullable<Camera>);
  63686. get camera(): Nullable<Camera>;
  63687. /**
  63688. * Gets the material used to render the camera gizmo
  63689. */
  63690. get material(): StandardMaterial;
  63691. /**
  63692. * @hidden
  63693. * Updates the gizmo to match the attached mesh's position/rotation
  63694. */
  63695. protected _update(): void;
  63696. private static _Scale;
  63697. private _invProjection;
  63698. /**
  63699. * Disposes of the camera gizmo
  63700. */
  63701. dispose(): void;
  63702. private static _CreateCameraMesh;
  63703. private static _CreateCameraFrustum;
  63704. }
  63705. }
  63706. declare module "babylonjs/Gizmos/index" {
  63707. export * from "babylonjs/Gizmos/axisDragGizmo";
  63708. export * from "babylonjs/Gizmos/axisScaleGizmo";
  63709. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  63710. export * from "babylonjs/Gizmos/gizmo";
  63711. export * from "babylonjs/Gizmos/gizmoManager";
  63712. export * from "babylonjs/Gizmos/planeRotationGizmo";
  63713. export * from "babylonjs/Gizmos/positionGizmo";
  63714. export * from "babylonjs/Gizmos/rotationGizmo";
  63715. export * from "babylonjs/Gizmos/scaleGizmo";
  63716. export * from "babylonjs/Gizmos/lightGizmo";
  63717. export * from "babylonjs/Gizmos/cameraGizmo";
  63718. export * from "babylonjs/Gizmos/planeDragGizmo";
  63719. }
  63720. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  63721. /** @hidden */
  63722. export var backgroundFragmentDeclaration: {
  63723. name: string;
  63724. shader: string;
  63725. };
  63726. }
  63727. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  63728. /** @hidden */
  63729. export var backgroundUboDeclaration: {
  63730. name: string;
  63731. shader: string;
  63732. };
  63733. }
  63734. declare module "babylonjs/Shaders/background.fragment" {
  63735. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  63736. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63737. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  63738. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63739. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63740. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63741. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63742. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63743. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  63746. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63747. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63748. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63749. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  63750. /** @hidden */
  63751. export var backgroundPixelShader: {
  63752. name: string;
  63753. shader: string;
  63754. };
  63755. }
  63756. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  63757. /** @hidden */
  63758. export var backgroundVertexDeclaration: {
  63759. name: string;
  63760. shader: string;
  63761. };
  63762. }
  63763. declare module "babylonjs/Shaders/background.vertex" {
  63764. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  63765. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63767. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63768. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63769. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  63770. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  63771. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63772. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63773. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63774. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63775. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63776. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  63777. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63778. /** @hidden */
  63779. export var backgroundVertexShader: {
  63780. name: string;
  63781. shader: string;
  63782. };
  63783. }
  63784. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  63785. import { Nullable, int, float } from "babylonjs/types";
  63786. import { Scene } from "babylonjs/scene";
  63787. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63788. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63790. import { Mesh } from "babylonjs/Meshes/mesh";
  63791. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  63792. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  63793. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  63794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63795. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  63796. import { Color3 } from "babylonjs/Maths/math.color";
  63797. import "babylonjs/Shaders/background.fragment";
  63798. import "babylonjs/Shaders/background.vertex";
  63799. /**
  63800. * Background material used to create an efficient environement around your scene.
  63801. */
  63802. export class BackgroundMaterial extends PushMaterial {
  63803. /**
  63804. * Standard reflectance value at parallel view angle.
  63805. */
  63806. static StandardReflectance0: number;
  63807. /**
  63808. * Standard reflectance value at grazing angle.
  63809. */
  63810. static StandardReflectance90: number;
  63811. protected _primaryColor: Color3;
  63812. /**
  63813. * Key light Color (multiply against the environement texture)
  63814. */
  63815. primaryColor: Color3;
  63816. protected __perceptualColor: Nullable<Color3>;
  63817. /**
  63818. * Experimental Internal Use Only.
  63819. *
  63820. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  63821. * This acts as a helper to set the primary color to a more "human friendly" value.
  63822. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  63823. * output color as close as possible from the chosen value.
  63824. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  63825. * part of lighting setup.)
  63826. */
  63827. get _perceptualColor(): Nullable<Color3>;
  63828. set _perceptualColor(value: Nullable<Color3>);
  63829. protected _primaryColorShadowLevel: float;
  63830. /**
  63831. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  63832. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  63833. */
  63834. get primaryColorShadowLevel(): float;
  63835. set primaryColorShadowLevel(value: float);
  63836. protected _primaryColorHighlightLevel: float;
  63837. /**
  63838. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  63839. * The primary color is used at the level chosen to define what the white area would look.
  63840. */
  63841. get primaryColorHighlightLevel(): float;
  63842. set primaryColorHighlightLevel(value: float);
  63843. protected _reflectionTexture: Nullable<BaseTexture>;
  63844. /**
  63845. * Reflection Texture used in the material.
  63846. * Should be author in a specific way for the best result (refer to the documentation).
  63847. */
  63848. reflectionTexture: Nullable<BaseTexture>;
  63849. protected _reflectionBlur: float;
  63850. /**
  63851. * Reflection Texture level of blur.
  63852. *
  63853. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  63854. * texture twice.
  63855. */
  63856. reflectionBlur: float;
  63857. protected _diffuseTexture: Nullable<BaseTexture>;
  63858. /**
  63859. * Diffuse Texture used in the material.
  63860. * Should be author in a specific way for the best result (refer to the documentation).
  63861. */
  63862. diffuseTexture: Nullable<BaseTexture>;
  63863. protected _shadowLights: Nullable<IShadowLight[]>;
  63864. /**
  63865. * Specify the list of lights casting shadow on the material.
  63866. * All scene shadow lights will be included if null.
  63867. */
  63868. shadowLights: Nullable<IShadowLight[]>;
  63869. protected _shadowLevel: float;
  63870. /**
  63871. * Helps adjusting the shadow to a softer level if required.
  63872. * 0 means black shadows and 1 means no shadows.
  63873. */
  63874. shadowLevel: float;
  63875. protected _sceneCenter: Vector3;
  63876. /**
  63877. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  63878. * It is usually zero but might be interesting to modify according to your setup.
  63879. */
  63880. sceneCenter: Vector3;
  63881. protected _opacityFresnel: boolean;
  63882. /**
  63883. * This helps specifying that the material is falling off to the sky box at grazing angle.
  63884. * This helps ensuring a nice transition when the camera goes under the ground.
  63885. */
  63886. opacityFresnel: boolean;
  63887. protected _reflectionFresnel: boolean;
  63888. /**
  63889. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  63890. * This helps adding a mirror texture on the ground.
  63891. */
  63892. reflectionFresnel: boolean;
  63893. protected _reflectionFalloffDistance: number;
  63894. /**
  63895. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  63896. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  63897. */
  63898. reflectionFalloffDistance: number;
  63899. protected _reflectionAmount: number;
  63900. /**
  63901. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  63902. */
  63903. reflectionAmount: number;
  63904. protected _reflectionReflectance0: number;
  63905. /**
  63906. * This specifies the weight of the reflection at grazing angle.
  63907. */
  63908. reflectionReflectance0: number;
  63909. protected _reflectionReflectance90: number;
  63910. /**
  63911. * This specifies the weight of the reflection at a perpendicular point of view.
  63912. */
  63913. reflectionReflectance90: number;
  63914. /**
  63915. * Sets the reflection reflectance fresnel values according to the default standard
  63916. * empirically know to work well :-)
  63917. */
  63918. set reflectionStandardFresnelWeight(value: number);
  63919. protected _useRGBColor: boolean;
  63920. /**
  63921. * Helps to directly use the maps channels instead of their level.
  63922. */
  63923. useRGBColor: boolean;
  63924. protected _enableNoise: boolean;
  63925. /**
  63926. * This helps reducing the banding effect that could occur on the background.
  63927. */
  63928. enableNoise: boolean;
  63929. /**
  63930. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  63931. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  63932. * Recommended to be keep at 1.0 except for special cases.
  63933. */
  63934. get fovMultiplier(): number;
  63935. set fovMultiplier(value: number);
  63936. private _fovMultiplier;
  63937. /**
  63938. * Enable the FOV adjustment feature controlled by fovMultiplier.
  63939. */
  63940. useEquirectangularFOV: boolean;
  63941. private _maxSimultaneousLights;
  63942. /**
  63943. * Number of Simultaneous lights allowed on the material.
  63944. */
  63945. maxSimultaneousLights: int;
  63946. private _shadowOnly;
  63947. /**
  63948. * Make the material only render shadows
  63949. */
  63950. shadowOnly: boolean;
  63951. /**
  63952. * Default configuration related to image processing available in the Background Material.
  63953. */
  63954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  63955. /**
  63956. * Keep track of the image processing observer to allow dispose and replace.
  63957. */
  63958. private _imageProcessingObserver;
  63959. /**
  63960. * Attaches a new image processing configuration to the PBR Material.
  63961. * @param configuration (if null the scene configuration will be use)
  63962. */
  63963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  63964. /**
  63965. * Gets the image processing configuration used either in this material.
  63966. */
  63967. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  63968. /**
  63969. * Sets the Default image processing configuration used either in the this material.
  63970. *
  63971. * If sets to null, the scene one is in use.
  63972. */
  63973. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  63974. /**
  63975. * Gets wether the color curves effect is enabled.
  63976. */
  63977. get cameraColorCurvesEnabled(): boolean;
  63978. /**
  63979. * Sets wether the color curves effect is enabled.
  63980. */
  63981. set cameraColorCurvesEnabled(value: boolean);
  63982. /**
  63983. * Gets wether the color grading effect is enabled.
  63984. */
  63985. get cameraColorGradingEnabled(): boolean;
  63986. /**
  63987. * Gets wether the color grading effect is enabled.
  63988. */
  63989. set cameraColorGradingEnabled(value: boolean);
  63990. /**
  63991. * Gets wether tonemapping is enabled or not.
  63992. */
  63993. get cameraToneMappingEnabled(): boolean;
  63994. /**
  63995. * Sets wether tonemapping is enabled or not
  63996. */
  63997. set cameraToneMappingEnabled(value: boolean);
  63998. /**
  63999. * The camera exposure used on this material.
  64000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64001. * This corresponds to a photographic exposure.
  64002. */
  64003. get cameraExposure(): float;
  64004. /**
  64005. * The camera exposure used on this material.
  64006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64007. * This corresponds to a photographic exposure.
  64008. */
  64009. set cameraExposure(value: float);
  64010. /**
  64011. * Gets The camera contrast used on this material.
  64012. */
  64013. get cameraContrast(): float;
  64014. /**
  64015. * Sets The camera contrast used on this material.
  64016. */
  64017. set cameraContrast(value: float);
  64018. /**
  64019. * Gets the Color Grading 2D Lookup Texture.
  64020. */
  64021. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  64022. /**
  64023. * Sets the Color Grading 2D Lookup Texture.
  64024. */
  64025. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  64026. /**
  64027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64029. * 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;
  64030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64031. */
  64032. get cameraColorCurves(): Nullable<ColorCurves>;
  64033. /**
  64034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64036. * 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;
  64037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64038. */
  64039. set cameraColorCurves(value: Nullable<ColorCurves>);
  64040. /**
  64041. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  64042. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  64043. */
  64044. switchToBGR: boolean;
  64045. private _renderTargets;
  64046. private _reflectionControls;
  64047. private _white;
  64048. private _primaryShadowColor;
  64049. private _primaryHighlightColor;
  64050. /**
  64051. * Instantiates a Background Material in the given scene
  64052. * @param name The friendly name of the material
  64053. * @param scene The scene to add the material to
  64054. */
  64055. constructor(name: string, scene: Scene);
  64056. /**
  64057. * Gets a boolean indicating that current material needs to register RTT
  64058. */
  64059. get hasRenderTargetTextures(): boolean;
  64060. /**
  64061. * The entire material has been created in order to prevent overdraw.
  64062. * @returns false
  64063. */
  64064. needAlphaTesting(): boolean;
  64065. /**
  64066. * The entire material has been created in order to prevent overdraw.
  64067. * @returns true if blending is enable
  64068. */
  64069. needAlphaBlending(): boolean;
  64070. /**
  64071. * Checks wether the material is ready to be rendered for a given mesh.
  64072. * @param mesh The mesh to render
  64073. * @param subMesh The submesh to check against
  64074. * @param useInstances Specify wether or not the material is used with instances
  64075. * @returns true if all the dependencies are ready (Textures, Effects...)
  64076. */
  64077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  64078. /**
  64079. * Compute the primary color according to the chosen perceptual color.
  64080. */
  64081. private _computePrimaryColorFromPerceptualColor;
  64082. /**
  64083. * Compute the highlights and shadow colors according to their chosen levels.
  64084. */
  64085. private _computePrimaryColors;
  64086. /**
  64087. * Build the uniform buffer used in the material.
  64088. */
  64089. buildUniformLayout(): void;
  64090. /**
  64091. * Unbind the material.
  64092. */
  64093. unbind(): void;
  64094. /**
  64095. * Bind only the world matrix to the material.
  64096. * @param world The world matrix to bind.
  64097. */
  64098. bindOnlyWorldMatrix(world: Matrix): void;
  64099. /**
  64100. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  64101. * @param world The world matrix to bind.
  64102. * @param subMesh The submesh to bind for.
  64103. */
  64104. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  64105. /**
  64106. * Checks to see if a texture is used in the material.
  64107. * @param texture - Base texture to use.
  64108. * @returns - Boolean specifying if a texture is used in the material.
  64109. */
  64110. hasTexture(texture: BaseTexture): boolean;
  64111. /**
  64112. * Dispose the material.
  64113. * @param forceDisposeEffect Force disposal of the associated effect.
  64114. * @param forceDisposeTextures Force disposal of the associated textures.
  64115. */
  64116. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  64117. /**
  64118. * Clones the material.
  64119. * @param name The cloned name.
  64120. * @returns The cloned material.
  64121. */
  64122. clone(name: string): BackgroundMaterial;
  64123. /**
  64124. * Serializes the current material to its JSON representation.
  64125. * @returns The JSON representation.
  64126. */
  64127. serialize(): any;
  64128. /**
  64129. * Gets the class name of the material
  64130. * @returns "BackgroundMaterial"
  64131. */
  64132. getClassName(): string;
  64133. /**
  64134. * Parse a JSON input to create back a background material.
  64135. * @param source The JSON data to parse
  64136. * @param scene The scene to create the parsed material in
  64137. * @param rootUrl The root url of the assets the material depends upon
  64138. * @returns the instantiated BackgroundMaterial.
  64139. */
  64140. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  64141. }
  64142. }
  64143. declare module "babylonjs/Helpers/environmentHelper" {
  64144. import { Observable } from "babylonjs/Misc/observable";
  64145. import { Nullable } from "babylonjs/types";
  64146. import { Scene } from "babylonjs/scene";
  64147. import { Vector3 } from "babylonjs/Maths/math.vector";
  64148. import { Color3 } from "babylonjs/Maths/math.color";
  64149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64150. import { Mesh } from "babylonjs/Meshes/mesh";
  64151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64152. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  64153. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64154. import "babylonjs/Meshes/Builders/planeBuilder";
  64155. import "babylonjs/Meshes/Builders/boxBuilder";
  64156. /**
  64157. * Represents the different options available during the creation of
  64158. * a Environment helper.
  64159. *
  64160. * This can control the default ground, skybox and image processing setup of your scene.
  64161. */
  64162. export interface IEnvironmentHelperOptions {
  64163. /**
  64164. * Specifies whether or not to create a ground.
  64165. * True by default.
  64166. */
  64167. createGround: boolean;
  64168. /**
  64169. * Specifies the ground size.
  64170. * 15 by default.
  64171. */
  64172. groundSize: number;
  64173. /**
  64174. * The texture used on the ground for the main color.
  64175. * Comes from the BabylonJS CDN by default.
  64176. *
  64177. * Remarks: Can be either a texture or a url.
  64178. */
  64179. groundTexture: string | BaseTexture;
  64180. /**
  64181. * The color mixed in the ground texture by default.
  64182. * BabylonJS clearColor by default.
  64183. */
  64184. groundColor: Color3;
  64185. /**
  64186. * Specifies the ground opacity.
  64187. * 1 by default.
  64188. */
  64189. groundOpacity: number;
  64190. /**
  64191. * Enables the ground to receive shadows.
  64192. * True by default.
  64193. */
  64194. enableGroundShadow: boolean;
  64195. /**
  64196. * Helps preventing the shadow to be fully black on the ground.
  64197. * 0.5 by default.
  64198. */
  64199. groundShadowLevel: number;
  64200. /**
  64201. * Creates a mirror texture attach to the ground.
  64202. * false by default.
  64203. */
  64204. enableGroundMirror: boolean;
  64205. /**
  64206. * Specifies the ground mirror size ratio.
  64207. * 0.3 by default as the default kernel is 64.
  64208. */
  64209. groundMirrorSizeRatio: number;
  64210. /**
  64211. * Specifies the ground mirror blur kernel size.
  64212. * 64 by default.
  64213. */
  64214. groundMirrorBlurKernel: number;
  64215. /**
  64216. * Specifies the ground mirror visibility amount.
  64217. * 1 by default
  64218. */
  64219. groundMirrorAmount: number;
  64220. /**
  64221. * Specifies the ground mirror reflectance weight.
  64222. * This uses the standard weight of the background material to setup the fresnel effect
  64223. * of the mirror.
  64224. * 1 by default.
  64225. */
  64226. groundMirrorFresnelWeight: number;
  64227. /**
  64228. * Specifies the ground mirror Falloff distance.
  64229. * This can helps reducing the size of the reflection.
  64230. * 0 by Default.
  64231. */
  64232. groundMirrorFallOffDistance: number;
  64233. /**
  64234. * Specifies the ground mirror texture type.
  64235. * Unsigned Int by Default.
  64236. */
  64237. groundMirrorTextureType: number;
  64238. /**
  64239. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  64240. * the shown objects.
  64241. */
  64242. groundYBias: number;
  64243. /**
  64244. * Specifies whether or not to create a skybox.
  64245. * True by default.
  64246. */
  64247. createSkybox: boolean;
  64248. /**
  64249. * Specifies the skybox size.
  64250. * 20 by default.
  64251. */
  64252. skyboxSize: number;
  64253. /**
  64254. * The texture used on the skybox for the main color.
  64255. * Comes from the BabylonJS CDN by default.
  64256. *
  64257. * Remarks: Can be either a texture or a url.
  64258. */
  64259. skyboxTexture: string | BaseTexture;
  64260. /**
  64261. * The color mixed in the skybox texture by default.
  64262. * BabylonJS clearColor by default.
  64263. */
  64264. skyboxColor: Color3;
  64265. /**
  64266. * The background rotation around the Y axis of the scene.
  64267. * This helps aligning the key lights of your scene with the background.
  64268. * 0 by default.
  64269. */
  64270. backgroundYRotation: number;
  64271. /**
  64272. * Compute automatically the size of the elements to best fit with the scene.
  64273. */
  64274. sizeAuto: boolean;
  64275. /**
  64276. * Default position of the rootMesh if autoSize is not true.
  64277. */
  64278. rootPosition: Vector3;
  64279. /**
  64280. * Sets up the image processing in the scene.
  64281. * true by default.
  64282. */
  64283. setupImageProcessing: boolean;
  64284. /**
  64285. * The texture used as your environment texture in the scene.
  64286. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  64287. *
  64288. * Remarks: Can be either a texture or a url.
  64289. */
  64290. environmentTexture: string | BaseTexture;
  64291. /**
  64292. * The value of the exposure to apply to the scene.
  64293. * 0.6 by default if setupImageProcessing is true.
  64294. */
  64295. cameraExposure: number;
  64296. /**
  64297. * The value of the contrast to apply to the scene.
  64298. * 1.6 by default if setupImageProcessing is true.
  64299. */
  64300. cameraContrast: number;
  64301. /**
  64302. * Specifies whether or not tonemapping should be enabled in the scene.
  64303. * true by default if setupImageProcessing is true.
  64304. */
  64305. toneMappingEnabled: boolean;
  64306. }
  64307. /**
  64308. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  64309. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  64310. * It also helps with the default setup of your imageProcessing configuration.
  64311. */
  64312. export class EnvironmentHelper {
  64313. /**
  64314. * Default ground texture URL.
  64315. */
  64316. private static _groundTextureCDNUrl;
  64317. /**
  64318. * Default skybox texture URL.
  64319. */
  64320. private static _skyboxTextureCDNUrl;
  64321. /**
  64322. * Default environment texture URL.
  64323. */
  64324. private static _environmentTextureCDNUrl;
  64325. /**
  64326. * Creates the default options for the helper.
  64327. */
  64328. private static _getDefaultOptions;
  64329. private _rootMesh;
  64330. /**
  64331. * Gets the root mesh created by the helper.
  64332. */
  64333. get rootMesh(): Mesh;
  64334. private _skybox;
  64335. /**
  64336. * Gets the skybox created by the helper.
  64337. */
  64338. get skybox(): Nullable<Mesh>;
  64339. private _skyboxTexture;
  64340. /**
  64341. * Gets the skybox texture created by the helper.
  64342. */
  64343. get skyboxTexture(): Nullable<BaseTexture>;
  64344. private _skyboxMaterial;
  64345. /**
  64346. * Gets the skybox material created by the helper.
  64347. */
  64348. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  64349. private _ground;
  64350. /**
  64351. * Gets the ground mesh created by the helper.
  64352. */
  64353. get ground(): Nullable<Mesh>;
  64354. private _groundTexture;
  64355. /**
  64356. * Gets the ground texture created by the helper.
  64357. */
  64358. get groundTexture(): Nullable<BaseTexture>;
  64359. private _groundMirror;
  64360. /**
  64361. * Gets the ground mirror created by the helper.
  64362. */
  64363. get groundMirror(): Nullable<MirrorTexture>;
  64364. /**
  64365. * Gets the ground mirror render list to helps pushing the meshes
  64366. * you wish in the ground reflection.
  64367. */
  64368. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  64369. private _groundMaterial;
  64370. /**
  64371. * Gets the ground material created by the helper.
  64372. */
  64373. get groundMaterial(): Nullable<BackgroundMaterial>;
  64374. /**
  64375. * Stores the creation options.
  64376. */
  64377. private readonly _scene;
  64378. private _options;
  64379. /**
  64380. * This observable will be notified with any error during the creation of the environment,
  64381. * mainly texture creation errors.
  64382. */
  64383. onErrorObservable: Observable<{
  64384. message?: string;
  64385. exception?: any;
  64386. }>;
  64387. /**
  64388. * constructor
  64389. * @param options Defines the options we want to customize the helper
  64390. * @param scene The scene to add the material to
  64391. */
  64392. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  64393. /**
  64394. * Updates the background according to the new options
  64395. * @param options
  64396. */
  64397. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  64398. /**
  64399. * Sets the primary color of all the available elements.
  64400. * @param color the main color to affect to the ground and the background
  64401. */
  64402. setMainColor(color: Color3): void;
  64403. /**
  64404. * Setup the image processing according to the specified options.
  64405. */
  64406. private _setupImageProcessing;
  64407. /**
  64408. * Setup the environment texture according to the specified options.
  64409. */
  64410. private _setupEnvironmentTexture;
  64411. /**
  64412. * Setup the background according to the specified options.
  64413. */
  64414. private _setupBackground;
  64415. /**
  64416. * Get the scene sizes according to the setup.
  64417. */
  64418. private _getSceneSize;
  64419. /**
  64420. * Setup the ground according to the specified options.
  64421. */
  64422. private _setupGround;
  64423. /**
  64424. * Setup the ground material according to the specified options.
  64425. */
  64426. private _setupGroundMaterial;
  64427. /**
  64428. * Setup the ground diffuse texture according to the specified options.
  64429. */
  64430. private _setupGroundDiffuseTexture;
  64431. /**
  64432. * Setup the ground mirror texture according to the specified options.
  64433. */
  64434. private _setupGroundMirrorTexture;
  64435. /**
  64436. * Setup the ground to receive the mirror texture.
  64437. */
  64438. private _setupMirrorInGroundMaterial;
  64439. /**
  64440. * Setup the skybox according to the specified options.
  64441. */
  64442. private _setupSkybox;
  64443. /**
  64444. * Setup the skybox material according to the specified options.
  64445. */
  64446. private _setupSkyboxMaterial;
  64447. /**
  64448. * Setup the skybox reflection texture according to the specified options.
  64449. */
  64450. private _setupSkyboxReflectionTexture;
  64451. private _errorHandler;
  64452. /**
  64453. * Dispose all the elements created by the Helper.
  64454. */
  64455. dispose(): void;
  64456. }
  64457. }
  64458. declare module "babylonjs/Helpers/textureDome" {
  64459. import { Scene } from "babylonjs/scene";
  64460. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64461. import { Mesh } from "babylonjs/Meshes/mesh";
  64462. import { Texture } from "babylonjs/Materials/Textures/texture";
  64463. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64464. import "babylonjs/Meshes/Builders/sphereBuilder";
  64465. import { Nullable } from "babylonjs/types";
  64466. import { Observable } from "babylonjs/Misc/observable";
  64467. /**
  64468. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  64469. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  64470. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64471. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64472. */
  64473. export abstract class TextureDome<T extends Texture> extends TransformNode {
  64474. protected onError: Nullable<(message?: string, exception?: any) => void>;
  64475. /**
  64476. * Define the source as a Monoscopic panoramic 360/180.
  64477. */
  64478. static readonly MODE_MONOSCOPIC: number;
  64479. /**
  64480. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  64481. */
  64482. static readonly MODE_TOPBOTTOM: number;
  64483. /**
  64484. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  64485. */
  64486. static readonly MODE_SIDEBYSIDE: number;
  64487. private _halfDome;
  64488. private _crossEye;
  64489. protected _useDirectMapping: boolean;
  64490. /**
  64491. * The texture being displayed on the sphere
  64492. */
  64493. protected _texture: T;
  64494. /**
  64495. * Gets the texture being displayed on the sphere
  64496. */
  64497. get texture(): T;
  64498. /**
  64499. * Sets the texture being displayed on the sphere
  64500. */
  64501. set texture(newTexture: T);
  64502. /**
  64503. * The skybox material
  64504. */
  64505. protected _material: BackgroundMaterial;
  64506. /**
  64507. * The surface used for the dome
  64508. */
  64509. protected _mesh: Mesh;
  64510. /**
  64511. * Gets the mesh used for the dome.
  64512. */
  64513. get mesh(): Mesh;
  64514. /**
  64515. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  64516. */
  64517. private _halfDomeMask;
  64518. /**
  64519. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64520. * Also see the options.resolution property.
  64521. */
  64522. get fovMultiplier(): number;
  64523. set fovMultiplier(value: number);
  64524. protected _textureMode: number;
  64525. /**
  64526. * Gets or set the current texture mode for the texture. It can be:
  64527. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64528. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64529. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64530. */
  64531. get textureMode(): number;
  64532. /**
  64533. * Sets the current texture mode for the texture. It can be:
  64534. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64535. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64536. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64537. */
  64538. set textureMode(value: number);
  64539. /**
  64540. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  64541. */
  64542. get halfDome(): boolean;
  64543. /**
  64544. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  64545. */
  64546. set halfDome(enabled: boolean);
  64547. /**
  64548. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  64549. */
  64550. set crossEye(enabled: boolean);
  64551. /**
  64552. * Is it a cross-eye texture?
  64553. */
  64554. get crossEye(): boolean;
  64555. /**
  64556. * The background material of this dome.
  64557. */
  64558. get material(): BackgroundMaterial;
  64559. /**
  64560. * Oberserver used in Stereoscopic VR Mode.
  64561. */
  64562. private _onBeforeCameraRenderObserver;
  64563. /**
  64564. * Observable raised when an error occured while loading the 360 image
  64565. */
  64566. onLoadErrorObservable: Observable<string>;
  64567. /**
  64568. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  64569. * @param name Element's name, child elements will append suffixes for their own names.
  64570. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  64571. * @param options An object containing optional or exposed sub element properties
  64572. */
  64573. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  64574. resolution?: number;
  64575. clickToPlay?: boolean;
  64576. autoPlay?: boolean;
  64577. loop?: boolean;
  64578. size?: number;
  64579. poster?: string;
  64580. faceForward?: boolean;
  64581. useDirectMapping?: boolean;
  64582. halfDomeMode?: boolean;
  64583. crossEyeMode?: boolean;
  64584. generateMipMaps?: boolean;
  64585. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  64586. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  64587. protected _changeTextureMode(value: number): void;
  64588. /**
  64589. * Releases resources associated with this node.
  64590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64592. */
  64593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64594. }
  64595. }
  64596. declare module "babylonjs/Helpers/photoDome" {
  64597. import { Scene } from "babylonjs/scene";
  64598. import { Texture } from "babylonjs/Materials/Textures/texture";
  64599. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64600. /**
  64601. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  64602. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  64603. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64604. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64605. */
  64606. export class PhotoDome extends TextureDome<Texture> {
  64607. /**
  64608. * Define the image as a Monoscopic panoramic 360 image.
  64609. */
  64610. static readonly MODE_MONOSCOPIC: number;
  64611. /**
  64612. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  64613. */
  64614. static readonly MODE_TOPBOTTOM: number;
  64615. /**
  64616. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  64617. */
  64618. static readonly MODE_SIDEBYSIDE: number;
  64619. /**
  64620. * Gets or sets the texture being displayed on the sphere
  64621. */
  64622. get photoTexture(): Texture;
  64623. /**
  64624. * sets the texture being displayed on the sphere
  64625. */
  64626. set photoTexture(value: Texture);
  64627. /**
  64628. * Gets the current video mode for the video. It can be:
  64629. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64630. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64631. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64632. */
  64633. get imageMode(): number;
  64634. /**
  64635. * Sets the current video mode for the video. It can be:
  64636. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64637. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64638. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64639. */
  64640. set imageMode(value: number);
  64641. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  64642. }
  64643. }
  64644. declare module "babylonjs/Misc/dds" {
  64645. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64647. import { Nullable } from "babylonjs/types";
  64648. import { Scene } from "babylonjs/scene";
  64649. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  64650. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64651. /**
  64652. * Direct draw surface info
  64653. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  64654. */
  64655. export interface DDSInfo {
  64656. /**
  64657. * Width of the texture
  64658. */
  64659. width: number;
  64660. /**
  64661. * Width of the texture
  64662. */
  64663. height: number;
  64664. /**
  64665. * Number of Mipmaps for the texture
  64666. * @see https://en.wikipedia.org/wiki/Mipmap
  64667. */
  64668. mipmapCount: number;
  64669. /**
  64670. * If the textures format is a known fourCC format
  64671. * @see https://www.fourcc.org/
  64672. */
  64673. isFourCC: boolean;
  64674. /**
  64675. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  64676. */
  64677. isRGB: boolean;
  64678. /**
  64679. * If the texture is a lumincance format
  64680. */
  64681. isLuminance: boolean;
  64682. /**
  64683. * If this is a cube texture
  64684. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  64685. */
  64686. isCube: boolean;
  64687. /**
  64688. * If the texture is a compressed format eg. FOURCC_DXT1
  64689. */
  64690. isCompressed: boolean;
  64691. /**
  64692. * The dxgiFormat of the texture
  64693. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  64694. */
  64695. dxgiFormat: number;
  64696. /**
  64697. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  64698. */
  64699. textureType: number;
  64700. /**
  64701. * Sphericle polynomial created for the dds texture
  64702. */
  64703. sphericalPolynomial?: SphericalPolynomial;
  64704. }
  64705. /**
  64706. * Class used to provide DDS decompression tools
  64707. */
  64708. export class DDSTools {
  64709. /**
  64710. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  64711. */
  64712. static StoreLODInAlphaChannel: boolean;
  64713. /**
  64714. * Gets DDS information from an array buffer
  64715. * @param data defines the array buffer view to read data from
  64716. * @returns the DDS information
  64717. */
  64718. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  64719. private static _FloatView;
  64720. private static _Int32View;
  64721. private static _ToHalfFloat;
  64722. private static _FromHalfFloat;
  64723. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  64724. private static _GetHalfFloatRGBAArrayBuffer;
  64725. private static _GetFloatRGBAArrayBuffer;
  64726. private static _GetFloatAsUIntRGBAArrayBuffer;
  64727. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  64728. private static _GetRGBAArrayBuffer;
  64729. private static _ExtractLongWordOrder;
  64730. private static _GetRGBArrayBuffer;
  64731. private static _GetLuminanceArrayBuffer;
  64732. /**
  64733. * Uploads DDS Levels to a Babylon Texture
  64734. * @hidden
  64735. */
  64736. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  64737. }
  64738. module "babylonjs/Engines/thinEngine" {
  64739. interface ThinEngine {
  64740. /**
  64741. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  64742. * @param rootUrl defines the url where the file to load is located
  64743. * @param scene defines the current scene
  64744. * @param lodScale defines scale to apply to the mip map selection
  64745. * @param lodOffset defines offset to apply to the mip map selection
  64746. * @param onLoad defines an optional callback raised when the texture is loaded
  64747. * @param onError defines an optional callback raised if there is an issue to load the texture
  64748. * @param format defines the format of the data
  64749. * @param forcedExtension defines the extension to use to pick the right loader
  64750. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  64751. * @returns the cube texture as an InternalTexture
  64752. */
  64753. 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;
  64754. }
  64755. }
  64756. }
  64757. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  64758. import { Nullable } from "babylonjs/types";
  64759. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64760. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64761. /**
  64762. * Implementation of the DDS Texture Loader.
  64763. * @hidden
  64764. */
  64765. export class _DDSTextureLoader implements IInternalTextureLoader {
  64766. /**
  64767. * Defines wether the loader supports cascade loading the different faces.
  64768. */
  64769. readonly supportCascades: boolean;
  64770. /**
  64771. * This returns if the loader support the current file information.
  64772. * @param extension defines the file extension of the file being loaded
  64773. * @returns true if the loader can load the specified file
  64774. */
  64775. canLoad(extension: string): boolean;
  64776. /**
  64777. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64778. * @param data contains the texture data
  64779. * @param texture defines the BabylonJS internal texture
  64780. * @param createPolynomials will be true if polynomials have been requested
  64781. * @param onLoad defines the callback to trigger once the texture is ready
  64782. * @param onError defines the callback to trigger in case of error
  64783. */
  64784. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64785. /**
  64786. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64787. * @param data contains the texture data
  64788. * @param texture defines the BabylonJS internal texture
  64789. * @param callback defines the method to call once ready to upload
  64790. */
  64791. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64792. }
  64793. }
  64794. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  64795. import { Nullable } from "babylonjs/types";
  64796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64797. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64798. /**
  64799. * Implementation of the ENV Texture Loader.
  64800. * @hidden
  64801. */
  64802. export class _ENVTextureLoader implements IInternalTextureLoader {
  64803. /**
  64804. * Defines wether the loader supports cascade loading the different faces.
  64805. */
  64806. readonly supportCascades: boolean;
  64807. /**
  64808. * This returns if the loader support the current file information.
  64809. * @param extension defines the file extension of the file being loaded
  64810. * @returns true if the loader can load the specified file
  64811. */
  64812. canLoad(extension: string): boolean;
  64813. /**
  64814. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64815. * @param data contains the texture data
  64816. * @param texture defines the BabylonJS internal texture
  64817. * @param createPolynomials will be true if polynomials have been requested
  64818. * @param onLoad defines the callback to trigger once the texture is ready
  64819. * @param onError defines the callback to trigger in case of error
  64820. */
  64821. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64822. /**
  64823. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64824. * @param data contains the texture data
  64825. * @param texture defines the BabylonJS internal texture
  64826. * @param callback defines the method to call once ready to upload
  64827. */
  64828. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64829. }
  64830. }
  64831. declare module "babylonjs/Misc/khronosTextureContainer" {
  64832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64833. /**
  64834. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  64835. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  64836. */
  64837. export class KhronosTextureContainer {
  64838. /** contents of the KTX container file */
  64839. data: ArrayBufferView;
  64840. private static HEADER_LEN;
  64841. private static COMPRESSED_2D;
  64842. private static COMPRESSED_3D;
  64843. private static TEX_2D;
  64844. private static TEX_3D;
  64845. /**
  64846. * Gets the openGL type
  64847. */
  64848. glType: number;
  64849. /**
  64850. * Gets the openGL type size
  64851. */
  64852. glTypeSize: number;
  64853. /**
  64854. * Gets the openGL format
  64855. */
  64856. glFormat: number;
  64857. /**
  64858. * Gets the openGL internal format
  64859. */
  64860. glInternalFormat: number;
  64861. /**
  64862. * Gets the base internal format
  64863. */
  64864. glBaseInternalFormat: number;
  64865. /**
  64866. * Gets image width in pixel
  64867. */
  64868. pixelWidth: number;
  64869. /**
  64870. * Gets image height in pixel
  64871. */
  64872. pixelHeight: number;
  64873. /**
  64874. * Gets image depth in pixels
  64875. */
  64876. pixelDepth: number;
  64877. /**
  64878. * Gets the number of array elements
  64879. */
  64880. numberOfArrayElements: number;
  64881. /**
  64882. * Gets the number of faces
  64883. */
  64884. numberOfFaces: number;
  64885. /**
  64886. * Gets the number of mipmap levels
  64887. */
  64888. numberOfMipmapLevels: number;
  64889. /**
  64890. * Gets the bytes of key value data
  64891. */
  64892. bytesOfKeyValueData: number;
  64893. /**
  64894. * Gets the load type
  64895. */
  64896. loadType: number;
  64897. /**
  64898. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  64899. */
  64900. isInvalid: boolean;
  64901. /**
  64902. * Creates a new KhronosTextureContainer
  64903. * @param data contents of the KTX container file
  64904. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  64905. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  64906. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  64907. */
  64908. constructor(
  64909. /** contents of the KTX container file */
  64910. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  64911. /**
  64912. * Uploads KTX content to a Babylon Texture.
  64913. * It is assumed that the texture has already been created & is currently bound
  64914. * @hidden
  64915. */
  64916. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  64917. private _upload2DCompressedLevels;
  64918. /**
  64919. * Checks if the given data starts with a KTX file identifier.
  64920. * @param data the data to check
  64921. * @returns true if the data is a KTX file or false otherwise
  64922. */
  64923. static IsValid(data: ArrayBufferView): boolean;
  64924. }
  64925. }
  64926. declare module "babylonjs/Misc/workerPool" {
  64927. import { IDisposable } from "babylonjs/scene";
  64928. /**
  64929. * Helper class to push actions to a pool of workers.
  64930. */
  64931. export class WorkerPool implements IDisposable {
  64932. private _workerInfos;
  64933. private _pendingActions;
  64934. /**
  64935. * Constructor
  64936. * @param workers Array of workers to use for actions
  64937. */
  64938. constructor(workers: Array<Worker>);
  64939. /**
  64940. * Terminates all workers and clears any pending actions.
  64941. */
  64942. dispose(): void;
  64943. /**
  64944. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64945. * pended until a worker has completed its action.
  64946. * @param action The action to perform. Call onComplete when the action is complete.
  64947. */
  64948. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64949. private _execute;
  64950. }
  64951. }
  64952. declare module "babylonjs/Misc/khronosTextureContainer2" {
  64953. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64954. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64955. /**
  64956. * Class for loading KTX2 files
  64957. */
  64958. export class KhronosTextureContainer2 {
  64959. private static _WorkerPoolPromise?;
  64960. private static _Initialized;
  64961. private static _Ktx2Decoder;
  64962. /**
  64963. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  64964. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  64965. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  64966. * Urls you can change:
  64967. * URLConfig.jsDecoderModule
  64968. * URLConfig.wasmUASTCToASTC
  64969. * URLConfig.wasmUASTCToBC7
  64970. * URLConfig.wasmUASTCToRGBA_UNORM
  64971. * URLConfig.wasmUASTCToRGBA_SRGB
  64972. * URLConfig.jsMSCTranscoder
  64973. * URLConfig.wasmMSCTranscoder
  64974. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  64975. */
  64976. static URLConfig: {
  64977. jsDecoderModule: string;
  64978. wasmUASTCToASTC: null;
  64979. wasmUASTCToBC7: null;
  64980. wasmUASTCToRGBA_UNORM: null;
  64981. wasmUASTCToRGBA_SRGB: null;
  64982. jsMSCTranscoder: null;
  64983. wasmMSCTranscoder: null;
  64984. };
  64985. /**
  64986. * Default number of workers used to handle data decoding
  64987. */
  64988. static DefaultNumWorkers: number;
  64989. private static GetDefaultNumWorkers;
  64990. private _engine;
  64991. private static _CreateWorkerPool;
  64992. /**
  64993. * Constructor
  64994. * @param engine The engine to use
  64995. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64996. */
  64997. constructor(engine: ThinEngine, numWorkers?: number);
  64998. /** @hidden */
  64999. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  65000. /**
  65001. * Stop all async operations and release resources.
  65002. */
  65003. dispose(): void;
  65004. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  65005. /**
  65006. * Checks if the given data starts with a KTX2 file identifier.
  65007. * @param data the data to check
  65008. * @returns true if the data is a KTX2 file or false otherwise
  65009. */
  65010. static IsValid(data: ArrayBufferView): boolean;
  65011. }
  65012. }
  65013. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  65014. import { Nullable } from "babylonjs/types";
  65015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65016. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65017. /**
  65018. * Implementation of the KTX Texture Loader.
  65019. * @hidden
  65020. */
  65021. export class _KTXTextureLoader implements IInternalTextureLoader {
  65022. /**
  65023. * Defines wether the loader supports cascade loading the different faces.
  65024. */
  65025. readonly supportCascades: boolean;
  65026. /**
  65027. * This returns if the loader support the current file information.
  65028. * @param extension defines the file extension of the file being loaded
  65029. * @param mimeType defines the optional mime type of the file being loaded
  65030. * @returns true if the loader can load the specified file
  65031. */
  65032. canLoad(extension: string, mimeType?: string): boolean;
  65033. /**
  65034. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65035. * @param data contains the texture data
  65036. * @param texture defines the BabylonJS internal texture
  65037. * @param createPolynomials will be true if polynomials have been requested
  65038. * @param onLoad defines the callback to trigger once the texture is ready
  65039. * @param onError defines the callback to trigger in case of error
  65040. */
  65041. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65042. /**
  65043. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65044. * @param data contains the texture data
  65045. * @param texture defines the BabylonJS internal texture
  65046. * @param callback defines the method to call once ready to upload
  65047. */
  65048. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  65049. }
  65050. }
  65051. declare module "babylonjs/Helpers/sceneHelpers" {
  65052. import { Nullable } from "babylonjs/types";
  65053. import { Mesh } from "babylonjs/Meshes/mesh";
  65054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65055. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  65056. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  65057. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65058. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65059. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65060. import "babylonjs/Meshes/Builders/boxBuilder";
  65061. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  65062. /** @hidden */
  65063. export var _forceSceneHelpersToBundle: boolean;
  65064. module "babylonjs/scene" {
  65065. interface Scene {
  65066. /**
  65067. * Creates a default light for the scene.
  65068. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  65069. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  65070. */
  65071. createDefaultLight(replace?: boolean): void;
  65072. /**
  65073. * Creates a default camera for the scene.
  65074. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  65075. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65076. * @param replace has default false, when true replaces the active camera in the scene
  65077. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  65078. */
  65079. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65080. /**
  65081. * Creates a default camera and a default light.
  65082. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  65083. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65084. * @param replace has the default false, when true replaces the active camera/light in the scene
  65085. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  65086. */
  65087. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65088. /**
  65089. * Creates a new sky box
  65090. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  65091. * @param environmentTexture defines the texture to use as environment texture
  65092. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  65093. * @param scale defines the overall scale of the skybox
  65094. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  65095. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  65096. * @returns a new mesh holding the sky box
  65097. */
  65098. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  65099. /**
  65100. * Creates a new environment
  65101. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  65102. * @param options defines the options you can use to configure the environment
  65103. * @returns the new EnvironmentHelper
  65104. */
  65105. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  65106. /**
  65107. * Creates a new VREXperienceHelper
  65108. * @see https://doc.babylonjs.com/how_to/webvr_helper
  65109. * @param webVROptions defines the options used to create the new VREXperienceHelper
  65110. * @returns a new VREXperienceHelper
  65111. */
  65112. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  65113. /**
  65114. * Creates a new WebXRDefaultExperience
  65115. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  65116. * @param options experience options
  65117. * @returns a promise for a new WebXRDefaultExperience
  65118. */
  65119. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  65120. }
  65121. }
  65122. }
  65123. declare module "babylonjs/Helpers/videoDome" {
  65124. import { Scene } from "babylonjs/scene";
  65125. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  65126. import { TextureDome } from "babylonjs/Helpers/textureDome";
  65127. /**
  65128. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  65129. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  65130. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  65131. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  65132. */
  65133. export class VideoDome extends TextureDome<VideoTexture> {
  65134. /**
  65135. * Define the video source as a Monoscopic panoramic 360 video.
  65136. */
  65137. static readonly MODE_MONOSCOPIC: number;
  65138. /**
  65139. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  65140. */
  65141. static readonly MODE_TOPBOTTOM: number;
  65142. /**
  65143. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  65144. */
  65145. static readonly MODE_SIDEBYSIDE: number;
  65146. /**
  65147. * Get the video texture associated with this video dome
  65148. */
  65149. get videoTexture(): VideoTexture;
  65150. /**
  65151. * Get the video mode of this dome
  65152. */
  65153. get videoMode(): number;
  65154. /**
  65155. * Set the video mode of this dome.
  65156. * @see textureMode
  65157. */
  65158. set videoMode(value: number);
  65159. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  65160. }
  65161. }
  65162. declare module "babylonjs/Helpers/index" {
  65163. export * from "babylonjs/Helpers/environmentHelper";
  65164. export * from "babylonjs/Helpers/photoDome";
  65165. export * from "babylonjs/Helpers/sceneHelpers";
  65166. export * from "babylonjs/Helpers/videoDome";
  65167. }
  65168. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  65169. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65170. import { IDisposable } from "babylonjs/scene";
  65171. import { Engine } from "babylonjs/Engines/engine";
  65172. /**
  65173. * This class can be used to get instrumentation data from a Babylon engine
  65174. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65175. */
  65176. export class EngineInstrumentation implements IDisposable {
  65177. /**
  65178. * Define the instrumented engine.
  65179. */
  65180. engine: Engine;
  65181. private _captureGPUFrameTime;
  65182. private _gpuFrameTimeToken;
  65183. private _gpuFrameTime;
  65184. private _captureShaderCompilationTime;
  65185. private _shaderCompilationTime;
  65186. private _onBeginFrameObserver;
  65187. private _onEndFrameObserver;
  65188. private _onBeforeShaderCompilationObserver;
  65189. private _onAfterShaderCompilationObserver;
  65190. /**
  65191. * Gets the perf counter used for GPU frame time
  65192. */
  65193. get gpuFrameTimeCounter(): PerfCounter;
  65194. /**
  65195. * Gets the GPU frame time capture status
  65196. */
  65197. get captureGPUFrameTime(): boolean;
  65198. /**
  65199. * Enable or disable the GPU frame time capture
  65200. */
  65201. set captureGPUFrameTime(value: boolean);
  65202. /**
  65203. * Gets the perf counter used for shader compilation time
  65204. */
  65205. get shaderCompilationTimeCounter(): PerfCounter;
  65206. /**
  65207. * Gets the shader compilation time capture status
  65208. */
  65209. get captureShaderCompilationTime(): boolean;
  65210. /**
  65211. * Enable or disable the shader compilation time capture
  65212. */
  65213. set captureShaderCompilationTime(value: boolean);
  65214. /**
  65215. * Instantiates a new engine instrumentation.
  65216. * This class can be used to get instrumentation data from a Babylon engine
  65217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65218. * @param engine Defines the engine to instrument
  65219. */
  65220. constructor(
  65221. /**
  65222. * Define the instrumented engine.
  65223. */
  65224. engine: Engine);
  65225. /**
  65226. * Dispose and release associated resources.
  65227. */
  65228. dispose(): void;
  65229. }
  65230. }
  65231. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  65232. import { Scene, IDisposable } from "babylonjs/scene";
  65233. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65234. /**
  65235. * This class can be used to get instrumentation data from a Babylon engine
  65236. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65237. */
  65238. export class SceneInstrumentation implements IDisposable {
  65239. /**
  65240. * Defines the scene to instrument
  65241. */
  65242. scene: Scene;
  65243. private _captureActiveMeshesEvaluationTime;
  65244. private _activeMeshesEvaluationTime;
  65245. private _captureRenderTargetsRenderTime;
  65246. private _renderTargetsRenderTime;
  65247. private _captureFrameTime;
  65248. private _frameTime;
  65249. private _captureRenderTime;
  65250. private _renderTime;
  65251. private _captureInterFrameTime;
  65252. private _interFrameTime;
  65253. private _captureParticlesRenderTime;
  65254. private _particlesRenderTime;
  65255. private _captureSpritesRenderTime;
  65256. private _spritesRenderTime;
  65257. private _capturePhysicsTime;
  65258. private _physicsTime;
  65259. private _captureAnimationsTime;
  65260. private _animationsTime;
  65261. private _captureCameraRenderTime;
  65262. private _cameraRenderTime;
  65263. private _onBeforeActiveMeshesEvaluationObserver;
  65264. private _onAfterActiveMeshesEvaluationObserver;
  65265. private _onBeforeRenderTargetsRenderObserver;
  65266. private _onAfterRenderTargetsRenderObserver;
  65267. private _onAfterRenderObserver;
  65268. private _onBeforeDrawPhaseObserver;
  65269. private _onAfterDrawPhaseObserver;
  65270. private _onBeforeAnimationsObserver;
  65271. private _onBeforeParticlesRenderingObserver;
  65272. private _onAfterParticlesRenderingObserver;
  65273. private _onBeforeSpritesRenderingObserver;
  65274. private _onAfterSpritesRenderingObserver;
  65275. private _onBeforePhysicsObserver;
  65276. private _onAfterPhysicsObserver;
  65277. private _onAfterAnimationsObserver;
  65278. private _onBeforeCameraRenderObserver;
  65279. private _onAfterCameraRenderObserver;
  65280. /**
  65281. * Gets the perf counter used for active meshes evaluation time
  65282. */
  65283. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  65284. /**
  65285. * Gets the active meshes evaluation time capture status
  65286. */
  65287. get captureActiveMeshesEvaluationTime(): boolean;
  65288. /**
  65289. * Enable or disable the active meshes evaluation time capture
  65290. */
  65291. set captureActiveMeshesEvaluationTime(value: boolean);
  65292. /**
  65293. * Gets the perf counter used for render targets render time
  65294. */
  65295. get renderTargetsRenderTimeCounter(): PerfCounter;
  65296. /**
  65297. * Gets the render targets render time capture status
  65298. */
  65299. get captureRenderTargetsRenderTime(): boolean;
  65300. /**
  65301. * Enable or disable the render targets render time capture
  65302. */
  65303. set captureRenderTargetsRenderTime(value: boolean);
  65304. /**
  65305. * Gets the perf counter used for particles render time
  65306. */
  65307. get particlesRenderTimeCounter(): PerfCounter;
  65308. /**
  65309. * Gets the particles render time capture status
  65310. */
  65311. get captureParticlesRenderTime(): boolean;
  65312. /**
  65313. * Enable or disable the particles render time capture
  65314. */
  65315. set captureParticlesRenderTime(value: boolean);
  65316. /**
  65317. * Gets the perf counter used for sprites render time
  65318. */
  65319. get spritesRenderTimeCounter(): PerfCounter;
  65320. /**
  65321. * Gets the sprites render time capture status
  65322. */
  65323. get captureSpritesRenderTime(): boolean;
  65324. /**
  65325. * Enable or disable the sprites render time capture
  65326. */
  65327. set captureSpritesRenderTime(value: boolean);
  65328. /**
  65329. * Gets the perf counter used for physics time
  65330. */
  65331. get physicsTimeCounter(): PerfCounter;
  65332. /**
  65333. * Gets the physics time capture status
  65334. */
  65335. get capturePhysicsTime(): boolean;
  65336. /**
  65337. * Enable or disable the physics time capture
  65338. */
  65339. set capturePhysicsTime(value: boolean);
  65340. /**
  65341. * Gets the perf counter used for animations time
  65342. */
  65343. get animationsTimeCounter(): PerfCounter;
  65344. /**
  65345. * Gets the animations time capture status
  65346. */
  65347. get captureAnimationsTime(): boolean;
  65348. /**
  65349. * Enable or disable the animations time capture
  65350. */
  65351. set captureAnimationsTime(value: boolean);
  65352. /**
  65353. * Gets the perf counter used for frame time capture
  65354. */
  65355. get frameTimeCounter(): PerfCounter;
  65356. /**
  65357. * Gets the frame time capture status
  65358. */
  65359. get captureFrameTime(): boolean;
  65360. /**
  65361. * Enable or disable the frame time capture
  65362. */
  65363. set captureFrameTime(value: boolean);
  65364. /**
  65365. * Gets the perf counter used for inter-frames time capture
  65366. */
  65367. get interFrameTimeCounter(): PerfCounter;
  65368. /**
  65369. * Gets the inter-frames time capture status
  65370. */
  65371. get captureInterFrameTime(): boolean;
  65372. /**
  65373. * Enable or disable the inter-frames time capture
  65374. */
  65375. set captureInterFrameTime(value: boolean);
  65376. /**
  65377. * Gets the perf counter used for render time capture
  65378. */
  65379. get renderTimeCounter(): PerfCounter;
  65380. /**
  65381. * Gets the render time capture status
  65382. */
  65383. get captureRenderTime(): boolean;
  65384. /**
  65385. * Enable or disable the render time capture
  65386. */
  65387. set captureRenderTime(value: boolean);
  65388. /**
  65389. * Gets the perf counter used for camera render time capture
  65390. */
  65391. get cameraRenderTimeCounter(): PerfCounter;
  65392. /**
  65393. * Gets the camera render time capture status
  65394. */
  65395. get captureCameraRenderTime(): boolean;
  65396. /**
  65397. * Enable or disable the camera render time capture
  65398. */
  65399. set captureCameraRenderTime(value: boolean);
  65400. /**
  65401. * Gets the perf counter used for draw calls
  65402. */
  65403. get drawCallsCounter(): PerfCounter;
  65404. /**
  65405. * Instantiates a new scene instrumentation.
  65406. * This class can be used to get instrumentation data from a Babylon engine
  65407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65408. * @param scene Defines the scene to instrument
  65409. */
  65410. constructor(
  65411. /**
  65412. * Defines the scene to instrument
  65413. */
  65414. scene: Scene);
  65415. /**
  65416. * Dispose and release associated resources.
  65417. */
  65418. dispose(): void;
  65419. }
  65420. }
  65421. declare module "babylonjs/Instrumentation/index" {
  65422. export * from "babylonjs/Instrumentation/engineInstrumentation";
  65423. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  65424. export * from "babylonjs/Instrumentation/timeToken";
  65425. }
  65426. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  65427. /** @hidden */
  65428. export var glowMapGenerationPixelShader: {
  65429. name: string;
  65430. shader: string;
  65431. };
  65432. }
  65433. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  65434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65437. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65439. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65440. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65441. /** @hidden */
  65442. export var glowMapGenerationVertexShader: {
  65443. name: string;
  65444. shader: string;
  65445. };
  65446. }
  65447. declare module "babylonjs/Layers/effectLayer" {
  65448. import { Observable } from "babylonjs/Misc/observable";
  65449. import { Nullable } from "babylonjs/types";
  65450. import { Camera } from "babylonjs/Cameras/camera";
  65451. import { Scene } from "babylonjs/scene";
  65452. import { ISize } from "babylonjs/Maths/math.size";
  65453. import { Color4 } from "babylonjs/Maths/math.color";
  65454. import { Engine } from "babylonjs/Engines/engine";
  65455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65457. import { Mesh } from "babylonjs/Meshes/mesh";
  65458. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65461. import { Effect } from "babylonjs/Materials/effect";
  65462. import { Material } from "babylonjs/Materials/material";
  65463. import "babylonjs/Shaders/glowMapGeneration.fragment";
  65464. import "babylonjs/Shaders/glowMapGeneration.vertex";
  65465. /**
  65466. * Effect layer options. This helps customizing the behaviour
  65467. * of the effect layer.
  65468. */
  65469. export interface IEffectLayerOptions {
  65470. /**
  65471. * Multiplication factor apply to the canvas size to compute the render target size
  65472. * used to generated the objects (the smaller the faster).
  65473. */
  65474. mainTextureRatio: number;
  65475. /**
  65476. * Enforces a fixed size texture to ensure effect stability across devices.
  65477. */
  65478. mainTextureFixedSize?: number;
  65479. /**
  65480. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  65481. */
  65482. alphaBlendingMode: number;
  65483. /**
  65484. * The camera attached to the layer.
  65485. */
  65486. camera: Nullable<Camera>;
  65487. /**
  65488. * The rendering group to draw the layer in.
  65489. */
  65490. renderingGroupId: number;
  65491. }
  65492. /**
  65493. * The effect layer Helps adding post process effect blended with the main pass.
  65494. *
  65495. * This can be for instance use to generate glow or higlight effects on the scene.
  65496. *
  65497. * The effect layer class can not be used directly and is intented to inherited from to be
  65498. * customized per effects.
  65499. */
  65500. export abstract class EffectLayer {
  65501. private _vertexBuffers;
  65502. private _indexBuffer;
  65503. private _cachedDefines;
  65504. private _effectLayerMapGenerationEffect;
  65505. private _effectLayerOptions;
  65506. private _mergeEffect;
  65507. protected _scene: Scene;
  65508. protected _engine: Engine;
  65509. protected _maxSize: number;
  65510. protected _mainTextureDesiredSize: ISize;
  65511. protected _mainTexture: RenderTargetTexture;
  65512. protected _shouldRender: boolean;
  65513. protected _postProcesses: PostProcess[];
  65514. protected _textures: BaseTexture[];
  65515. protected _emissiveTextureAndColor: {
  65516. texture: Nullable<BaseTexture>;
  65517. color: Color4;
  65518. };
  65519. /**
  65520. * The name of the layer
  65521. */
  65522. name: string;
  65523. /**
  65524. * The clear color of the texture used to generate the glow map.
  65525. */
  65526. neutralColor: Color4;
  65527. /**
  65528. * Specifies whether the highlight layer is enabled or not.
  65529. */
  65530. isEnabled: boolean;
  65531. /**
  65532. * Gets the camera attached to the layer.
  65533. */
  65534. get camera(): Nullable<Camera>;
  65535. /**
  65536. * Gets the rendering group id the layer should render in.
  65537. */
  65538. get renderingGroupId(): number;
  65539. set renderingGroupId(renderingGroupId: number);
  65540. /**
  65541. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  65542. */
  65543. disableBoundingBoxesFromEffectLayer: boolean;
  65544. /**
  65545. * An event triggered when the effect layer has been disposed.
  65546. */
  65547. onDisposeObservable: Observable<EffectLayer>;
  65548. /**
  65549. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  65550. */
  65551. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  65552. /**
  65553. * An event triggered when the generated texture is being merged in the scene.
  65554. */
  65555. onBeforeComposeObservable: Observable<EffectLayer>;
  65556. /**
  65557. * An event triggered when the mesh is rendered into the effect render target.
  65558. */
  65559. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  65560. /**
  65561. * An event triggered after the mesh has been rendered into the effect render target.
  65562. */
  65563. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  65564. /**
  65565. * An event triggered when the generated texture has been merged in the scene.
  65566. */
  65567. onAfterComposeObservable: Observable<EffectLayer>;
  65568. /**
  65569. * An event triggered when the efffect layer changes its size.
  65570. */
  65571. onSizeChangedObservable: Observable<EffectLayer>;
  65572. /** @hidden */
  65573. static _SceneComponentInitialization: (scene: Scene) => void;
  65574. /**
  65575. * Instantiates a new effect Layer and references it in the scene.
  65576. * @param name The name of the layer
  65577. * @param scene The scene to use the layer in
  65578. */
  65579. constructor(
  65580. /** The Friendly of the effect in the scene */
  65581. name: string, scene: Scene);
  65582. /**
  65583. * Get the effect name of the layer.
  65584. * @return The effect name
  65585. */
  65586. abstract getEffectName(): string;
  65587. /**
  65588. * Checks for the readiness of the element composing the layer.
  65589. * @param subMesh the mesh to check for
  65590. * @param useInstances specify whether or not to use instances to render the mesh
  65591. * @return true if ready otherwise, false
  65592. */
  65593. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65594. /**
  65595. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65596. * @returns true if the effect requires stencil during the main canvas render pass.
  65597. */
  65598. abstract needStencil(): boolean;
  65599. /**
  65600. * Create the merge effect. This is the shader use to blit the information back
  65601. * to the main canvas at the end of the scene rendering.
  65602. * @returns The effect containing the shader used to merge the effect on the main canvas
  65603. */
  65604. protected abstract _createMergeEffect(): Effect;
  65605. /**
  65606. * Creates the render target textures and post processes used in the effect layer.
  65607. */
  65608. protected abstract _createTextureAndPostProcesses(): void;
  65609. /**
  65610. * Implementation specific of rendering the generating effect on the main canvas.
  65611. * @param effect The effect used to render through
  65612. */
  65613. protected abstract _internalRender(effect: Effect): void;
  65614. /**
  65615. * Sets the required values for both the emissive texture and and the main color.
  65616. */
  65617. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65618. /**
  65619. * Free any resources and references associated to a mesh.
  65620. * Internal use
  65621. * @param mesh The mesh to free.
  65622. */
  65623. abstract _disposeMesh(mesh: Mesh): void;
  65624. /**
  65625. * Serializes this layer (Glow or Highlight for example)
  65626. * @returns a serialized layer object
  65627. */
  65628. abstract serialize?(): any;
  65629. /**
  65630. * Initializes the effect layer with the required options.
  65631. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  65632. */
  65633. protected _init(options: Partial<IEffectLayerOptions>): void;
  65634. /**
  65635. * Generates the index buffer of the full screen quad blending to the main canvas.
  65636. */
  65637. private _generateIndexBuffer;
  65638. /**
  65639. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  65640. */
  65641. private _generateVertexBuffer;
  65642. /**
  65643. * Sets the main texture desired size which is the closest power of two
  65644. * of the engine canvas size.
  65645. */
  65646. private _setMainTextureSize;
  65647. /**
  65648. * Creates the main texture for the effect layer.
  65649. */
  65650. protected _createMainTexture(): void;
  65651. /**
  65652. * Adds specific effects defines.
  65653. * @param defines The defines to add specifics to.
  65654. */
  65655. protected _addCustomEffectDefines(defines: string[]): void;
  65656. /**
  65657. * Checks for the readiness of the element composing the layer.
  65658. * @param subMesh the mesh to check for
  65659. * @param useInstances specify whether or not to use instances to render the mesh
  65660. * @param emissiveTexture the associated emissive texture used to generate the glow
  65661. * @return true if ready otherwise, false
  65662. */
  65663. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  65664. /**
  65665. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  65666. */
  65667. render(): void;
  65668. /**
  65669. * Determine if a given mesh will be used in the current effect.
  65670. * @param mesh mesh to test
  65671. * @returns true if the mesh will be used
  65672. */
  65673. hasMesh(mesh: AbstractMesh): boolean;
  65674. /**
  65675. * Returns true if the layer contains information to display, otherwise false.
  65676. * @returns true if the glow layer should be rendered
  65677. */
  65678. shouldRender(): boolean;
  65679. /**
  65680. * Returns true if the mesh should render, otherwise false.
  65681. * @param mesh The mesh to render
  65682. * @returns true if it should render otherwise false
  65683. */
  65684. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  65685. /**
  65686. * Returns true if the mesh can be rendered, otherwise false.
  65687. * @param mesh The mesh to render
  65688. * @param material The material used on the mesh
  65689. * @returns true if it can be rendered otherwise false
  65690. */
  65691. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65692. /**
  65693. * Returns true if the mesh should render, otherwise false.
  65694. * @param mesh The mesh to render
  65695. * @returns true if it should render otherwise false
  65696. */
  65697. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  65698. /**
  65699. * Renders the submesh passed in parameter to the generation map.
  65700. */
  65701. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  65702. /**
  65703. * Defines whether the current material of the mesh should be use to render the effect.
  65704. * @param mesh defines the current mesh to render
  65705. */
  65706. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65707. /**
  65708. * Rebuild the required buffers.
  65709. * @hidden Internal use only.
  65710. */
  65711. _rebuild(): void;
  65712. /**
  65713. * Dispose only the render target textures and post process.
  65714. */
  65715. private _disposeTextureAndPostProcesses;
  65716. /**
  65717. * Dispose the highlight layer and free resources.
  65718. */
  65719. dispose(): void;
  65720. /**
  65721. * Gets the class name of the effect layer
  65722. * @returns the string with the class name of the effect layer
  65723. */
  65724. getClassName(): string;
  65725. /**
  65726. * Creates an effect layer from parsed effect layer data
  65727. * @param parsedEffectLayer defines effect layer data
  65728. * @param scene defines the current scene
  65729. * @param rootUrl defines the root URL containing the effect layer information
  65730. * @returns a parsed effect Layer
  65731. */
  65732. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  65733. }
  65734. }
  65735. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  65736. import { Scene } from "babylonjs/scene";
  65737. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  65738. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65739. import { AbstractScene } from "babylonjs/abstractScene";
  65740. module "babylonjs/abstractScene" {
  65741. interface AbstractScene {
  65742. /**
  65743. * The list of effect layers (highlights/glow) added to the scene
  65744. * @see https://doc.babylonjs.com/how_to/highlight_layer
  65745. * @see https://doc.babylonjs.com/how_to/glow_layer
  65746. */
  65747. effectLayers: Array<EffectLayer>;
  65748. /**
  65749. * Removes the given effect layer from this scene.
  65750. * @param toRemove defines the effect layer to remove
  65751. * @returns the index of the removed effect layer
  65752. */
  65753. removeEffectLayer(toRemove: EffectLayer): number;
  65754. /**
  65755. * Adds the given effect layer to this scene
  65756. * @param newEffectLayer defines the effect layer to add
  65757. */
  65758. addEffectLayer(newEffectLayer: EffectLayer): void;
  65759. }
  65760. }
  65761. /**
  65762. * Defines the layer scene component responsible to manage any effect layers
  65763. * in a given scene.
  65764. */
  65765. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  65766. /**
  65767. * The component name helpfull to identify the component in the list of scene components.
  65768. */
  65769. readonly name: string;
  65770. /**
  65771. * The scene the component belongs to.
  65772. */
  65773. scene: Scene;
  65774. private _engine;
  65775. private _renderEffects;
  65776. private _needStencil;
  65777. private _previousStencilState;
  65778. /**
  65779. * Creates a new instance of the component for the given scene
  65780. * @param scene Defines the scene to register the component in
  65781. */
  65782. constructor(scene: Scene);
  65783. /**
  65784. * Registers the component in a given scene
  65785. */
  65786. register(): void;
  65787. /**
  65788. * Rebuilds the elements related to this component in case of
  65789. * context lost for instance.
  65790. */
  65791. rebuild(): void;
  65792. /**
  65793. * Serializes the component data to the specified json object
  65794. * @param serializationObject The object to serialize to
  65795. */
  65796. serialize(serializationObject: any): void;
  65797. /**
  65798. * Adds all the elements from the container to the scene
  65799. * @param container the container holding the elements
  65800. */
  65801. addFromContainer(container: AbstractScene): void;
  65802. /**
  65803. * Removes all the elements in the container from the scene
  65804. * @param container contains the elements to remove
  65805. * @param dispose if the removed element should be disposed (default: false)
  65806. */
  65807. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65808. /**
  65809. * Disposes the component and the associated ressources.
  65810. */
  65811. dispose(): void;
  65812. private _isReadyForMesh;
  65813. private _renderMainTexture;
  65814. private _setStencil;
  65815. private _setStencilBack;
  65816. private _draw;
  65817. private _drawCamera;
  65818. private _drawRenderingGroup;
  65819. }
  65820. }
  65821. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  65822. /** @hidden */
  65823. export var glowMapMergePixelShader: {
  65824. name: string;
  65825. shader: string;
  65826. };
  65827. }
  65828. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  65829. /** @hidden */
  65830. export var glowMapMergeVertexShader: {
  65831. name: string;
  65832. shader: string;
  65833. };
  65834. }
  65835. declare module "babylonjs/Layers/glowLayer" {
  65836. import { Nullable } from "babylonjs/types";
  65837. import { Camera } from "babylonjs/Cameras/camera";
  65838. import { Scene } from "babylonjs/scene";
  65839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65841. import { Mesh } from "babylonjs/Meshes/mesh";
  65842. import { Texture } from "babylonjs/Materials/Textures/texture";
  65843. import { Effect } from "babylonjs/Materials/effect";
  65844. import { Material } from "babylonjs/Materials/material";
  65845. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65846. import { Color4 } from "babylonjs/Maths/math.color";
  65847. import "babylonjs/Shaders/glowMapMerge.fragment";
  65848. import "babylonjs/Shaders/glowMapMerge.vertex";
  65849. import "babylonjs/Layers/effectLayerSceneComponent";
  65850. module "babylonjs/abstractScene" {
  65851. interface AbstractScene {
  65852. /**
  65853. * Return a the first highlight layer of the scene with a given name.
  65854. * @param name The name of the highlight layer to look for.
  65855. * @return The highlight layer if found otherwise null.
  65856. */
  65857. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  65858. }
  65859. }
  65860. /**
  65861. * Glow layer options. This helps customizing the behaviour
  65862. * of the glow layer.
  65863. */
  65864. export interface IGlowLayerOptions {
  65865. /**
  65866. * Multiplication factor apply to the canvas size to compute the render target size
  65867. * used to generated the glowing objects (the smaller the faster).
  65868. */
  65869. mainTextureRatio: number;
  65870. /**
  65871. * Enforces a fixed size texture to ensure resize independant blur.
  65872. */
  65873. mainTextureFixedSize?: number;
  65874. /**
  65875. * How big is the kernel of the blur texture.
  65876. */
  65877. blurKernelSize: number;
  65878. /**
  65879. * The camera attached to the layer.
  65880. */
  65881. camera: Nullable<Camera>;
  65882. /**
  65883. * Enable MSAA by chosing the number of samples.
  65884. */
  65885. mainTextureSamples?: number;
  65886. /**
  65887. * The rendering group to draw the layer in.
  65888. */
  65889. renderingGroupId: number;
  65890. }
  65891. /**
  65892. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  65893. *
  65894. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  65895. *
  65896. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  65897. */
  65898. export class GlowLayer extends EffectLayer {
  65899. /**
  65900. * Effect Name of the layer.
  65901. */
  65902. static readonly EffectName: string;
  65903. /**
  65904. * The default blur kernel size used for the glow.
  65905. */
  65906. static DefaultBlurKernelSize: number;
  65907. /**
  65908. * The default texture size ratio used for the glow.
  65909. */
  65910. static DefaultTextureRatio: number;
  65911. /**
  65912. * Sets the kernel size of the blur.
  65913. */
  65914. set blurKernelSize(value: number);
  65915. /**
  65916. * Gets the kernel size of the blur.
  65917. */
  65918. get blurKernelSize(): number;
  65919. /**
  65920. * Sets the glow intensity.
  65921. */
  65922. set intensity(value: number);
  65923. /**
  65924. * Gets the glow intensity.
  65925. */
  65926. get intensity(): number;
  65927. private _options;
  65928. private _intensity;
  65929. private _horizontalBlurPostprocess1;
  65930. private _verticalBlurPostprocess1;
  65931. private _horizontalBlurPostprocess2;
  65932. private _verticalBlurPostprocess2;
  65933. private _blurTexture1;
  65934. private _blurTexture2;
  65935. private _postProcesses1;
  65936. private _postProcesses2;
  65937. private _includedOnlyMeshes;
  65938. private _excludedMeshes;
  65939. private _meshesUsingTheirOwnMaterials;
  65940. /**
  65941. * Callback used to let the user override the color selection on a per mesh basis
  65942. */
  65943. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  65944. /**
  65945. * Callback used to let the user override the texture selection on a per mesh basis
  65946. */
  65947. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  65948. /**
  65949. * Instantiates a new glow Layer and references it to the scene.
  65950. * @param name The name of the layer
  65951. * @param scene The scene to use the layer in
  65952. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  65953. */
  65954. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  65955. /**
  65956. * Get the effect name of the layer.
  65957. * @return The effect name
  65958. */
  65959. getEffectName(): string;
  65960. /**
  65961. * Create the merge effect. This is the shader use to blit the information back
  65962. * to the main canvas at the end of the scene rendering.
  65963. */
  65964. protected _createMergeEffect(): Effect;
  65965. /**
  65966. * Creates the render target textures and post processes used in the glow layer.
  65967. */
  65968. protected _createTextureAndPostProcesses(): void;
  65969. /**
  65970. * Checks for the readiness of the element composing the layer.
  65971. * @param subMesh the mesh to check for
  65972. * @param useInstances specify wether or not to use instances to render the mesh
  65973. * @param emissiveTexture the associated emissive texture used to generate the glow
  65974. * @return true if ready otherwise, false
  65975. */
  65976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65977. /**
  65978. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65979. */
  65980. needStencil(): boolean;
  65981. /**
  65982. * Returns true if the mesh can be rendered, otherwise false.
  65983. * @param mesh The mesh to render
  65984. * @param material The material used on the mesh
  65985. * @returns true if it can be rendered otherwise false
  65986. */
  65987. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65988. /**
  65989. * Implementation specific of rendering the generating effect on the main canvas.
  65990. * @param effect The effect used to render through
  65991. */
  65992. protected _internalRender(effect: Effect): void;
  65993. /**
  65994. * Sets the required values for both the emissive texture and and the main color.
  65995. */
  65996. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65997. /**
  65998. * Returns true if the mesh should render, otherwise false.
  65999. * @param mesh The mesh to render
  66000. * @returns true if it should render otherwise false
  66001. */
  66002. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66003. /**
  66004. * Adds specific effects defines.
  66005. * @param defines The defines to add specifics to.
  66006. */
  66007. protected _addCustomEffectDefines(defines: string[]): void;
  66008. /**
  66009. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  66010. * @param mesh The mesh to exclude from the glow layer
  66011. */
  66012. addExcludedMesh(mesh: Mesh): void;
  66013. /**
  66014. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  66015. * @param mesh The mesh to remove
  66016. */
  66017. removeExcludedMesh(mesh: Mesh): void;
  66018. /**
  66019. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  66020. * @param mesh The mesh to include in the glow layer
  66021. */
  66022. addIncludedOnlyMesh(mesh: Mesh): void;
  66023. /**
  66024. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  66025. * @param mesh The mesh to remove
  66026. */
  66027. removeIncludedOnlyMesh(mesh: Mesh): void;
  66028. /**
  66029. * Determine if a given mesh will be used in the glow layer
  66030. * @param mesh The mesh to test
  66031. * @returns true if the mesh will be highlighted by the current glow layer
  66032. */
  66033. hasMesh(mesh: AbstractMesh): boolean;
  66034. /**
  66035. * Defines whether the current material of the mesh should be use to render the effect.
  66036. * @param mesh defines the current mesh to render
  66037. */
  66038. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  66039. /**
  66040. * Add a mesh to be rendered through its own material and not with emissive only.
  66041. * @param mesh The mesh for which we need to use its material
  66042. */
  66043. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  66044. /**
  66045. * Remove a mesh from being rendered through its own material and not with emissive only.
  66046. * @param mesh The mesh for which we need to not use its material
  66047. */
  66048. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  66049. /**
  66050. * Free any resources and references associated to a mesh.
  66051. * Internal use
  66052. * @param mesh The mesh to free.
  66053. * @hidden
  66054. */
  66055. _disposeMesh(mesh: Mesh): void;
  66056. /**
  66057. * Gets the class name of the effect layer
  66058. * @returns the string with the class name of the effect layer
  66059. */
  66060. getClassName(): string;
  66061. /**
  66062. * Serializes this glow layer
  66063. * @returns a serialized glow layer object
  66064. */
  66065. serialize(): any;
  66066. /**
  66067. * Creates a Glow Layer from parsed glow layer data
  66068. * @param parsedGlowLayer defines glow layer data
  66069. * @param scene defines the current scene
  66070. * @param rootUrl defines the root URL containing the glow layer information
  66071. * @returns a parsed Glow Layer
  66072. */
  66073. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  66074. }
  66075. }
  66076. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  66077. /** @hidden */
  66078. export var glowBlurPostProcessPixelShader: {
  66079. name: string;
  66080. shader: string;
  66081. };
  66082. }
  66083. declare module "babylonjs/Layers/highlightLayer" {
  66084. import { Observable } from "babylonjs/Misc/observable";
  66085. import { Nullable } from "babylonjs/types";
  66086. import { Camera } from "babylonjs/Cameras/camera";
  66087. import { Scene } from "babylonjs/scene";
  66088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66090. import { Mesh } from "babylonjs/Meshes/mesh";
  66091. import { Effect } from "babylonjs/Materials/effect";
  66092. import { Material } from "babylonjs/Materials/material";
  66093. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  66094. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66095. import "babylonjs/Shaders/glowMapMerge.fragment";
  66096. import "babylonjs/Shaders/glowMapMerge.vertex";
  66097. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  66098. module "babylonjs/abstractScene" {
  66099. interface AbstractScene {
  66100. /**
  66101. * Return a the first highlight layer of the scene with a given name.
  66102. * @param name The name of the highlight layer to look for.
  66103. * @return The highlight layer if found otherwise null.
  66104. */
  66105. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  66106. }
  66107. }
  66108. /**
  66109. * Highlight layer options. This helps customizing the behaviour
  66110. * of the highlight layer.
  66111. */
  66112. export interface IHighlightLayerOptions {
  66113. /**
  66114. * Multiplication factor apply to the canvas size to compute the render target size
  66115. * used to generated the glowing objects (the smaller the faster).
  66116. */
  66117. mainTextureRatio: number;
  66118. /**
  66119. * Enforces a fixed size texture to ensure resize independant blur.
  66120. */
  66121. mainTextureFixedSize?: number;
  66122. /**
  66123. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  66124. * of the picture to blur (the smaller the faster).
  66125. */
  66126. blurTextureSizeRatio: number;
  66127. /**
  66128. * How big in texel of the blur texture is the vertical blur.
  66129. */
  66130. blurVerticalSize: number;
  66131. /**
  66132. * How big in texel of the blur texture is the horizontal blur.
  66133. */
  66134. blurHorizontalSize: number;
  66135. /**
  66136. * Alpha blending mode used to apply the blur. Default is combine.
  66137. */
  66138. alphaBlendingMode: number;
  66139. /**
  66140. * The camera attached to the layer.
  66141. */
  66142. camera: Nullable<Camera>;
  66143. /**
  66144. * Should we display highlight as a solid stroke?
  66145. */
  66146. isStroke?: boolean;
  66147. /**
  66148. * The rendering group to draw the layer in.
  66149. */
  66150. renderingGroupId: number;
  66151. }
  66152. /**
  66153. * The highlight layer Helps adding a glow effect around a mesh.
  66154. *
  66155. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  66156. * glowy meshes to your scene.
  66157. *
  66158. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  66159. */
  66160. export class HighlightLayer extends EffectLayer {
  66161. name: string;
  66162. /**
  66163. * Effect Name of the highlight layer.
  66164. */
  66165. static readonly EffectName: string;
  66166. /**
  66167. * The neutral color used during the preparation of the glow effect.
  66168. * This is black by default as the blend operation is a blend operation.
  66169. */
  66170. static NeutralColor: Color4;
  66171. /**
  66172. * Stencil value used for glowing meshes.
  66173. */
  66174. static GlowingMeshStencilReference: number;
  66175. /**
  66176. * Stencil value used for the other meshes in the scene.
  66177. */
  66178. static NormalMeshStencilReference: number;
  66179. /**
  66180. * Specifies whether or not the inner glow is ACTIVE in the layer.
  66181. */
  66182. innerGlow: boolean;
  66183. /**
  66184. * Specifies whether or not the outer glow is ACTIVE in the layer.
  66185. */
  66186. outerGlow: boolean;
  66187. /**
  66188. * Specifies the horizontal size of the blur.
  66189. */
  66190. set blurHorizontalSize(value: number);
  66191. /**
  66192. * Specifies the vertical size of the blur.
  66193. */
  66194. set blurVerticalSize(value: number);
  66195. /**
  66196. * Gets the horizontal size of the blur.
  66197. */
  66198. get blurHorizontalSize(): number;
  66199. /**
  66200. * Gets the vertical size of the blur.
  66201. */
  66202. get blurVerticalSize(): number;
  66203. /**
  66204. * An event triggered when the highlight layer is being blurred.
  66205. */
  66206. onBeforeBlurObservable: Observable<HighlightLayer>;
  66207. /**
  66208. * An event triggered when the highlight layer has been blurred.
  66209. */
  66210. onAfterBlurObservable: Observable<HighlightLayer>;
  66211. private _instanceGlowingMeshStencilReference;
  66212. private _options;
  66213. private _downSamplePostprocess;
  66214. private _horizontalBlurPostprocess;
  66215. private _verticalBlurPostprocess;
  66216. private _blurTexture;
  66217. private _meshes;
  66218. private _excludedMeshes;
  66219. /**
  66220. * Instantiates a new highlight Layer and references it to the scene..
  66221. * @param name The name of the layer
  66222. * @param scene The scene to use the layer in
  66223. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  66224. */
  66225. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  66226. /**
  66227. * Get the effect name of the layer.
  66228. * @return The effect name
  66229. */
  66230. getEffectName(): string;
  66231. /**
  66232. * Create the merge effect. This is the shader use to blit the information back
  66233. * to the main canvas at the end of the scene rendering.
  66234. */
  66235. protected _createMergeEffect(): Effect;
  66236. /**
  66237. * Creates the render target textures and post processes used in the highlight layer.
  66238. */
  66239. protected _createTextureAndPostProcesses(): void;
  66240. /**
  66241. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  66242. */
  66243. needStencil(): boolean;
  66244. /**
  66245. * Checks for the readiness of the element composing the layer.
  66246. * @param subMesh the mesh to check for
  66247. * @param useInstances specify wether or not to use instances to render the mesh
  66248. * @param emissiveTexture the associated emissive texture used to generate the glow
  66249. * @return true if ready otherwise, false
  66250. */
  66251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66252. /**
  66253. * Implementation specific of rendering the generating effect on the main canvas.
  66254. * @param effect The effect used to render through
  66255. */
  66256. protected _internalRender(effect: Effect): void;
  66257. /**
  66258. * Returns true if the layer contains information to display, otherwise false.
  66259. */
  66260. shouldRender(): boolean;
  66261. /**
  66262. * Returns true if the mesh should render, otherwise false.
  66263. * @param mesh The mesh to render
  66264. * @returns true if it should render otherwise false
  66265. */
  66266. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66267. /**
  66268. * Returns true if the mesh can be rendered, otherwise false.
  66269. * @param mesh The mesh to render
  66270. * @param material The material used on the mesh
  66271. * @returns true if it can be rendered otherwise false
  66272. */
  66273. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66274. /**
  66275. * Adds specific effects defines.
  66276. * @param defines The defines to add specifics to.
  66277. */
  66278. protected _addCustomEffectDefines(defines: string[]): void;
  66279. /**
  66280. * Sets the required values for both the emissive texture and and the main color.
  66281. */
  66282. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66283. /**
  66284. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  66285. * @param mesh The mesh to exclude from the highlight layer
  66286. */
  66287. addExcludedMesh(mesh: Mesh): void;
  66288. /**
  66289. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  66290. * @param mesh The mesh to highlight
  66291. */
  66292. removeExcludedMesh(mesh: Mesh): void;
  66293. /**
  66294. * Determine if a given mesh will be highlighted by the current HighlightLayer
  66295. * @param mesh mesh to test
  66296. * @returns true if the mesh will be highlighted by the current HighlightLayer
  66297. */
  66298. hasMesh(mesh: AbstractMesh): boolean;
  66299. /**
  66300. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  66301. * @param mesh The mesh to highlight
  66302. * @param color The color of the highlight
  66303. * @param glowEmissiveOnly Extract the glow from the emissive texture
  66304. */
  66305. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  66306. /**
  66307. * Remove a mesh from the highlight layer in order to make it stop glowing.
  66308. * @param mesh The mesh to highlight
  66309. */
  66310. removeMesh(mesh: Mesh): void;
  66311. /**
  66312. * Remove all the meshes currently referenced in the highlight layer
  66313. */
  66314. removeAllMeshes(): void;
  66315. /**
  66316. * Force the stencil to the normal expected value for none glowing parts
  66317. */
  66318. private _defaultStencilReference;
  66319. /**
  66320. * Free any resources and references associated to a mesh.
  66321. * Internal use
  66322. * @param mesh The mesh to free.
  66323. * @hidden
  66324. */
  66325. _disposeMesh(mesh: Mesh): void;
  66326. /**
  66327. * Dispose the highlight layer and free resources.
  66328. */
  66329. dispose(): void;
  66330. /**
  66331. * Gets the class name of the effect layer
  66332. * @returns the string with the class name of the effect layer
  66333. */
  66334. getClassName(): string;
  66335. /**
  66336. * Serializes this Highlight layer
  66337. * @returns a serialized Highlight layer object
  66338. */
  66339. serialize(): any;
  66340. /**
  66341. * Creates a Highlight layer from parsed Highlight layer data
  66342. * @param parsedHightlightLayer defines the Highlight layer data
  66343. * @param scene defines the current scene
  66344. * @param rootUrl defines the root URL containing the Highlight layer information
  66345. * @returns a parsed Highlight layer
  66346. */
  66347. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  66348. }
  66349. }
  66350. declare module "babylonjs/Layers/layerSceneComponent" {
  66351. import { Scene } from "babylonjs/scene";
  66352. import { ISceneComponent } from "babylonjs/sceneComponent";
  66353. import { Layer } from "babylonjs/Layers/layer";
  66354. import { AbstractScene } from "babylonjs/abstractScene";
  66355. module "babylonjs/abstractScene" {
  66356. interface AbstractScene {
  66357. /**
  66358. * The list of layers (background and foreground) of the scene
  66359. */
  66360. layers: Array<Layer>;
  66361. }
  66362. }
  66363. /**
  66364. * Defines the layer scene component responsible to manage any layers
  66365. * in a given scene.
  66366. */
  66367. export class LayerSceneComponent implements ISceneComponent {
  66368. /**
  66369. * The component name helpfull to identify the component in the list of scene components.
  66370. */
  66371. readonly name: string;
  66372. /**
  66373. * The scene the component belongs to.
  66374. */
  66375. scene: Scene;
  66376. private _engine;
  66377. /**
  66378. * Creates a new instance of the component for the given scene
  66379. * @param scene Defines the scene to register the component in
  66380. */
  66381. constructor(scene: Scene);
  66382. /**
  66383. * Registers the component in a given scene
  66384. */
  66385. register(): void;
  66386. /**
  66387. * Rebuilds the elements related to this component in case of
  66388. * context lost for instance.
  66389. */
  66390. rebuild(): void;
  66391. /**
  66392. * Disposes the component and the associated ressources.
  66393. */
  66394. dispose(): void;
  66395. private _draw;
  66396. private _drawCameraPredicate;
  66397. private _drawCameraBackground;
  66398. private _drawCameraForeground;
  66399. private _drawRenderTargetPredicate;
  66400. private _drawRenderTargetBackground;
  66401. private _drawRenderTargetForeground;
  66402. /**
  66403. * Adds all the elements from the container to the scene
  66404. * @param container the container holding the elements
  66405. */
  66406. addFromContainer(container: AbstractScene): void;
  66407. /**
  66408. * Removes all the elements in the container from the scene
  66409. * @param container contains the elements to remove
  66410. * @param dispose if the removed element should be disposed (default: false)
  66411. */
  66412. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66413. }
  66414. }
  66415. declare module "babylonjs/Shaders/layer.fragment" {
  66416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66417. /** @hidden */
  66418. export var layerPixelShader: {
  66419. name: string;
  66420. shader: string;
  66421. };
  66422. }
  66423. declare module "babylonjs/Shaders/layer.vertex" {
  66424. /** @hidden */
  66425. export var layerVertexShader: {
  66426. name: string;
  66427. shader: string;
  66428. };
  66429. }
  66430. declare module "babylonjs/Layers/layer" {
  66431. import { Observable } from "babylonjs/Misc/observable";
  66432. import { Nullable } from "babylonjs/types";
  66433. import { Scene } from "babylonjs/scene";
  66434. import { Vector2 } from "babylonjs/Maths/math.vector";
  66435. import { Color4 } from "babylonjs/Maths/math.color";
  66436. import { Texture } from "babylonjs/Materials/Textures/texture";
  66437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66438. import "babylonjs/Shaders/layer.fragment";
  66439. import "babylonjs/Shaders/layer.vertex";
  66440. /**
  66441. * This represents a full screen 2d layer.
  66442. * This can be useful to display a picture in the background of your scene for instance.
  66443. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66444. */
  66445. export class Layer {
  66446. /**
  66447. * Define the name of the layer.
  66448. */
  66449. name: string;
  66450. /**
  66451. * Define the texture the layer should display.
  66452. */
  66453. texture: Nullable<Texture>;
  66454. /**
  66455. * Is the layer in background or foreground.
  66456. */
  66457. isBackground: boolean;
  66458. /**
  66459. * Define the color of the layer (instead of texture).
  66460. */
  66461. color: Color4;
  66462. /**
  66463. * Define the scale of the layer in order to zoom in out of the texture.
  66464. */
  66465. scale: Vector2;
  66466. /**
  66467. * Define an offset for the layer in order to shift the texture.
  66468. */
  66469. offset: Vector2;
  66470. /**
  66471. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  66472. */
  66473. alphaBlendingMode: number;
  66474. /**
  66475. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  66476. * Alpha test will not mix with the background color in case of transparency.
  66477. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  66478. */
  66479. alphaTest: boolean;
  66480. /**
  66481. * Define a mask to restrict the layer to only some of the scene cameras.
  66482. */
  66483. layerMask: number;
  66484. /**
  66485. * Define the list of render target the layer is visible into.
  66486. */
  66487. renderTargetTextures: RenderTargetTexture[];
  66488. /**
  66489. * Define if the layer is only used in renderTarget or if it also
  66490. * renders in the main frame buffer of the canvas.
  66491. */
  66492. renderOnlyInRenderTargetTextures: boolean;
  66493. private _scene;
  66494. private _vertexBuffers;
  66495. private _indexBuffer;
  66496. private _effect;
  66497. private _previousDefines;
  66498. /**
  66499. * An event triggered when the layer is disposed.
  66500. */
  66501. onDisposeObservable: Observable<Layer>;
  66502. private _onDisposeObserver;
  66503. /**
  66504. * Back compatibility with callback before the onDisposeObservable existed.
  66505. * The set callback will be triggered when the layer has been disposed.
  66506. */
  66507. set onDispose(callback: () => void);
  66508. /**
  66509. * An event triggered before rendering the scene
  66510. */
  66511. onBeforeRenderObservable: Observable<Layer>;
  66512. private _onBeforeRenderObserver;
  66513. /**
  66514. * Back compatibility with callback before the onBeforeRenderObservable existed.
  66515. * The set callback will be triggered just before rendering the layer.
  66516. */
  66517. set onBeforeRender(callback: () => void);
  66518. /**
  66519. * An event triggered after rendering the scene
  66520. */
  66521. onAfterRenderObservable: Observable<Layer>;
  66522. private _onAfterRenderObserver;
  66523. /**
  66524. * Back compatibility with callback before the onAfterRenderObservable existed.
  66525. * The set callback will be triggered just after rendering the layer.
  66526. */
  66527. set onAfterRender(callback: () => void);
  66528. /**
  66529. * Instantiates a new layer.
  66530. * This represents a full screen 2d layer.
  66531. * This can be useful to display a picture in the background of your scene for instance.
  66532. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66533. * @param name Define the name of the layer in the scene
  66534. * @param imgUrl Define the url of the texture to display in the layer
  66535. * @param scene Define the scene the layer belongs to
  66536. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  66537. * @param color Defines a color for the layer
  66538. */
  66539. constructor(
  66540. /**
  66541. * Define the name of the layer.
  66542. */
  66543. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  66544. private _createIndexBuffer;
  66545. /** @hidden */
  66546. _rebuild(): void;
  66547. /**
  66548. * Renders the layer in the scene.
  66549. */
  66550. render(): void;
  66551. /**
  66552. * Disposes and releases the associated ressources.
  66553. */
  66554. dispose(): void;
  66555. }
  66556. }
  66557. declare module "babylonjs/Layers/index" {
  66558. export * from "babylonjs/Layers/effectLayer";
  66559. export * from "babylonjs/Layers/effectLayerSceneComponent";
  66560. export * from "babylonjs/Layers/glowLayer";
  66561. export * from "babylonjs/Layers/highlightLayer";
  66562. export * from "babylonjs/Layers/layer";
  66563. export * from "babylonjs/Layers/layerSceneComponent";
  66564. }
  66565. declare module "babylonjs/Shaders/lensFlare.fragment" {
  66566. /** @hidden */
  66567. export var lensFlarePixelShader: {
  66568. name: string;
  66569. shader: string;
  66570. };
  66571. }
  66572. declare module "babylonjs/Shaders/lensFlare.vertex" {
  66573. /** @hidden */
  66574. export var lensFlareVertexShader: {
  66575. name: string;
  66576. shader: string;
  66577. };
  66578. }
  66579. declare module "babylonjs/LensFlares/lensFlareSystem" {
  66580. import { Scene } from "babylonjs/scene";
  66581. import { Vector3 } from "babylonjs/Maths/math.vector";
  66582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66583. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  66584. import "babylonjs/Shaders/lensFlare.fragment";
  66585. import "babylonjs/Shaders/lensFlare.vertex";
  66586. import { Viewport } from "babylonjs/Maths/math.viewport";
  66587. /**
  66588. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66589. * It is usually composed of several `lensFlare`.
  66590. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66591. */
  66592. export class LensFlareSystem {
  66593. /**
  66594. * Define the name of the lens flare system
  66595. */
  66596. name: string;
  66597. /**
  66598. * List of lens flares used in this system.
  66599. */
  66600. lensFlares: LensFlare[];
  66601. /**
  66602. * Define a limit from the border the lens flare can be visible.
  66603. */
  66604. borderLimit: number;
  66605. /**
  66606. * Define a viewport border we do not want to see the lens flare in.
  66607. */
  66608. viewportBorder: number;
  66609. /**
  66610. * Define a predicate which could limit the list of meshes able to occlude the effect.
  66611. */
  66612. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  66613. /**
  66614. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  66615. */
  66616. layerMask: number;
  66617. /**
  66618. * Define the id of the lens flare system in the scene.
  66619. * (equal to name by default)
  66620. */
  66621. id: string;
  66622. private _scene;
  66623. private _emitter;
  66624. private _vertexBuffers;
  66625. private _indexBuffer;
  66626. private _effect;
  66627. private _positionX;
  66628. private _positionY;
  66629. private _isEnabled;
  66630. /** @hidden */
  66631. static _SceneComponentInitialization: (scene: Scene) => void;
  66632. /**
  66633. * Instantiates a lens flare system.
  66634. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66635. * It is usually composed of several `lensFlare`.
  66636. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66637. * @param name Define the name of the lens flare system in the scene
  66638. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  66639. * @param scene Define the scene the lens flare system belongs to
  66640. */
  66641. constructor(
  66642. /**
  66643. * Define the name of the lens flare system
  66644. */
  66645. name: string, emitter: any, scene: Scene);
  66646. /**
  66647. * Define if the lens flare system is enabled.
  66648. */
  66649. get isEnabled(): boolean;
  66650. set isEnabled(value: boolean);
  66651. /**
  66652. * Get the scene the effects belongs to.
  66653. * @returns the scene holding the lens flare system
  66654. */
  66655. getScene(): Scene;
  66656. /**
  66657. * Get the emitter of the lens flare system.
  66658. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66659. * @returns the emitter of the lens flare system
  66660. */
  66661. getEmitter(): any;
  66662. /**
  66663. * Set the emitter of the lens flare system.
  66664. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66665. * @param newEmitter Define the new emitter of the system
  66666. */
  66667. setEmitter(newEmitter: any): void;
  66668. /**
  66669. * Get the lens flare system emitter position.
  66670. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  66671. * @returns the position
  66672. */
  66673. getEmitterPosition(): Vector3;
  66674. /**
  66675. * @hidden
  66676. */
  66677. computeEffectivePosition(globalViewport: Viewport): boolean;
  66678. /** @hidden */
  66679. _isVisible(): boolean;
  66680. /**
  66681. * @hidden
  66682. */
  66683. render(): boolean;
  66684. /**
  66685. * Dispose and release the lens flare with its associated resources.
  66686. */
  66687. dispose(): void;
  66688. /**
  66689. * Parse a lens flare system from a JSON repressentation
  66690. * @param parsedLensFlareSystem Define the JSON to parse
  66691. * @param scene Define the scene the parsed system should be instantiated in
  66692. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  66693. * @returns the parsed system
  66694. */
  66695. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  66696. /**
  66697. * Serialize the current Lens Flare System into a JSON representation.
  66698. * @returns the serialized JSON
  66699. */
  66700. serialize(): any;
  66701. }
  66702. }
  66703. declare module "babylonjs/LensFlares/lensFlare" {
  66704. import { Nullable } from "babylonjs/types";
  66705. import { Color3 } from "babylonjs/Maths/math.color";
  66706. import { Texture } from "babylonjs/Materials/Textures/texture";
  66707. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66708. /**
  66709. * This represents one of the lens effect in a `lensFlareSystem`.
  66710. * It controls one of the indiviual texture used in the effect.
  66711. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66712. */
  66713. export class LensFlare {
  66714. /**
  66715. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66716. */
  66717. size: number;
  66718. /**
  66719. * 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.
  66720. */
  66721. position: number;
  66722. /**
  66723. * Define the lens color.
  66724. */
  66725. color: Color3;
  66726. /**
  66727. * Define the lens texture.
  66728. */
  66729. texture: Nullable<Texture>;
  66730. /**
  66731. * Define the alpha mode to render this particular lens.
  66732. */
  66733. alphaMode: number;
  66734. private _system;
  66735. /**
  66736. * Creates a new Lens Flare.
  66737. * This represents one of the lens effect in a `lensFlareSystem`.
  66738. * It controls one of the indiviual texture used in the effect.
  66739. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66740. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  66741. * @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.
  66742. * @param color Define the lens color
  66743. * @param imgUrl Define the lens texture url
  66744. * @param system Define the `lensFlareSystem` this flare is part of
  66745. * @returns The newly created Lens Flare
  66746. */
  66747. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  66748. /**
  66749. * Instantiates a new Lens Flare.
  66750. * This represents one of the lens effect in a `lensFlareSystem`.
  66751. * It controls one of the indiviual texture used in the effect.
  66752. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66753. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  66754. * @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.
  66755. * @param color Define the lens color
  66756. * @param imgUrl Define the lens texture url
  66757. * @param system Define the `lensFlareSystem` this flare is part of
  66758. */
  66759. constructor(
  66760. /**
  66761. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66762. */
  66763. size: number,
  66764. /**
  66765. * 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.
  66766. */
  66767. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  66768. /**
  66769. * Dispose and release the lens flare with its associated resources.
  66770. */
  66771. dispose(): void;
  66772. }
  66773. }
  66774. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  66775. import { Nullable } from "babylonjs/types";
  66776. import { Scene } from "babylonjs/scene";
  66777. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  66778. import { AbstractScene } from "babylonjs/abstractScene";
  66779. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66780. module "babylonjs/abstractScene" {
  66781. interface AbstractScene {
  66782. /**
  66783. * The list of lens flare system added to the scene
  66784. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66785. */
  66786. lensFlareSystems: Array<LensFlareSystem>;
  66787. /**
  66788. * Removes the given lens flare system from this scene.
  66789. * @param toRemove The lens flare system to remove
  66790. * @returns The index of the removed lens flare system
  66791. */
  66792. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  66793. /**
  66794. * Adds the given lens flare system to this scene
  66795. * @param newLensFlareSystem The lens flare system to add
  66796. */
  66797. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  66798. /**
  66799. * Gets a lens flare system using its name
  66800. * @param name defines the name to look for
  66801. * @returns the lens flare system or null if not found
  66802. */
  66803. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  66804. /**
  66805. * Gets a lens flare system using its id
  66806. * @param id defines the id to look for
  66807. * @returns the lens flare system or null if not found
  66808. */
  66809. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  66810. }
  66811. }
  66812. /**
  66813. * Defines the lens flare scene component responsible to manage any lens flares
  66814. * in a given scene.
  66815. */
  66816. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  66817. /**
  66818. * The component name helpfull to identify the component in the list of scene components.
  66819. */
  66820. readonly name: string;
  66821. /**
  66822. * The scene the component belongs to.
  66823. */
  66824. scene: Scene;
  66825. /**
  66826. * Creates a new instance of the component for the given scene
  66827. * @param scene Defines the scene to register the component in
  66828. */
  66829. constructor(scene: Scene);
  66830. /**
  66831. * Registers the component in a given scene
  66832. */
  66833. register(): void;
  66834. /**
  66835. * Rebuilds the elements related to this component in case of
  66836. * context lost for instance.
  66837. */
  66838. rebuild(): void;
  66839. /**
  66840. * Adds all the elements from the container to the scene
  66841. * @param container the container holding the elements
  66842. */
  66843. addFromContainer(container: AbstractScene): void;
  66844. /**
  66845. * Removes all the elements in the container from the scene
  66846. * @param container contains the elements to remove
  66847. * @param dispose if the removed element should be disposed (default: false)
  66848. */
  66849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66850. /**
  66851. * Serializes the component data to the specified json object
  66852. * @param serializationObject The object to serialize to
  66853. */
  66854. serialize(serializationObject: any): void;
  66855. /**
  66856. * Disposes the component and the associated ressources.
  66857. */
  66858. dispose(): void;
  66859. private _draw;
  66860. }
  66861. }
  66862. declare module "babylonjs/LensFlares/index" {
  66863. export * from "babylonjs/LensFlares/lensFlare";
  66864. export * from "babylonjs/LensFlares/lensFlareSystem";
  66865. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  66866. }
  66867. declare module "babylonjs/Shaders/depth.fragment" {
  66868. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66869. /** @hidden */
  66870. export var depthPixelShader: {
  66871. name: string;
  66872. shader: string;
  66873. };
  66874. }
  66875. declare module "babylonjs/Shaders/depth.vertex" {
  66876. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66877. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66878. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66879. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66880. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66881. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66882. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66883. /** @hidden */
  66884. export var depthVertexShader: {
  66885. name: string;
  66886. shader: string;
  66887. };
  66888. }
  66889. declare module "babylonjs/Rendering/depthRenderer" {
  66890. import { Nullable } from "babylonjs/types";
  66891. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66892. import { Scene } from "babylonjs/scene";
  66893. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66894. import { Camera } from "babylonjs/Cameras/camera";
  66895. import "babylonjs/Shaders/depth.fragment";
  66896. import "babylonjs/Shaders/depth.vertex";
  66897. /**
  66898. * This represents a depth renderer in Babylon.
  66899. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66900. */
  66901. export class DepthRenderer {
  66902. private _scene;
  66903. private _depthMap;
  66904. private _effect;
  66905. private readonly _storeNonLinearDepth;
  66906. private readonly _clearColor;
  66907. /** Get if the depth renderer is using packed depth or not */
  66908. readonly isPacked: boolean;
  66909. private _cachedDefines;
  66910. private _camera;
  66911. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  66912. enabled: boolean;
  66913. /**
  66914. * Specifiess that the depth renderer will only be used within
  66915. * the camera it is created for.
  66916. * This can help forcing its rendering during the camera processing.
  66917. */
  66918. useOnlyInActiveCamera: boolean;
  66919. /** @hidden */
  66920. static _SceneComponentInitialization: (scene: Scene) => void;
  66921. /**
  66922. * Instantiates a depth renderer
  66923. * @param scene The scene the renderer belongs to
  66924. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66925. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66926. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66927. */
  66928. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66929. /**
  66930. * Creates the depth rendering effect and checks if the effect is ready.
  66931. * @param subMesh The submesh to be used to render the depth map of
  66932. * @param useInstances If multiple world instances should be used
  66933. * @returns if the depth renderer is ready to render the depth map
  66934. */
  66935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66936. /**
  66937. * Gets the texture which the depth map will be written to.
  66938. * @returns The depth map texture
  66939. */
  66940. getDepthMap(): RenderTargetTexture;
  66941. /**
  66942. * Disposes of the depth renderer.
  66943. */
  66944. dispose(): void;
  66945. }
  66946. }
  66947. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  66948. /** @hidden */
  66949. export var minmaxReduxPixelShader: {
  66950. name: string;
  66951. shader: string;
  66952. };
  66953. }
  66954. declare module "babylonjs/Misc/minMaxReducer" {
  66955. import { Nullable } from "babylonjs/types";
  66956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66957. import { Camera } from "babylonjs/Cameras/camera";
  66958. import { Observer } from "babylonjs/Misc/observable";
  66959. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66960. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  66961. import { Observable } from "babylonjs/Misc/observable";
  66962. import "babylonjs/Shaders/minmaxRedux.fragment";
  66963. /**
  66964. * This class computes a min/max reduction from a texture: it means it computes the minimum
  66965. * and maximum values from all values of the texture.
  66966. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  66967. * The source values are read from the red channel of the texture.
  66968. */
  66969. export class MinMaxReducer {
  66970. /**
  66971. * Observable triggered when the computation has been performed
  66972. */
  66973. onAfterReductionPerformed: Observable<{
  66974. min: number;
  66975. max: number;
  66976. }>;
  66977. protected _camera: Camera;
  66978. protected _sourceTexture: Nullable<RenderTargetTexture>;
  66979. protected _reductionSteps: Nullable<Array<PostProcess>>;
  66980. protected _postProcessManager: PostProcessManager;
  66981. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  66982. protected _forceFullscreenViewport: boolean;
  66983. /**
  66984. * Creates a min/max reducer
  66985. * @param camera The camera to use for the post processes
  66986. */
  66987. constructor(camera: Camera);
  66988. /**
  66989. * Gets the texture used to read the values from.
  66990. */
  66991. get sourceTexture(): Nullable<RenderTargetTexture>;
  66992. /**
  66993. * Sets the source texture to read the values from.
  66994. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  66995. * because in such textures '1' value must not be taken into account to compute the maximum
  66996. * as this value is used to clear the texture.
  66997. * Note that the computation is not activated by calling this function, you must call activate() for that!
  66998. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  66999. * @param depthRedux Indicates if the texture is a depth texture or not
  67000. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  67001. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67002. */
  67003. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67004. /**
  67005. * Defines the refresh rate of the computation.
  67006. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67007. */
  67008. get refreshRate(): number;
  67009. set refreshRate(value: number);
  67010. protected _activated: boolean;
  67011. /**
  67012. * Gets the activation status of the reducer
  67013. */
  67014. get activated(): boolean;
  67015. /**
  67016. * Activates the reduction computation.
  67017. * When activated, the observers registered in onAfterReductionPerformed are
  67018. * called after the compuation is performed
  67019. */
  67020. activate(): void;
  67021. /**
  67022. * Deactivates the reduction computation.
  67023. */
  67024. deactivate(): void;
  67025. /**
  67026. * Disposes the min/max reducer
  67027. * @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.
  67028. */
  67029. dispose(disposeAll?: boolean): void;
  67030. }
  67031. }
  67032. declare module "babylonjs/Misc/depthReducer" {
  67033. import { Nullable } from "babylonjs/types";
  67034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67035. import { Camera } from "babylonjs/Cameras/camera";
  67036. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67037. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  67038. /**
  67039. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  67040. */
  67041. export class DepthReducer extends MinMaxReducer {
  67042. private _depthRenderer;
  67043. private _depthRendererId;
  67044. /**
  67045. * Gets the depth renderer used for the computation.
  67046. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  67047. */
  67048. get depthRenderer(): Nullable<DepthRenderer>;
  67049. /**
  67050. * Creates a depth reducer
  67051. * @param camera The camera used to render the depth texture
  67052. */
  67053. constructor(camera: Camera);
  67054. /**
  67055. * Sets the depth renderer to use to generate the depth map
  67056. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  67057. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  67058. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67059. */
  67060. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  67061. /** @hidden */
  67062. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67063. /**
  67064. * Activates the reduction computation.
  67065. * When activated, the observers registered in onAfterReductionPerformed are
  67066. * called after the compuation is performed
  67067. */
  67068. activate(): void;
  67069. /**
  67070. * Deactivates the reduction computation.
  67071. */
  67072. deactivate(): void;
  67073. /**
  67074. * Disposes the depth reducer
  67075. * @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.
  67076. */
  67077. dispose(disposeAll?: boolean): void;
  67078. }
  67079. }
  67080. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  67081. import { Nullable } from "babylonjs/types";
  67082. import { Scene } from "babylonjs/scene";
  67083. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67084. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67086. import { Effect } from "babylonjs/Materials/effect";
  67087. import "babylonjs/Shaders/shadowMap.fragment";
  67088. import "babylonjs/Shaders/shadowMap.vertex";
  67089. import "babylonjs/Shaders/depthBoxBlur.fragment";
  67090. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  67091. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67092. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67093. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67094. /**
  67095. * A CSM implementation allowing casting shadows on large scenes.
  67096. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67097. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  67098. */
  67099. export class CascadedShadowGenerator extends ShadowGenerator {
  67100. private static readonly frustumCornersNDCSpace;
  67101. /**
  67102. * Name of the CSM class
  67103. */
  67104. static CLASSNAME: string;
  67105. /**
  67106. * Defines the default number of cascades used by the CSM.
  67107. */
  67108. static readonly DEFAULT_CASCADES_COUNT: number;
  67109. /**
  67110. * Defines the minimum number of cascades used by the CSM.
  67111. */
  67112. static readonly MIN_CASCADES_COUNT: number;
  67113. /**
  67114. * Defines the maximum number of cascades used by the CSM.
  67115. */
  67116. static readonly MAX_CASCADES_COUNT: number;
  67117. protected _validateFilter(filter: number): number;
  67118. /**
  67119. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  67120. */
  67121. penumbraDarkness: number;
  67122. private _numCascades;
  67123. /**
  67124. * Gets or set the number of cascades used by the CSM.
  67125. */
  67126. get numCascades(): number;
  67127. set numCascades(value: number);
  67128. /**
  67129. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  67130. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  67131. */
  67132. stabilizeCascades: boolean;
  67133. private _freezeShadowCastersBoundingInfo;
  67134. private _freezeShadowCastersBoundingInfoObservable;
  67135. /**
  67136. * Enables or disables the shadow casters bounding info computation.
  67137. * If your shadow casters don't move, you can disable this feature.
  67138. * If it is enabled, the bounding box computation is done every frame.
  67139. */
  67140. get freezeShadowCastersBoundingInfo(): boolean;
  67141. set freezeShadowCastersBoundingInfo(freeze: boolean);
  67142. private _scbiMin;
  67143. private _scbiMax;
  67144. protected _computeShadowCastersBoundingInfo(): void;
  67145. protected _shadowCastersBoundingInfo: BoundingInfo;
  67146. /**
  67147. * Gets or sets the shadow casters bounding info.
  67148. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  67149. * so that the system won't overwrite the bounds you provide
  67150. */
  67151. get shadowCastersBoundingInfo(): BoundingInfo;
  67152. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  67153. protected _breaksAreDirty: boolean;
  67154. protected _minDistance: number;
  67155. protected _maxDistance: number;
  67156. /**
  67157. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  67158. *
  67159. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  67160. * If you don't know these values, simply leave them to their defaults and don't call this function.
  67161. * @param min minimal distance for the breaks (default to 0.)
  67162. * @param max maximal distance for the breaks (default to 1.)
  67163. */
  67164. setMinMaxDistance(min: number, max: number): void;
  67165. /** Gets the minimal distance used in the cascade break computation */
  67166. get minDistance(): number;
  67167. /** Gets the maximal distance used in the cascade break computation */
  67168. get maxDistance(): number;
  67169. /**
  67170. * Gets the class name of that object
  67171. * @returns "CascadedShadowGenerator"
  67172. */
  67173. getClassName(): string;
  67174. private _cascadeMinExtents;
  67175. private _cascadeMaxExtents;
  67176. /**
  67177. * Gets a cascade minimum extents
  67178. * @param cascadeIndex index of the cascade
  67179. * @returns the minimum cascade extents
  67180. */
  67181. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  67182. /**
  67183. * Gets a cascade maximum extents
  67184. * @param cascadeIndex index of the cascade
  67185. * @returns the maximum cascade extents
  67186. */
  67187. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  67188. private _cascades;
  67189. private _currentLayer;
  67190. private _viewSpaceFrustumsZ;
  67191. private _viewMatrices;
  67192. private _projectionMatrices;
  67193. private _transformMatrices;
  67194. private _transformMatricesAsArray;
  67195. private _frustumLengths;
  67196. private _lightSizeUVCorrection;
  67197. private _depthCorrection;
  67198. private _frustumCornersWorldSpace;
  67199. private _frustumCenter;
  67200. private _shadowCameraPos;
  67201. private _shadowMaxZ;
  67202. /**
  67203. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  67204. * It defaults to camera.maxZ
  67205. */
  67206. get shadowMaxZ(): number;
  67207. /**
  67208. * Sets the shadow max z distance.
  67209. */
  67210. set shadowMaxZ(value: number);
  67211. protected _debug: boolean;
  67212. /**
  67213. * Gets or sets the debug flag.
  67214. * When enabled, the cascades are materialized by different colors on the screen.
  67215. */
  67216. get debug(): boolean;
  67217. set debug(dbg: boolean);
  67218. private _depthClamp;
  67219. /**
  67220. * Gets or sets the depth clamping value.
  67221. *
  67222. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  67223. * to account for the shadow casters far away.
  67224. *
  67225. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  67226. */
  67227. get depthClamp(): boolean;
  67228. set depthClamp(value: boolean);
  67229. private _cascadeBlendPercentage;
  67230. /**
  67231. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  67232. * It defaults to 0.1 (10% blending).
  67233. */
  67234. get cascadeBlendPercentage(): number;
  67235. set cascadeBlendPercentage(value: number);
  67236. private _lambda;
  67237. /**
  67238. * Gets or set the lambda parameter.
  67239. * This parameter is used to split the camera frustum and create the cascades.
  67240. * 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.
  67241. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  67242. */
  67243. get lambda(): number;
  67244. set lambda(value: number);
  67245. /**
  67246. * Gets the view matrix corresponding to a given cascade
  67247. * @param cascadeNum cascade to retrieve the view matrix from
  67248. * @returns the cascade view matrix
  67249. */
  67250. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  67251. /**
  67252. * Gets the projection matrix corresponding to a given cascade
  67253. * @param cascadeNum cascade to retrieve the projection matrix from
  67254. * @returns the cascade projection matrix
  67255. */
  67256. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  67257. /**
  67258. * Gets the transformation matrix corresponding to a given cascade
  67259. * @param cascadeNum cascade to retrieve the transformation matrix from
  67260. * @returns the cascade transformation matrix
  67261. */
  67262. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  67263. private _depthRenderer;
  67264. /**
  67265. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  67266. *
  67267. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  67268. *
  67269. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  67270. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  67271. * @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
  67272. */
  67273. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  67274. private _depthReducer;
  67275. private _autoCalcDepthBounds;
  67276. /**
  67277. * Gets or sets the autoCalcDepthBounds property.
  67278. *
  67279. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  67280. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  67281. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  67282. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  67283. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  67284. */
  67285. get autoCalcDepthBounds(): boolean;
  67286. set autoCalcDepthBounds(value: boolean);
  67287. /**
  67288. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  67289. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67290. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  67291. * for setting the refresh rate on the renderer yourself!
  67292. */
  67293. get autoCalcDepthBoundsRefreshRate(): number;
  67294. set autoCalcDepthBoundsRefreshRate(value: number);
  67295. /**
  67296. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  67297. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  67298. * you change the camera near/far planes!
  67299. */
  67300. splitFrustum(): void;
  67301. private _splitFrustum;
  67302. private _computeMatrices;
  67303. private _computeFrustumInWorldSpace;
  67304. private _computeCascadeFrustum;
  67305. /**
  67306. * Support test.
  67307. */
  67308. static get IsSupported(): boolean;
  67309. /** @hidden */
  67310. static _SceneComponentInitialization: (scene: Scene) => void;
  67311. /**
  67312. * Creates a Cascaded Shadow Generator object.
  67313. * A ShadowGenerator is the required tool to use the shadows.
  67314. * Each directional light casting shadows needs to use its own ShadowGenerator.
  67315. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67316. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67317. * @param light The directional light object generating the shadows.
  67318. * @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.
  67319. */
  67320. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  67321. protected _initializeGenerator(): void;
  67322. protected _createTargetRenderTexture(): void;
  67323. protected _initializeShadowMap(): void;
  67324. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  67325. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  67326. /**
  67327. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67328. * @param defines Defines of the material we want to update
  67329. * @param lightIndex Index of the light in the enabled light list of the material
  67330. */
  67331. prepareDefines(defines: any, lightIndex: number): void;
  67332. /**
  67333. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67334. * defined in the generator but impacting the effect).
  67335. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67336. * @param effect The effect we are binfing the information for
  67337. */
  67338. bindShadowLight(lightIndex: string, effect: Effect): void;
  67339. /**
  67340. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  67341. * (eq to view projection * shadow projection matrices)
  67342. * @returns The transform matrix used to create the shadow map
  67343. */
  67344. getTransformMatrix(): Matrix;
  67345. /**
  67346. * Disposes the ShadowGenerator.
  67347. * Returns nothing.
  67348. */
  67349. dispose(): void;
  67350. /**
  67351. * Serializes the shadow generator setup to a json object.
  67352. * @returns The serialized JSON object
  67353. */
  67354. serialize(): any;
  67355. /**
  67356. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67357. * @param parsedShadowGenerator The JSON object to parse
  67358. * @param scene The scene to create the shadow map for
  67359. * @returns The parsed shadow generator
  67360. */
  67361. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67362. }
  67363. }
  67364. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  67365. import { Scene } from "babylonjs/scene";
  67366. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67367. import { AbstractScene } from "babylonjs/abstractScene";
  67368. /**
  67369. * Defines the shadow generator component responsible to manage any shadow generators
  67370. * in a given scene.
  67371. */
  67372. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  67373. /**
  67374. * The component name helpfull to identify the component in the list of scene components.
  67375. */
  67376. readonly name: string;
  67377. /**
  67378. * The scene the component belongs to.
  67379. */
  67380. scene: Scene;
  67381. /**
  67382. * Creates a new instance of the component for the given scene
  67383. * @param scene Defines the scene to register the component in
  67384. */
  67385. constructor(scene: Scene);
  67386. /**
  67387. * Registers the component in a given scene
  67388. */
  67389. register(): void;
  67390. /**
  67391. * Rebuilds the elements related to this component in case of
  67392. * context lost for instance.
  67393. */
  67394. rebuild(): void;
  67395. /**
  67396. * Serializes the component data to the specified json object
  67397. * @param serializationObject The object to serialize to
  67398. */
  67399. serialize(serializationObject: any): void;
  67400. /**
  67401. * Adds all the elements from the container to the scene
  67402. * @param container the container holding the elements
  67403. */
  67404. addFromContainer(container: AbstractScene): void;
  67405. /**
  67406. * Removes all the elements in the container from the scene
  67407. * @param container contains the elements to remove
  67408. * @param dispose if the removed element should be disposed (default: false)
  67409. */
  67410. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67411. /**
  67412. * Rebuilds the elements related to this component in case of
  67413. * context lost for instance.
  67414. */
  67415. dispose(): void;
  67416. private _gatherRenderTargets;
  67417. }
  67418. }
  67419. declare module "babylonjs/Lights/Shadows/index" {
  67420. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  67421. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  67422. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  67423. }
  67424. declare module "babylonjs/Lights/pointLight" {
  67425. import { Scene } from "babylonjs/scene";
  67426. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67428. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  67429. import { Effect } from "babylonjs/Materials/effect";
  67430. /**
  67431. * A point light is a light defined by an unique point in world space.
  67432. * The light is emitted in every direction from this point.
  67433. * A good example of a point light is a standard light bulb.
  67434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  67435. */
  67436. export class PointLight extends ShadowLight {
  67437. private _shadowAngle;
  67438. /**
  67439. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67440. * This specifies what angle the shadow will use to be created.
  67441. *
  67442. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67443. */
  67444. get shadowAngle(): number;
  67445. /**
  67446. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67447. * This specifies what angle the shadow will use to be created.
  67448. *
  67449. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67450. */
  67451. set shadowAngle(value: number);
  67452. /**
  67453. * Gets the direction if it has been set.
  67454. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67455. */
  67456. get direction(): Vector3;
  67457. /**
  67458. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67459. */
  67460. set direction(value: Vector3);
  67461. /**
  67462. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  67463. * A PointLight emits the light in every direction.
  67464. * It can cast shadows.
  67465. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  67466. * ```javascript
  67467. * var pointLight = new PointLight("pl", camera.position, scene);
  67468. * ```
  67469. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67470. * @param name The light friendly name
  67471. * @param position The position of the point light in the scene
  67472. * @param scene The scene the lights belongs to
  67473. */
  67474. constructor(name: string, position: Vector3, scene: Scene);
  67475. /**
  67476. * Returns the string "PointLight"
  67477. * @returns the class name
  67478. */
  67479. getClassName(): string;
  67480. /**
  67481. * Returns the integer 0.
  67482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67483. */
  67484. getTypeID(): number;
  67485. /**
  67486. * Specifies wether or not the shadowmap should be a cube texture.
  67487. * @returns true if the shadowmap needs to be a cube texture.
  67488. */
  67489. needCube(): boolean;
  67490. /**
  67491. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  67492. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67493. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67494. */
  67495. getShadowDirection(faceIndex?: number): Vector3;
  67496. /**
  67497. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  67498. * - fov = PI / 2
  67499. * - aspect ratio : 1.0
  67500. * - z-near and far equal to the active camera minZ and maxZ.
  67501. * Returns the PointLight.
  67502. */
  67503. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67504. protected _buildUniformLayout(): void;
  67505. /**
  67506. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  67507. * @param effect The effect to update
  67508. * @param lightIndex The index of the light in the effect to update
  67509. * @returns The point light
  67510. */
  67511. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  67512. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  67513. /**
  67514. * Prepares the list of defines specific to the light type.
  67515. * @param defines the list of defines
  67516. * @param lightIndex defines the index of the light for the effect
  67517. */
  67518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67519. }
  67520. }
  67521. declare module "babylonjs/Lights/index" {
  67522. export * from "babylonjs/Lights/light";
  67523. export * from "babylonjs/Lights/shadowLight";
  67524. export * from "babylonjs/Lights/Shadows/index";
  67525. export * from "babylonjs/Lights/directionalLight";
  67526. export * from "babylonjs/Lights/hemisphericLight";
  67527. export * from "babylonjs/Lights/pointLight";
  67528. export * from "babylonjs/Lights/spotLight";
  67529. }
  67530. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  67531. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67532. /**
  67533. * Header information of HDR texture files.
  67534. */
  67535. export interface HDRInfo {
  67536. /**
  67537. * The height of the texture in pixels.
  67538. */
  67539. height: number;
  67540. /**
  67541. * The width of the texture in pixels.
  67542. */
  67543. width: number;
  67544. /**
  67545. * The index of the beginning of the data in the binary file.
  67546. */
  67547. dataPosition: number;
  67548. }
  67549. /**
  67550. * This groups tools to convert HDR texture to native colors array.
  67551. */
  67552. export class HDRTools {
  67553. private static Ldexp;
  67554. private static Rgbe2float;
  67555. private static readStringLine;
  67556. /**
  67557. * Reads header information from an RGBE texture stored in a native array.
  67558. * More information on this format are available here:
  67559. * https://en.wikipedia.org/wiki/RGBE_image_format
  67560. *
  67561. * @param uint8array The binary file stored in native array.
  67562. * @return The header information.
  67563. */
  67564. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  67565. /**
  67566. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  67567. * This RGBE texture needs to store the information as a panorama.
  67568. *
  67569. * More information on this format are available here:
  67570. * https://en.wikipedia.org/wiki/RGBE_image_format
  67571. *
  67572. * @param buffer The binary file stored in an array buffer.
  67573. * @param size The expected size of the extracted cubemap.
  67574. * @return The Cube Map information.
  67575. */
  67576. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  67577. /**
  67578. * Returns the pixels data extracted from an RGBE texture.
  67579. * This pixels will be stored left to right up to down in the R G B order in one array.
  67580. *
  67581. * More information on this format are available here:
  67582. * https://en.wikipedia.org/wiki/RGBE_image_format
  67583. *
  67584. * @param uint8array The binary file stored in an array buffer.
  67585. * @param hdrInfo The header information of the file.
  67586. * @return The pixels data in RGB right to left up to down order.
  67587. */
  67588. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  67589. private static RGBE_ReadPixels_RLE;
  67590. private static RGBE_ReadPixels_NOT_RLE;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/effectRenderer" {
  67594. import { Nullable } from "babylonjs/types";
  67595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  67596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67597. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67598. import { Viewport } from "babylonjs/Maths/math.viewport";
  67599. import { Observable } from "babylonjs/Misc/observable";
  67600. import { Effect } from "babylonjs/Materials/effect";
  67601. import "babylonjs/Shaders/postprocess.vertex";
  67602. /**
  67603. * Effect Render Options
  67604. */
  67605. export interface IEffectRendererOptions {
  67606. /**
  67607. * Defines the vertices positions.
  67608. */
  67609. positions?: number[];
  67610. /**
  67611. * Defines the indices.
  67612. */
  67613. indices?: number[];
  67614. }
  67615. /**
  67616. * Helper class to render one or more effects.
  67617. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  67618. */
  67619. export class EffectRenderer {
  67620. private engine;
  67621. private static _DefaultOptions;
  67622. private _vertexBuffers;
  67623. private _indexBuffer;
  67624. private _fullscreenViewport;
  67625. /**
  67626. * Creates an effect renderer
  67627. * @param engine the engine to use for rendering
  67628. * @param options defines the options of the effect renderer
  67629. */
  67630. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  67631. /**
  67632. * Sets the current viewport in normalized coordinates 0-1
  67633. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  67634. */
  67635. setViewport(viewport?: Viewport): void;
  67636. /**
  67637. * Binds the embedded attributes buffer to the effect.
  67638. * @param effect Defines the effect to bind the attributes for
  67639. */
  67640. bindBuffers(effect: Effect): void;
  67641. /**
  67642. * Sets the current effect wrapper to use during draw.
  67643. * The effect needs to be ready before calling this api.
  67644. * This also sets the default full screen position attribute.
  67645. * @param effectWrapper Defines the effect to draw with
  67646. */
  67647. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  67648. /**
  67649. * Restores engine states
  67650. */
  67651. restoreStates(): void;
  67652. /**
  67653. * Draws a full screen quad.
  67654. */
  67655. draw(): void;
  67656. private isRenderTargetTexture;
  67657. /**
  67658. * renders one or more effects to a specified texture
  67659. * @param effectWrapper the effect to renderer
  67660. * @param outputTexture texture to draw to, if null it will render to the screen.
  67661. */
  67662. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  67663. /**
  67664. * Disposes of the effect renderer
  67665. */
  67666. dispose(): void;
  67667. }
  67668. /**
  67669. * Options to create an EffectWrapper
  67670. */
  67671. interface EffectWrapperCreationOptions {
  67672. /**
  67673. * Engine to use to create the effect
  67674. */
  67675. engine: ThinEngine;
  67676. /**
  67677. * Fragment shader for the effect
  67678. */
  67679. fragmentShader: string;
  67680. /**
  67681. * Use the shader store instead of direct source code
  67682. */
  67683. useShaderStore?: boolean;
  67684. /**
  67685. * Vertex shader for the effect
  67686. */
  67687. vertexShader?: string;
  67688. /**
  67689. * Attributes to use in the shader
  67690. */
  67691. attributeNames?: Array<string>;
  67692. /**
  67693. * Uniforms to use in the shader
  67694. */
  67695. uniformNames?: Array<string>;
  67696. /**
  67697. * Texture sampler names to use in the shader
  67698. */
  67699. samplerNames?: Array<string>;
  67700. /**
  67701. * Defines to use in the shader
  67702. */
  67703. defines?: Array<string>;
  67704. /**
  67705. * Callback when effect is compiled
  67706. */
  67707. onCompiled?: Nullable<(effect: Effect) => void>;
  67708. /**
  67709. * The friendly name of the effect displayed in Spector.
  67710. */
  67711. name?: string;
  67712. }
  67713. /**
  67714. * Wraps an effect to be used for rendering
  67715. */
  67716. export class EffectWrapper {
  67717. /**
  67718. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  67719. */
  67720. onApplyObservable: Observable<{}>;
  67721. /**
  67722. * The underlying effect
  67723. */
  67724. effect: Effect;
  67725. /**
  67726. * Creates an effect to be renderer
  67727. * @param creationOptions options to create the effect
  67728. */
  67729. constructor(creationOptions: EffectWrapperCreationOptions);
  67730. /**
  67731. * Disposes of the effect wrapper
  67732. */
  67733. dispose(): void;
  67734. }
  67735. }
  67736. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  67737. /** @hidden */
  67738. export var hdrFilteringVertexShader: {
  67739. name: string;
  67740. shader: string;
  67741. };
  67742. }
  67743. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  67744. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67745. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  67746. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  67747. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  67748. /** @hidden */
  67749. export var hdrFilteringPixelShader: {
  67750. name: string;
  67751. shader: string;
  67752. };
  67753. }
  67754. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  67755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67756. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67757. import { Nullable } from "babylonjs/types";
  67758. import "babylonjs/Shaders/hdrFiltering.vertex";
  67759. import "babylonjs/Shaders/hdrFiltering.fragment";
  67760. /**
  67761. * Options for texture filtering
  67762. */
  67763. interface IHDRFilteringOptions {
  67764. /**
  67765. * Scales pixel intensity for the input HDR map.
  67766. */
  67767. hdrScale?: number;
  67768. /**
  67769. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  67770. */
  67771. quality?: number;
  67772. }
  67773. /**
  67774. * Filters HDR maps to get correct renderings of PBR reflections
  67775. */
  67776. export class HDRFiltering {
  67777. private _engine;
  67778. private _effectRenderer;
  67779. private _effectWrapper;
  67780. private _lodGenerationOffset;
  67781. private _lodGenerationScale;
  67782. /**
  67783. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  67784. * you care about baking speed.
  67785. */
  67786. quality: number;
  67787. /**
  67788. * Scales pixel intensity for the input HDR map.
  67789. */
  67790. hdrScale: number;
  67791. /**
  67792. * Instantiates HDR filter for reflection maps
  67793. *
  67794. * @param engine Thin engine
  67795. * @param options Options
  67796. */
  67797. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  67798. private _createRenderTarget;
  67799. private _prefilterInternal;
  67800. private _createEffect;
  67801. /**
  67802. * Get a value indicating if the filter is ready to be used
  67803. * @param texture Texture to filter
  67804. * @returns true if the filter is ready
  67805. */
  67806. isReady(texture: BaseTexture): boolean;
  67807. /**
  67808. * Prefilters a cube texture to have mipmap levels representing roughness values.
  67809. * Prefiltering will be invoked at the end of next rendering pass.
  67810. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  67811. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  67812. * @param texture Texture to filter
  67813. * @param onFinished Callback when filtering is done
  67814. * @return Promise called when prefiltering is done
  67815. */
  67816. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  67817. }
  67818. }
  67819. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  67820. import { Nullable } from "babylonjs/types";
  67821. import { Scene } from "babylonjs/scene";
  67822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67824. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67825. import "babylonjs/Engines/Extensions/engine.rawTexture";
  67826. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  67827. /**
  67828. * This represents a texture coming from an HDR input.
  67829. *
  67830. * The only supported format is currently panorama picture stored in RGBE format.
  67831. * Example of such files can be found on HDRLib: http://hdrlib.com/
  67832. */
  67833. export class HDRCubeTexture extends BaseTexture {
  67834. private static _facesMapping;
  67835. private _generateHarmonics;
  67836. private _noMipmap;
  67837. private _prefilterOnLoad;
  67838. private _textureMatrix;
  67839. private _size;
  67840. private _onLoad;
  67841. private _onError;
  67842. /**
  67843. * The texture URL.
  67844. */
  67845. url: string;
  67846. protected _isBlocking: boolean;
  67847. /**
  67848. * Sets wether or not the texture is blocking during loading.
  67849. */
  67850. set isBlocking(value: boolean);
  67851. /**
  67852. * Gets wether or not the texture is blocking during loading.
  67853. */
  67854. get isBlocking(): boolean;
  67855. protected _rotationY: number;
  67856. /**
  67857. * Sets texture matrix rotation angle around Y axis in radians.
  67858. */
  67859. set rotationY(value: number);
  67860. /**
  67861. * Gets texture matrix rotation angle around Y axis radians.
  67862. */
  67863. get rotationY(): number;
  67864. /**
  67865. * Gets or sets the center of the bounding box associated with the cube texture
  67866. * It must define where the camera used to render the texture was set
  67867. */
  67868. boundingBoxPosition: Vector3;
  67869. private _boundingBoxSize;
  67870. /**
  67871. * Gets or sets the size of the bounding box associated with the cube texture
  67872. * When defined, the cubemap will switch to local mode
  67873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67874. * @example https://www.babylonjs-playground.com/#RNASML
  67875. */
  67876. set boundingBoxSize(value: Vector3);
  67877. get boundingBoxSize(): Vector3;
  67878. /**
  67879. * Instantiates an HDRTexture from the following parameters.
  67880. *
  67881. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  67882. * @param sceneOrEngine The scene or engine the texture will be used in
  67883. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67884. * @param noMipmap Forces to not generate the mipmap if true
  67885. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  67886. * @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)
  67887. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  67888. */
  67889. 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>);
  67890. /**
  67891. * Get the current class name of the texture useful for serialization or dynamic coding.
  67892. * @returns "HDRCubeTexture"
  67893. */
  67894. getClassName(): string;
  67895. /**
  67896. * Occurs when the file is raw .hdr file.
  67897. */
  67898. private loadTexture;
  67899. clone(): HDRCubeTexture;
  67900. delayLoad(): void;
  67901. /**
  67902. * Get the texture reflection matrix used to rotate/transform the reflection.
  67903. * @returns the reflection matrix
  67904. */
  67905. getReflectionTextureMatrix(): Matrix;
  67906. /**
  67907. * Set the texture reflection matrix used to rotate/transform the reflection.
  67908. * @param value Define the reflection matrix to set
  67909. */
  67910. setReflectionTextureMatrix(value: Matrix): void;
  67911. /**
  67912. * Parses a JSON representation of an HDR Texture in order to create the texture
  67913. * @param parsedTexture Define the JSON representation
  67914. * @param scene Define the scene the texture should be created in
  67915. * @param rootUrl Define the root url in case we need to load relative dependencies
  67916. * @returns the newly created texture after parsing
  67917. */
  67918. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  67919. serialize(): any;
  67920. }
  67921. }
  67922. declare module "babylonjs/Physics/physicsEngine" {
  67923. import { Nullable } from "babylonjs/types";
  67924. import { Vector3 } from "babylonjs/Maths/math.vector";
  67925. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67926. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  67927. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  67928. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67929. /**
  67930. * Class used to control physics engine
  67931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67932. */
  67933. export class PhysicsEngine implements IPhysicsEngine {
  67934. private _physicsPlugin;
  67935. /**
  67936. * Global value used to control the smallest number supported by the simulation
  67937. */
  67938. static Epsilon: number;
  67939. private _impostors;
  67940. private _joints;
  67941. private _subTimeStep;
  67942. /**
  67943. * Gets the gravity vector used by the simulation
  67944. */
  67945. gravity: Vector3;
  67946. /**
  67947. * Factory used to create the default physics plugin.
  67948. * @returns The default physics plugin
  67949. */
  67950. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  67951. /**
  67952. * Creates a new Physics Engine
  67953. * @param gravity defines the gravity vector used by the simulation
  67954. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  67955. */
  67956. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  67957. /**
  67958. * Sets the gravity vector used by the simulation
  67959. * @param gravity defines the gravity vector to use
  67960. */
  67961. setGravity(gravity: Vector3): void;
  67962. /**
  67963. * Set the time step of the physics engine.
  67964. * Default is 1/60.
  67965. * To slow it down, enter 1/600 for example.
  67966. * To speed it up, 1/30
  67967. * @param newTimeStep defines the new timestep to apply to this world.
  67968. */
  67969. setTimeStep(newTimeStep?: number): void;
  67970. /**
  67971. * Get the time step of the physics engine.
  67972. * @returns the current time step
  67973. */
  67974. getTimeStep(): number;
  67975. /**
  67976. * Set the sub time step of the physics engine.
  67977. * Default is 0 meaning there is no sub steps
  67978. * To increase physics resolution precision, set a small value (like 1 ms)
  67979. * @param subTimeStep defines the new sub timestep used for physics resolution.
  67980. */
  67981. setSubTimeStep(subTimeStep?: number): void;
  67982. /**
  67983. * Get the sub time step of the physics engine.
  67984. * @returns the current sub time step
  67985. */
  67986. getSubTimeStep(): number;
  67987. /**
  67988. * Release all resources
  67989. */
  67990. dispose(): void;
  67991. /**
  67992. * Gets the name of the current physics plugin
  67993. * @returns the name of the plugin
  67994. */
  67995. getPhysicsPluginName(): string;
  67996. /**
  67997. * Adding a new impostor for the impostor tracking.
  67998. * This will be done by the impostor itself.
  67999. * @param impostor the impostor to add
  68000. */
  68001. addImpostor(impostor: PhysicsImpostor): void;
  68002. /**
  68003. * Remove an impostor from the engine.
  68004. * This impostor and its mesh will not longer be updated by the physics engine.
  68005. * @param impostor the impostor to remove
  68006. */
  68007. removeImpostor(impostor: PhysicsImpostor): void;
  68008. /**
  68009. * Add a joint to the physics engine
  68010. * @param mainImpostor defines the main impostor to which the joint is added.
  68011. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  68012. * @param joint defines the joint that will connect both impostors.
  68013. */
  68014. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68015. /**
  68016. * Removes a joint from the simulation
  68017. * @param mainImpostor defines the impostor used with the joint
  68018. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  68019. * @param joint defines the joint to remove
  68020. */
  68021. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68022. /**
  68023. * Called by the scene. No need to call it.
  68024. * @param delta defines the timespam between frames
  68025. */
  68026. _step(delta: number): void;
  68027. /**
  68028. * Gets the current plugin used to run the simulation
  68029. * @returns current plugin
  68030. */
  68031. getPhysicsPlugin(): IPhysicsEnginePlugin;
  68032. /**
  68033. * Gets the list of physic impostors
  68034. * @returns an array of PhysicsImpostor
  68035. */
  68036. getImpostors(): Array<PhysicsImpostor>;
  68037. /**
  68038. * Gets the impostor for a physics enabled object
  68039. * @param object defines the object impersonated by the impostor
  68040. * @returns the PhysicsImpostor or null if not found
  68041. */
  68042. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  68043. /**
  68044. * Gets the impostor for a physics body object
  68045. * @param body defines physics body used by the impostor
  68046. * @returns the PhysicsImpostor or null if not found
  68047. */
  68048. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  68049. /**
  68050. * Does a raycast in the physics world
  68051. * @param from when should the ray start?
  68052. * @param to when should the ray end?
  68053. * @returns PhysicsRaycastResult
  68054. */
  68055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68056. }
  68057. }
  68058. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  68059. import { Nullable } from "babylonjs/types";
  68060. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68062. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68063. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68064. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68065. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68066. /** @hidden */
  68067. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  68068. private _useDeltaForWorldStep;
  68069. world: any;
  68070. name: string;
  68071. private _physicsMaterials;
  68072. private _fixedTimeStep;
  68073. private _cannonRaycastResult;
  68074. private _raycastResult;
  68075. private _physicsBodysToRemoveAfterStep;
  68076. private _firstFrame;
  68077. BJSCANNON: any;
  68078. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  68079. setGravity(gravity: Vector3): void;
  68080. setTimeStep(timeStep: number): void;
  68081. getTimeStep(): number;
  68082. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68083. private _removeMarkedPhysicsBodiesFromWorld;
  68084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68085. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68086. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68087. private _processChildMeshes;
  68088. removePhysicsBody(impostor: PhysicsImpostor): void;
  68089. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68091. private _addMaterial;
  68092. private _checkWithEpsilon;
  68093. private _createShape;
  68094. private _createHeightmap;
  68095. private _minus90X;
  68096. private _plus90X;
  68097. private _tmpPosition;
  68098. private _tmpDeltaPosition;
  68099. private _tmpUnityRotation;
  68100. private _updatePhysicsBodyTransformation;
  68101. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68102. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68103. isSupported(): boolean;
  68104. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68105. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68106. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68107. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68108. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68109. getBodyMass(impostor: PhysicsImpostor): number;
  68110. getBodyFriction(impostor: PhysicsImpostor): number;
  68111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68112. getBodyRestitution(impostor: PhysicsImpostor): number;
  68113. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68114. sleepBody(impostor: PhysicsImpostor): void;
  68115. wakeUpBody(impostor: PhysicsImpostor): void;
  68116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  68117. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68118. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68120. getRadius(impostor: PhysicsImpostor): number;
  68121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68122. dispose(): void;
  68123. private _extendNamespace;
  68124. /**
  68125. * Does a raycast in the physics world
  68126. * @param from when should the ray start?
  68127. * @param to when should the ray end?
  68128. * @returns PhysicsRaycastResult
  68129. */
  68130. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68131. }
  68132. }
  68133. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  68134. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68135. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68136. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68138. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68139. import { Nullable } from "babylonjs/types";
  68140. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68141. /** @hidden */
  68142. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  68143. private _useDeltaForWorldStep;
  68144. world: any;
  68145. name: string;
  68146. BJSOIMO: any;
  68147. private _raycastResult;
  68148. private _fixedTimeStep;
  68149. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  68150. setGravity(gravity: Vector3): void;
  68151. setTimeStep(timeStep: number): void;
  68152. getTimeStep(): number;
  68153. private _tmpImpostorsArray;
  68154. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68156. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68158. private _tmpPositionVector;
  68159. removePhysicsBody(impostor: PhysicsImpostor): void;
  68160. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68161. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68162. isSupported(): boolean;
  68163. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68164. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68165. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68166. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68167. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68168. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68169. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68170. getBodyMass(impostor: PhysicsImpostor): number;
  68171. getBodyFriction(impostor: PhysicsImpostor): number;
  68172. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68173. getBodyRestitution(impostor: PhysicsImpostor): number;
  68174. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68175. sleepBody(impostor: PhysicsImpostor): void;
  68176. wakeUpBody(impostor: PhysicsImpostor): void;
  68177. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68178. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  68179. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  68180. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68181. getRadius(impostor: PhysicsImpostor): number;
  68182. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68183. dispose(): void;
  68184. /**
  68185. * Does a raycast in the physics world
  68186. * @param from when should the ray start?
  68187. * @param to when should the ray end?
  68188. * @returns PhysicsRaycastResult
  68189. */
  68190. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68191. }
  68192. }
  68193. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  68194. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  68195. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68196. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68197. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68198. import { Nullable } from "babylonjs/types";
  68199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68200. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68201. /**
  68202. * AmmoJS Physics plugin
  68203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68204. * @see https://github.com/kripken/ammo.js/
  68205. */
  68206. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  68207. private _useDeltaForWorldStep;
  68208. /**
  68209. * Reference to the Ammo library
  68210. */
  68211. bjsAMMO: any;
  68212. /**
  68213. * Created ammoJS world which physics bodies are added to
  68214. */
  68215. world: any;
  68216. /**
  68217. * Name of the plugin
  68218. */
  68219. name: string;
  68220. private _timeStep;
  68221. private _fixedTimeStep;
  68222. private _maxSteps;
  68223. private _tmpQuaternion;
  68224. private _tmpAmmoTransform;
  68225. private _tmpAmmoQuaternion;
  68226. private _tmpAmmoConcreteContactResultCallback;
  68227. private _collisionConfiguration;
  68228. private _dispatcher;
  68229. private _overlappingPairCache;
  68230. private _solver;
  68231. private _softBodySolver;
  68232. private _tmpAmmoVectorA;
  68233. private _tmpAmmoVectorB;
  68234. private _tmpAmmoVectorC;
  68235. private _tmpAmmoVectorD;
  68236. private _tmpContactCallbackResult;
  68237. private _tmpAmmoVectorRCA;
  68238. private _tmpAmmoVectorRCB;
  68239. private _raycastResult;
  68240. private _tmpContactPoint;
  68241. private static readonly DISABLE_COLLISION_FLAG;
  68242. private static readonly KINEMATIC_FLAG;
  68243. private static readonly DISABLE_DEACTIVATION_FLAG;
  68244. /**
  68245. * Initializes the ammoJS plugin
  68246. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  68247. * @param ammoInjection can be used to inject your own ammo reference
  68248. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  68249. */
  68250. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  68251. /**
  68252. * Sets the gravity of the physics world (m/(s^2))
  68253. * @param gravity Gravity to set
  68254. */
  68255. setGravity(gravity: Vector3): void;
  68256. /**
  68257. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  68258. * @param timeStep timestep to use in seconds
  68259. */
  68260. setTimeStep(timeStep: number): void;
  68261. /**
  68262. * 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)
  68263. * @param fixedTimeStep fixedTimeStep to use in seconds
  68264. */
  68265. setFixedTimeStep(fixedTimeStep: number): void;
  68266. /**
  68267. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  68268. * @param maxSteps the maximum number of steps by the physics engine per frame
  68269. */
  68270. setMaxSteps(maxSteps: number): void;
  68271. /**
  68272. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  68273. * @returns the current timestep in seconds
  68274. */
  68275. getTimeStep(): number;
  68276. /**
  68277. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  68278. */
  68279. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  68280. private _isImpostorInContact;
  68281. private _isImpostorPairInContact;
  68282. private _stepSimulation;
  68283. /**
  68284. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  68285. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  68286. * After the step the babylon meshes are set to the position of the physics imposters
  68287. * @param delta amount of time to step forward
  68288. * @param impostors array of imposters to update before/after the step
  68289. */
  68290. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68291. /**
  68292. * Update babylon mesh to match physics world object
  68293. * @param impostor imposter to match
  68294. */
  68295. private _afterSoftStep;
  68296. /**
  68297. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68298. * @param impostor imposter to match
  68299. */
  68300. private _ropeStep;
  68301. /**
  68302. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68303. * @param impostor imposter to match
  68304. */
  68305. private _softbodyOrClothStep;
  68306. private _tmpMatrix;
  68307. /**
  68308. * Applies an impulse on the imposter
  68309. * @param impostor imposter to apply impulse to
  68310. * @param force amount of force to be applied to the imposter
  68311. * @param contactPoint the location to apply the impulse on the imposter
  68312. */
  68313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68314. /**
  68315. * Applies a force on the imposter
  68316. * @param impostor imposter to apply force
  68317. * @param force amount of force to be applied to the imposter
  68318. * @param contactPoint the location to apply the force on the imposter
  68319. */
  68320. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68321. /**
  68322. * Creates a physics body using the plugin
  68323. * @param impostor the imposter to create the physics body on
  68324. */
  68325. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68326. /**
  68327. * Removes the physics body from the imposter and disposes of the body's memory
  68328. * @param impostor imposter to remove the physics body from
  68329. */
  68330. removePhysicsBody(impostor: PhysicsImpostor): void;
  68331. /**
  68332. * Generates a joint
  68333. * @param impostorJoint the imposter joint to create the joint with
  68334. */
  68335. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68336. /**
  68337. * Removes a joint
  68338. * @param impostorJoint the imposter joint to remove the joint from
  68339. */
  68340. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68341. private _addMeshVerts;
  68342. /**
  68343. * Initialise the soft body vertices to match its object's (mesh) vertices
  68344. * Softbody vertices (nodes) are in world space and to match this
  68345. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  68346. * @param impostor to create the softbody for
  68347. */
  68348. private _softVertexData;
  68349. /**
  68350. * Create an impostor's soft body
  68351. * @param impostor to create the softbody for
  68352. */
  68353. private _createSoftbody;
  68354. /**
  68355. * Create cloth for an impostor
  68356. * @param impostor to create the softbody for
  68357. */
  68358. private _createCloth;
  68359. /**
  68360. * Create rope for an impostor
  68361. * @param impostor to create the softbody for
  68362. */
  68363. private _createRope;
  68364. /**
  68365. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  68366. * @param impostor to create the custom physics shape for
  68367. */
  68368. private _createCustom;
  68369. private _addHullVerts;
  68370. private _createShape;
  68371. /**
  68372. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  68373. * @param impostor imposter containing the physics body and babylon object
  68374. */
  68375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68376. /**
  68377. * Sets the babylon object's position/rotation from the physics body's position/rotation
  68378. * @param impostor imposter containing the physics body and babylon object
  68379. * @param newPosition new position
  68380. * @param newRotation new rotation
  68381. */
  68382. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68383. /**
  68384. * If this plugin is supported
  68385. * @returns true if its supported
  68386. */
  68387. isSupported(): boolean;
  68388. /**
  68389. * Sets the linear velocity of the physics body
  68390. * @param impostor imposter to set the velocity on
  68391. * @param velocity velocity to set
  68392. */
  68393. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68394. /**
  68395. * Sets the angular velocity of the physics body
  68396. * @param impostor imposter to set the velocity on
  68397. * @param velocity velocity to set
  68398. */
  68399. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68400. /**
  68401. * gets the linear velocity
  68402. * @param impostor imposter to get linear velocity from
  68403. * @returns linear velocity
  68404. */
  68405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68406. /**
  68407. * gets the angular velocity
  68408. * @param impostor imposter to get angular velocity from
  68409. * @returns angular velocity
  68410. */
  68411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68412. /**
  68413. * Sets the mass of physics body
  68414. * @param impostor imposter to set the mass on
  68415. * @param mass mass to set
  68416. */
  68417. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68418. /**
  68419. * Gets the mass of the physics body
  68420. * @param impostor imposter to get the mass from
  68421. * @returns mass
  68422. */
  68423. getBodyMass(impostor: PhysicsImpostor): number;
  68424. /**
  68425. * Gets friction of the impostor
  68426. * @param impostor impostor to get friction from
  68427. * @returns friction value
  68428. */
  68429. getBodyFriction(impostor: PhysicsImpostor): number;
  68430. /**
  68431. * Sets friction of the impostor
  68432. * @param impostor impostor to set friction on
  68433. * @param friction friction value
  68434. */
  68435. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68436. /**
  68437. * Gets restitution of the impostor
  68438. * @param impostor impostor to get restitution from
  68439. * @returns restitution value
  68440. */
  68441. getBodyRestitution(impostor: PhysicsImpostor): number;
  68442. /**
  68443. * Sets resitution of the impostor
  68444. * @param impostor impostor to set resitution on
  68445. * @param restitution resitution value
  68446. */
  68447. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68448. /**
  68449. * Gets pressure inside the impostor
  68450. * @param impostor impostor to get pressure from
  68451. * @returns pressure value
  68452. */
  68453. getBodyPressure(impostor: PhysicsImpostor): number;
  68454. /**
  68455. * Sets pressure inside a soft body impostor
  68456. * Cloth and rope must remain 0 pressure
  68457. * @param impostor impostor to set pressure on
  68458. * @param pressure pressure value
  68459. */
  68460. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  68461. /**
  68462. * Gets stiffness of the impostor
  68463. * @param impostor impostor to get stiffness from
  68464. * @returns pressure value
  68465. */
  68466. getBodyStiffness(impostor: PhysicsImpostor): number;
  68467. /**
  68468. * Sets stiffness of the impostor
  68469. * @param impostor impostor to set stiffness on
  68470. * @param stiffness stiffness value from 0 to 1
  68471. */
  68472. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  68473. /**
  68474. * Gets velocityIterations of the impostor
  68475. * @param impostor impostor to get velocity iterations from
  68476. * @returns velocityIterations value
  68477. */
  68478. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  68479. /**
  68480. * Sets velocityIterations of the impostor
  68481. * @param impostor impostor to set velocity iterations on
  68482. * @param velocityIterations velocityIterations value
  68483. */
  68484. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  68485. /**
  68486. * Gets positionIterations of the impostor
  68487. * @param impostor impostor to get position iterations from
  68488. * @returns positionIterations value
  68489. */
  68490. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  68491. /**
  68492. * Sets positionIterations of the impostor
  68493. * @param impostor impostor to set position on
  68494. * @param positionIterations positionIterations value
  68495. */
  68496. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  68497. /**
  68498. * Append an anchor to a cloth object
  68499. * @param impostor is the cloth impostor to add anchor to
  68500. * @param otherImpostor is the rigid impostor to anchor to
  68501. * @param width ratio across width from 0 to 1
  68502. * @param height ratio up height from 0 to 1
  68503. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  68504. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68505. */
  68506. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68507. /**
  68508. * Append an hook to a rope object
  68509. * @param impostor is the rope impostor to add hook to
  68510. * @param otherImpostor is the rigid impostor to hook to
  68511. * @param length ratio along the rope from 0 to 1
  68512. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  68513. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68514. */
  68515. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68516. /**
  68517. * Sleeps the physics body and stops it from being active
  68518. * @param impostor impostor to sleep
  68519. */
  68520. sleepBody(impostor: PhysicsImpostor): void;
  68521. /**
  68522. * Activates the physics body
  68523. * @param impostor impostor to activate
  68524. */
  68525. wakeUpBody(impostor: PhysicsImpostor): void;
  68526. /**
  68527. * Updates the distance parameters of the joint
  68528. * @param joint joint to update
  68529. * @param maxDistance maximum distance of the joint
  68530. * @param minDistance minimum distance of the joint
  68531. */
  68532. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68533. /**
  68534. * Sets a motor on the joint
  68535. * @param joint joint to set motor on
  68536. * @param speed speed of the motor
  68537. * @param maxForce maximum force of the motor
  68538. * @param motorIndex index of the motor
  68539. */
  68540. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68541. /**
  68542. * Sets the motors limit
  68543. * @param joint joint to set limit on
  68544. * @param upperLimit upper limit
  68545. * @param lowerLimit lower limit
  68546. */
  68547. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68548. /**
  68549. * Syncs the position and rotation of a mesh with the impostor
  68550. * @param mesh mesh to sync
  68551. * @param impostor impostor to update the mesh with
  68552. */
  68553. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68554. /**
  68555. * Gets the radius of the impostor
  68556. * @param impostor impostor to get radius from
  68557. * @returns the radius
  68558. */
  68559. getRadius(impostor: PhysicsImpostor): number;
  68560. /**
  68561. * Gets the box size of the impostor
  68562. * @param impostor impostor to get box size from
  68563. * @param result the resulting box size
  68564. */
  68565. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68566. /**
  68567. * Disposes of the impostor
  68568. */
  68569. dispose(): void;
  68570. /**
  68571. * Does a raycast in the physics world
  68572. * @param from when should the ray start?
  68573. * @param to when should the ray end?
  68574. * @returns PhysicsRaycastResult
  68575. */
  68576. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68577. }
  68578. }
  68579. declare module "babylonjs/Probes/reflectionProbe" {
  68580. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68581. import { Vector3 } from "babylonjs/Maths/math.vector";
  68582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68583. import { Nullable } from "babylonjs/types";
  68584. import { Scene } from "babylonjs/scene";
  68585. module "babylonjs/abstractScene" {
  68586. interface AbstractScene {
  68587. /**
  68588. * The list of reflection probes added to the scene
  68589. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68590. */
  68591. reflectionProbes: Array<ReflectionProbe>;
  68592. /**
  68593. * Removes the given reflection probe from this scene.
  68594. * @param toRemove The reflection probe to remove
  68595. * @returns The index of the removed reflection probe
  68596. */
  68597. removeReflectionProbe(toRemove: ReflectionProbe): number;
  68598. /**
  68599. * Adds the given reflection probe to this scene.
  68600. * @param newReflectionProbe The reflection probe to add
  68601. */
  68602. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  68603. }
  68604. }
  68605. /**
  68606. * Class used to generate realtime reflection / refraction cube textures
  68607. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68608. */
  68609. export class ReflectionProbe {
  68610. /** defines the name of the probe */
  68611. name: string;
  68612. private _scene;
  68613. private _renderTargetTexture;
  68614. private _projectionMatrix;
  68615. private _viewMatrix;
  68616. private _target;
  68617. private _add;
  68618. private _attachedMesh;
  68619. private _invertYAxis;
  68620. /** Gets or sets probe position (center of the cube map) */
  68621. position: Vector3;
  68622. /**
  68623. * Creates a new reflection probe
  68624. * @param name defines the name of the probe
  68625. * @param size defines the texture resolution (for each face)
  68626. * @param scene defines the hosting scene
  68627. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  68628. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  68629. */
  68630. constructor(
  68631. /** defines the name of the probe */
  68632. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  68633. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  68634. get samples(): number;
  68635. set samples(value: number);
  68636. /** Gets or sets the refresh rate to use (on every frame by default) */
  68637. get refreshRate(): number;
  68638. set refreshRate(value: number);
  68639. /**
  68640. * Gets the hosting scene
  68641. * @returns a Scene
  68642. */
  68643. getScene(): Scene;
  68644. /** Gets the internal CubeTexture used to render to */
  68645. get cubeTexture(): RenderTargetTexture;
  68646. /** Gets the list of meshes to render */
  68647. get renderList(): Nullable<AbstractMesh[]>;
  68648. /**
  68649. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  68650. * @param mesh defines the mesh to attach to
  68651. */
  68652. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  68653. /**
  68654. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  68655. * @param renderingGroupId The rendering group id corresponding to its index
  68656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  68657. */
  68658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  68659. /**
  68660. * Clean all associated resources
  68661. */
  68662. dispose(): void;
  68663. /**
  68664. * Converts the reflection probe information to a readable string for debug purpose.
  68665. * @param fullDetails Supports for multiple levels of logging within scene loading
  68666. * @returns the human readable reflection probe info
  68667. */
  68668. toString(fullDetails?: boolean): string;
  68669. /**
  68670. * Get the class name of the relfection probe.
  68671. * @returns "ReflectionProbe"
  68672. */
  68673. getClassName(): string;
  68674. /**
  68675. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  68676. * @returns The JSON representation of the texture
  68677. */
  68678. serialize(): any;
  68679. /**
  68680. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  68681. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  68682. * @param scene Define the scene the parsed reflection probe should be instantiated in
  68683. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68684. * @returns The parsed reflection probe if successful
  68685. */
  68686. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  68687. }
  68688. }
  68689. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  68690. /** @hidden */
  68691. export var _BabylonLoaderRegistered: boolean;
  68692. /**
  68693. * Helps setting up some configuration for the babylon file loader.
  68694. */
  68695. export class BabylonFileLoaderConfiguration {
  68696. /**
  68697. * The loader does not allow injecting custom physix engine into the plugins.
  68698. * Unfortunately in ES6, we need to manually inject them into the plugin.
  68699. * So you could set this variable to your engine import to make it work.
  68700. */
  68701. static LoaderInjectedPhysicsEngine: any;
  68702. }
  68703. }
  68704. declare module "babylonjs/Loading/Plugins/index" {
  68705. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  68706. }
  68707. declare module "babylonjs/Loading/index" {
  68708. export * from "babylonjs/Loading/loadingScreen";
  68709. export * from "babylonjs/Loading/Plugins/index";
  68710. export * from "babylonjs/Loading/sceneLoader";
  68711. export * from "babylonjs/Loading/sceneLoaderFlags";
  68712. }
  68713. declare module "babylonjs/Materials/Background/index" {
  68714. export * from "babylonjs/Materials/Background/backgroundMaterial";
  68715. }
  68716. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  68717. import { Scene } from "babylonjs/scene";
  68718. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  68719. import "babylonjs/Shaders/color.fragment";
  68720. import "babylonjs/Shaders/color.vertex";
  68721. /**
  68722. * A material to use for fast depth-only rendering.
  68723. */
  68724. export class OcclusionMaterial extends ShaderMaterial {
  68725. constructor(name: string, scene: Scene);
  68726. }
  68727. }
  68728. declare module "babylonjs/Materials/Occlusion/index" {
  68729. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  68730. }
  68731. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  68732. import { Scene } from "babylonjs/scene";
  68733. import { Color3 } from "babylonjs/Maths/math.color";
  68734. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68736. /**
  68737. * The Physically based simple base material of BJS.
  68738. *
  68739. * This enables better naming and convention enforcements on top of the pbrMaterial.
  68740. * It is used as the base class for both the specGloss and metalRough conventions.
  68741. */
  68742. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  68743. /**
  68744. * Number of Simultaneous lights allowed on the material.
  68745. */
  68746. maxSimultaneousLights: number;
  68747. /**
  68748. * If sets to true, disables all the lights affecting the material.
  68749. */
  68750. disableLighting: boolean;
  68751. /**
  68752. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  68753. */
  68754. environmentTexture: BaseTexture;
  68755. /**
  68756. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  68757. */
  68758. invertNormalMapX: boolean;
  68759. /**
  68760. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  68761. */
  68762. invertNormalMapY: boolean;
  68763. /**
  68764. * Normal map used in the model.
  68765. */
  68766. normalTexture: BaseTexture;
  68767. /**
  68768. * Emissivie color used to self-illuminate the model.
  68769. */
  68770. emissiveColor: Color3;
  68771. /**
  68772. * Emissivie texture used to self-illuminate the model.
  68773. */
  68774. emissiveTexture: BaseTexture;
  68775. /**
  68776. * Occlusion Channel Strenght.
  68777. */
  68778. occlusionStrength: number;
  68779. /**
  68780. * Occlusion Texture of the material (adding extra occlusion effects).
  68781. */
  68782. occlusionTexture: BaseTexture;
  68783. /**
  68784. * Defines the alpha limits in alpha test mode.
  68785. */
  68786. alphaCutOff: number;
  68787. /**
  68788. * Gets the current double sided mode.
  68789. */
  68790. get doubleSided(): boolean;
  68791. /**
  68792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  68793. */
  68794. set doubleSided(value: boolean);
  68795. /**
  68796. * Stores the pre-calculated light information of a mesh in a texture.
  68797. */
  68798. lightmapTexture: BaseTexture;
  68799. /**
  68800. * If true, the light map contains occlusion information instead of lighting info.
  68801. */
  68802. useLightmapAsShadowmap: boolean;
  68803. /**
  68804. * Instantiates a new PBRMaterial instance.
  68805. *
  68806. * @param name The material name
  68807. * @param scene The scene the material will be use in.
  68808. */
  68809. constructor(name: string, scene: Scene);
  68810. getClassName(): string;
  68811. }
  68812. }
  68813. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  68814. import { Scene } from "babylonjs/scene";
  68815. import { Color3 } from "babylonjs/Maths/math.color";
  68816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68817. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68818. /**
  68819. * The PBR material of BJS following the metal roughness convention.
  68820. *
  68821. * This fits to the PBR convention in the GLTF definition:
  68822. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  68823. */
  68824. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  68825. /**
  68826. * The base color has two different interpretations depending on the value of metalness.
  68827. * When the material is a metal, the base color is the specific measured reflectance value
  68828. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  68829. * of the material.
  68830. */
  68831. baseColor: Color3;
  68832. /**
  68833. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  68834. * well as opacity information in the alpha channel.
  68835. */
  68836. baseTexture: BaseTexture;
  68837. /**
  68838. * Specifies the metallic scalar value of the material.
  68839. * Can also be used to scale the metalness values of the metallic texture.
  68840. */
  68841. metallic: number;
  68842. /**
  68843. * Specifies the roughness scalar value of the material.
  68844. * Can also be used to scale the roughness values of the metallic texture.
  68845. */
  68846. roughness: number;
  68847. /**
  68848. * Texture containing both the metallic value in the B channel and the
  68849. * roughness value in the G channel to keep better precision.
  68850. */
  68851. metallicRoughnessTexture: BaseTexture;
  68852. /**
  68853. * Instantiates a new PBRMetalRoughnessMaterial instance.
  68854. *
  68855. * @param name The material name
  68856. * @param scene The scene the material will be use in.
  68857. */
  68858. constructor(name: string, scene: Scene);
  68859. /**
  68860. * Return the currrent class name of the material.
  68861. */
  68862. getClassName(): string;
  68863. /**
  68864. * Makes a duplicate of the current material.
  68865. * @param name - name to use for the new material.
  68866. */
  68867. clone(name: string): PBRMetallicRoughnessMaterial;
  68868. /**
  68869. * Serialize the material to a parsable JSON object.
  68870. */
  68871. serialize(): any;
  68872. /**
  68873. * Parses a JSON object correponding to the serialize function.
  68874. */
  68875. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  68876. }
  68877. }
  68878. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  68879. import { Scene } from "babylonjs/scene";
  68880. import { Color3 } from "babylonjs/Maths/math.color";
  68881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68882. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68883. /**
  68884. * The PBR material of BJS following the specular glossiness convention.
  68885. *
  68886. * This fits to the PBR convention in the GLTF definition:
  68887. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  68888. */
  68889. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  68890. /**
  68891. * Specifies the diffuse color of the material.
  68892. */
  68893. diffuseColor: Color3;
  68894. /**
  68895. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  68896. * channel.
  68897. */
  68898. diffuseTexture: BaseTexture;
  68899. /**
  68900. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  68901. */
  68902. specularColor: Color3;
  68903. /**
  68904. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  68905. */
  68906. glossiness: number;
  68907. /**
  68908. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  68909. */
  68910. specularGlossinessTexture: BaseTexture;
  68911. /**
  68912. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  68913. */
  68914. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  68915. /**
  68916. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  68917. *
  68918. * @param name The material name
  68919. * @param scene The scene the material will be use in.
  68920. */
  68921. constructor(name: string, scene: Scene);
  68922. /**
  68923. * Return the currrent class name of the material.
  68924. */
  68925. getClassName(): string;
  68926. /**
  68927. * Makes a duplicate of the current material.
  68928. * @param name - name to use for the new material.
  68929. */
  68930. clone(name: string): PBRSpecularGlossinessMaterial;
  68931. /**
  68932. * Serialize the material to a parsable JSON object.
  68933. */
  68934. serialize(): any;
  68935. /**
  68936. * Parses a JSON object correponding to the serialize function.
  68937. */
  68938. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  68939. }
  68940. }
  68941. declare module "babylonjs/Materials/PBR/index" {
  68942. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68943. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68944. export * from "babylonjs/Materials/PBR/pbrMaterial";
  68945. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  68946. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  68947. }
  68948. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  68949. import { Nullable } from "babylonjs/types";
  68950. import { Scene } from "babylonjs/scene";
  68951. import { Matrix } from "babylonjs/Maths/math.vector";
  68952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68953. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68954. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68955. /**
  68956. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  68957. * It can help converting any input color in a desired output one. This can then be used to create effects
  68958. * from sepia, black and white to sixties or futuristic rendering...
  68959. *
  68960. * The only supported format is currently 3dl.
  68961. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  68962. */
  68963. export class ColorGradingTexture extends BaseTexture {
  68964. /**
  68965. * The texture URL.
  68966. */
  68967. url: string;
  68968. /**
  68969. * Empty line regex stored for GC.
  68970. */
  68971. private static _noneEmptyLineRegex;
  68972. private _textureMatrix;
  68973. private _onLoad;
  68974. /**
  68975. * Instantiates a ColorGradingTexture from the following parameters.
  68976. *
  68977. * @param url The location of the color gradind data (currently only supporting 3dl)
  68978. * @param sceneOrEngine The scene or engine the texture will be used in
  68979. * @param onLoad defines a callback triggered when the texture has been loaded
  68980. */
  68981. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  68982. /**
  68983. * Fires the onload event from the constructor if requested.
  68984. */
  68985. private _triggerOnLoad;
  68986. /**
  68987. * Returns the texture matrix used in most of the material.
  68988. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  68989. */
  68990. getTextureMatrix(): Matrix;
  68991. /**
  68992. * Occurs when the file being loaded is a .3dl LUT file.
  68993. */
  68994. private load3dlTexture;
  68995. /**
  68996. * Starts the loading process of the texture.
  68997. */
  68998. private loadTexture;
  68999. /**
  69000. * Clones the color gradind texture.
  69001. */
  69002. clone(): ColorGradingTexture;
  69003. /**
  69004. * Called during delayed load for textures.
  69005. */
  69006. delayLoad(): void;
  69007. /**
  69008. * Parses a color grading texture serialized by Babylon.
  69009. * @param parsedTexture The texture information being parsedTexture
  69010. * @param scene The scene to load the texture in
  69011. * @param rootUrl The root url of the data assets to load
  69012. * @return A color gradind texture
  69013. */
  69014. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  69015. /**
  69016. * Serializes the LUT texture to json format.
  69017. */
  69018. serialize(): any;
  69019. }
  69020. }
  69021. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  69022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69023. import { Scene } from "babylonjs/scene";
  69024. import { Nullable } from "babylonjs/types";
  69025. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69026. /**
  69027. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  69028. */
  69029. export class EquiRectangularCubeTexture extends BaseTexture {
  69030. /** The six faces of the cube. */
  69031. private static _FacesMapping;
  69032. private _noMipmap;
  69033. private _onLoad;
  69034. private _onError;
  69035. /** The size of the cubemap. */
  69036. private _size;
  69037. /** The buffer of the image. */
  69038. private _buffer;
  69039. /** The width of the input image. */
  69040. private _width;
  69041. /** The height of the input image. */
  69042. private _height;
  69043. /** The URL to the image. */
  69044. url: string;
  69045. /**
  69046. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  69047. * @param url The location of the image
  69048. * @param scene The scene the texture will be used in
  69049. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  69050. * @param noMipmap Forces to not generate the mipmap if true
  69051. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69052. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69053. * @param onLoad — defines a callback called when texture is loaded
  69054. * @param onError — defines a callback called if there is an error
  69055. */
  69056. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  69057. /**
  69058. * Load the image data, by putting the image on a canvas and extracting its buffer.
  69059. */
  69060. private loadImage;
  69061. /**
  69062. * Convert the image buffer into a cubemap and create a CubeTexture.
  69063. */
  69064. private loadTexture;
  69065. /**
  69066. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  69067. * @param buffer The ArrayBuffer that should be converted.
  69068. * @returns The buffer as Float32Array.
  69069. */
  69070. private getFloat32ArrayFromArrayBuffer;
  69071. /**
  69072. * Get the current class name of the texture useful for serialization or dynamic coding.
  69073. * @returns "EquiRectangularCubeTexture"
  69074. */
  69075. getClassName(): string;
  69076. /**
  69077. * Create a clone of the current EquiRectangularCubeTexture and return it.
  69078. * @returns A clone of the current EquiRectangularCubeTexture.
  69079. */
  69080. clone(): EquiRectangularCubeTexture;
  69081. }
  69082. }
  69083. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  69084. import { Nullable } from "babylonjs/types";
  69085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69086. import { Matrix } from "babylonjs/Maths/math.vector";
  69087. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  69088. import "babylonjs/Engines/Extensions/engine.videoTexture";
  69089. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  69090. import { Scene } from "babylonjs/scene";
  69091. /**
  69092. * Defines the options related to the creation of an HtmlElementTexture
  69093. */
  69094. export interface IHtmlElementTextureOptions {
  69095. /**
  69096. * Defines wether mip maps should be created or not.
  69097. */
  69098. generateMipMaps?: boolean;
  69099. /**
  69100. * Defines the sampling mode of the texture.
  69101. */
  69102. samplingMode?: number;
  69103. /**
  69104. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  69105. */
  69106. engine: Nullable<ThinEngine>;
  69107. /**
  69108. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  69109. */
  69110. scene: Nullable<Scene>;
  69111. }
  69112. /**
  69113. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  69114. * To be as efficient as possible depending on your constraints nothing aside the first upload
  69115. * is automatically managed.
  69116. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  69117. * in your application.
  69118. *
  69119. * As the update is not automatic, you need to call them manually.
  69120. */
  69121. export class HtmlElementTexture extends BaseTexture {
  69122. /**
  69123. * The texture URL.
  69124. */
  69125. element: HTMLVideoElement | HTMLCanvasElement;
  69126. private static readonly DefaultOptions;
  69127. private _textureMatrix;
  69128. private _isVideo;
  69129. private _generateMipMaps;
  69130. private _samplingMode;
  69131. /**
  69132. * Instantiates a HtmlElementTexture from the following parameters.
  69133. *
  69134. * @param name Defines the name of the texture
  69135. * @param element Defines the video or canvas the texture is filled with
  69136. * @param options Defines the other none mandatory texture creation options
  69137. */
  69138. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  69139. private _createInternalTexture;
  69140. /**
  69141. * Returns the texture matrix used in most of the material.
  69142. */
  69143. getTextureMatrix(): Matrix;
  69144. /**
  69145. * Updates the content of the texture.
  69146. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  69147. */
  69148. update(invertY?: Nullable<boolean>): void;
  69149. }
  69150. }
  69151. declare module "babylonjs/Misc/tga" {
  69152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69153. /**
  69154. * Based on jsTGALoader - Javascript loader for TGA file
  69155. * By Vincent Thibault
  69156. * @see http://blog.robrowser.com/javascript-tga-loader.html
  69157. */
  69158. export class TGATools {
  69159. private static _TYPE_INDEXED;
  69160. private static _TYPE_RGB;
  69161. private static _TYPE_GREY;
  69162. private static _TYPE_RLE_INDEXED;
  69163. private static _TYPE_RLE_RGB;
  69164. private static _TYPE_RLE_GREY;
  69165. private static _ORIGIN_MASK;
  69166. private static _ORIGIN_SHIFT;
  69167. private static _ORIGIN_BL;
  69168. private static _ORIGIN_BR;
  69169. private static _ORIGIN_UL;
  69170. private static _ORIGIN_UR;
  69171. /**
  69172. * Gets the header of a TGA file
  69173. * @param data defines the TGA data
  69174. * @returns the header
  69175. */
  69176. static GetTGAHeader(data: Uint8Array): any;
  69177. /**
  69178. * Uploads TGA content to a Babylon Texture
  69179. * @hidden
  69180. */
  69181. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  69182. /** @hidden */
  69183. 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;
  69184. /** @hidden */
  69185. 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;
  69186. /** @hidden */
  69187. 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;
  69188. /** @hidden */
  69189. 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;
  69190. /** @hidden */
  69191. 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;
  69192. /** @hidden */
  69193. 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;
  69194. }
  69195. }
  69196. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  69197. import { Nullable } from "babylonjs/types";
  69198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69199. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69200. /**
  69201. * Implementation of the TGA Texture Loader.
  69202. * @hidden
  69203. */
  69204. export class _TGATextureLoader implements IInternalTextureLoader {
  69205. /**
  69206. * Defines wether the loader supports cascade loading the different faces.
  69207. */
  69208. readonly supportCascades: boolean;
  69209. /**
  69210. * This returns if the loader support the current file information.
  69211. * @param extension defines the file extension of the file being loaded
  69212. * @returns true if the loader can load the specified file
  69213. */
  69214. canLoad(extension: string): boolean;
  69215. /**
  69216. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69217. * @param data contains the texture data
  69218. * @param texture defines the BabylonJS internal texture
  69219. * @param createPolynomials will be true if polynomials have been requested
  69220. * @param onLoad defines the callback to trigger once the texture is ready
  69221. * @param onError defines the callback to trigger in case of error
  69222. */
  69223. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69224. /**
  69225. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69226. * @param data contains the texture data
  69227. * @param texture defines the BabylonJS internal texture
  69228. * @param callback defines the method to call once ready to upload
  69229. */
  69230. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69231. }
  69232. }
  69233. declare module "babylonjs/Materials/Textures/Loaders/hdrTextureLoader" {
  69234. import { Nullable } from "babylonjs/types";
  69235. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69236. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69237. /**
  69238. * Implementation of the HDR Texture Loader.
  69239. * @hidden
  69240. */
  69241. export class _HDRTextureLoader implements IInternalTextureLoader {
  69242. /**
  69243. * Defines wether the loader supports cascade loading the different faces.
  69244. */
  69245. readonly supportCascades: boolean;
  69246. /**
  69247. * This returns if the loader support the current file information.
  69248. * @param extension defines the file extension of the file being loaded
  69249. * @returns true if the loader can load the specified file
  69250. */
  69251. canLoad(extension: string): boolean;
  69252. /**
  69253. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69254. * @param data contains the texture data
  69255. * @param texture defines the BabylonJS internal texture
  69256. * @param createPolynomials will be true if polynomials have been requested
  69257. * @param onLoad defines the callback to trigger once the texture is ready
  69258. * @param onError defines the callback to trigger in case of error
  69259. */
  69260. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69261. /**
  69262. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69263. * @param data contains the texture data
  69264. * @param texture defines the BabylonJS internal texture
  69265. * @param callback defines the method to call once ready to upload
  69266. */
  69267. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69268. }
  69269. }
  69270. declare module "babylonjs/Misc/basis" {
  69271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69272. /**
  69273. * Info about the .basis files
  69274. */
  69275. class BasisFileInfo {
  69276. /**
  69277. * If the file has alpha
  69278. */
  69279. hasAlpha: boolean;
  69280. /**
  69281. * Info about each image of the basis file
  69282. */
  69283. images: Array<{
  69284. levels: Array<{
  69285. width: number;
  69286. height: number;
  69287. transcodedPixels: ArrayBufferView;
  69288. }>;
  69289. }>;
  69290. }
  69291. /**
  69292. * Result of transcoding a basis file
  69293. */
  69294. class TranscodeResult {
  69295. /**
  69296. * Info about the .basis file
  69297. */
  69298. fileInfo: BasisFileInfo;
  69299. /**
  69300. * Format to use when loading the file
  69301. */
  69302. format: number;
  69303. }
  69304. /**
  69305. * Configuration options for the Basis transcoder
  69306. */
  69307. export class BasisTranscodeConfiguration {
  69308. /**
  69309. * Supported compression formats used to determine the supported output format of the transcoder
  69310. */
  69311. supportedCompressionFormats?: {
  69312. /**
  69313. * etc1 compression format
  69314. */
  69315. etc1?: boolean;
  69316. /**
  69317. * s3tc compression format
  69318. */
  69319. s3tc?: boolean;
  69320. /**
  69321. * pvrtc compression format
  69322. */
  69323. pvrtc?: boolean;
  69324. /**
  69325. * etc2 compression format
  69326. */
  69327. etc2?: boolean;
  69328. };
  69329. /**
  69330. * If mipmap levels should be loaded for transcoded images (Default: true)
  69331. */
  69332. loadMipmapLevels?: boolean;
  69333. /**
  69334. * Index of a single image to load (Default: all images)
  69335. */
  69336. loadSingleImage?: number;
  69337. }
  69338. /**
  69339. * Used to load .Basis files
  69340. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  69341. */
  69342. export class BasisTools {
  69343. private static _IgnoreSupportedFormats;
  69344. /**
  69345. * URL to use when loading the basis transcoder
  69346. */
  69347. static JSModuleURL: string;
  69348. /**
  69349. * URL to use when loading the wasm module for the transcoder
  69350. */
  69351. static WasmModuleURL: string;
  69352. /**
  69353. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  69354. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  69355. * @returns internal format corresponding to the Basis format
  69356. */
  69357. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  69358. private static _WorkerPromise;
  69359. private static _Worker;
  69360. private static _actionId;
  69361. private static _CreateWorkerAsync;
  69362. /**
  69363. * Transcodes a loaded image file to compressed pixel data
  69364. * @param data image data to transcode
  69365. * @param config configuration options for the transcoding
  69366. * @returns a promise resulting in the transcoded image
  69367. */
  69368. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  69369. /**
  69370. * Loads a texture from the transcode result
  69371. * @param texture texture load to
  69372. * @param transcodeResult the result of transcoding the basis file to load from
  69373. */
  69374. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  69375. }
  69376. }
  69377. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  69378. import { Nullable } from "babylonjs/types";
  69379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69380. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69381. /**
  69382. * Loader for .basis file format
  69383. */
  69384. export class _BasisTextureLoader implements IInternalTextureLoader {
  69385. /**
  69386. * Defines whether the loader supports cascade loading the different faces.
  69387. */
  69388. readonly supportCascades: boolean;
  69389. /**
  69390. * This returns if the loader support the current file information.
  69391. * @param extension defines the file extension of the file being loaded
  69392. * @returns true if the loader can load the specified file
  69393. */
  69394. canLoad(extension: string): boolean;
  69395. /**
  69396. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69397. * @param data contains the texture data
  69398. * @param texture defines the BabylonJS internal texture
  69399. * @param createPolynomials will be true if polynomials have been requested
  69400. * @param onLoad defines the callback to trigger once the texture is ready
  69401. * @param onError defines the callback to trigger in case of error
  69402. */
  69403. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69404. /**
  69405. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69406. * @param data contains the texture data
  69407. * @param texture defines the BabylonJS internal texture
  69408. * @param callback defines the method to call once ready to upload
  69409. */
  69410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69411. }
  69412. }
  69413. declare module "babylonjs/Materials/Textures/Loaders/index" {
  69414. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  69415. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  69416. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  69417. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  69418. export * from "babylonjs/Materials/Textures/Loaders/hdrTextureLoader";
  69419. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  69420. }
  69421. declare module "babylonjs/Materials/Textures/Packer/frame" {
  69422. import { Vector2 } from "babylonjs/Maths/math.vector";
  69423. /**
  69424. * Defines the basic options interface of a TexturePacker Frame
  69425. */
  69426. export interface ITexturePackerFrame {
  69427. /**
  69428. * The frame ID
  69429. */
  69430. id: number;
  69431. /**
  69432. * The frames Scale
  69433. */
  69434. scale: Vector2;
  69435. /**
  69436. * The Frames offset
  69437. */
  69438. offset: Vector2;
  69439. }
  69440. /**
  69441. * This is a support class for frame Data on texture packer sets.
  69442. */
  69443. export class TexturePackerFrame implements ITexturePackerFrame {
  69444. /**
  69445. * The frame ID
  69446. */
  69447. id: number;
  69448. /**
  69449. * The frames Scale
  69450. */
  69451. scale: Vector2;
  69452. /**
  69453. * The Frames offset
  69454. */
  69455. offset: Vector2;
  69456. /**
  69457. * Initializes a texture package frame.
  69458. * @param id The numerical frame identifier
  69459. * @param scale Scalar Vector2 for UV frame
  69460. * @param offset Vector2 for the frame position in UV units.
  69461. * @returns TexturePackerFrame
  69462. */
  69463. constructor(id: number, scale: Vector2, offset: Vector2);
  69464. }
  69465. }
  69466. declare module "babylonjs/Materials/Textures/Packer/packer" {
  69467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69468. import { Scene } from "babylonjs/scene";
  69469. import { Nullable } from "babylonjs/types";
  69470. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  69471. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  69472. /**
  69473. * Defines the basic options interface of a TexturePacker
  69474. */
  69475. export interface ITexturePackerOptions {
  69476. /**
  69477. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  69478. */
  69479. map?: string[];
  69480. /**
  69481. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69482. */
  69483. uvsIn?: string;
  69484. /**
  69485. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69486. */
  69487. uvsOut?: string;
  69488. /**
  69489. * number representing the layout style. Defaults to LAYOUT_STRIP
  69490. */
  69491. layout?: number;
  69492. /**
  69493. * number of columns if using custom column count layout(2). This defaults to 4.
  69494. */
  69495. colnum?: number;
  69496. /**
  69497. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  69498. */
  69499. updateInputMeshes?: boolean;
  69500. /**
  69501. * boolean flag to dispose all the source textures. Defaults to true.
  69502. */
  69503. disposeSources?: boolean;
  69504. /**
  69505. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  69506. */
  69507. fillBlanks?: boolean;
  69508. /**
  69509. * string value representing the context fill style color. Defaults to 'black'.
  69510. */
  69511. customFillColor?: string;
  69512. /**
  69513. * Width and Height Value of each Frame in the TexturePacker Sets
  69514. */
  69515. frameSize?: number;
  69516. /**
  69517. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  69518. */
  69519. paddingRatio?: number;
  69520. /**
  69521. * Number that declares the fill method for the padding gutter.
  69522. */
  69523. paddingMode?: number;
  69524. /**
  69525. * If in SUBUV_COLOR padding mode what color to use.
  69526. */
  69527. paddingColor?: Color3 | Color4;
  69528. }
  69529. /**
  69530. * Defines the basic interface of a TexturePacker JSON File
  69531. */
  69532. export interface ITexturePackerJSON {
  69533. /**
  69534. * The frame ID
  69535. */
  69536. name: string;
  69537. /**
  69538. * The base64 channel data
  69539. */
  69540. sets: any;
  69541. /**
  69542. * The options of the Packer
  69543. */
  69544. options: ITexturePackerOptions;
  69545. /**
  69546. * The frame data of the Packer
  69547. */
  69548. frames: Array<number>;
  69549. }
  69550. /**
  69551. * This is a support class that generates a series of packed texture sets.
  69552. * @see https://doc.babylonjs.com/babylon101/materials
  69553. */
  69554. export class TexturePacker {
  69555. /** Packer Layout Constant 0 */
  69556. static readonly LAYOUT_STRIP: number;
  69557. /** Packer Layout Constant 1 */
  69558. static readonly LAYOUT_POWER2: number;
  69559. /** Packer Layout Constant 2 */
  69560. static readonly LAYOUT_COLNUM: number;
  69561. /** Packer Layout Constant 0 */
  69562. static readonly SUBUV_WRAP: number;
  69563. /** Packer Layout Constant 1 */
  69564. static readonly SUBUV_EXTEND: number;
  69565. /** Packer Layout Constant 2 */
  69566. static readonly SUBUV_COLOR: number;
  69567. /** The Name of the Texture Package */
  69568. name: string;
  69569. /** The scene scope of the TexturePacker */
  69570. scene: Scene;
  69571. /** The Meshes to target */
  69572. meshes: AbstractMesh[];
  69573. /** Arguments passed with the Constructor */
  69574. options: ITexturePackerOptions;
  69575. /** The promise that is started upon initialization */
  69576. promise: Nullable<Promise<TexturePacker | string>>;
  69577. /** The Container object for the channel sets that are generated */
  69578. sets: object;
  69579. /** The Container array for the frames that are generated */
  69580. frames: TexturePackerFrame[];
  69581. /** The expected number of textures the system is parsing. */
  69582. private _expecting;
  69583. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  69584. private _paddingValue;
  69585. /**
  69586. * Initializes a texture package series from an array of meshes or a single mesh.
  69587. * @param name The name of the package
  69588. * @param meshes The target meshes to compose the package from
  69589. * @param options The arguments that texture packer should follow while building.
  69590. * @param scene The scene which the textures are scoped to.
  69591. * @returns TexturePacker
  69592. */
  69593. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  69594. /**
  69595. * Starts the package process
  69596. * @param resolve The promises resolution function
  69597. * @returns TexturePacker
  69598. */
  69599. private _createFrames;
  69600. /**
  69601. * Calculates the Size of the Channel Sets
  69602. * @returns Vector2
  69603. */
  69604. private _calculateSize;
  69605. /**
  69606. * Calculates the UV data for the frames.
  69607. * @param baseSize the base frameSize
  69608. * @param padding the base frame padding
  69609. * @param dtSize size of the Dynamic Texture for that channel
  69610. * @param dtUnits is 1/dtSize
  69611. * @param update flag to update the input meshes
  69612. */
  69613. private _calculateMeshUVFrames;
  69614. /**
  69615. * Calculates the frames Offset.
  69616. * @param index of the frame
  69617. * @returns Vector2
  69618. */
  69619. private _getFrameOffset;
  69620. /**
  69621. * Updates a Mesh to the frame data
  69622. * @param mesh that is the target
  69623. * @param frameID or the frame index
  69624. */
  69625. private _updateMeshUV;
  69626. /**
  69627. * Updates a Meshes materials to use the texture packer channels
  69628. * @param m is the mesh to target
  69629. * @param force all channels on the packer to be set.
  69630. */
  69631. private _updateTextureReferences;
  69632. /**
  69633. * Public method to set a Mesh to a frame
  69634. * @param m that is the target
  69635. * @param frameID or the frame index
  69636. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  69637. */
  69638. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  69639. /**
  69640. * Starts the async promise to compile the texture packer.
  69641. * @returns Promise<void>
  69642. */
  69643. processAsync(): Promise<void>;
  69644. /**
  69645. * Disposes all textures associated with this packer
  69646. */
  69647. dispose(): void;
  69648. /**
  69649. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  69650. * @param imageType is the image type to use.
  69651. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  69652. */
  69653. download(imageType?: string, quality?: number): void;
  69654. /**
  69655. * Public method to load a texturePacker JSON file.
  69656. * @param data of the JSON file in string format.
  69657. */
  69658. updateFromJSON(data: string): void;
  69659. }
  69660. }
  69661. declare module "babylonjs/Materials/Textures/Packer/index" {
  69662. export * from "babylonjs/Materials/Textures/Packer/packer";
  69663. export * from "babylonjs/Materials/Textures/Packer/frame";
  69664. }
  69665. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  69666. import { Scene } from "babylonjs/scene";
  69667. import { Texture } from "babylonjs/Materials/Textures/texture";
  69668. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69669. /**
  69670. * 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.
  69671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69672. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69673. */
  69674. export class CustomProceduralTexture extends ProceduralTexture {
  69675. private _animate;
  69676. private _time;
  69677. private _config;
  69678. private _texturePath;
  69679. /**
  69680. * Instantiates a new Custom Procedural Texture.
  69681. * 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.
  69682. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69683. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69684. * @param name Define the name of the texture
  69685. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  69686. * @param size Define the size of the texture to create
  69687. * @param scene Define the scene the texture belongs to
  69688. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69689. * @param generateMipMaps Define if the texture should creates mip maps or not
  69690. */
  69691. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69692. private _loadJson;
  69693. /**
  69694. * Is the texture ready to be used ? (rendered at least once)
  69695. * @returns true if ready, otherwise, false.
  69696. */
  69697. isReady(): boolean;
  69698. /**
  69699. * Render the texture to its associated render target.
  69700. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69701. */
  69702. render(useCameraPostProcess?: boolean): void;
  69703. /**
  69704. * Update the list of dependant textures samplers in the shader.
  69705. */
  69706. updateTextures(): void;
  69707. /**
  69708. * Update the uniform values of the procedural texture in the shader.
  69709. */
  69710. updateShaderUniforms(): void;
  69711. /**
  69712. * Define if the texture animates or not.
  69713. */
  69714. get animate(): boolean;
  69715. set animate(value: boolean);
  69716. }
  69717. }
  69718. declare module "babylonjs/Shaders/noise.fragment" {
  69719. /** @hidden */
  69720. export var noisePixelShader: {
  69721. name: string;
  69722. shader: string;
  69723. };
  69724. }
  69725. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  69726. import { Nullable } from "babylonjs/types";
  69727. import { Scene } from "babylonjs/scene";
  69728. import { Texture } from "babylonjs/Materials/Textures/texture";
  69729. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69730. import "babylonjs/Shaders/noise.fragment";
  69731. /**
  69732. * Class used to generate noise procedural textures
  69733. */
  69734. export class NoiseProceduralTexture extends ProceduralTexture {
  69735. /** Gets or sets the start time (default is 0) */
  69736. time: number;
  69737. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  69738. brightness: number;
  69739. /** Defines the number of octaves to process */
  69740. octaves: number;
  69741. /** Defines the level of persistence (0.8 by default) */
  69742. persistence: number;
  69743. /** Gets or sets animation speed factor (default is 1) */
  69744. animationSpeedFactor: number;
  69745. /**
  69746. * Creates a new NoiseProceduralTexture
  69747. * @param name defines the name fo the texture
  69748. * @param size defines the size of the texture (default is 256)
  69749. * @param scene defines the hosting scene
  69750. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  69751. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  69752. */
  69753. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69754. private _updateShaderUniforms;
  69755. protected _getDefines(): string;
  69756. /** Generate the current state of the procedural texture */
  69757. render(useCameraPostProcess?: boolean): void;
  69758. /**
  69759. * Serializes this noise procedural texture
  69760. * @returns a serialized noise procedural texture object
  69761. */
  69762. serialize(): any;
  69763. /**
  69764. * Clone the texture.
  69765. * @returns the cloned texture
  69766. */
  69767. clone(): NoiseProceduralTexture;
  69768. /**
  69769. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  69770. * @param parsedTexture defines parsed texture data
  69771. * @param scene defines the current scene
  69772. * @param rootUrl defines the root URL containing noise procedural texture information
  69773. * @returns a parsed NoiseProceduralTexture
  69774. */
  69775. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  69776. }
  69777. }
  69778. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  69779. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  69780. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  69781. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69782. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  69783. }
  69784. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  69785. import { Nullable } from "babylonjs/types";
  69786. import { Scene } from "babylonjs/scene";
  69787. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  69788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69789. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69790. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69791. /**
  69792. * Raw cube texture where the raw buffers are passed in
  69793. */
  69794. export class RawCubeTexture extends CubeTexture {
  69795. /**
  69796. * Creates a cube texture where the raw buffers are passed in.
  69797. * @param scene defines the scene the texture is attached to
  69798. * @param data defines the array of data to use to create each face
  69799. * @param size defines the size of the textures
  69800. * @param format defines the format of the data
  69801. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  69802. * @param generateMipMaps defines if the engine should generate the mip levels
  69803. * @param invertY defines if data must be stored with Y axis inverted
  69804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  69805. * @param compression defines the compression used (null by default)
  69806. */
  69807. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  69808. /**
  69809. * Updates the raw cube texture.
  69810. * @param data defines the data to store
  69811. * @param format defines the data format
  69812. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69813. * @param invertY defines if data must be stored with Y axis inverted
  69814. * @param compression defines the compression used (null by default)
  69815. * @param level defines which level of the texture to update
  69816. */
  69817. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  69818. /**
  69819. * Updates a raw cube texture with RGBD encoded data.
  69820. * @param data defines the array of data [mipmap][face] to use to create each face
  69821. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  69822. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  69823. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  69824. * @returns a promsie that resolves when the operation is complete
  69825. */
  69826. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  69827. /**
  69828. * Clones the raw cube texture.
  69829. * @return a new cube texture
  69830. */
  69831. clone(): CubeTexture;
  69832. /** @hidden */
  69833. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  69834. }
  69835. }
  69836. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  69837. import { Scene } from "babylonjs/scene";
  69838. import { Texture } from "babylonjs/Materials/Textures/texture";
  69839. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69840. /**
  69841. * Class used to store 2D array textures containing user data
  69842. */
  69843. export class RawTexture2DArray extends Texture {
  69844. /** Gets or sets the texture format to use */
  69845. format: number;
  69846. /**
  69847. * Create a new RawTexture2DArray
  69848. * @param data defines the data of the texture
  69849. * @param width defines the width of the texture
  69850. * @param height defines the height of the texture
  69851. * @param depth defines the number of layers of the texture
  69852. * @param format defines the texture format to use
  69853. * @param scene defines the hosting scene
  69854. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69855. * @param invertY defines if texture must be stored with Y axis inverted
  69856. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69857. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69858. */
  69859. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69860. /** Gets or sets the texture format to use */
  69861. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69862. /**
  69863. * Update the texture with new data
  69864. * @param data defines the data to store in the texture
  69865. */
  69866. update(data: ArrayBufferView): void;
  69867. }
  69868. }
  69869. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  69870. import { Scene } from "babylonjs/scene";
  69871. import { Texture } from "babylonjs/Materials/Textures/texture";
  69872. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69873. /**
  69874. * Class used to store 3D textures containing user data
  69875. */
  69876. export class RawTexture3D extends Texture {
  69877. /** Gets or sets the texture format to use */
  69878. format: number;
  69879. /**
  69880. * Create a new RawTexture3D
  69881. * @param data defines the data of the texture
  69882. * @param width defines the width of the texture
  69883. * @param height defines the height of the texture
  69884. * @param depth defines the depth of the texture
  69885. * @param format defines the texture format to use
  69886. * @param scene defines the hosting scene
  69887. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69888. * @param invertY defines if texture must be stored with Y axis inverted
  69889. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69890. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69891. */
  69892. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69893. /** Gets or sets the texture format to use */
  69894. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69895. /**
  69896. * Update the texture with new data
  69897. * @param data defines the data to store in the texture
  69898. */
  69899. update(data: ArrayBufferView): void;
  69900. }
  69901. }
  69902. declare module "babylonjs/Materials/Textures/refractionTexture" {
  69903. import { Scene } from "babylonjs/scene";
  69904. import { Plane } from "babylonjs/Maths/math.plane";
  69905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69906. /**
  69907. * Creates a refraction texture used by refraction channel of the standard material.
  69908. * It is like a mirror but to see through a material.
  69909. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69910. */
  69911. export class RefractionTexture extends RenderTargetTexture {
  69912. /**
  69913. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  69914. * 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.
  69915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69916. */
  69917. refractionPlane: Plane;
  69918. /**
  69919. * Define how deep under the surface we should see.
  69920. */
  69921. depth: number;
  69922. /**
  69923. * Creates a refraction texture used by refraction channel of the standard material.
  69924. * It is like a mirror but to see through a material.
  69925. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69926. * @param name Define the texture name
  69927. * @param size Define the size of the underlying texture
  69928. * @param scene Define the scene the refraction belongs to
  69929. * @param generateMipMaps Define if we need to generate mips level for the refraction
  69930. */
  69931. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  69932. /**
  69933. * Clone the refraction texture.
  69934. * @returns the cloned texture
  69935. */
  69936. clone(): RefractionTexture;
  69937. /**
  69938. * Serialize the texture to a JSON representation you could use in Parse later on
  69939. * @returns the serialized JSON representation
  69940. */
  69941. serialize(): any;
  69942. }
  69943. }
  69944. declare module "babylonjs/Materials/Textures/index" {
  69945. export * from "babylonjs/Materials/Textures/baseTexture";
  69946. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  69947. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  69948. export * from "babylonjs/Materials/Textures/cubeTexture";
  69949. export * from "babylonjs/Materials/Textures/dynamicTexture";
  69950. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69951. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  69952. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  69953. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  69954. export * from "babylonjs/Materials/Textures/internalTexture";
  69955. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  69956. export * from "babylonjs/Materials/Textures/Loaders/index";
  69957. export * from "babylonjs/Materials/Textures/mirrorTexture";
  69958. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  69959. export * from "babylonjs/Materials/Textures/Packer/index";
  69960. export * from "babylonjs/Materials/Textures/Procedurals/index";
  69961. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  69962. export * from "babylonjs/Materials/Textures/rawTexture";
  69963. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  69964. export * from "babylonjs/Materials/Textures/rawTexture3D";
  69965. export * from "babylonjs/Materials/Textures/refractionTexture";
  69966. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  69967. export * from "babylonjs/Materials/Textures/texture";
  69968. export * from "babylonjs/Materials/Textures/videoTexture";
  69969. }
  69970. declare module "babylonjs/Materials/Node/Enums/index" {
  69971. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  69972. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  69973. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  69974. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  69975. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  69976. }
  69977. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  69978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69981. import { Mesh } from "babylonjs/Meshes/mesh";
  69982. import { Effect } from "babylonjs/Materials/effect";
  69983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69984. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69986. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69987. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69988. /**
  69989. * Block used to add support for vertex skinning (bones)
  69990. */
  69991. export class BonesBlock extends NodeMaterialBlock {
  69992. /**
  69993. * Creates a new BonesBlock
  69994. * @param name defines the block name
  69995. */
  69996. constructor(name: string);
  69997. /**
  69998. * Initialize the block and prepare the context for build
  69999. * @param state defines the state that will be used for the build
  70000. */
  70001. initialize(state: NodeMaterialBuildState): void;
  70002. /**
  70003. * Gets the current class name
  70004. * @returns the class name
  70005. */
  70006. getClassName(): string;
  70007. /**
  70008. * Gets the matrix indices input component
  70009. */
  70010. get matricesIndices(): NodeMaterialConnectionPoint;
  70011. /**
  70012. * Gets the matrix weights input component
  70013. */
  70014. get matricesWeights(): NodeMaterialConnectionPoint;
  70015. /**
  70016. * Gets the extra matrix indices input component
  70017. */
  70018. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  70019. /**
  70020. * Gets the extra matrix weights input component
  70021. */
  70022. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  70023. /**
  70024. * Gets the world input component
  70025. */
  70026. get world(): NodeMaterialConnectionPoint;
  70027. /**
  70028. * Gets the output component
  70029. */
  70030. get output(): NodeMaterialConnectionPoint;
  70031. autoConfigure(material: NodeMaterial): void;
  70032. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  70033. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70034. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70035. protected _buildBlock(state: NodeMaterialBuildState): this;
  70036. }
  70037. }
  70038. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  70039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70043. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70045. /**
  70046. * Block used to add support for instances
  70047. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  70048. */
  70049. export class InstancesBlock extends NodeMaterialBlock {
  70050. /**
  70051. * Creates a new InstancesBlock
  70052. * @param name defines the block name
  70053. */
  70054. constructor(name: string);
  70055. /**
  70056. * Gets the current class name
  70057. * @returns the class name
  70058. */
  70059. getClassName(): string;
  70060. /**
  70061. * Gets the first world row input component
  70062. */
  70063. get world0(): NodeMaterialConnectionPoint;
  70064. /**
  70065. * Gets the second world row input component
  70066. */
  70067. get world1(): NodeMaterialConnectionPoint;
  70068. /**
  70069. * Gets the third world row input component
  70070. */
  70071. get world2(): NodeMaterialConnectionPoint;
  70072. /**
  70073. * Gets the forth world row input component
  70074. */
  70075. get world3(): NodeMaterialConnectionPoint;
  70076. /**
  70077. * Gets the world input component
  70078. */
  70079. get world(): NodeMaterialConnectionPoint;
  70080. /**
  70081. * Gets the output component
  70082. */
  70083. get output(): NodeMaterialConnectionPoint;
  70084. /**
  70085. * Gets the isntanceID component
  70086. */
  70087. get instanceID(): NodeMaterialConnectionPoint;
  70088. autoConfigure(material: NodeMaterial): void;
  70089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  70090. protected _buildBlock(state: NodeMaterialBuildState): this;
  70091. }
  70092. }
  70093. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  70094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70099. import { Effect } from "babylonjs/Materials/effect";
  70100. import { Mesh } from "babylonjs/Meshes/mesh";
  70101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70103. /**
  70104. * Block used to add morph targets support to vertex shader
  70105. */
  70106. export class MorphTargetsBlock extends NodeMaterialBlock {
  70107. private _repeatableContentAnchor;
  70108. /**
  70109. * Create a new MorphTargetsBlock
  70110. * @param name defines the block name
  70111. */
  70112. constructor(name: string);
  70113. /**
  70114. * Gets the current class name
  70115. * @returns the class name
  70116. */
  70117. getClassName(): string;
  70118. /**
  70119. * Gets the position input component
  70120. */
  70121. get position(): NodeMaterialConnectionPoint;
  70122. /**
  70123. * Gets the normal input component
  70124. */
  70125. get normal(): NodeMaterialConnectionPoint;
  70126. /**
  70127. * Gets the tangent input component
  70128. */
  70129. get tangent(): NodeMaterialConnectionPoint;
  70130. /**
  70131. * Gets the tangent input component
  70132. */
  70133. get uv(): NodeMaterialConnectionPoint;
  70134. /**
  70135. * Gets the position output component
  70136. */
  70137. get positionOutput(): NodeMaterialConnectionPoint;
  70138. /**
  70139. * Gets the normal output component
  70140. */
  70141. get normalOutput(): NodeMaterialConnectionPoint;
  70142. /**
  70143. * Gets the tangent output component
  70144. */
  70145. get tangentOutput(): NodeMaterialConnectionPoint;
  70146. /**
  70147. * Gets the tangent output component
  70148. */
  70149. get uvOutput(): NodeMaterialConnectionPoint;
  70150. initialize(state: NodeMaterialBuildState): void;
  70151. autoConfigure(material: NodeMaterial): void;
  70152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70154. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  70155. protected _buildBlock(state: NodeMaterialBuildState): this;
  70156. }
  70157. }
  70158. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  70159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70162. import { Nullable } from "babylonjs/types";
  70163. import { Scene } from "babylonjs/scene";
  70164. import { Effect } from "babylonjs/Materials/effect";
  70165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70166. import { Mesh } from "babylonjs/Meshes/mesh";
  70167. import { Light } from "babylonjs/Lights/light";
  70168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70169. /**
  70170. * Block used to get data information from a light
  70171. */
  70172. export class LightInformationBlock extends NodeMaterialBlock {
  70173. private _lightDataUniformName;
  70174. private _lightColorUniformName;
  70175. private _lightTypeDefineName;
  70176. /**
  70177. * Gets or sets the light associated with this block
  70178. */
  70179. light: Nullable<Light>;
  70180. /**
  70181. * Creates a new LightInformationBlock
  70182. * @param name defines the block name
  70183. */
  70184. constructor(name: string);
  70185. /**
  70186. * Gets the current class name
  70187. * @returns the class name
  70188. */
  70189. getClassName(): string;
  70190. /**
  70191. * Gets the world position input component
  70192. */
  70193. get worldPosition(): NodeMaterialConnectionPoint;
  70194. /**
  70195. * Gets the direction output component
  70196. */
  70197. get direction(): NodeMaterialConnectionPoint;
  70198. /**
  70199. * Gets the direction output component
  70200. */
  70201. get color(): NodeMaterialConnectionPoint;
  70202. /**
  70203. * Gets the direction output component
  70204. */
  70205. get intensity(): NodeMaterialConnectionPoint;
  70206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70208. protected _buildBlock(state: NodeMaterialBuildState): this;
  70209. serialize(): any;
  70210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70211. }
  70212. }
  70213. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  70214. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  70215. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  70216. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  70217. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  70218. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  70219. }
  70220. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  70221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70226. import { Effect } from "babylonjs/Materials/effect";
  70227. import { Mesh } from "babylonjs/Meshes/mesh";
  70228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70229. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70230. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70231. /**
  70232. * Block used to add image processing support to fragment shader
  70233. */
  70234. export class ImageProcessingBlock extends NodeMaterialBlock {
  70235. /**
  70236. * Create a new ImageProcessingBlock
  70237. * @param name defines the block name
  70238. */
  70239. constructor(name: string);
  70240. /**
  70241. * Gets the current class name
  70242. * @returns the class name
  70243. */
  70244. getClassName(): string;
  70245. /**
  70246. * Gets the color input component
  70247. */
  70248. get color(): NodeMaterialConnectionPoint;
  70249. /**
  70250. * Gets the output component
  70251. */
  70252. get output(): NodeMaterialConnectionPoint;
  70253. /**
  70254. * Initialize the block and prepare the context for build
  70255. * @param state defines the state that will be used for the build
  70256. */
  70257. initialize(state: NodeMaterialBuildState): void;
  70258. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  70259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70261. protected _buildBlock(state: NodeMaterialBuildState): this;
  70262. }
  70263. }
  70264. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  70265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70268. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70270. import { Effect } from "babylonjs/Materials/effect";
  70271. import { Mesh } from "babylonjs/Meshes/mesh";
  70272. import { Scene } from "babylonjs/scene";
  70273. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70274. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70275. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70276. /**
  70277. * Block used to pertub normals based on a normal map
  70278. */
  70279. export class PerturbNormalBlock extends NodeMaterialBlock {
  70280. private _tangentSpaceParameterName;
  70281. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  70282. invertX: boolean;
  70283. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  70284. invertY: boolean;
  70285. /**
  70286. * Create a new PerturbNormalBlock
  70287. * @param name defines the block name
  70288. */
  70289. constructor(name: string);
  70290. /**
  70291. * Gets the current class name
  70292. * @returns the class name
  70293. */
  70294. getClassName(): string;
  70295. /**
  70296. * Gets the world position input component
  70297. */
  70298. get worldPosition(): NodeMaterialConnectionPoint;
  70299. /**
  70300. * Gets the world normal input component
  70301. */
  70302. get worldNormal(): NodeMaterialConnectionPoint;
  70303. /**
  70304. * Gets the world tangent input component
  70305. */
  70306. get worldTangent(): NodeMaterialConnectionPoint;
  70307. /**
  70308. * Gets the uv input component
  70309. */
  70310. get uv(): NodeMaterialConnectionPoint;
  70311. /**
  70312. * Gets the normal map color input component
  70313. */
  70314. get normalMapColor(): NodeMaterialConnectionPoint;
  70315. /**
  70316. * Gets the strength input component
  70317. */
  70318. get strength(): NodeMaterialConnectionPoint;
  70319. /**
  70320. * Gets the output component
  70321. */
  70322. get output(): NodeMaterialConnectionPoint;
  70323. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70324. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70325. autoConfigure(material: NodeMaterial): void;
  70326. protected _buildBlock(state: NodeMaterialBuildState): this;
  70327. protected _dumpPropertiesCode(): string;
  70328. serialize(): any;
  70329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70330. }
  70331. }
  70332. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  70333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70336. /**
  70337. * Block used to discard a pixel if a value is smaller than a cutoff
  70338. */
  70339. export class DiscardBlock extends NodeMaterialBlock {
  70340. /**
  70341. * Create a new DiscardBlock
  70342. * @param name defines the block name
  70343. */
  70344. constructor(name: string);
  70345. /**
  70346. * Gets the current class name
  70347. * @returns the class name
  70348. */
  70349. getClassName(): string;
  70350. /**
  70351. * Gets the color input component
  70352. */
  70353. get value(): NodeMaterialConnectionPoint;
  70354. /**
  70355. * Gets the cutoff input component
  70356. */
  70357. get cutoff(): NodeMaterialConnectionPoint;
  70358. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70359. }
  70360. }
  70361. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  70362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70365. /**
  70366. * Block used to test if the fragment shader is front facing
  70367. */
  70368. export class FrontFacingBlock extends NodeMaterialBlock {
  70369. /**
  70370. * Creates a new FrontFacingBlock
  70371. * @param name defines the block name
  70372. */
  70373. constructor(name: string);
  70374. /**
  70375. * Gets the current class name
  70376. * @returns the class name
  70377. */
  70378. getClassName(): string;
  70379. /**
  70380. * Gets the output component
  70381. */
  70382. get output(): NodeMaterialConnectionPoint;
  70383. protected _buildBlock(state: NodeMaterialBuildState): this;
  70384. }
  70385. }
  70386. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  70387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70390. /**
  70391. * Block used to get the derivative value on x and y of a given input
  70392. */
  70393. export class DerivativeBlock extends NodeMaterialBlock {
  70394. /**
  70395. * Create a new DerivativeBlock
  70396. * @param name defines the block name
  70397. */
  70398. constructor(name: string);
  70399. /**
  70400. * Gets the current class name
  70401. * @returns the class name
  70402. */
  70403. getClassName(): string;
  70404. /**
  70405. * Gets the input component
  70406. */
  70407. get input(): NodeMaterialConnectionPoint;
  70408. /**
  70409. * Gets the derivative output on x
  70410. */
  70411. get dx(): NodeMaterialConnectionPoint;
  70412. /**
  70413. * Gets the derivative output on y
  70414. */
  70415. get dy(): NodeMaterialConnectionPoint;
  70416. protected _buildBlock(state: NodeMaterialBuildState): this;
  70417. }
  70418. }
  70419. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  70420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70423. /**
  70424. * Block used to make gl_FragCoord available
  70425. */
  70426. export class FragCoordBlock extends NodeMaterialBlock {
  70427. /**
  70428. * Creates a new FragCoordBlock
  70429. * @param name defines the block name
  70430. */
  70431. constructor(name: string);
  70432. /**
  70433. * Gets the current class name
  70434. * @returns the class name
  70435. */
  70436. getClassName(): string;
  70437. /**
  70438. * Gets the xy component
  70439. */
  70440. get xy(): NodeMaterialConnectionPoint;
  70441. /**
  70442. * Gets the xyz component
  70443. */
  70444. get xyz(): NodeMaterialConnectionPoint;
  70445. /**
  70446. * Gets the xyzw component
  70447. */
  70448. get xyzw(): NodeMaterialConnectionPoint;
  70449. /**
  70450. * Gets the x component
  70451. */
  70452. get x(): NodeMaterialConnectionPoint;
  70453. /**
  70454. * Gets the y component
  70455. */
  70456. get y(): NodeMaterialConnectionPoint;
  70457. /**
  70458. * Gets the z component
  70459. */
  70460. get z(): NodeMaterialConnectionPoint;
  70461. /**
  70462. * Gets the w component
  70463. */
  70464. get output(): NodeMaterialConnectionPoint;
  70465. protected writeOutputs(state: NodeMaterialBuildState): string;
  70466. protected _buildBlock(state: NodeMaterialBuildState): this;
  70467. }
  70468. }
  70469. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  70470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70473. import { Effect } from "babylonjs/Materials/effect";
  70474. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70475. import { Mesh } from "babylonjs/Meshes/mesh";
  70476. /**
  70477. * Block used to get the screen sizes
  70478. */
  70479. export class ScreenSizeBlock extends NodeMaterialBlock {
  70480. private _varName;
  70481. private _scene;
  70482. /**
  70483. * Creates a new ScreenSizeBlock
  70484. * @param name defines the block name
  70485. */
  70486. constructor(name: string);
  70487. /**
  70488. * Gets the current class name
  70489. * @returns the class name
  70490. */
  70491. getClassName(): string;
  70492. /**
  70493. * Gets the xy component
  70494. */
  70495. get xy(): NodeMaterialConnectionPoint;
  70496. /**
  70497. * Gets the x component
  70498. */
  70499. get x(): NodeMaterialConnectionPoint;
  70500. /**
  70501. * Gets the y component
  70502. */
  70503. get y(): NodeMaterialConnectionPoint;
  70504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70505. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  70506. protected _buildBlock(state: NodeMaterialBuildState): this;
  70507. }
  70508. }
  70509. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  70510. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  70511. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  70512. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  70513. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  70514. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  70515. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  70516. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  70517. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  70518. }
  70519. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  70520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70522. import { Mesh } from "babylonjs/Meshes/mesh";
  70523. import { Effect } from "babylonjs/Materials/effect";
  70524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70527. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  70528. /**
  70529. * Block used to add support for scene fog
  70530. */
  70531. export class FogBlock extends NodeMaterialBlock {
  70532. private _fogDistanceName;
  70533. private _fogParameters;
  70534. /**
  70535. * Create a new FogBlock
  70536. * @param name defines the block name
  70537. */
  70538. constructor(name: string);
  70539. /**
  70540. * Gets the current class name
  70541. * @returns the class name
  70542. */
  70543. getClassName(): string;
  70544. /**
  70545. * Gets the world position input component
  70546. */
  70547. get worldPosition(): NodeMaterialConnectionPoint;
  70548. /**
  70549. * Gets the view input component
  70550. */
  70551. get view(): NodeMaterialConnectionPoint;
  70552. /**
  70553. * Gets the color input component
  70554. */
  70555. get input(): NodeMaterialConnectionPoint;
  70556. /**
  70557. * Gets the fog color input component
  70558. */
  70559. get fogColor(): NodeMaterialConnectionPoint;
  70560. /**
  70561. * Gets the output component
  70562. */
  70563. get output(): NodeMaterialConnectionPoint;
  70564. autoConfigure(material: NodeMaterial): void;
  70565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70567. protected _buildBlock(state: NodeMaterialBuildState): this;
  70568. }
  70569. }
  70570. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  70571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70575. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70576. import { Effect } from "babylonjs/Materials/effect";
  70577. import { Mesh } from "babylonjs/Meshes/mesh";
  70578. import { Light } from "babylonjs/Lights/light";
  70579. import { Nullable } from "babylonjs/types";
  70580. import { Scene } from "babylonjs/scene";
  70581. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  70582. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  70583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  70584. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  70585. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  70586. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70587. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  70588. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  70589. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  70590. /**
  70591. * Block used to add light in the fragment shader
  70592. */
  70593. export class LightBlock extends NodeMaterialBlock {
  70594. private _lightId;
  70595. /**
  70596. * Gets or sets the light associated with this block
  70597. */
  70598. light: Nullable<Light>;
  70599. /**
  70600. * Create a new LightBlock
  70601. * @param name defines the block name
  70602. */
  70603. constructor(name: string);
  70604. /**
  70605. * Gets the current class name
  70606. * @returns the class name
  70607. */
  70608. getClassName(): string;
  70609. /**
  70610. * Gets the world position input component
  70611. */
  70612. get worldPosition(): NodeMaterialConnectionPoint;
  70613. /**
  70614. * Gets the world normal input component
  70615. */
  70616. get worldNormal(): NodeMaterialConnectionPoint;
  70617. /**
  70618. * Gets the camera (or eye) position component
  70619. */
  70620. get cameraPosition(): NodeMaterialConnectionPoint;
  70621. /**
  70622. * Gets the glossiness component
  70623. */
  70624. get glossiness(): NodeMaterialConnectionPoint;
  70625. /**
  70626. * Gets the glossinness power component
  70627. */
  70628. get glossPower(): NodeMaterialConnectionPoint;
  70629. /**
  70630. * Gets the diffuse color component
  70631. */
  70632. get diffuseColor(): NodeMaterialConnectionPoint;
  70633. /**
  70634. * Gets the specular color component
  70635. */
  70636. get specularColor(): NodeMaterialConnectionPoint;
  70637. /**
  70638. * Gets the view matrix component
  70639. */
  70640. get view(): NodeMaterialConnectionPoint;
  70641. /**
  70642. * Gets the diffuse output component
  70643. */
  70644. get diffuseOutput(): NodeMaterialConnectionPoint;
  70645. /**
  70646. * Gets the specular output component
  70647. */
  70648. get specularOutput(): NodeMaterialConnectionPoint;
  70649. /**
  70650. * Gets the shadow output component
  70651. */
  70652. get shadow(): NodeMaterialConnectionPoint;
  70653. autoConfigure(material: NodeMaterial): void;
  70654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70655. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70656. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70657. private _injectVertexCode;
  70658. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70659. serialize(): any;
  70660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70661. }
  70662. }
  70663. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  70664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70666. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70667. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  70668. /**
  70669. * Block used to read a reflection texture from a sampler
  70670. */
  70671. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  70672. /**
  70673. * Create a new ReflectionTextureBlock
  70674. * @param name defines the block name
  70675. */
  70676. constructor(name: string);
  70677. /**
  70678. * Gets the current class name
  70679. * @returns the class name
  70680. */
  70681. getClassName(): string;
  70682. /**
  70683. * Gets the world position input component
  70684. */
  70685. get position(): NodeMaterialConnectionPoint;
  70686. /**
  70687. * Gets the world position input component
  70688. */
  70689. get worldPosition(): NodeMaterialConnectionPoint;
  70690. /**
  70691. * Gets the world normal input component
  70692. */
  70693. get worldNormal(): NodeMaterialConnectionPoint;
  70694. /**
  70695. * Gets the world input component
  70696. */
  70697. get world(): NodeMaterialConnectionPoint;
  70698. /**
  70699. * Gets the camera (or eye) position component
  70700. */
  70701. get cameraPosition(): NodeMaterialConnectionPoint;
  70702. /**
  70703. * Gets the view input component
  70704. */
  70705. get view(): NodeMaterialConnectionPoint;
  70706. /**
  70707. * Gets the rgb output component
  70708. */
  70709. get rgb(): NodeMaterialConnectionPoint;
  70710. /**
  70711. * Gets the rgba output component
  70712. */
  70713. get rgba(): NodeMaterialConnectionPoint;
  70714. /**
  70715. * Gets the r output component
  70716. */
  70717. get r(): NodeMaterialConnectionPoint;
  70718. /**
  70719. * Gets the g output component
  70720. */
  70721. get g(): NodeMaterialConnectionPoint;
  70722. /**
  70723. * Gets the b output component
  70724. */
  70725. get b(): NodeMaterialConnectionPoint;
  70726. /**
  70727. * Gets the a output component
  70728. */
  70729. get a(): NodeMaterialConnectionPoint;
  70730. autoConfigure(material: NodeMaterial): void;
  70731. protected _buildBlock(state: NodeMaterialBuildState): this;
  70732. }
  70733. }
  70734. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  70735. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  70736. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  70737. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  70738. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  70739. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  70740. }
  70741. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  70742. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  70743. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  70744. }
  70745. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  70746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70749. /**
  70750. * Block used to add 2 vectors
  70751. */
  70752. export class AddBlock extends NodeMaterialBlock {
  70753. /**
  70754. * Creates a new AddBlock
  70755. * @param name defines the block name
  70756. */
  70757. constructor(name: string);
  70758. /**
  70759. * Gets the current class name
  70760. * @returns the class name
  70761. */
  70762. getClassName(): string;
  70763. /**
  70764. * Gets the left operand input component
  70765. */
  70766. get left(): NodeMaterialConnectionPoint;
  70767. /**
  70768. * Gets the right operand input component
  70769. */
  70770. get right(): NodeMaterialConnectionPoint;
  70771. /**
  70772. * Gets the output component
  70773. */
  70774. get output(): NodeMaterialConnectionPoint;
  70775. protected _buildBlock(state: NodeMaterialBuildState): this;
  70776. }
  70777. }
  70778. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  70779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70782. /**
  70783. * Block used to scale a vector by a float
  70784. */
  70785. export class ScaleBlock extends NodeMaterialBlock {
  70786. /**
  70787. * Creates a new ScaleBlock
  70788. * @param name defines the block name
  70789. */
  70790. constructor(name: string);
  70791. /**
  70792. * Gets the current class name
  70793. * @returns the class name
  70794. */
  70795. getClassName(): string;
  70796. /**
  70797. * Gets the input component
  70798. */
  70799. get input(): NodeMaterialConnectionPoint;
  70800. /**
  70801. * Gets the factor input component
  70802. */
  70803. get factor(): NodeMaterialConnectionPoint;
  70804. /**
  70805. * Gets the output component
  70806. */
  70807. get output(): NodeMaterialConnectionPoint;
  70808. protected _buildBlock(state: NodeMaterialBuildState): this;
  70809. }
  70810. }
  70811. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  70812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70815. import { Scene } from "babylonjs/scene";
  70816. /**
  70817. * Block used to clamp a float
  70818. */
  70819. export class ClampBlock extends NodeMaterialBlock {
  70820. /** Gets or sets the minimum range */
  70821. minimum: number;
  70822. /** Gets or sets the maximum range */
  70823. maximum: number;
  70824. /**
  70825. * Creates a new ClampBlock
  70826. * @param name defines the block name
  70827. */
  70828. constructor(name: string);
  70829. /**
  70830. * Gets the current class name
  70831. * @returns the class name
  70832. */
  70833. getClassName(): string;
  70834. /**
  70835. * Gets the value input component
  70836. */
  70837. get value(): NodeMaterialConnectionPoint;
  70838. /**
  70839. * Gets the output component
  70840. */
  70841. get output(): NodeMaterialConnectionPoint;
  70842. protected _buildBlock(state: NodeMaterialBuildState): this;
  70843. protected _dumpPropertiesCode(): string;
  70844. serialize(): any;
  70845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70846. }
  70847. }
  70848. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  70849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70852. /**
  70853. * Block used to apply a cross product between 2 vectors
  70854. */
  70855. export class CrossBlock extends NodeMaterialBlock {
  70856. /**
  70857. * Creates a new CrossBlock
  70858. * @param name defines the block name
  70859. */
  70860. constructor(name: string);
  70861. /**
  70862. * Gets the current class name
  70863. * @returns the class name
  70864. */
  70865. getClassName(): string;
  70866. /**
  70867. * Gets the left operand input component
  70868. */
  70869. get left(): NodeMaterialConnectionPoint;
  70870. /**
  70871. * Gets the right operand input component
  70872. */
  70873. get right(): NodeMaterialConnectionPoint;
  70874. /**
  70875. * Gets the output component
  70876. */
  70877. get output(): NodeMaterialConnectionPoint;
  70878. protected _buildBlock(state: NodeMaterialBuildState): this;
  70879. }
  70880. }
  70881. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  70882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70885. /**
  70886. * Block used to apply a dot product between 2 vectors
  70887. */
  70888. export class DotBlock extends NodeMaterialBlock {
  70889. /**
  70890. * Creates a new DotBlock
  70891. * @param name defines the block name
  70892. */
  70893. constructor(name: string);
  70894. /**
  70895. * Gets the current class name
  70896. * @returns the class name
  70897. */
  70898. getClassName(): string;
  70899. /**
  70900. * Gets the left operand input component
  70901. */
  70902. get left(): NodeMaterialConnectionPoint;
  70903. /**
  70904. * Gets the right operand input component
  70905. */
  70906. get right(): NodeMaterialConnectionPoint;
  70907. /**
  70908. * Gets the output component
  70909. */
  70910. get output(): NodeMaterialConnectionPoint;
  70911. protected _buildBlock(state: NodeMaterialBuildState): this;
  70912. }
  70913. }
  70914. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  70915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70918. /**
  70919. * Block used to normalize a vector
  70920. */
  70921. export class NormalizeBlock extends NodeMaterialBlock {
  70922. /**
  70923. * Creates a new NormalizeBlock
  70924. * @param name defines the block name
  70925. */
  70926. constructor(name: string);
  70927. /**
  70928. * Gets the current class name
  70929. * @returns the class name
  70930. */
  70931. getClassName(): string;
  70932. /**
  70933. * Gets the input component
  70934. */
  70935. get input(): NodeMaterialConnectionPoint;
  70936. /**
  70937. * Gets the output component
  70938. */
  70939. get output(): NodeMaterialConnectionPoint;
  70940. protected _buildBlock(state: NodeMaterialBuildState): this;
  70941. }
  70942. }
  70943. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  70944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70947. /**
  70948. * Block used to create a Color3/4 out of individual inputs (one for each component)
  70949. */
  70950. export class ColorMergerBlock extends NodeMaterialBlock {
  70951. /**
  70952. * Create a new ColorMergerBlock
  70953. * @param name defines the block name
  70954. */
  70955. constructor(name: string);
  70956. /**
  70957. * Gets the current class name
  70958. * @returns the class name
  70959. */
  70960. getClassName(): string;
  70961. /**
  70962. * Gets the rgb component (input)
  70963. */
  70964. get rgbIn(): NodeMaterialConnectionPoint;
  70965. /**
  70966. * Gets the r component (input)
  70967. */
  70968. get r(): NodeMaterialConnectionPoint;
  70969. /**
  70970. * Gets the g component (input)
  70971. */
  70972. get g(): NodeMaterialConnectionPoint;
  70973. /**
  70974. * Gets the b component (input)
  70975. */
  70976. get b(): NodeMaterialConnectionPoint;
  70977. /**
  70978. * Gets the a component (input)
  70979. */
  70980. get a(): NodeMaterialConnectionPoint;
  70981. /**
  70982. * Gets the rgba component (output)
  70983. */
  70984. get rgba(): NodeMaterialConnectionPoint;
  70985. /**
  70986. * Gets the rgb component (output)
  70987. */
  70988. get rgbOut(): NodeMaterialConnectionPoint;
  70989. /**
  70990. * Gets the rgb component (output)
  70991. * @deprecated Please use rgbOut instead.
  70992. */
  70993. get rgb(): NodeMaterialConnectionPoint;
  70994. protected _buildBlock(state: NodeMaterialBuildState): this;
  70995. }
  70996. }
  70997. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  70998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71001. /**
  71002. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  71003. */
  71004. export class VectorSplitterBlock extends NodeMaterialBlock {
  71005. /**
  71006. * Create a new VectorSplitterBlock
  71007. * @param name defines the block name
  71008. */
  71009. constructor(name: string);
  71010. /**
  71011. * Gets the current class name
  71012. * @returns the class name
  71013. */
  71014. getClassName(): string;
  71015. /**
  71016. * Gets the xyzw component (input)
  71017. */
  71018. get xyzw(): NodeMaterialConnectionPoint;
  71019. /**
  71020. * Gets the xyz component (input)
  71021. */
  71022. get xyzIn(): NodeMaterialConnectionPoint;
  71023. /**
  71024. * Gets the xy component (input)
  71025. */
  71026. get xyIn(): NodeMaterialConnectionPoint;
  71027. /**
  71028. * Gets the xyz component (output)
  71029. */
  71030. get xyzOut(): NodeMaterialConnectionPoint;
  71031. /**
  71032. * Gets the xy component (output)
  71033. */
  71034. get xyOut(): NodeMaterialConnectionPoint;
  71035. /**
  71036. * Gets the x component (output)
  71037. */
  71038. get x(): NodeMaterialConnectionPoint;
  71039. /**
  71040. * Gets the y component (output)
  71041. */
  71042. get y(): NodeMaterialConnectionPoint;
  71043. /**
  71044. * Gets the z component (output)
  71045. */
  71046. get z(): NodeMaterialConnectionPoint;
  71047. /**
  71048. * Gets the w component (output)
  71049. */
  71050. get w(): NodeMaterialConnectionPoint;
  71051. protected _inputRename(name: string): string;
  71052. protected _outputRename(name: string): string;
  71053. protected _buildBlock(state: NodeMaterialBuildState): this;
  71054. }
  71055. }
  71056. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  71057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71060. /**
  71061. * Block used to lerp between 2 values
  71062. */
  71063. export class LerpBlock extends NodeMaterialBlock {
  71064. /**
  71065. * Creates a new LerpBlock
  71066. * @param name defines the block name
  71067. */
  71068. constructor(name: string);
  71069. /**
  71070. * Gets the current class name
  71071. * @returns the class name
  71072. */
  71073. getClassName(): string;
  71074. /**
  71075. * Gets the left operand input component
  71076. */
  71077. get left(): NodeMaterialConnectionPoint;
  71078. /**
  71079. * Gets the right operand input component
  71080. */
  71081. get right(): NodeMaterialConnectionPoint;
  71082. /**
  71083. * Gets the gradient operand input component
  71084. */
  71085. get gradient(): NodeMaterialConnectionPoint;
  71086. /**
  71087. * Gets the output component
  71088. */
  71089. get output(): NodeMaterialConnectionPoint;
  71090. protected _buildBlock(state: NodeMaterialBuildState): this;
  71091. }
  71092. }
  71093. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  71094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71097. /**
  71098. * Block used to divide 2 vectors
  71099. */
  71100. export class DivideBlock extends NodeMaterialBlock {
  71101. /**
  71102. * Creates a new DivideBlock
  71103. * @param name defines the block name
  71104. */
  71105. constructor(name: string);
  71106. /**
  71107. * Gets the current class name
  71108. * @returns the class name
  71109. */
  71110. getClassName(): string;
  71111. /**
  71112. * Gets the left operand input component
  71113. */
  71114. get left(): NodeMaterialConnectionPoint;
  71115. /**
  71116. * Gets the right operand input component
  71117. */
  71118. get right(): NodeMaterialConnectionPoint;
  71119. /**
  71120. * Gets the output component
  71121. */
  71122. get output(): NodeMaterialConnectionPoint;
  71123. protected _buildBlock(state: NodeMaterialBuildState): this;
  71124. }
  71125. }
  71126. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  71127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71130. /**
  71131. * Block used to subtract 2 vectors
  71132. */
  71133. export class SubtractBlock extends NodeMaterialBlock {
  71134. /**
  71135. * Creates a new SubtractBlock
  71136. * @param name defines the block name
  71137. */
  71138. constructor(name: string);
  71139. /**
  71140. * Gets the current class name
  71141. * @returns the class name
  71142. */
  71143. getClassName(): string;
  71144. /**
  71145. * Gets the left operand input component
  71146. */
  71147. get left(): NodeMaterialConnectionPoint;
  71148. /**
  71149. * Gets the right operand input component
  71150. */
  71151. get right(): NodeMaterialConnectionPoint;
  71152. /**
  71153. * Gets the output component
  71154. */
  71155. get output(): NodeMaterialConnectionPoint;
  71156. protected _buildBlock(state: NodeMaterialBuildState): this;
  71157. }
  71158. }
  71159. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  71160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71163. /**
  71164. * Block used to step a value
  71165. */
  71166. export class StepBlock extends NodeMaterialBlock {
  71167. /**
  71168. * Creates a new StepBlock
  71169. * @param name defines the block name
  71170. */
  71171. constructor(name: string);
  71172. /**
  71173. * Gets the current class name
  71174. * @returns the class name
  71175. */
  71176. getClassName(): string;
  71177. /**
  71178. * Gets the value operand input component
  71179. */
  71180. get value(): NodeMaterialConnectionPoint;
  71181. /**
  71182. * Gets the edge operand input component
  71183. */
  71184. get edge(): NodeMaterialConnectionPoint;
  71185. /**
  71186. * Gets the output component
  71187. */
  71188. get output(): NodeMaterialConnectionPoint;
  71189. protected _buildBlock(state: NodeMaterialBuildState): this;
  71190. }
  71191. }
  71192. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  71193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71196. /**
  71197. * Block used to get the opposite (1 - x) of a value
  71198. */
  71199. export class OneMinusBlock extends NodeMaterialBlock {
  71200. /**
  71201. * Creates a new OneMinusBlock
  71202. * @param name defines the block name
  71203. */
  71204. constructor(name: string);
  71205. /**
  71206. * Gets the current class name
  71207. * @returns the class name
  71208. */
  71209. getClassName(): string;
  71210. /**
  71211. * Gets the input component
  71212. */
  71213. get input(): NodeMaterialConnectionPoint;
  71214. /**
  71215. * Gets the output component
  71216. */
  71217. get output(): NodeMaterialConnectionPoint;
  71218. protected _buildBlock(state: NodeMaterialBuildState): this;
  71219. }
  71220. }
  71221. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  71222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71225. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71226. /**
  71227. * Block used to get the view direction
  71228. */
  71229. export class ViewDirectionBlock extends NodeMaterialBlock {
  71230. /**
  71231. * Creates a new ViewDirectionBlock
  71232. * @param name defines the block name
  71233. */
  71234. constructor(name: string);
  71235. /**
  71236. * Gets the current class name
  71237. * @returns the class name
  71238. */
  71239. getClassName(): string;
  71240. /**
  71241. * Gets the world position component
  71242. */
  71243. get worldPosition(): NodeMaterialConnectionPoint;
  71244. /**
  71245. * Gets the camera position component
  71246. */
  71247. get cameraPosition(): NodeMaterialConnectionPoint;
  71248. /**
  71249. * Gets the output component
  71250. */
  71251. get output(): NodeMaterialConnectionPoint;
  71252. autoConfigure(material: NodeMaterial): void;
  71253. protected _buildBlock(state: NodeMaterialBuildState): this;
  71254. }
  71255. }
  71256. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  71257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71260. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71261. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  71262. /**
  71263. * Block used to compute fresnel value
  71264. */
  71265. export class FresnelBlock extends NodeMaterialBlock {
  71266. /**
  71267. * Create a new FresnelBlock
  71268. * @param name defines the block name
  71269. */
  71270. constructor(name: string);
  71271. /**
  71272. * Gets the current class name
  71273. * @returns the class name
  71274. */
  71275. getClassName(): string;
  71276. /**
  71277. * Gets the world normal input component
  71278. */
  71279. get worldNormal(): NodeMaterialConnectionPoint;
  71280. /**
  71281. * Gets the view direction input component
  71282. */
  71283. get viewDirection(): NodeMaterialConnectionPoint;
  71284. /**
  71285. * Gets the bias input component
  71286. */
  71287. get bias(): NodeMaterialConnectionPoint;
  71288. /**
  71289. * Gets the camera (or eye) position component
  71290. */
  71291. get power(): NodeMaterialConnectionPoint;
  71292. /**
  71293. * Gets the fresnel output component
  71294. */
  71295. get fresnel(): NodeMaterialConnectionPoint;
  71296. autoConfigure(material: NodeMaterial): void;
  71297. protected _buildBlock(state: NodeMaterialBuildState): this;
  71298. }
  71299. }
  71300. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  71301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71304. /**
  71305. * Block used to get the max of 2 values
  71306. */
  71307. export class MaxBlock extends NodeMaterialBlock {
  71308. /**
  71309. * Creates a new MaxBlock
  71310. * @param name defines the block name
  71311. */
  71312. constructor(name: string);
  71313. /**
  71314. * Gets the current class name
  71315. * @returns the class name
  71316. */
  71317. getClassName(): string;
  71318. /**
  71319. * Gets the left operand input component
  71320. */
  71321. get left(): NodeMaterialConnectionPoint;
  71322. /**
  71323. * Gets the right operand input component
  71324. */
  71325. get right(): NodeMaterialConnectionPoint;
  71326. /**
  71327. * Gets the output component
  71328. */
  71329. get output(): NodeMaterialConnectionPoint;
  71330. protected _buildBlock(state: NodeMaterialBuildState): this;
  71331. }
  71332. }
  71333. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  71334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71337. /**
  71338. * Block used to get the min of 2 values
  71339. */
  71340. export class MinBlock extends NodeMaterialBlock {
  71341. /**
  71342. * Creates a new MinBlock
  71343. * @param name defines the block name
  71344. */
  71345. constructor(name: string);
  71346. /**
  71347. * Gets the current class name
  71348. * @returns the class name
  71349. */
  71350. getClassName(): string;
  71351. /**
  71352. * Gets the left operand input component
  71353. */
  71354. get left(): NodeMaterialConnectionPoint;
  71355. /**
  71356. * Gets the right operand input component
  71357. */
  71358. get right(): NodeMaterialConnectionPoint;
  71359. /**
  71360. * Gets the output component
  71361. */
  71362. get output(): NodeMaterialConnectionPoint;
  71363. protected _buildBlock(state: NodeMaterialBuildState): this;
  71364. }
  71365. }
  71366. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  71367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71370. /**
  71371. * Block used to get the distance between 2 values
  71372. */
  71373. export class DistanceBlock extends NodeMaterialBlock {
  71374. /**
  71375. * Creates a new DistanceBlock
  71376. * @param name defines the block name
  71377. */
  71378. constructor(name: string);
  71379. /**
  71380. * Gets the current class name
  71381. * @returns the class name
  71382. */
  71383. getClassName(): string;
  71384. /**
  71385. * Gets the left operand input component
  71386. */
  71387. get left(): NodeMaterialConnectionPoint;
  71388. /**
  71389. * Gets the right operand input component
  71390. */
  71391. get right(): NodeMaterialConnectionPoint;
  71392. /**
  71393. * Gets the output component
  71394. */
  71395. get output(): NodeMaterialConnectionPoint;
  71396. protected _buildBlock(state: NodeMaterialBuildState): this;
  71397. }
  71398. }
  71399. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  71400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71403. /**
  71404. * Block used to get the length of a vector
  71405. */
  71406. export class LengthBlock extends NodeMaterialBlock {
  71407. /**
  71408. * Creates a new LengthBlock
  71409. * @param name defines the block name
  71410. */
  71411. constructor(name: string);
  71412. /**
  71413. * Gets the current class name
  71414. * @returns the class name
  71415. */
  71416. getClassName(): string;
  71417. /**
  71418. * Gets the value input component
  71419. */
  71420. get value(): NodeMaterialConnectionPoint;
  71421. /**
  71422. * Gets the output component
  71423. */
  71424. get output(): NodeMaterialConnectionPoint;
  71425. protected _buildBlock(state: NodeMaterialBuildState): this;
  71426. }
  71427. }
  71428. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  71429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71432. /**
  71433. * Block used to get negative version of a value (i.e. x * -1)
  71434. */
  71435. export class NegateBlock extends NodeMaterialBlock {
  71436. /**
  71437. * Creates a new NegateBlock
  71438. * @param name defines the block name
  71439. */
  71440. constructor(name: string);
  71441. /**
  71442. * Gets the current class name
  71443. * @returns the class name
  71444. */
  71445. getClassName(): string;
  71446. /**
  71447. * Gets the value input component
  71448. */
  71449. get value(): NodeMaterialConnectionPoint;
  71450. /**
  71451. * Gets the output component
  71452. */
  71453. get output(): NodeMaterialConnectionPoint;
  71454. protected _buildBlock(state: NodeMaterialBuildState): this;
  71455. }
  71456. }
  71457. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  71458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71461. /**
  71462. * Block used to get the value of the first parameter raised to the power of the second
  71463. */
  71464. export class PowBlock extends NodeMaterialBlock {
  71465. /**
  71466. * Creates a new PowBlock
  71467. * @param name defines the block name
  71468. */
  71469. constructor(name: string);
  71470. /**
  71471. * Gets the current class name
  71472. * @returns the class name
  71473. */
  71474. getClassName(): string;
  71475. /**
  71476. * Gets the value operand input component
  71477. */
  71478. get value(): NodeMaterialConnectionPoint;
  71479. /**
  71480. * Gets the power operand input component
  71481. */
  71482. get power(): NodeMaterialConnectionPoint;
  71483. /**
  71484. * Gets the output component
  71485. */
  71486. get output(): NodeMaterialConnectionPoint;
  71487. protected _buildBlock(state: NodeMaterialBuildState): this;
  71488. }
  71489. }
  71490. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  71491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71495. /**
  71496. * Block used to get a random number
  71497. */
  71498. export class RandomNumberBlock extends NodeMaterialBlock {
  71499. /**
  71500. * Creates a new RandomNumberBlock
  71501. * @param name defines the block name
  71502. */
  71503. constructor(name: string);
  71504. /**
  71505. * Gets the current class name
  71506. * @returns the class name
  71507. */
  71508. getClassName(): string;
  71509. /**
  71510. * Gets the seed input component
  71511. */
  71512. get seed(): NodeMaterialConnectionPoint;
  71513. /**
  71514. * Gets the output component
  71515. */
  71516. get output(): NodeMaterialConnectionPoint;
  71517. protected _buildBlock(state: NodeMaterialBuildState): this;
  71518. }
  71519. }
  71520. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  71521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71524. /**
  71525. * Block used to compute arc tangent of 2 values
  71526. */
  71527. export class ArcTan2Block extends NodeMaterialBlock {
  71528. /**
  71529. * Creates a new ArcTan2Block
  71530. * @param name defines the block name
  71531. */
  71532. constructor(name: string);
  71533. /**
  71534. * Gets the current class name
  71535. * @returns the class name
  71536. */
  71537. getClassName(): string;
  71538. /**
  71539. * Gets the x operand input component
  71540. */
  71541. get x(): NodeMaterialConnectionPoint;
  71542. /**
  71543. * Gets the y operand input component
  71544. */
  71545. get y(): NodeMaterialConnectionPoint;
  71546. /**
  71547. * Gets the output component
  71548. */
  71549. get output(): NodeMaterialConnectionPoint;
  71550. protected _buildBlock(state: NodeMaterialBuildState): this;
  71551. }
  71552. }
  71553. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  71554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71557. /**
  71558. * Block used to smooth step a value
  71559. */
  71560. export class SmoothStepBlock extends NodeMaterialBlock {
  71561. /**
  71562. * Creates a new SmoothStepBlock
  71563. * @param name defines the block name
  71564. */
  71565. constructor(name: string);
  71566. /**
  71567. * Gets the current class name
  71568. * @returns the class name
  71569. */
  71570. getClassName(): string;
  71571. /**
  71572. * Gets the value operand input component
  71573. */
  71574. get value(): NodeMaterialConnectionPoint;
  71575. /**
  71576. * Gets the first edge operand input component
  71577. */
  71578. get edge0(): NodeMaterialConnectionPoint;
  71579. /**
  71580. * Gets the second edge operand input component
  71581. */
  71582. get edge1(): NodeMaterialConnectionPoint;
  71583. /**
  71584. * Gets the output component
  71585. */
  71586. get output(): NodeMaterialConnectionPoint;
  71587. protected _buildBlock(state: NodeMaterialBuildState): this;
  71588. }
  71589. }
  71590. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  71591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71594. /**
  71595. * Block used to get the reciprocal (1 / x) of a value
  71596. */
  71597. export class ReciprocalBlock extends NodeMaterialBlock {
  71598. /**
  71599. * Creates a new ReciprocalBlock
  71600. * @param name defines the block name
  71601. */
  71602. constructor(name: string);
  71603. /**
  71604. * Gets the current class name
  71605. * @returns the class name
  71606. */
  71607. getClassName(): string;
  71608. /**
  71609. * Gets the input component
  71610. */
  71611. get input(): NodeMaterialConnectionPoint;
  71612. /**
  71613. * Gets the output component
  71614. */
  71615. get output(): NodeMaterialConnectionPoint;
  71616. protected _buildBlock(state: NodeMaterialBuildState): this;
  71617. }
  71618. }
  71619. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  71620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71623. /**
  71624. * Block used to replace a color by another one
  71625. */
  71626. export class ReplaceColorBlock extends NodeMaterialBlock {
  71627. /**
  71628. * Creates a new ReplaceColorBlock
  71629. * @param name defines the block name
  71630. */
  71631. constructor(name: string);
  71632. /**
  71633. * Gets the current class name
  71634. * @returns the class name
  71635. */
  71636. getClassName(): string;
  71637. /**
  71638. * Gets the value input component
  71639. */
  71640. get value(): NodeMaterialConnectionPoint;
  71641. /**
  71642. * Gets the reference input component
  71643. */
  71644. get reference(): NodeMaterialConnectionPoint;
  71645. /**
  71646. * Gets the distance input component
  71647. */
  71648. get distance(): NodeMaterialConnectionPoint;
  71649. /**
  71650. * Gets the replacement input component
  71651. */
  71652. get replacement(): NodeMaterialConnectionPoint;
  71653. /**
  71654. * Gets the output component
  71655. */
  71656. get output(): NodeMaterialConnectionPoint;
  71657. protected _buildBlock(state: NodeMaterialBuildState): this;
  71658. }
  71659. }
  71660. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  71661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71664. /**
  71665. * Block used to posterize a value
  71666. * @see https://en.wikipedia.org/wiki/Posterization
  71667. */
  71668. export class PosterizeBlock extends NodeMaterialBlock {
  71669. /**
  71670. * Creates a new PosterizeBlock
  71671. * @param name defines the block name
  71672. */
  71673. constructor(name: string);
  71674. /**
  71675. * Gets the current class name
  71676. * @returns the class name
  71677. */
  71678. getClassName(): string;
  71679. /**
  71680. * Gets the value input component
  71681. */
  71682. get value(): NodeMaterialConnectionPoint;
  71683. /**
  71684. * Gets the steps input component
  71685. */
  71686. get steps(): NodeMaterialConnectionPoint;
  71687. /**
  71688. * Gets the output component
  71689. */
  71690. get output(): NodeMaterialConnectionPoint;
  71691. protected _buildBlock(state: NodeMaterialBuildState): this;
  71692. }
  71693. }
  71694. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  71695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71698. import { Scene } from "babylonjs/scene";
  71699. /**
  71700. * Operations supported by the Wave block
  71701. */
  71702. export enum WaveBlockKind {
  71703. /** SawTooth */
  71704. SawTooth = 0,
  71705. /** Square */
  71706. Square = 1,
  71707. /** Triangle */
  71708. Triangle = 2
  71709. }
  71710. /**
  71711. * Block used to apply wave operation to floats
  71712. */
  71713. export class WaveBlock extends NodeMaterialBlock {
  71714. /**
  71715. * Gets or sets the kibnd of wave to be applied by the block
  71716. */
  71717. kind: WaveBlockKind;
  71718. /**
  71719. * Creates a new WaveBlock
  71720. * @param name defines the block name
  71721. */
  71722. constructor(name: string);
  71723. /**
  71724. * Gets the current class name
  71725. * @returns the class name
  71726. */
  71727. getClassName(): string;
  71728. /**
  71729. * Gets the input component
  71730. */
  71731. get input(): NodeMaterialConnectionPoint;
  71732. /**
  71733. * Gets the output component
  71734. */
  71735. get output(): NodeMaterialConnectionPoint;
  71736. protected _buildBlock(state: NodeMaterialBuildState): this;
  71737. serialize(): any;
  71738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71739. }
  71740. }
  71741. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  71742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71745. import { Color3 } from "babylonjs/Maths/math.color";
  71746. import { Scene } from "babylonjs/scene";
  71747. import { Observable } from "babylonjs/Misc/observable";
  71748. /**
  71749. * Class used to store a color step for the GradientBlock
  71750. */
  71751. export class GradientBlockColorStep {
  71752. private _step;
  71753. /**
  71754. * Gets value indicating which step this color is associated with (between 0 and 1)
  71755. */
  71756. get step(): number;
  71757. /**
  71758. * Sets a value indicating which step this color is associated with (between 0 and 1)
  71759. */
  71760. set step(val: number);
  71761. private _color;
  71762. /**
  71763. * Gets the color associated with this step
  71764. */
  71765. get color(): Color3;
  71766. /**
  71767. * Sets the color associated with this step
  71768. */
  71769. set color(val: Color3);
  71770. /**
  71771. * Creates a new GradientBlockColorStep
  71772. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  71773. * @param color defines the color associated with this step
  71774. */
  71775. constructor(step: number, color: Color3);
  71776. }
  71777. /**
  71778. * Block used to return a color from a gradient based on an input value between 0 and 1
  71779. */
  71780. export class GradientBlock extends NodeMaterialBlock {
  71781. /**
  71782. * Gets or sets the list of color steps
  71783. */
  71784. colorSteps: GradientBlockColorStep[];
  71785. /** Gets an observable raised when the value is changed */
  71786. onValueChangedObservable: Observable<GradientBlock>;
  71787. /** calls observable when the value is changed*/
  71788. colorStepsUpdated(): void;
  71789. /**
  71790. * Creates a new GradientBlock
  71791. * @param name defines the block name
  71792. */
  71793. constructor(name: string);
  71794. /**
  71795. * Gets the current class name
  71796. * @returns the class name
  71797. */
  71798. getClassName(): string;
  71799. /**
  71800. * Gets the gradient input component
  71801. */
  71802. get gradient(): NodeMaterialConnectionPoint;
  71803. /**
  71804. * Gets the output component
  71805. */
  71806. get output(): NodeMaterialConnectionPoint;
  71807. private _writeColorConstant;
  71808. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71809. serialize(): any;
  71810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71811. protected _dumpPropertiesCode(): string;
  71812. }
  71813. }
  71814. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  71815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71818. /**
  71819. * Block used to normalize lerp between 2 values
  71820. */
  71821. export class NLerpBlock extends NodeMaterialBlock {
  71822. /**
  71823. * Creates a new NLerpBlock
  71824. * @param name defines the block name
  71825. */
  71826. constructor(name: string);
  71827. /**
  71828. * Gets the current class name
  71829. * @returns the class name
  71830. */
  71831. getClassName(): string;
  71832. /**
  71833. * Gets the left operand input component
  71834. */
  71835. get left(): NodeMaterialConnectionPoint;
  71836. /**
  71837. * Gets the right operand input component
  71838. */
  71839. get right(): NodeMaterialConnectionPoint;
  71840. /**
  71841. * Gets the gradient operand input component
  71842. */
  71843. get gradient(): NodeMaterialConnectionPoint;
  71844. /**
  71845. * Gets the output component
  71846. */
  71847. get output(): NodeMaterialConnectionPoint;
  71848. protected _buildBlock(state: NodeMaterialBuildState): this;
  71849. }
  71850. }
  71851. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  71852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71855. import { Scene } from "babylonjs/scene";
  71856. /**
  71857. * block used to Generate a Worley Noise 3D Noise Pattern
  71858. */
  71859. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  71860. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  71861. manhattanDistance: boolean;
  71862. /**
  71863. * Creates a new WorleyNoise3DBlock
  71864. * @param name defines the block name
  71865. */
  71866. constructor(name: string);
  71867. /**
  71868. * Gets the current class name
  71869. * @returns the class name
  71870. */
  71871. getClassName(): string;
  71872. /**
  71873. * Gets the seed input component
  71874. */
  71875. get seed(): NodeMaterialConnectionPoint;
  71876. /**
  71877. * Gets the jitter input component
  71878. */
  71879. get jitter(): NodeMaterialConnectionPoint;
  71880. /**
  71881. * Gets the output component
  71882. */
  71883. get output(): NodeMaterialConnectionPoint;
  71884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71885. /**
  71886. * Exposes the properties to the UI?
  71887. */
  71888. protected _dumpPropertiesCode(): string;
  71889. /**
  71890. * Exposes the properties to the Seralize?
  71891. */
  71892. serialize(): any;
  71893. /**
  71894. * Exposes the properties to the deseralize?
  71895. */
  71896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71897. }
  71898. }
  71899. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  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 Generate a Simplex Perlin 3d Noise Pattern
  71905. */
  71906. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  71907. /**
  71908. * Creates a new SimplexPerlin3DBlock
  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 seed operand input component
  71919. */
  71920. get seed(): NodeMaterialConnectionPoint;
  71921. /**
  71922. * Gets the output component
  71923. */
  71924. get output(): NodeMaterialConnectionPoint;
  71925. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71926. }
  71927. }
  71928. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  71929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71932. /**
  71933. * Block used to blend normals
  71934. */
  71935. export class NormalBlendBlock extends NodeMaterialBlock {
  71936. /**
  71937. * Creates a new NormalBlendBlock
  71938. * @param name defines the block name
  71939. */
  71940. constructor(name: string);
  71941. /**
  71942. * Gets the current class name
  71943. * @returns the class name
  71944. */
  71945. getClassName(): string;
  71946. /**
  71947. * Gets the first input component
  71948. */
  71949. get normalMap0(): NodeMaterialConnectionPoint;
  71950. /**
  71951. * Gets the second input component
  71952. */
  71953. get normalMap1(): NodeMaterialConnectionPoint;
  71954. /**
  71955. * Gets the output component
  71956. */
  71957. get output(): NodeMaterialConnectionPoint;
  71958. protected _buildBlock(state: NodeMaterialBuildState): this;
  71959. }
  71960. }
  71961. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  71962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71965. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71966. /**
  71967. * Block used to rotate a 2d vector by a given angle
  71968. */
  71969. export class Rotate2dBlock extends NodeMaterialBlock {
  71970. /**
  71971. * Creates a new Rotate2dBlock
  71972. * @param name defines the block name
  71973. */
  71974. constructor(name: string);
  71975. /**
  71976. * Gets the current class name
  71977. * @returns the class name
  71978. */
  71979. getClassName(): string;
  71980. /**
  71981. * Gets the input vector
  71982. */
  71983. get input(): NodeMaterialConnectionPoint;
  71984. /**
  71985. * Gets the input angle
  71986. */
  71987. get angle(): NodeMaterialConnectionPoint;
  71988. /**
  71989. * Gets the output component
  71990. */
  71991. get output(): NodeMaterialConnectionPoint;
  71992. autoConfigure(material: NodeMaterial): void;
  71993. protected _buildBlock(state: NodeMaterialBuildState): this;
  71994. }
  71995. }
  71996. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  71997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72000. /**
  72001. * Block used to get the reflected vector from a direction and a normal
  72002. */
  72003. export class ReflectBlock extends NodeMaterialBlock {
  72004. /**
  72005. * Creates a new ReflectBlock
  72006. * @param name defines the block name
  72007. */
  72008. constructor(name: string);
  72009. /**
  72010. * Gets the current class name
  72011. * @returns the class name
  72012. */
  72013. getClassName(): string;
  72014. /**
  72015. * Gets the incident component
  72016. */
  72017. get incident(): NodeMaterialConnectionPoint;
  72018. /**
  72019. * Gets the normal component
  72020. */
  72021. get normal(): NodeMaterialConnectionPoint;
  72022. /**
  72023. * Gets the output component
  72024. */
  72025. get output(): NodeMaterialConnectionPoint;
  72026. protected _buildBlock(state: NodeMaterialBuildState): this;
  72027. }
  72028. }
  72029. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  72030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72033. /**
  72034. * Block used to get the refracted vector from a direction and a normal
  72035. */
  72036. export class RefractBlock extends NodeMaterialBlock {
  72037. /**
  72038. * Creates a new RefractBlock
  72039. * @param name defines the block name
  72040. */
  72041. constructor(name: string);
  72042. /**
  72043. * Gets the current class name
  72044. * @returns the class name
  72045. */
  72046. getClassName(): string;
  72047. /**
  72048. * Gets the incident component
  72049. */
  72050. get incident(): NodeMaterialConnectionPoint;
  72051. /**
  72052. * Gets the normal component
  72053. */
  72054. get normal(): NodeMaterialConnectionPoint;
  72055. /**
  72056. * Gets the index of refraction component
  72057. */
  72058. get ior(): NodeMaterialConnectionPoint;
  72059. /**
  72060. * Gets the output component
  72061. */
  72062. get output(): NodeMaterialConnectionPoint;
  72063. protected _buildBlock(state: NodeMaterialBuildState): this;
  72064. }
  72065. }
  72066. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  72067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72070. /**
  72071. * Block used to desaturate a color
  72072. */
  72073. export class DesaturateBlock extends NodeMaterialBlock {
  72074. /**
  72075. * Creates a new DesaturateBlock
  72076. * @param name defines the block name
  72077. */
  72078. constructor(name: string);
  72079. /**
  72080. * Gets the current class name
  72081. * @returns the class name
  72082. */
  72083. getClassName(): string;
  72084. /**
  72085. * Gets the color operand input component
  72086. */
  72087. get color(): NodeMaterialConnectionPoint;
  72088. /**
  72089. * Gets the level operand input component
  72090. */
  72091. get level(): NodeMaterialConnectionPoint;
  72092. /**
  72093. * Gets the output component
  72094. */
  72095. get output(): NodeMaterialConnectionPoint;
  72096. protected _buildBlock(state: NodeMaterialBuildState): this;
  72097. }
  72098. }
  72099. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  72100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72102. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72103. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  72104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72105. import { Nullable } from "babylonjs/types";
  72106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72107. import { Mesh } from "babylonjs/Meshes/mesh";
  72108. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72109. import { Effect } from "babylonjs/Materials/effect";
  72110. import { Scene } from "babylonjs/scene";
  72111. /**
  72112. * Block used to implement the reflection module of the PBR material
  72113. */
  72114. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  72115. /** @hidden */
  72116. _defineLODReflectionAlpha: string;
  72117. /** @hidden */
  72118. _defineLinearSpecularReflection: string;
  72119. private _vEnvironmentIrradianceName;
  72120. /** @hidden */
  72121. _vReflectionMicrosurfaceInfosName: string;
  72122. /** @hidden */
  72123. _vReflectionInfosName: string;
  72124. /** @hidden */
  72125. _vReflectionFilteringInfoName: string;
  72126. private _scene;
  72127. /**
  72128. * The properties below are set by the main PBR block prior to calling methods of this class.
  72129. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72130. * It's less burden on the user side in the editor part.
  72131. */
  72132. /** @hidden */
  72133. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72134. /** @hidden */
  72135. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72136. /** @hidden */
  72137. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  72138. /** @hidden */
  72139. viewConnectionPoint: NodeMaterialConnectionPoint;
  72140. /**
  72141. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  72142. * diffuse part of the IBL.
  72143. */
  72144. useSphericalHarmonics: boolean;
  72145. /**
  72146. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  72147. */
  72148. forceIrradianceInFragment: boolean;
  72149. /**
  72150. * Create a new ReflectionBlock
  72151. * @param name defines the block name
  72152. */
  72153. constructor(name: string);
  72154. /**
  72155. * Gets the current class name
  72156. * @returns the class name
  72157. */
  72158. getClassName(): string;
  72159. /**
  72160. * Gets the position input component
  72161. */
  72162. get position(): NodeMaterialConnectionPoint;
  72163. /**
  72164. * Gets the world position input component
  72165. */
  72166. get worldPosition(): NodeMaterialConnectionPoint;
  72167. /**
  72168. * Gets the world normal input component
  72169. */
  72170. get worldNormal(): NodeMaterialConnectionPoint;
  72171. /**
  72172. * Gets the world input component
  72173. */
  72174. get world(): NodeMaterialConnectionPoint;
  72175. /**
  72176. * Gets the camera (or eye) position component
  72177. */
  72178. get cameraPosition(): NodeMaterialConnectionPoint;
  72179. /**
  72180. * Gets the view input component
  72181. */
  72182. get view(): NodeMaterialConnectionPoint;
  72183. /**
  72184. * Gets the color input component
  72185. */
  72186. get color(): NodeMaterialConnectionPoint;
  72187. /**
  72188. * Gets the reflection object output component
  72189. */
  72190. get reflection(): NodeMaterialConnectionPoint;
  72191. /**
  72192. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  72193. */
  72194. get hasTexture(): boolean;
  72195. /**
  72196. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  72197. */
  72198. get reflectionColor(): string;
  72199. protected _getTexture(): Nullable<BaseTexture>;
  72200. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72201. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72202. /**
  72203. * Gets the code to inject in the vertex shader
  72204. * @param state current state of the node material building
  72205. * @returns the shader code
  72206. */
  72207. handleVertexSide(state: NodeMaterialBuildState): string;
  72208. /**
  72209. * Gets the main code of the block (fragment side)
  72210. * @param state current state of the node material building
  72211. * @param normalVarName name of the existing variable corresponding to the normal
  72212. * @returns the shader code
  72213. */
  72214. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  72215. protected _buildBlock(state: NodeMaterialBuildState): this;
  72216. protected _dumpPropertiesCode(): string;
  72217. serialize(): any;
  72218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72219. }
  72220. }
  72221. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  72222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72227. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72228. import { Scene } from "babylonjs/scene";
  72229. import { Nullable } from "babylonjs/types";
  72230. /**
  72231. * Block used to implement the sheen module of the PBR material
  72232. */
  72233. export class SheenBlock extends NodeMaterialBlock {
  72234. /**
  72235. * Create a new SheenBlock
  72236. * @param name defines the block name
  72237. */
  72238. constructor(name: string);
  72239. /**
  72240. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  72241. * It allows the strength of the sheen effect to not depend on the base color of the material,
  72242. * making it easier to setup and tweak the effect
  72243. */
  72244. albedoScaling: boolean;
  72245. /**
  72246. * Defines if the sheen is linked to the sheen color.
  72247. */
  72248. linkSheenWithAlbedo: boolean;
  72249. /**
  72250. * Initialize the block and prepare the context for build
  72251. * @param state defines the state that will be used for the build
  72252. */
  72253. initialize(state: NodeMaterialBuildState): void;
  72254. /**
  72255. * Gets the current class name
  72256. * @returns the class name
  72257. */
  72258. getClassName(): string;
  72259. /**
  72260. * Gets the intensity input component
  72261. */
  72262. get intensity(): NodeMaterialConnectionPoint;
  72263. /**
  72264. * Gets the color input component
  72265. */
  72266. get color(): NodeMaterialConnectionPoint;
  72267. /**
  72268. * Gets the roughness input component
  72269. */
  72270. get roughness(): NodeMaterialConnectionPoint;
  72271. /**
  72272. * Gets the sheen object output component
  72273. */
  72274. get sheen(): NodeMaterialConnectionPoint;
  72275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72276. /**
  72277. * Gets the main code of the block (fragment side)
  72278. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72279. * @returns the shader code
  72280. */
  72281. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  72282. protected _buildBlock(state: NodeMaterialBuildState): this;
  72283. protected _dumpPropertiesCode(): string;
  72284. serialize(): any;
  72285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72286. }
  72287. }
  72288. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  72289. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72294. /**
  72295. * Block used to implement the anisotropy module of the PBR material
  72296. */
  72297. export class AnisotropyBlock extends NodeMaterialBlock {
  72298. /**
  72299. * The two properties below are set by the main PBR block prior to calling methods of this class.
  72300. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72301. * It's less burden on the user side in the editor part.
  72302. */
  72303. /** @hidden */
  72304. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72305. /** @hidden */
  72306. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72307. /**
  72308. * Create a new AnisotropyBlock
  72309. * @param name defines the block name
  72310. */
  72311. constructor(name: string);
  72312. /**
  72313. * Initialize the block and prepare the context for build
  72314. * @param state defines the state that will be used for the build
  72315. */
  72316. initialize(state: NodeMaterialBuildState): void;
  72317. /**
  72318. * Gets the current class name
  72319. * @returns the class name
  72320. */
  72321. getClassName(): string;
  72322. /**
  72323. * Gets the intensity input component
  72324. */
  72325. get intensity(): NodeMaterialConnectionPoint;
  72326. /**
  72327. * Gets the direction input component
  72328. */
  72329. get direction(): NodeMaterialConnectionPoint;
  72330. /**
  72331. * Gets the uv input component
  72332. */
  72333. get uv(): NodeMaterialConnectionPoint;
  72334. /**
  72335. * Gets the worldTangent input component
  72336. */
  72337. get worldTangent(): NodeMaterialConnectionPoint;
  72338. /**
  72339. * Gets the anisotropy object output component
  72340. */
  72341. get anisotropy(): NodeMaterialConnectionPoint;
  72342. private _generateTBNSpace;
  72343. /**
  72344. * Gets the main code of the block (fragment side)
  72345. * @param state current state of the node material building
  72346. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72347. * @returns the shader code
  72348. */
  72349. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  72350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72351. protected _buildBlock(state: NodeMaterialBuildState): this;
  72352. }
  72353. }
  72354. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  72355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72358. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72360. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72361. import { Scene } from "babylonjs/scene";
  72362. import { Nullable } from "babylonjs/types";
  72363. import { Mesh } from "babylonjs/Meshes/mesh";
  72364. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72365. import { Effect } from "babylonjs/Materials/effect";
  72366. /**
  72367. * Block used to implement the clear coat module of the PBR material
  72368. */
  72369. export class ClearCoatBlock extends NodeMaterialBlock {
  72370. private _scene;
  72371. /**
  72372. * Create a new ClearCoatBlock
  72373. * @param name defines the block name
  72374. */
  72375. constructor(name: string);
  72376. /**
  72377. * Defines if the F0 value should be remapped to account for the interface change in the material.
  72378. */
  72379. remapF0OnInterfaceChange: boolean;
  72380. /**
  72381. * Initialize the block and prepare the context for build
  72382. * @param state defines the state that will be used for the build
  72383. */
  72384. initialize(state: NodeMaterialBuildState): void;
  72385. /**
  72386. * Gets the current class name
  72387. * @returns the class name
  72388. */
  72389. getClassName(): string;
  72390. /**
  72391. * Gets the intensity input component
  72392. */
  72393. get intensity(): NodeMaterialConnectionPoint;
  72394. /**
  72395. * Gets the roughness input component
  72396. */
  72397. get roughness(): NodeMaterialConnectionPoint;
  72398. /**
  72399. * Gets the ior input component
  72400. */
  72401. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72402. /**
  72403. * Gets the bump texture input component
  72404. */
  72405. get normalMapColor(): NodeMaterialConnectionPoint;
  72406. /**
  72407. * Gets the uv input component
  72408. */
  72409. get uv(): NodeMaterialConnectionPoint;
  72410. /**
  72411. * Gets the tint color input component
  72412. */
  72413. get tintColor(): NodeMaterialConnectionPoint;
  72414. /**
  72415. * Gets the tint "at distance" input component
  72416. */
  72417. get tintAtDistance(): NodeMaterialConnectionPoint;
  72418. /**
  72419. * Gets the tint thickness input component
  72420. */
  72421. get tintThickness(): NodeMaterialConnectionPoint;
  72422. /**
  72423. * Gets the world tangent input component
  72424. */
  72425. get worldTangent(): NodeMaterialConnectionPoint;
  72426. /**
  72427. * Gets the clear coat object output component
  72428. */
  72429. get clearcoat(): NodeMaterialConnectionPoint;
  72430. autoConfigure(material: NodeMaterial): void;
  72431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72433. private _generateTBNSpace;
  72434. /**
  72435. * Gets the main code of the block (fragment side)
  72436. * @param state current state of the node material building
  72437. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  72438. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72439. * @param worldPosVarName name of the variable holding the world position
  72440. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72441. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  72442. * @param worldNormalVarName name of the variable holding the world normal
  72443. * @returns the shader code
  72444. */
  72445. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  72446. protected _buildBlock(state: NodeMaterialBuildState): this;
  72447. protected _dumpPropertiesCode(): string;
  72448. serialize(): any;
  72449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72450. }
  72451. }
  72452. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  72453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72456. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72458. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72459. import { Nullable } from "babylonjs/types";
  72460. /**
  72461. * Block used to implement the sub surface module of the PBR material
  72462. */
  72463. export class SubSurfaceBlock extends NodeMaterialBlock {
  72464. /**
  72465. * Create a new SubSurfaceBlock
  72466. * @param name defines the block name
  72467. */
  72468. constructor(name: string);
  72469. /**
  72470. * Initialize the block and prepare the context for build
  72471. * @param state defines the state that will be used for the build
  72472. */
  72473. initialize(state: NodeMaterialBuildState): void;
  72474. /**
  72475. * Gets the current class name
  72476. * @returns the class name
  72477. */
  72478. getClassName(): string;
  72479. /**
  72480. * Gets the thickness component
  72481. */
  72482. get thickness(): NodeMaterialConnectionPoint;
  72483. /**
  72484. * Gets the tint color input component
  72485. */
  72486. get tintColor(): NodeMaterialConnectionPoint;
  72487. /**
  72488. * Gets the translucency intensity input component
  72489. */
  72490. get translucencyIntensity(): NodeMaterialConnectionPoint;
  72491. /**
  72492. * Gets the translucency diffusion distance input component
  72493. */
  72494. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  72495. /**
  72496. * Gets the refraction object parameters
  72497. */
  72498. get refraction(): NodeMaterialConnectionPoint;
  72499. /**
  72500. * Gets the sub surface object output component
  72501. */
  72502. get subsurface(): NodeMaterialConnectionPoint;
  72503. autoConfigure(material: NodeMaterial): void;
  72504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72505. /**
  72506. * Gets the main code of the block (fragment side)
  72507. * @param state current state of the node material building
  72508. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  72509. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72510. * @param worldPosVarName name of the variable holding the world position
  72511. * @returns the shader code
  72512. */
  72513. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  72514. protected _buildBlock(state: NodeMaterialBuildState): this;
  72515. }
  72516. }
  72517. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  72518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72521. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72522. import { Light } from "babylonjs/Lights/light";
  72523. import { Nullable } from "babylonjs/types";
  72524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72525. import { Effect } from "babylonjs/Materials/effect";
  72526. import { Mesh } from "babylonjs/Meshes/mesh";
  72527. import { Scene } from "babylonjs/scene";
  72528. /**
  72529. * Block used to implement the PBR metallic/roughness model
  72530. */
  72531. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  72532. /**
  72533. * Gets or sets the light associated with this block
  72534. */
  72535. light: Nullable<Light>;
  72536. private _lightId;
  72537. private _scene;
  72538. private _environmentBRDFTexture;
  72539. private _environmentBrdfSamplerName;
  72540. private _vNormalWName;
  72541. private _invertNormalName;
  72542. private _metallicReflectanceColor;
  72543. private _metallicF0Factor;
  72544. private _vMetallicReflectanceFactorsName;
  72545. /**
  72546. * Create a new ReflectionBlock
  72547. * @param name defines the block name
  72548. */
  72549. constructor(name: string);
  72550. /**
  72551. * Intensity of the direct lights e.g. the four lights available in your scene.
  72552. * This impacts both the direct diffuse and specular highlights.
  72553. */
  72554. directIntensity: number;
  72555. /**
  72556. * Intensity of the environment e.g. how much the environment will light the object
  72557. * either through harmonics for rough material or through the refelction for shiny ones.
  72558. */
  72559. environmentIntensity: number;
  72560. /**
  72561. * This is a special control allowing the reduction of the specular highlights coming from the
  72562. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  72563. */
  72564. specularIntensity: number;
  72565. /**
  72566. * Defines the falloff type used in this material.
  72567. * It by default is Physical.
  72568. */
  72569. lightFalloff: number;
  72570. /**
  72571. * Specifies that alpha test should be used
  72572. */
  72573. useAlphaTest: boolean;
  72574. /**
  72575. * Defines the alpha limits in alpha test mode.
  72576. */
  72577. alphaTestCutoff: number;
  72578. /**
  72579. * Specifies that alpha blending should be used
  72580. */
  72581. useAlphaBlending: boolean;
  72582. /**
  72583. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  72584. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  72585. */
  72586. useRadianceOverAlpha: boolean;
  72587. /**
  72588. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  72589. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  72590. */
  72591. useSpecularOverAlpha: boolean;
  72592. /**
  72593. * Enables specular anti aliasing in the PBR shader.
  72594. * It will both interacts on the Geometry for analytical and IBL lighting.
  72595. * It also prefilter the roughness map based on the bump values.
  72596. */
  72597. enableSpecularAntiAliasing: boolean;
  72598. /**
  72599. * Enables realtime filtering on the texture.
  72600. */
  72601. realTimeFiltering: boolean;
  72602. /**
  72603. * Quality switch for realtime filtering
  72604. */
  72605. realTimeFilteringQuality: number;
  72606. /**
  72607. * Defines if the material uses energy conservation.
  72608. */
  72609. useEnergyConservation: boolean;
  72610. /**
  72611. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  72612. * too much the area relying on ambient texture to define their ambient occlusion.
  72613. */
  72614. useRadianceOcclusion: boolean;
  72615. /**
  72616. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  72617. * makes the reflect vector face the model (under horizon).
  72618. */
  72619. useHorizonOcclusion: boolean;
  72620. /**
  72621. * If set to true, no lighting calculations will be applied.
  72622. */
  72623. unlit: boolean;
  72624. /**
  72625. * Force normal to face away from face.
  72626. */
  72627. forceNormalForward: boolean;
  72628. /**
  72629. * Defines the material debug mode.
  72630. * It helps seeing only some components of the material while troubleshooting.
  72631. */
  72632. debugMode: number;
  72633. /**
  72634. * Specify from where on screen the debug mode should start.
  72635. * The value goes from -1 (full screen) to 1 (not visible)
  72636. * It helps with side by side comparison against the final render
  72637. * This defaults to 0
  72638. */
  72639. debugLimit: number;
  72640. /**
  72641. * As the default viewing range might not be enough (if the ambient is really small for instance)
  72642. * You can use the factor to better multiply the final value.
  72643. */
  72644. debugFactor: number;
  72645. /**
  72646. * Initialize the block and prepare the context for build
  72647. * @param state defines the state that will be used for the build
  72648. */
  72649. initialize(state: NodeMaterialBuildState): void;
  72650. /**
  72651. * Gets the current class name
  72652. * @returns the class name
  72653. */
  72654. getClassName(): string;
  72655. /**
  72656. * Gets the world position input component
  72657. */
  72658. get worldPosition(): NodeMaterialConnectionPoint;
  72659. /**
  72660. * Gets the world normal input component
  72661. */
  72662. get worldNormal(): NodeMaterialConnectionPoint;
  72663. /**
  72664. * Gets the view matrix parameter
  72665. */
  72666. get view(): NodeMaterialConnectionPoint;
  72667. /**
  72668. * Gets the camera position input component
  72669. */
  72670. get cameraPosition(): NodeMaterialConnectionPoint;
  72671. /**
  72672. * Gets the perturbed normal input component
  72673. */
  72674. get perturbedNormal(): NodeMaterialConnectionPoint;
  72675. /**
  72676. * Gets the base color input component
  72677. */
  72678. get baseColor(): NodeMaterialConnectionPoint;
  72679. /**
  72680. * Gets the metallic input component
  72681. */
  72682. get metallic(): NodeMaterialConnectionPoint;
  72683. /**
  72684. * Gets the roughness input component
  72685. */
  72686. get roughness(): NodeMaterialConnectionPoint;
  72687. /**
  72688. * Gets the ambient occlusion input component
  72689. */
  72690. get ambientOcc(): NodeMaterialConnectionPoint;
  72691. /**
  72692. * Gets the opacity input component
  72693. */
  72694. get opacity(): NodeMaterialConnectionPoint;
  72695. /**
  72696. * Gets the index of refraction input component
  72697. */
  72698. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72699. /**
  72700. * Gets the ambient color input component
  72701. */
  72702. get ambientColor(): NodeMaterialConnectionPoint;
  72703. /**
  72704. * Gets the reflection object parameters
  72705. */
  72706. get reflection(): NodeMaterialConnectionPoint;
  72707. /**
  72708. * Gets the clear coat object parameters
  72709. */
  72710. get clearcoat(): NodeMaterialConnectionPoint;
  72711. /**
  72712. * Gets the sheen object parameters
  72713. */
  72714. get sheen(): NodeMaterialConnectionPoint;
  72715. /**
  72716. * Gets the sub surface object parameters
  72717. */
  72718. get subsurface(): NodeMaterialConnectionPoint;
  72719. /**
  72720. * Gets the anisotropy object parameters
  72721. */
  72722. get anisotropy(): NodeMaterialConnectionPoint;
  72723. /**
  72724. * Gets the ambient output component
  72725. */
  72726. get ambientClr(): NodeMaterialConnectionPoint;
  72727. /**
  72728. * Gets the diffuse output component
  72729. */
  72730. get diffuseDir(): NodeMaterialConnectionPoint;
  72731. /**
  72732. * Gets the specular output component
  72733. */
  72734. get specularDir(): NodeMaterialConnectionPoint;
  72735. /**
  72736. * Gets the clear coat output component
  72737. */
  72738. get clearcoatDir(): NodeMaterialConnectionPoint;
  72739. /**
  72740. * Gets the sheen output component
  72741. */
  72742. get sheenDir(): NodeMaterialConnectionPoint;
  72743. /**
  72744. * Gets the indirect diffuse output component
  72745. */
  72746. get diffuseIndirect(): NodeMaterialConnectionPoint;
  72747. /**
  72748. * Gets the indirect specular output component
  72749. */
  72750. get specularIndirect(): NodeMaterialConnectionPoint;
  72751. /**
  72752. * Gets the indirect clear coat output component
  72753. */
  72754. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  72755. /**
  72756. * Gets the indirect sheen output component
  72757. */
  72758. get sheenIndirect(): NodeMaterialConnectionPoint;
  72759. /**
  72760. * Gets the refraction output component
  72761. */
  72762. get refraction(): NodeMaterialConnectionPoint;
  72763. /**
  72764. * Gets the global lighting output component
  72765. */
  72766. get lighting(): NodeMaterialConnectionPoint;
  72767. /**
  72768. * Gets the shadow output component
  72769. */
  72770. get shadow(): NodeMaterialConnectionPoint;
  72771. /**
  72772. * Gets the alpha output component
  72773. */
  72774. get alpha(): NodeMaterialConnectionPoint;
  72775. autoConfigure(material: NodeMaterial): void;
  72776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72777. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  72778. isReady(): boolean;
  72779. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  72780. private _injectVertexCode;
  72781. private _getAlbedoOpacityCode;
  72782. private _getAmbientOcclusionCode;
  72783. private _getReflectivityCode;
  72784. protected _buildBlock(state: NodeMaterialBuildState): this;
  72785. protected _dumpPropertiesCode(): string;
  72786. serialize(): any;
  72787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72788. }
  72789. }
  72790. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  72791. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  72792. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  72793. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  72794. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72795. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  72796. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  72797. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  72798. }
  72799. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  72800. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  72801. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  72802. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  72803. }
  72804. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  72805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72808. /**
  72809. * Block used to compute value of one parameter modulo another
  72810. */
  72811. export class ModBlock extends NodeMaterialBlock {
  72812. /**
  72813. * Creates a new ModBlock
  72814. * @param name defines the block name
  72815. */
  72816. constructor(name: string);
  72817. /**
  72818. * Gets the current class name
  72819. * @returns the class name
  72820. */
  72821. getClassName(): string;
  72822. /**
  72823. * Gets the left operand input component
  72824. */
  72825. get left(): NodeMaterialConnectionPoint;
  72826. /**
  72827. * Gets the right operand input component
  72828. */
  72829. get right(): NodeMaterialConnectionPoint;
  72830. /**
  72831. * Gets the output component
  72832. */
  72833. get output(): NodeMaterialConnectionPoint;
  72834. protected _buildBlock(state: NodeMaterialBuildState): this;
  72835. }
  72836. }
  72837. declare module "babylonjs/Materials/Node/Blocks/index" {
  72838. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  72839. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  72840. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  72841. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  72842. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  72843. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  72844. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  72845. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  72846. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  72847. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  72848. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  72849. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  72850. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  72851. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  72852. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  72853. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  72854. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  72855. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  72856. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  72857. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  72858. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  72859. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  72860. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  72861. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  72862. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  72863. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  72864. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  72865. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  72866. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  72867. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  72868. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  72869. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  72870. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  72871. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  72872. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  72873. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  72874. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  72875. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  72876. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  72877. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  72878. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  72879. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  72880. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  72881. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  72882. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  72883. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  72884. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  72885. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  72886. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  72887. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  72888. }
  72889. declare module "babylonjs/Materials/Node/Optimizers/index" {
  72890. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  72891. }
  72892. declare module "babylonjs/Materials/Node/index" {
  72893. export * from "babylonjs/Materials/Node/Enums/index";
  72894. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72895. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  72896. export * from "babylonjs/Materials/Node/nodeMaterial";
  72897. export * from "babylonjs/Materials/Node/Blocks/index";
  72898. export * from "babylonjs/Materials/Node/Optimizers/index";
  72899. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  72900. }
  72901. declare module "babylonjs/Materials/index" {
  72902. export * from "babylonjs/Materials/Background/index";
  72903. export * from "babylonjs/Materials/colorCurves";
  72904. export * from "babylonjs/Materials/iEffectFallbacks";
  72905. export * from "babylonjs/Materials/effectFallbacks";
  72906. export * from "babylonjs/Materials/effect";
  72907. export * from "babylonjs/Materials/fresnelParameters";
  72908. export * from "babylonjs/Materials/imageProcessingConfiguration";
  72909. export * from "babylonjs/Materials/material";
  72910. export * from "babylonjs/Materials/materialDefines";
  72911. export * from "babylonjs/Materials/thinMaterialHelper";
  72912. export * from "babylonjs/Materials/materialHelper";
  72913. export * from "babylonjs/Materials/multiMaterial";
  72914. export * from "babylonjs/Materials/Occlusion/index";
  72915. export * from "babylonjs/Materials/PBR/index";
  72916. export * from "babylonjs/Materials/pushMaterial";
  72917. export * from "babylonjs/Materials/shaderMaterial";
  72918. export * from "babylonjs/Materials/standardMaterial";
  72919. export * from "babylonjs/Materials/Textures/index";
  72920. export * from "babylonjs/Materials/uniformBuffer";
  72921. export * from "babylonjs/Materials/materialFlags";
  72922. export * from "babylonjs/Materials/Node/index";
  72923. export * from "babylonjs/Materials/effectRenderer";
  72924. export * from "babylonjs/Materials/shadowDepthWrapper";
  72925. }
  72926. declare module "babylonjs/Maths/index" {
  72927. export * from "babylonjs/Maths/math.scalar";
  72928. export * from "babylonjs/Maths/math.functions";
  72929. export * from "babylonjs/Maths/math";
  72930. export * from "babylonjs/Maths/sphericalPolynomial";
  72931. }
  72932. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  72933. import { IDisposable } from "babylonjs/scene";
  72934. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  72935. /**
  72936. * Configuration for Draco compression
  72937. */
  72938. export interface IDracoCompressionConfiguration {
  72939. /**
  72940. * Configuration for the decoder.
  72941. */
  72942. decoder: {
  72943. /**
  72944. * The url to the WebAssembly module.
  72945. */
  72946. wasmUrl?: string;
  72947. /**
  72948. * The url to the WebAssembly binary.
  72949. */
  72950. wasmBinaryUrl?: string;
  72951. /**
  72952. * The url to the fallback JavaScript module.
  72953. */
  72954. fallbackUrl?: string;
  72955. };
  72956. }
  72957. /**
  72958. * Draco compression (https://google.github.io/draco/)
  72959. *
  72960. * This class wraps the Draco module.
  72961. *
  72962. * **Encoder**
  72963. *
  72964. * The encoder is not currently implemented.
  72965. *
  72966. * **Decoder**
  72967. *
  72968. * 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.
  72969. *
  72970. * To update the configuration, use the following code:
  72971. * ```javascript
  72972. * DracoCompression.Configuration = {
  72973. * decoder: {
  72974. * wasmUrl: "<url to the WebAssembly library>",
  72975. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  72976. * fallbackUrl: "<url to the fallback JavaScript library>",
  72977. * }
  72978. * };
  72979. * ```
  72980. *
  72981. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  72982. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  72983. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  72984. *
  72985. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  72986. * ```javascript
  72987. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  72988. * ```
  72989. *
  72990. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  72991. */
  72992. export class DracoCompression implements IDisposable {
  72993. private _workerPoolPromise?;
  72994. private _decoderModulePromise?;
  72995. /**
  72996. * The configuration. Defaults to the following urls:
  72997. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  72998. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  72999. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  73000. */
  73001. static Configuration: IDracoCompressionConfiguration;
  73002. /**
  73003. * Returns true if the decoder configuration is available.
  73004. */
  73005. static get DecoderAvailable(): boolean;
  73006. /**
  73007. * Default number of workers to create when creating the draco compression object.
  73008. */
  73009. static DefaultNumWorkers: number;
  73010. private static GetDefaultNumWorkers;
  73011. private static _Default;
  73012. /**
  73013. * Default instance for the draco compression object.
  73014. */
  73015. static get Default(): DracoCompression;
  73016. /**
  73017. * Constructor
  73018. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  73019. */
  73020. constructor(numWorkers?: number);
  73021. /**
  73022. * Stop all async operations and release resources.
  73023. */
  73024. dispose(): void;
  73025. /**
  73026. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  73027. * @returns a promise that resolves when ready
  73028. */
  73029. whenReadyAsync(): Promise<void>;
  73030. /**
  73031. * Decode Draco compressed mesh data to vertex data.
  73032. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  73033. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  73034. * @returns A promise that resolves with the decoded vertex data
  73035. */
  73036. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  73037. [kind: string]: number;
  73038. }): Promise<VertexData>;
  73039. }
  73040. }
  73041. declare module "babylonjs/Meshes/Compression/index" {
  73042. export * from "babylonjs/Meshes/Compression/dracoCompression";
  73043. }
  73044. declare module "babylonjs/Meshes/csg" {
  73045. import { Nullable } from "babylonjs/types";
  73046. import { Scene } from "babylonjs/scene";
  73047. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  73048. import { Mesh } from "babylonjs/Meshes/mesh";
  73049. import { Material } from "babylonjs/Materials/material";
  73050. /**
  73051. * Class for building Constructive Solid Geometry
  73052. */
  73053. export class CSG {
  73054. private polygons;
  73055. /**
  73056. * The world matrix
  73057. */
  73058. matrix: Matrix;
  73059. /**
  73060. * Stores the position
  73061. */
  73062. position: Vector3;
  73063. /**
  73064. * Stores the rotation
  73065. */
  73066. rotation: Vector3;
  73067. /**
  73068. * Stores the rotation quaternion
  73069. */
  73070. rotationQuaternion: Nullable<Quaternion>;
  73071. /**
  73072. * Stores the scaling vector
  73073. */
  73074. scaling: Vector3;
  73075. /**
  73076. * Convert the Mesh to CSG
  73077. * @param mesh The Mesh to convert to CSG
  73078. * @returns A new CSG from the Mesh
  73079. */
  73080. static FromMesh(mesh: Mesh): CSG;
  73081. /**
  73082. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  73083. * @param polygons Polygons used to construct a CSG solid
  73084. */
  73085. private static FromPolygons;
  73086. /**
  73087. * Clones, or makes a deep copy, of the CSG
  73088. * @returns A new CSG
  73089. */
  73090. clone(): CSG;
  73091. /**
  73092. * Unions this CSG with another CSG
  73093. * @param csg The CSG to union against this CSG
  73094. * @returns The unioned CSG
  73095. */
  73096. union(csg: CSG): CSG;
  73097. /**
  73098. * Unions this CSG with another CSG in place
  73099. * @param csg The CSG to union against this CSG
  73100. */
  73101. unionInPlace(csg: CSG): void;
  73102. /**
  73103. * Subtracts this CSG with another CSG
  73104. * @param csg The CSG to subtract against this CSG
  73105. * @returns A new CSG
  73106. */
  73107. subtract(csg: CSG): CSG;
  73108. /**
  73109. * Subtracts this CSG with another CSG in place
  73110. * @param csg The CSG to subtact against this CSG
  73111. */
  73112. subtractInPlace(csg: CSG): void;
  73113. /**
  73114. * Intersect this CSG with another CSG
  73115. * @param csg The CSG to intersect against this CSG
  73116. * @returns A new CSG
  73117. */
  73118. intersect(csg: CSG): CSG;
  73119. /**
  73120. * Intersects this CSG with another CSG in place
  73121. * @param csg The CSG to intersect against this CSG
  73122. */
  73123. intersectInPlace(csg: CSG): void;
  73124. /**
  73125. * Return a new CSG solid with solid and empty space switched. This solid is
  73126. * not modified.
  73127. * @returns A new CSG solid with solid and empty space switched
  73128. */
  73129. inverse(): CSG;
  73130. /**
  73131. * Inverses the CSG in place
  73132. */
  73133. inverseInPlace(): void;
  73134. /**
  73135. * This is used to keep meshes transformations so they can be restored
  73136. * when we build back a Babylon Mesh
  73137. * NB : All CSG operations are performed in world coordinates
  73138. * @param csg The CSG to copy the transform attributes from
  73139. * @returns This CSG
  73140. */
  73141. copyTransformAttributes(csg: CSG): CSG;
  73142. /**
  73143. * Build Raw mesh from CSG
  73144. * Coordinates here are in world space
  73145. * @param name The name of the mesh geometry
  73146. * @param scene The Scene
  73147. * @param keepSubMeshes Specifies if the submeshes should be kept
  73148. * @returns A new Mesh
  73149. */
  73150. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73151. /**
  73152. * Build Mesh from CSG taking material and transforms into account
  73153. * @param name The name of the Mesh
  73154. * @param material The material of the Mesh
  73155. * @param scene The Scene
  73156. * @param keepSubMeshes Specifies if submeshes should be kept
  73157. * @returns The new Mesh
  73158. */
  73159. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73160. }
  73161. }
  73162. declare module "babylonjs/Meshes/trailMesh" {
  73163. import { Mesh } from "babylonjs/Meshes/mesh";
  73164. import { Scene } from "babylonjs/scene";
  73165. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73166. /**
  73167. * Class used to create a trail following a mesh
  73168. */
  73169. export class TrailMesh extends Mesh {
  73170. private _generator;
  73171. private _autoStart;
  73172. private _running;
  73173. private _diameter;
  73174. private _length;
  73175. private _sectionPolygonPointsCount;
  73176. private _sectionVectors;
  73177. private _sectionNormalVectors;
  73178. private _beforeRenderObserver;
  73179. /**
  73180. * @constructor
  73181. * @param name The value used by scene.getMeshByName() to do a lookup.
  73182. * @param generator The mesh or transform node to generate a trail.
  73183. * @param scene The scene to add this mesh to.
  73184. * @param diameter Diameter of trailing mesh. Default is 1.
  73185. * @param length Length of trailing mesh. Default is 60.
  73186. * @param autoStart Automatically start trailing mesh. Default true.
  73187. */
  73188. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  73189. /**
  73190. * "TrailMesh"
  73191. * @returns "TrailMesh"
  73192. */
  73193. getClassName(): string;
  73194. private _createMesh;
  73195. /**
  73196. * Start trailing mesh.
  73197. */
  73198. start(): void;
  73199. /**
  73200. * Stop trailing mesh.
  73201. */
  73202. stop(): void;
  73203. /**
  73204. * Update trailing mesh geometry.
  73205. */
  73206. update(): void;
  73207. /**
  73208. * Returns a new TrailMesh object.
  73209. * @param name is a string, the name given to the new mesh
  73210. * @param newGenerator use new generator object for cloned trail mesh
  73211. * @returns a new mesh
  73212. */
  73213. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  73214. /**
  73215. * Serializes this trail mesh
  73216. * @param serializationObject object to write serialization to
  73217. */
  73218. serialize(serializationObject: any): void;
  73219. /**
  73220. * Parses a serialized trail mesh
  73221. * @param parsedMesh the serialized mesh
  73222. * @param scene the scene to create the trail mesh in
  73223. * @returns the created trail mesh
  73224. */
  73225. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  73226. }
  73227. }
  73228. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  73229. import { Nullable } from "babylonjs/types";
  73230. import { Scene } from "babylonjs/scene";
  73231. import { Vector4 } from "babylonjs/Maths/math.vector";
  73232. import { Color4 } from "babylonjs/Maths/math.color";
  73233. import { Mesh } from "babylonjs/Meshes/mesh";
  73234. /**
  73235. * Class containing static functions to help procedurally build meshes
  73236. */
  73237. export class TiledBoxBuilder {
  73238. /**
  73239. * Creates a box mesh
  73240. * 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)
  73241. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73245. * @param name defines the name of the mesh
  73246. * @param options defines the options used to create the mesh
  73247. * @param scene defines the hosting scene
  73248. * @returns the box mesh
  73249. */
  73250. static CreateTiledBox(name: string, options: {
  73251. pattern?: number;
  73252. width?: number;
  73253. height?: number;
  73254. depth?: number;
  73255. tileSize?: number;
  73256. tileWidth?: number;
  73257. tileHeight?: number;
  73258. alignHorizontal?: number;
  73259. alignVertical?: number;
  73260. faceUV?: Vector4[];
  73261. faceColors?: Color4[];
  73262. sideOrientation?: number;
  73263. updatable?: boolean;
  73264. }, scene?: Nullable<Scene>): Mesh;
  73265. }
  73266. }
  73267. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  73268. import { Vector4 } from "babylonjs/Maths/math.vector";
  73269. import { Mesh } from "babylonjs/Meshes/mesh";
  73270. /**
  73271. * Class containing static functions to help procedurally build meshes
  73272. */
  73273. export class TorusKnotBuilder {
  73274. /**
  73275. * Creates a torus knot mesh
  73276. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73277. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73278. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73279. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73283. * @param name defines the name of the mesh
  73284. * @param options defines the options used to create the mesh
  73285. * @param scene defines the hosting scene
  73286. * @returns the torus knot mesh
  73287. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73288. */
  73289. static CreateTorusKnot(name: string, options: {
  73290. radius?: number;
  73291. tube?: number;
  73292. radialSegments?: number;
  73293. tubularSegments?: number;
  73294. p?: number;
  73295. q?: number;
  73296. updatable?: boolean;
  73297. sideOrientation?: number;
  73298. frontUVs?: Vector4;
  73299. backUVs?: Vector4;
  73300. }, scene: any): Mesh;
  73301. }
  73302. }
  73303. declare module "babylonjs/Meshes/polygonMesh" {
  73304. import { Scene } from "babylonjs/scene";
  73305. import { Vector2 } from "babylonjs/Maths/math.vector";
  73306. import { Mesh } from "babylonjs/Meshes/mesh";
  73307. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73308. import { Path2 } from "babylonjs/Maths/math.path";
  73309. /**
  73310. * Polygon
  73311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  73312. */
  73313. export class Polygon {
  73314. /**
  73315. * Creates a rectangle
  73316. * @param xmin bottom X coord
  73317. * @param ymin bottom Y coord
  73318. * @param xmax top X coord
  73319. * @param ymax top Y coord
  73320. * @returns points that make the resulting rectation
  73321. */
  73322. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  73323. /**
  73324. * Creates a circle
  73325. * @param radius radius of circle
  73326. * @param cx scale in x
  73327. * @param cy scale in y
  73328. * @param numberOfSides number of sides that make up the circle
  73329. * @returns points that make the resulting circle
  73330. */
  73331. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  73332. /**
  73333. * Creates a polygon from input string
  73334. * @param input Input polygon data
  73335. * @returns the parsed points
  73336. */
  73337. static Parse(input: string): Vector2[];
  73338. /**
  73339. * Starts building a polygon from x and y coordinates
  73340. * @param x x coordinate
  73341. * @param y y coordinate
  73342. * @returns the started path2
  73343. */
  73344. static StartingAt(x: number, y: number): Path2;
  73345. }
  73346. /**
  73347. * Builds a polygon
  73348. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  73349. */
  73350. export class PolygonMeshBuilder {
  73351. private _points;
  73352. private _outlinepoints;
  73353. private _holes;
  73354. private _name;
  73355. private _scene;
  73356. private _epoints;
  73357. private _eholes;
  73358. private _addToepoint;
  73359. /**
  73360. * Babylon reference to the earcut plugin.
  73361. */
  73362. bjsEarcut: any;
  73363. /**
  73364. * Creates a PolygonMeshBuilder
  73365. * @param name name of the builder
  73366. * @param contours Path of the polygon
  73367. * @param scene scene to add to when creating the mesh
  73368. * @param earcutInjection can be used to inject your own earcut reference
  73369. */
  73370. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  73371. /**
  73372. * Adds a hole within the polygon
  73373. * @param hole Array of points defining the hole
  73374. * @returns this
  73375. */
  73376. addHole(hole: Vector2[]): PolygonMeshBuilder;
  73377. /**
  73378. * Creates the polygon
  73379. * @param updatable If the mesh should be updatable
  73380. * @param depth The depth of the mesh created
  73381. * @param smoothingThreshold Dot product threshold for smoothed normals
  73382. * @returns the created mesh
  73383. */
  73384. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  73385. /**
  73386. * Creates the polygon
  73387. * @param depth The depth of the mesh created
  73388. * @param smoothingThreshold Dot product threshold for smoothed normals
  73389. * @returns the created VertexData
  73390. */
  73391. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  73392. /**
  73393. * Adds a side to the polygon
  73394. * @param positions points that make the polygon
  73395. * @param normals normals of the polygon
  73396. * @param uvs uvs of the polygon
  73397. * @param indices indices of the polygon
  73398. * @param bounds bounds of the polygon
  73399. * @param points points of the polygon
  73400. * @param depth depth of the polygon
  73401. * @param flip flip of the polygon
  73402. */
  73403. private addSide;
  73404. }
  73405. }
  73406. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  73407. import { Scene } from "babylonjs/scene";
  73408. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73409. import { Color4 } from "babylonjs/Maths/math.color";
  73410. import { Mesh } from "babylonjs/Meshes/mesh";
  73411. import { Nullable } from "babylonjs/types";
  73412. /**
  73413. * Class containing static functions to help procedurally build meshes
  73414. */
  73415. export class PolygonBuilder {
  73416. /**
  73417. * Creates a polygon mesh
  73418. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73419. * * 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
  73420. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  73423. * * Remember you can only change the shape positions, not their number when updating a polygon
  73424. * @param name defines the name of the mesh
  73425. * @param options defines the options used to create the mesh
  73426. * @param scene defines the hosting scene
  73427. * @param earcutInjection can be used to inject your own earcut reference
  73428. * @returns the polygon mesh
  73429. */
  73430. static CreatePolygon(name: string, options: {
  73431. shape: Vector3[];
  73432. holes?: Vector3[][];
  73433. depth?: number;
  73434. smoothingThreshold?: number;
  73435. faceUV?: Vector4[];
  73436. faceColors?: Color4[];
  73437. updatable?: boolean;
  73438. sideOrientation?: number;
  73439. frontUVs?: Vector4;
  73440. backUVs?: Vector4;
  73441. wrap?: boolean;
  73442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73443. /**
  73444. * Creates an extruded polygon mesh, with depth in the Y direction.
  73445. * * 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)
  73446. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73447. * @param name defines the name of the mesh
  73448. * @param options defines the options used to create the mesh
  73449. * @param scene defines the hosting scene
  73450. * @param earcutInjection can be used to inject your own earcut reference
  73451. * @returns the polygon mesh
  73452. */
  73453. static ExtrudePolygon(name: string, options: {
  73454. shape: Vector3[];
  73455. holes?: Vector3[][];
  73456. depth?: number;
  73457. faceUV?: Vector4[];
  73458. faceColors?: Color4[];
  73459. updatable?: boolean;
  73460. sideOrientation?: number;
  73461. frontUVs?: Vector4;
  73462. backUVs?: Vector4;
  73463. wrap?: boolean;
  73464. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73465. }
  73466. }
  73467. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  73468. import { Scene } from "babylonjs/scene";
  73469. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73470. import { Mesh } from "babylonjs/Meshes/mesh";
  73471. import { Nullable } from "babylonjs/types";
  73472. /**
  73473. * Class containing static functions to help procedurally build meshes
  73474. */
  73475. export class LatheBuilder {
  73476. /**
  73477. * Creates lathe mesh.
  73478. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73479. * * 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
  73480. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73481. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73482. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73483. * * 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
  73484. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73485. * * 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
  73486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73490. * @param name defines the name of the mesh
  73491. * @param options defines the options used to create the mesh
  73492. * @param scene defines the hosting scene
  73493. * @returns the lathe mesh
  73494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73495. */
  73496. static CreateLathe(name: string, options: {
  73497. shape: Vector3[];
  73498. radius?: number;
  73499. tessellation?: number;
  73500. clip?: number;
  73501. arc?: number;
  73502. closed?: boolean;
  73503. updatable?: boolean;
  73504. sideOrientation?: number;
  73505. frontUVs?: Vector4;
  73506. backUVs?: Vector4;
  73507. cap?: number;
  73508. invertUV?: boolean;
  73509. }, scene?: Nullable<Scene>): Mesh;
  73510. }
  73511. }
  73512. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  73513. import { Nullable } from "babylonjs/types";
  73514. import { Scene } from "babylonjs/scene";
  73515. import { Vector4 } from "babylonjs/Maths/math.vector";
  73516. import { Mesh } from "babylonjs/Meshes/mesh";
  73517. /**
  73518. * Class containing static functions to help procedurally build meshes
  73519. */
  73520. export class TiledPlaneBuilder {
  73521. /**
  73522. * Creates a tiled plane mesh
  73523. * * The parameter `pattern` will, depending on value, do nothing or
  73524. * * * flip (reflect about central vertical) alternate tiles across and up
  73525. * * * flip every tile on alternate rows
  73526. * * * rotate (180 degs) alternate tiles across and up
  73527. * * * rotate every tile on alternate rows
  73528. * * * flip and rotate alternate tiles across and up
  73529. * * * flip and rotate every tile on alternate rows
  73530. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  73531. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  73532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73534. * * 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)
  73535. * * 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)
  73536. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73537. * @param name defines the name of the mesh
  73538. * @param options defines the options used to create the mesh
  73539. * @param scene defines the hosting scene
  73540. * @returns the box mesh
  73541. */
  73542. static CreateTiledPlane(name: string, options: {
  73543. pattern?: number;
  73544. tileSize?: number;
  73545. tileWidth?: number;
  73546. tileHeight?: number;
  73547. size?: number;
  73548. width?: number;
  73549. height?: number;
  73550. alignHorizontal?: number;
  73551. alignVertical?: number;
  73552. sideOrientation?: number;
  73553. frontUVs?: Vector4;
  73554. backUVs?: Vector4;
  73555. updatable?: boolean;
  73556. }, scene?: Nullable<Scene>): Mesh;
  73557. }
  73558. }
  73559. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  73560. import { Nullable } from "babylonjs/types";
  73561. import { Scene } from "babylonjs/scene";
  73562. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73563. import { Mesh } from "babylonjs/Meshes/mesh";
  73564. /**
  73565. * Class containing static functions to help procedurally build meshes
  73566. */
  73567. export class TubeBuilder {
  73568. /**
  73569. * Creates a tube mesh.
  73570. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73571. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  73572. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  73573. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  73574. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  73575. * * 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)
  73576. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  73577. * * 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
  73578. * * 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
  73579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73583. * @param name defines the name of the mesh
  73584. * @param options defines the options used to create the mesh
  73585. * @param scene defines the hosting scene
  73586. * @returns the tube mesh
  73587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73588. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  73589. */
  73590. static CreateTube(name: string, options: {
  73591. path: Vector3[];
  73592. radius?: number;
  73593. tessellation?: number;
  73594. radiusFunction?: {
  73595. (i: number, distance: number): number;
  73596. };
  73597. cap?: number;
  73598. arc?: number;
  73599. updatable?: boolean;
  73600. sideOrientation?: number;
  73601. frontUVs?: Vector4;
  73602. backUVs?: Vector4;
  73603. instance?: Mesh;
  73604. invertUV?: boolean;
  73605. }, scene?: Nullable<Scene>): Mesh;
  73606. }
  73607. }
  73608. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  73609. import { Scene } from "babylonjs/scene";
  73610. import { Vector4 } from "babylonjs/Maths/math.vector";
  73611. import { Mesh } from "babylonjs/Meshes/mesh";
  73612. import { Nullable } from "babylonjs/types";
  73613. /**
  73614. * Class containing static functions to help procedurally build meshes
  73615. */
  73616. export class IcoSphereBuilder {
  73617. /**
  73618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73620. * * 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`)
  73621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73622. * * 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
  73623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73626. * @param name defines the name of the mesh
  73627. * @param options defines the options used to create the mesh
  73628. * @param scene defines the hosting scene
  73629. * @returns the icosahedron mesh
  73630. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73631. */
  73632. static CreateIcoSphere(name: string, options: {
  73633. radius?: number;
  73634. radiusX?: number;
  73635. radiusY?: number;
  73636. radiusZ?: number;
  73637. flat?: boolean;
  73638. subdivisions?: number;
  73639. sideOrientation?: number;
  73640. frontUVs?: Vector4;
  73641. backUVs?: Vector4;
  73642. updatable?: boolean;
  73643. }, scene?: Nullable<Scene>): Mesh;
  73644. }
  73645. }
  73646. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  73647. import { Vector3 } from "babylonjs/Maths/math.vector";
  73648. import { Mesh } from "babylonjs/Meshes/mesh";
  73649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73650. /**
  73651. * Class containing static functions to help procedurally build meshes
  73652. */
  73653. export class DecalBuilder {
  73654. /**
  73655. * Creates a decal mesh.
  73656. * 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
  73657. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  73658. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  73659. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  73660. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  73661. * @param name defines the name of the mesh
  73662. * @param sourceMesh defines the mesh where the decal must be applied
  73663. * @param options defines the options used to create the mesh
  73664. * @param scene defines the hosting scene
  73665. * @returns the decal mesh
  73666. * @see https://doc.babylonjs.com/how_to/decals
  73667. */
  73668. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  73669. position?: Vector3;
  73670. normal?: Vector3;
  73671. size?: Vector3;
  73672. angle?: number;
  73673. }): Mesh;
  73674. }
  73675. }
  73676. declare module "babylonjs/Meshes/meshBuilder" {
  73677. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  73678. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  73679. import { Nullable } from "babylonjs/types";
  73680. import { Scene } from "babylonjs/scene";
  73681. import { Mesh } from "babylonjs/Meshes/mesh";
  73682. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  73683. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  73684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73685. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  73686. import { Plane } from "babylonjs/Maths/math.plane";
  73687. /**
  73688. * Class containing static functions to help procedurally build meshes
  73689. */
  73690. export class MeshBuilder {
  73691. /**
  73692. * Creates a box mesh
  73693. * * The parameter `size` sets the size (float) of each box side (default 1)
  73694. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  73695. * * 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)
  73696. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73700. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73701. * @param name defines the name of the mesh
  73702. * @param options defines the options used to create the mesh
  73703. * @param scene defines the hosting scene
  73704. * @returns the box mesh
  73705. */
  73706. static CreateBox(name: string, options: {
  73707. size?: number;
  73708. width?: number;
  73709. height?: number;
  73710. depth?: number;
  73711. faceUV?: Vector4[];
  73712. faceColors?: Color4[];
  73713. sideOrientation?: number;
  73714. frontUVs?: Vector4;
  73715. backUVs?: Vector4;
  73716. wrap?: boolean;
  73717. topBaseAt?: number;
  73718. bottomBaseAt?: number;
  73719. updatable?: boolean;
  73720. }, scene?: Nullable<Scene>): Mesh;
  73721. /**
  73722. * Creates a tiled box mesh
  73723. * * faceTiles sets the pattern, tile size and number of tiles for a face
  73724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73725. * @param name defines the name of the mesh
  73726. * @param options defines the options used to create the mesh
  73727. * @param scene defines the hosting scene
  73728. * @returns the tiled box mesh
  73729. */
  73730. static CreateTiledBox(name: string, options: {
  73731. pattern?: number;
  73732. size?: number;
  73733. width?: number;
  73734. height?: number;
  73735. depth: number;
  73736. tileSize?: number;
  73737. tileWidth?: number;
  73738. tileHeight?: number;
  73739. faceUV?: Vector4[];
  73740. faceColors?: Color4[];
  73741. alignHorizontal?: number;
  73742. alignVertical?: number;
  73743. sideOrientation?: number;
  73744. updatable?: boolean;
  73745. }, scene?: Nullable<Scene>): Mesh;
  73746. /**
  73747. * Creates a sphere mesh
  73748. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  73749. * * 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`)
  73750. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  73751. * * 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
  73752. * * 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)
  73753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73756. * @param name defines the name of the mesh
  73757. * @param options defines the options used to create the mesh
  73758. * @param scene defines the hosting scene
  73759. * @returns the sphere mesh
  73760. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  73761. */
  73762. static CreateSphere(name: string, options: {
  73763. segments?: number;
  73764. diameter?: number;
  73765. diameterX?: number;
  73766. diameterY?: number;
  73767. diameterZ?: number;
  73768. arc?: number;
  73769. slice?: number;
  73770. sideOrientation?: number;
  73771. frontUVs?: Vector4;
  73772. backUVs?: Vector4;
  73773. updatable?: boolean;
  73774. }, scene?: Nullable<Scene>): Mesh;
  73775. /**
  73776. * Creates a plane polygonal mesh. By default, this is a disc
  73777. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  73778. * * 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
  73779. * * 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
  73780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73783. * @param name defines the name of the mesh
  73784. * @param options defines the options used to create the mesh
  73785. * @param scene defines the hosting scene
  73786. * @returns the plane polygonal mesh
  73787. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  73788. */
  73789. static CreateDisc(name: string, options: {
  73790. radius?: number;
  73791. tessellation?: number;
  73792. arc?: number;
  73793. updatable?: boolean;
  73794. sideOrientation?: number;
  73795. frontUVs?: Vector4;
  73796. backUVs?: Vector4;
  73797. }, scene?: Nullable<Scene>): Mesh;
  73798. /**
  73799. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73800. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73801. * * 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`)
  73802. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73803. * * 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
  73804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73807. * @param name defines the name of the mesh
  73808. * @param options defines the options used to create the mesh
  73809. * @param scene defines the hosting scene
  73810. * @returns the icosahedron mesh
  73811. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73812. */
  73813. static CreateIcoSphere(name: string, options: {
  73814. radius?: number;
  73815. radiusX?: number;
  73816. radiusY?: number;
  73817. radiusZ?: number;
  73818. flat?: boolean;
  73819. subdivisions?: number;
  73820. sideOrientation?: number;
  73821. frontUVs?: Vector4;
  73822. backUVs?: Vector4;
  73823. updatable?: boolean;
  73824. }, scene?: Nullable<Scene>): Mesh;
  73825. /**
  73826. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73827. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  73828. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  73829. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  73830. * * 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
  73831. * * 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
  73832. * * 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
  73833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73836. * * 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
  73837. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  73838. * * 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
  73839. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  73840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73841. * @param name defines the name of the mesh
  73842. * @param options defines the options used to create the mesh
  73843. * @param scene defines the hosting scene
  73844. * @returns the ribbon mesh
  73845. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  73846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73847. */
  73848. static CreateRibbon(name: string, options: {
  73849. pathArray: Vector3[][];
  73850. closeArray?: boolean;
  73851. closePath?: boolean;
  73852. offset?: number;
  73853. updatable?: boolean;
  73854. sideOrientation?: number;
  73855. frontUVs?: Vector4;
  73856. backUVs?: Vector4;
  73857. instance?: Mesh;
  73858. invertUV?: boolean;
  73859. uvs?: Vector2[];
  73860. colors?: Color4[];
  73861. }, scene?: Nullable<Scene>): Mesh;
  73862. /**
  73863. * Creates a cylinder or a cone mesh
  73864. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  73865. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  73866. * * 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.
  73867. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  73868. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  73869. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  73870. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  73871. * * 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).
  73872. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  73873. * * 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).
  73874. * * 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
  73875. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  73876. * * 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
  73877. * * 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.
  73878. * * If `enclose` is false, a ring surface is one element.
  73879. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  73880. * * 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
  73881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73884. * @param name defines the name of the mesh
  73885. * @param options defines the options used to create the mesh
  73886. * @param scene defines the hosting scene
  73887. * @returns the cylinder mesh
  73888. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  73889. */
  73890. static CreateCylinder(name: string, options: {
  73891. height?: number;
  73892. diameterTop?: number;
  73893. diameterBottom?: number;
  73894. diameter?: number;
  73895. tessellation?: number;
  73896. subdivisions?: number;
  73897. arc?: number;
  73898. faceColors?: Color4[];
  73899. faceUV?: Vector4[];
  73900. updatable?: boolean;
  73901. hasRings?: boolean;
  73902. enclose?: boolean;
  73903. cap?: number;
  73904. sideOrientation?: number;
  73905. frontUVs?: Vector4;
  73906. backUVs?: Vector4;
  73907. }, scene?: Nullable<Scene>): Mesh;
  73908. /**
  73909. * Creates a torus mesh
  73910. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  73911. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  73912. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  73913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73916. * @param name defines the name of the mesh
  73917. * @param options defines the options used to create the mesh
  73918. * @param scene defines the hosting scene
  73919. * @returns the torus mesh
  73920. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  73921. */
  73922. static CreateTorus(name: string, options: {
  73923. diameter?: number;
  73924. thickness?: number;
  73925. tessellation?: number;
  73926. updatable?: boolean;
  73927. sideOrientation?: number;
  73928. frontUVs?: Vector4;
  73929. backUVs?: Vector4;
  73930. }, scene?: Nullable<Scene>): Mesh;
  73931. /**
  73932. * Creates a torus knot mesh
  73933. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73934. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73935. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73936. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73940. * @param name defines the name of the mesh
  73941. * @param options defines the options used to create the mesh
  73942. * @param scene defines the hosting scene
  73943. * @returns the torus knot mesh
  73944. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73945. */
  73946. static CreateTorusKnot(name: string, options: {
  73947. radius?: number;
  73948. tube?: number;
  73949. radialSegments?: number;
  73950. tubularSegments?: number;
  73951. p?: number;
  73952. q?: number;
  73953. updatable?: boolean;
  73954. sideOrientation?: number;
  73955. frontUVs?: Vector4;
  73956. backUVs?: Vector4;
  73957. }, scene?: Nullable<Scene>): Mesh;
  73958. /**
  73959. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  73960. * * 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
  73961. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  73962. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  73963. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  73964. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  73965. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  73966. * * 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
  73967. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  73968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  73970. * @param name defines the name of the new line system
  73971. * @param options defines the options used to create the line system
  73972. * @param scene defines the hosting scene
  73973. * @returns a new line system mesh
  73974. */
  73975. static CreateLineSystem(name: string, options: {
  73976. lines: Vector3[][];
  73977. updatable?: boolean;
  73978. instance?: Nullable<LinesMesh>;
  73979. colors?: Nullable<Color4[][]>;
  73980. useVertexAlpha?: boolean;
  73981. }, scene: Nullable<Scene>): LinesMesh;
  73982. /**
  73983. * Creates a line mesh
  73984. * 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
  73985. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  73986. * * The parameter `points` is an array successive Vector3
  73987. * * 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
  73988. * * The optional parameter `colors` is an array of successive Color4, one per line point
  73989. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  73990. * * When updating an instance, remember that only point positions can change, not the number of points
  73991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  73993. * @param name defines the name of the new line system
  73994. * @param options defines the options used to create the line system
  73995. * @param scene defines the hosting scene
  73996. * @returns a new line mesh
  73997. */
  73998. static CreateLines(name: string, options: {
  73999. points: Vector3[];
  74000. updatable?: boolean;
  74001. instance?: Nullable<LinesMesh>;
  74002. colors?: Color4[];
  74003. useVertexAlpha?: boolean;
  74004. }, scene?: Nullable<Scene>): LinesMesh;
  74005. /**
  74006. * Creates a dashed line mesh
  74007. * * 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
  74008. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  74009. * * The parameter `points` is an array successive Vector3
  74010. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  74011. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  74012. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  74013. * * 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
  74014. * * When updating an instance, remember that only point positions can change, not the number of points
  74015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74016. * @param name defines the name of the mesh
  74017. * @param options defines the options used to create the mesh
  74018. * @param scene defines the hosting scene
  74019. * @returns the dashed line mesh
  74020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  74021. */
  74022. static CreateDashedLines(name: string, options: {
  74023. points: Vector3[];
  74024. dashSize?: number;
  74025. gapSize?: number;
  74026. dashNb?: number;
  74027. updatable?: boolean;
  74028. instance?: LinesMesh;
  74029. }, scene?: Nullable<Scene>): LinesMesh;
  74030. /**
  74031. * 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.
  74032. * * 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.
  74033. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74034. * * 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.
  74035. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  74036. * * 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
  74037. * * 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
  74038. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  74039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  74042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74043. * @param name defines the name of the mesh
  74044. * @param options defines the options used to create the mesh
  74045. * @param scene defines the hosting scene
  74046. * @returns the extruded shape mesh
  74047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74049. */
  74050. static ExtrudeShape(name: string, options: {
  74051. shape: Vector3[];
  74052. path: Vector3[];
  74053. scale?: number;
  74054. rotation?: number;
  74055. cap?: number;
  74056. updatable?: boolean;
  74057. sideOrientation?: number;
  74058. frontUVs?: Vector4;
  74059. backUVs?: Vector4;
  74060. instance?: Mesh;
  74061. invertUV?: boolean;
  74062. }, scene?: Nullable<Scene>): Mesh;
  74063. /**
  74064. * Creates an custom extruded shape mesh.
  74065. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  74066. * * 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.
  74067. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74068. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  74069. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  74070. * * 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
  74071. * * It must returns a float value that will be the scale value applied to the shape on each path point
  74072. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  74073. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  74074. * * 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
  74075. * * 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
  74076. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  74077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74081. * @param name defines the name of the mesh
  74082. * @param options defines the options used to create the mesh
  74083. * @param scene defines the hosting scene
  74084. * @returns the custom extruded shape mesh
  74085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  74086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74088. */
  74089. static ExtrudeShapeCustom(name: string, options: {
  74090. shape: Vector3[];
  74091. path: Vector3[];
  74092. scaleFunction?: any;
  74093. rotationFunction?: any;
  74094. ribbonCloseArray?: boolean;
  74095. ribbonClosePath?: boolean;
  74096. cap?: number;
  74097. updatable?: boolean;
  74098. sideOrientation?: number;
  74099. frontUVs?: Vector4;
  74100. backUVs?: Vector4;
  74101. instance?: Mesh;
  74102. invertUV?: boolean;
  74103. }, scene?: Nullable<Scene>): Mesh;
  74104. /**
  74105. * Creates lathe mesh.
  74106. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  74107. * * 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
  74108. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  74109. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  74110. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  74111. * * 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
  74112. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  74113. * * 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
  74114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74118. * @param name defines the name of the mesh
  74119. * @param options defines the options used to create the mesh
  74120. * @param scene defines the hosting scene
  74121. * @returns the lathe mesh
  74122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  74123. */
  74124. static CreateLathe(name: string, options: {
  74125. shape: Vector3[];
  74126. radius?: number;
  74127. tessellation?: number;
  74128. clip?: number;
  74129. arc?: number;
  74130. closed?: boolean;
  74131. updatable?: boolean;
  74132. sideOrientation?: number;
  74133. frontUVs?: Vector4;
  74134. backUVs?: Vector4;
  74135. cap?: number;
  74136. invertUV?: boolean;
  74137. }, scene?: Nullable<Scene>): Mesh;
  74138. /**
  74139. * Creates a tiled plane mesh
  74140. * * You can set a limited pattern arrangement with the tiles
  74141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74144. * @param name defines the name of the mesh
  74145. * @param options defines the options used to create the mesh
  74146. * @param scene defines the hosting scene
  74147. * @returns the plane mesh
  74148. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74149. */
  74150. static CreateTiledPlane(name: string, options: {
  74151. pattern?: number;
  74152. tileSize?: number;
  74153. tileWidth?: number;
  74154. tileHeight?: number;
  74155. size?: number;
  74156. width?: number;
  74157. height?: number;
  74158. alignHorizontal?: number;
  74159. alignVertical?: number;
  74160. sideOrientation?: number;
  74161. frontUVs?: Vector4;
  74162. backUVs?: Vector4;
  74163. updatable?: boolean;
  74164. }, scene?: Nullable<Scene>): Mesh;
  74165. /**
  74166. * Creates a plane mesh
  74167. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  74168. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  74169. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  74170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74173. * @param name defines the name of the mesh
  74174. * @param options defines the options used to create the mesh
  74175. * @param scene defines the hosting scene
  74176. * @returns the plane mesh
  74177. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74178. */
  74179. static CreatePlane(name: string, options: {
  74180. size?: number;
  74181. width?: number;
  74182. height?: number;
  74183. sideOrientation?: number;
  74184. frontUVs?: Vector4;
  74185. backUVs?: Vector4;
  74186. updatable?: boolean;
  74187. sourcePlane?: Plane;
  74188. }, scene?: Nullable<Scene>): Mesh;
  74189. /**
  74190. * Creates a ground mesh
  74191. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  74192. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  74193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74194. * @param name defines the name of the mesh
  74195. * @param options defines the options used to create the mesh
  74196. * @param scene defines the hosting scene
  74197. * @returns the ground mesh
  74198. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  74199. */
  74200. static CreateGround(name: string, options: {
  74201. width?: number;
  74202. height?: number;
  74203. subdivisions?: number;
  74204. subdivisionsX?: number;
  74205. subdivisionsY?: number;
  74206. updatable?: boolean;
  74207. }, scene?: Nullable<Scene>): Mesh;
  74208. /**
  74209. * Creates a tiled ground mesh
  74210. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  74211. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  74212. * * 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
  74213. * * 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
  74214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74215. * @param name defines the name of the mesh
  74216. * @param options defines the options used to create the mesh
  74217. * @param scene defines the hosting scene
  74218. * @returns the tiled ground mesh
  74219. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  74220. */
  74221. static CreateTiledGround(name: string, options: {
  74222. xmin: number;
  74223. zmin: number;
  74224. xmax: number;
  74225. zmax: number;
  74226. subdivisions?: {
  74227. w: number;
  74228. h: number;
  74229. };
  74230. precision?: {
  74231. w: number;
  74232. h: number;
  74233. };
  74234. updatable?: boolean;
  74235. }, scene?: Nullable<Scene>): Mesh;
  74236. /**
  74237. * Creates a ground mesh from a height map
  74238. * * The parameter `url` sets the URL of the height map image resource.
  74239. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  74240. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  74241. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  74242. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  74243. * * 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.
  74244. * * 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).
  74245. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  74246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74247. * @param name defines the name of the mesh
  74248. * @param url defines the url to the height map
  74249. * @param options defines the options used to create the mesh
  74250. * @param scene defines the hosting scene
  74251. * @returns the ground mesh
  74252. * @see https://doc.babylonjs.com/babylon101/height_map
  74253. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  74254. */
  74255. static CreateGroundFromHeightMap(name: string, url: string, options: {
  74256. width?: number;
  74257. height?: number;
  74258. subdivisions?: number;
  74259. minHeight?: number;
  74260. maxHeight?: number;
  74261. colorFilter?: Color3;
  74262. alphaFilter?: number;
  74263. updatable?: boolean;
  74264. onReady?: (mesh: GroundMesh) => void;
  74265. }, scene?: Nullable<Scene>): GroundMesh;
  74266. /**
  74267. * Creates a polygon mesh
  74268. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  74269. * * 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
  74270. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  74271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  74273. * * Remember you can only change the shape positions, not their number when updating a polygon
  74274. * @param name defines the name of the mesh
  74275. * @param options defines the options used to create the mesh
  74276. * @param scene defines the hosting scene
  74277. * @param earcutInjection can be used to inject your own earcut reference
  74278. * @returns the polygon mesh
  74279. */
  74280. static CreatePolygon(name: string, options: {
  74281. shape: Vector3[];
  74282. holes?: Vector3[][];
  74283. depth?: number;
  74284. faceUV?: Vector4[];
  74285. faceColors?: Color4[];
  74286. updatable?: boolean;
  74287. sideOrientation?: number;
  74288. frontUVs?: Vector4;
  74289. backUVs?: Vector4;
  74290. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74291. /**
  74292. * Creates an extruded polygon mesh, with depth in the Y direction.
  74293. * * 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)
  74294. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74295. * @param name defines the name of the mesh
  74296. * @param options defines the options used to create the mesh
  74297. * @param scene defines the hosting scene
  74298. * @param earcutInjection can be used to inject your own earcut reference
  74299. * @returns the polygon mesh
  74300. */
  74301. static ExtrudePolygon(name: string, options: {
  74302. shape: Vector3[];
  74303. holes?: Vector3[][];
  74304. depth?: number;
  74305. faceUV?: Vector4[];
  74306. faceColors?: Color4[];
  74307. updatable?: boolean;
  74308. sideOrientation?: number;
  74309. frontUVs?: Vector4;
  74310. backUVs?: Vector4;
  74311. wrap?: boolean;
  74312. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74313. /**
  74314. * Creates a tube mesh.
  74315. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74316. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74317. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74318. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74319. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  74320. * * 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)
  74321. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74322. * * 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
  74323. * * 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
  74324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74328. * @param name defines the name of the mesh
  74329. * @param options defines the options used to create the mesh
  74330. * @param scene defines the hosting scene
  74331. * @returns the tube mesh
  74332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74333. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74334. */
  74335. static CreateTube(name: string, options: {
  74336. path: Vector3[];
  74337. radius?: number;
  74338. tessellation?: number;
  74339. radiusFunction?: {
  74340. (i: number, distance: number): number;
  74341. };
  74342. cap?: number;
  74343. arc?: number;
  74344. updatable?: boolean;
  74345. sideOrientation?: number;
  74346. frontUVs?: Vector4;
  74347. backUVs?: Vector4;
  74348. instance?: Mesh;
  74349. invertUV?: boolean;
  74350. }, scene?: Nullable<Scene>): Mesh;
  74351. /**
  74352. * Creates a polyhedron mesh
  74353. * * 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
  74354. * * The parameter `size` (positive float, default 1) sets the polygon size
  74355. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  74356. * * 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`
  74357. * * 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
  74358. * * 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)`)
  74359. * * 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
  74360. * * 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
  74361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74364. * @param name defines the name of the mesh
  74365. * @param options defines the options used to create the mesh
  74366. * @param scene defines the hosting scene
  74367. * @returns the polyhedron mesh
  74368. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  74369. */
  74370. static CreatePolyhedron(name: string, options: {
  74371. type?: number;
  74372. size?: number;
  74373. sizeX?: number;
  74374. sizeY?: number;
  74375. sizeZ?: number;
  74376. custom?: any;
  74377. faceUV?: Vector4[];
  74378. faceColors?: Color4[];
  74379. flat?: boolean;
  74380. updatable?: boolean;
  74381. sideOrientation?: number;
  74382. frontUVs?: Vector4;
  74383. backUVs?: Vector4;
  74384. }, scene?: Nullable<Scene>): Mesh;
  74385. /**
  74386. * Creates a decal mesh.
  74387. * 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
  74388. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74389. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74390. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74391. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74392. * @param name defines the name of the mesh
  74393. * @param sourceMesh defines the mesh where the decal must be applied
  74394. * @param options defines the options used to create the mesh
  74395. * @param scene defines the hosting scene
  74396. * @returns the decal mesh
  74397. * @see https://doc.babylonjs.com/how_to/decals
  74398. */
  74399. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74400. position?: Vector3;
  74401. normal?: Vector3;
  74402. size?: Vector3;
  74403. angle?: number;
  74404. }): Mesh;
  74405. /**
  74406. * Creates a Capsule Mesh
  74407. * @param name defines the name of the mesh.
  74408. * @param options the constructors options used to shape the mesh.
  74409. * @param scene defines the scene the mesh is scoped to.
  74410. * @returns the capsule mesh
  74411. * @see https://doc.babylonjs.com/how_to/capsule_shape
  74412. */
  74413. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  74414. }
  74415. }
  74416. declare module "babylonjs/Meshes/meshSimplification" {
  74417. import { Mesh } from "babylonjs/Meshes/mesh";
  74418. /**
  74419. * A simplifier interface for future simplification implementations
  74420. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74421. */
  74422. export interface ISimplifier {
  74423. /**
  74424. * Simplification of a given mesh according to the given settings.
  74425. * Since this requires computation, it is assumed that the function runs async.
  74426. * @param settings The settings of the simplification, including quality and distance
  74427. * @param successCallback A callback that will be called after the mesh was simplified.
  74428. * @param errorCallback in case of an error, this callback will be called. optional.
  74429. */
  74430. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  74431. }
  74432. /**
  74433. * Expected simplification settings.
  74434. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  74435. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74436. */
  74437. export interface ISimplificationSettings {
  74438. /**
  74439. * Gets or sets the expected quality
  74440. */
  74441. quality: number;
  74442. /**
  74443. * Gets or sets the distance when this optimized version should be used
  74444. */
  74445. distance: number;
  74446. /**
  74447. * Gets an already optimized mesh
  74448. */
  74449. optimizeMesh?: boolean;
  74450. }
  74451. /**
  74452. * Class used to specify simplification options
  74453. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74454. */
  74455. export class SimplificationSettings implements ISimplificationSettings {
  74456. /** expected quality */
  74457. quality: number;
  74458. /** distance when this optimized version should be used */
  74459. distance: number;
  74460. /** already optimized mesh */
  74461. optimizeMesh?: boolean | undefined;
  74462. /**
  74463. * Creates a SimplificationSettings
  74464. * @param quality expected quality
  74465. * @param distance distance when this optimized version should be used
  74466. * @param optimizeMesh already optimized mesh
  74467. */
  74468. constructor(
  74469. /** expected quality */
  74470. quality: number,
  74471. /** distance when this optimized version should be used */
  74472. distance: number,
  74473. /** already optimized mesh */
  74474. optimizeMesh?: boolean | undefined);
  74475. }
  74476. /**
  74477. * Interface used to define a simplification task
  74478. */
  74479. export interface ISimplificationTask {
  74480. /**
  74481. * Array of settings
  74482. */
  74483. settings: Array<ISimplificationSettings>;
  74484. /**
  74485. * Simplification type
  74486. */
  74487. simplificationType: SimplificationType;
  74488. /**
  74489. * Mesh to simplify
  74490. */
  74491. mesh: Mesh;
  74492. /**
  74493. * Callback called on success
  74494. */
  74495. successCallback?: () => void;
  74496. /**
  74497. * Defines if parallel processing can be used
  74498. */
  74499. parallelProcessing: boolean;
  74500. }
  74501. /**
  74502. * Queue used to order the simplification tasks
  74503. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74504. */
  74505. export class SimplificationQueue {
  74506. private _simplificationArray;
  74507. /**
  74508. * Gets a boolean indicating that the process is still running
  74509. */
  74510. running: boolean;
  74511. /**
  74512. * Creates a new queue
  74513. */
  74514. constructor();
  74515. /**
  74516. * Adds a new simplification task
  74517. * @param task defines a task to add
  74518. */
  74519. addTask(task: ISimplificationTask): void;
  74520. /**
  74521. * Execute next task
  74522. */
  74523. executeNext(): void;
  74524. /**
  74525. * Execute a simplification task
  74526. * @param task defines the task to run
  74527. */
  74528. runSimplification(task: ISimplificationTask): void;
  74529. private getSimplifier;
  74530. }
  74531. /**
  74532. * The implemented types of simplification
  74533. * At the moment only Quadratic Error Decimation is implemented
  74534. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74535. */
  74536. export enum SimplificationType {
  74537. /** Quadratic error decimation */
  74538. QUADRATIC = 0
  74539. }
  74540. /**
  74541. * An implementation of the Quadratic Error simplification algorithm.
  74542. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  74543. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  74544. * @author RaananW
  74545. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74546. */
  74547. export class QuadraticErrorSimplification implements ISimplifier {
  74548. private _mesh;
  74549. private triangles;
  74550. private vertices;
  74551. private references;
  74552. private _reconstructedMesh;
  74553. /** Gets or sets the number pf sync interations */
  74554. syncIterations: number;
  74555. /** Gets or sets the aggressiveness of the simplifier */
  74556. aggressiveness: number;
  74557. /** Gets or sets the number of allowed iterations for decimation */
  74558. decimationIterations: number;
  74559. /** Gets or sets the espilon to use for bounding box computation */
  74560. boundingBoxEpsilon: number;
  74561. /**
  74562. * Creates a new QuadraticErrorSimplification
  74563. * @param _mesh defines the target mesh
  74564. */
  74565. constructor(_mesh: Mesh);
  74566. /**
  74567. * Simplification of a given mesh according to the given settings.
  74568. * Since this requires computation, it is assumed that the function runs async.
  74569. * @param settings The settings of the simplification, including quality and distance
  74570. * @param successCallback A callback that will be called after the mesh was simplified.
  74571. */
  74572. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  74573. private runDecimation;
  74574. private initWithMesh;
  74575. private init;
  74576. private reconstructMesh;
  74577. private initDecimatedMesh;
  74578. private isFlipped;
  74579. private updateTriangles;
  74580. private identifyBorder;
  74581. private updateMesh;
  74582. private vertexError;
  74583. private calculateError;
  74584. }
  74585. }
  74586. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  74587. import { Scene } from "babylonjs/scene";
  74588. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  74589. import { ISceneComponent } from "babylonjs/sceneComponent";
  74590. module "babylonjs/scene" {
  74591. interface Scene {
  74592. /** @hidden (Backing field) */
  74593. _simplificationQueue: SimplificationQueue;
  74594. /**
  74595. * Gets or sets the simplification queue attached to the scene
  74596. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74597. */
  74598. simplificationQueue: SimplificationQueue;
  74599. }
  74600. }
  74601. module "babylonjs/Meshes/mesh" {
  74602. interface Mesh {
  74603. /**
  74604. * Simplify the mesh according to the given array of settings.
  74605. * Function will return immediately and will simplify async
  74606. * @param settings a collection of simplification settings
  74607. * @param parallelProcessing should all levels calculate parallel or one after the other
  74608. * @param simplificationType the type of simplification to run
  74609. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  74610. * @returns the current mesh
  74611. */
  74612. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  74613. }
  74614. }
  74615. /**
  74616. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  74617. * created in a scene
  74618. */
  74619. export class SimplicationQueueSceneComponent implements ISceneComponent {
  74620. /**
  74621. * The component name helpfull to identify the component in the list of scene components.
  74622. */
  74623. readonly name: string;
  74624. /**
  74625. * The scene the component belongs to.
  74626. */
  74627. scene: Scene;
  74628. /**
  74629. * Creates a new instance of the component for the given scene
  74630. * @param scene Defines the scene to register the component in
  74631. */
  74632. constructor(scene: Scene);
  74633. /**
  74634. * Registers the component in a given scene
  74635. */
  74636. register(): void;
  74637. /**
  74638. * Rebuilds the elements related to this component in case of
  74639. * context lost for instance.
  74640. */
  74641. rebuild(): void;
  74642. /**
  74643. * Disposes the component and the associated ressources
  74644. */
  74645. dispose(): void;
  74646. private _beforeCameraUpdate;
  74647. }
  74648. }
  74649. declare module "babylonjs/Meshes/Builders/index" {
  74650. export * from "babylonjs/Meshes/Builders/boxBuilder";
  74651. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  74652. export * from "babylonjs/Meshes/Builders/discBuilder";
  74653. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  74654. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  74655. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  74656. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  74657. export * from "babylonjs/Meshes/Builders/torusBuilder";
  74658. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  74659. export * from "babylonjs/Meshes/Builders/linesBuilder";
  74660. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  74661. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  74662. export * from "babylonjs/Meshes/Builders/latheBuilder";
  74663. export * from "babylonjs/Meshes/Builders/planeBuilder";
  74664. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  74665. export * from "babylonjs/Meshes/Builders/groundBuilder";
  74666. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  74667. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  74668. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74669. export * from "babylonjs/Meshes/Builders/decalBuilder";
  74670. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74671. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  74672. }
  74673. declare module "babylonjs/Meshes/thinInstanceMesh" {
  74674. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  74675. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  74676. import { Matrix } from "babylonjs/Maths/math.vector";
  74677. module "babylonjs/Meshes/mesh" {
  74678. interface Mesh {
  74679. /**
  74680. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  74681. */
  74682. thinInstanceEnablePicking: boolean;
  74683. /**
  74684. * Creates a new thin instance
  74685. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  74686. * @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
  74687. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  74688. */
  74689. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  74690. /**
  74691. * Adds the transformation (matrix) of the current mesh as a thin instance
  74692. * @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
  74693. * @returns the thin instance index number
  74694. */
  74695. thinInstanceAddSelf(refresh: boolean): number;
  74696. /**
  74697. * Registers a custom attribute to be used with thin instances
  74698. * @param kind name of the attribute
  74699. * @param stride size in floats of the attribute
  74700. */
  74701. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  74702. /**
  74703. * Sets the matrix of a thin instance
  74704. * @param index index of the thin instance
  74705. * @param matrix matrix to set
  74706. * @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
  74707. */
  74708. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  74709. /**
  74710. * Sets the value of a custom attribute for a thin instance
  74711. * @param kind name of the attribute
  74712. * @param index index of the thin instance
  74713. * @param value value to set
  74714. * @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
  74715. */
  74716. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  74717. /**
  74718. * 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.
  74719. */
  74720. thinInstanceCount: number;
  74721. /**
  74722. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  74723. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  74724. * @param buffer buffer to set
  74725. * @param stride size in floats of each value of the buffer
  74726. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  74727. */
  74728. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  74729. /**
  74730. * Gets the list of world matrices
  74731. * @return an array containing all the world matrices from the thin instances
  74732. */
  74733. thinInstanceGetWorldMatrices(): Matrix[];
  74734. /**
  74735. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  74736. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74737. */
  74738. thinInstanceBufferUpdated(kind: string): void;
  74739. /**
  74740. * Applies a partial update to a buffer directly on the GPU
  74741. * 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
  74742. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74743. * @param data the data to set in the GPU buffer
  74744. * @param offset the offset in the GPU buffer where to update the data
  74745. */
  74746. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  74747. /**
  74748. * Refreshes the bounding info, taking into account all the thin instances defined
  74749. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  74750. */
  74751. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  74752. /** @hidden */
  74753. _thinInstanceInitializeUserStorage(): void;
  74754. /** @hidden */
  74755. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  74756. /** @hidden */
  74757. _userThinInstanceBuffersStorage: {
  74758. data: {
  74759. [key: string]: Float32Array;
  74760. };
  74761. sizes: {
  74762. [key: string]: number;
  74763. };
  74764. vertexBuffers: {
  74765. [key: string]: Nullable<VertexBuffer>;
  74766. };
  74767. strides: {
  74768. [key: string]: number;
  74769. };
  74770. };
  74771. }
  74772. }
  74773. }
  74774. declare module "babylonjs/Meshes/index" {
  74775. export * from "babylonjs/Meshes/abstractMesh";
  74776. export * from "babylonjs/Meshes/buffer";
  74777. export * from "babylonjs/Meshes/Compression/index";
  74778. export * from "babylonjs/Meshes/csg";
  74779. export * from "babylonjs/Meshes/geometry";
  74780. export * from "babylonjs/Meshes/groundMesh";
  74781. export * from "babylonjs/Meshes/trailMesh";
  74782. export * from "babylonjs/Meshes/instancedMesh";
  74783. export * from "babylonjs/Meshes/linesMesh";
  74784. export * from "babylonjs/Meshes/mesh";
  74785. export * from "babylonjs/Meshes/mesh.vertexData";
  74786. export * from "babylonjs/Meshes/meshBuilder";
  74787. export * from "babylonjs/Meshes/meshSimplification";
  74788. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  74789. export * from "babylonjs/Meshes/polygonMesh";
  74790. export * from "babylonjs/Meshes/subMesh";
  74791. export * from "babylonjs/Meshes/meshLODLevel";
  74792. export * from "babylonjs/Meshes/transformNode";
  74793. export * from "babylonjs/Meshes/Builders/index";
  74794. export * from "babylonjs/Meshes/dataBuffer";
  74795. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  74796. export * from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  74797. import "babylonjs/Meshes/thinInstanceMesh";
  74798. export * from "babylonjs/Meshes/thinInstanceMesh";
  74799. }
  74800. declare module "babylonjs/Morph/index" {
  74801. export * from "babylonjs/Morph/morphTarget";
  74802. export * from "babylonjs/Morph/morphTargetManager";
  74803. }
  74804. declare module "babylonjs/Navigation/INavigationEngine" {
  74805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74806. import { Vector3 } from "babylonjs/Maths/math";
  74807. import { Mesh } from "babylonjs/Meshes/mesh";
  74808. import { Scene } from "babylonjs/scene";
  74809. /**
  74810. * Navigation plugin interface to add navigation constrained by a navigation mesh
  74811. */
  74812. export interface INavigationEnginePlugin {
  74813. /**
  74814. * plugin name
  74815. */
  74816. name: string;
  74817. /**
  74818. * Creates a navigation mesh
  74819. * @param meshes array of all the geometry used to compute the navigatio mesh
  74820. * @param parameters bunch of parameters used to filter geometry
  74821. */
  74822. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74823. /**
  74824. * Create a navigation mesh debug mesh
  74825. * @param scene is where the mesh will be added
  74826. * @returns debug display mesh
  74827. */
  74828. createDebugNavMesh(scene: Scene): Mesh;
  74829. /**
  74830. * Get a navigation mesh constrained position, closest to the parameter position
  74831. * @param position world position
  74832. * @returns the closest point to position constrained by the navigation mesh
  74833. */
  74834. getClosestPoint(position: Vector3): Vector3;
  74835. /**
  74836. * Get a navigation mesh constrained position, closest to the parameter position
  74837. * @param position world position
  74838. * @param result output the closest point to position constrained by the navigation mesh
  74839. */
  74840. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74841. /**
  74842. * Get a navigation mesh constrained position, within a particular radius
  74843. * @param position world position
  74844. * @param maxRadius the maximum distance to the constrained world position
  74845. * @returns the closest point to position constrained by the navigation mesh
  74846. */
  74847. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74848. /**
  74849. * Get a navigation mesh constrained position, within a particular radius
  74850. * @param position world position
  74851. * @param maxRadius the maximum distance to the constrained world position
  74852. * @param result output the closest point to position constrained by the navigation mesh
  74853. */
  74854. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74855. /**
  74856. * Compute the final position from a segment made of destination-position
  74857. * @param position world position
  74858. * @param destination world position
  74859. * @returns the resulting point along the navmesh
  74860. */
  74861. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74862. /**
  74863. * Compute the final position from a segment made of destination-position
  74864. * @param position world position
  74865. * @param destination world position
  74866. * @param result output the resulting point along the navmesh
  74867. */
  74868. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74869. /**
  74870. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74871. * @param start world position
  74872. * @param end world position
  74873. * @returns array containing world position composing the path
  74874. */
  74875. computePath(start: Vector3, end: Vector3): Vector3[];
  74876. /**
  74877. * If this plugin is supported
  74878. * @returns true if plugin is supported
  74879. */
  74880. isSupported(): boolean;
  74881. /**
  74882. * Create a new Crowd so you can add agents
  74883. * @param maxAgents the maximum agent count in the crowd
  74884. * @param maxAgentRadius the maximum radius an agent can have
  74885. * @param scene to attach the crowd to
  74886. * @returns the crowd you can add agents to
  74887. */
  74888. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  74889. /**
  74890. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74891. * The queries will try to find a solution within those bounds
  74892. * default is (1,1,1)
  74893. * @param extent x,y,z value that define the extent around the queries point of reference
  74894. */
  74895. setDefaultQueryExtent(extent: Vector3): void;
  74896. /**
  74897. * Get the Bounding box extent specified by setDefaultQueryExtent
  74898. * @returns the box extent values
  74899. */
  74900. getDefaultQueryExtent(): Vector3;
  74901. /**
  74902. * build the navmesh from a previously saved state using getNavmeshData
  74903. * @param data the Uint8Array returned by getNavmeshData
  74904. */
  74905. buildFromNavmeshData(data: Uint8Array): void;
  74906. /**
  74907. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  74908. * @returns data the Uint8Array that can be saved and reused
  74909. */
  74910. getNavmeshData(): Uint8Array;
  74911. /**
  74912. * Get the Bounding box extent result specified by setDefaultQueryExtent
  74913. * @param result output the box extent values
  74914. */
  74915. getDefaultQueryExtentToRef(result: Vector3): void;
  74916. /**
  74917. * Set the time step of the navigation tick update.
  74918. * Default is 1/60.
  74919. * A value of 0 will disable fixed time update
  74920. * @param newTimeStep the new timestep to apply to this world.
  74921. */
  74922. setTimeStep(newTimeStep: number): void;
  74923. /**
  74924. * Get the time step of the navigation tick update.
  74925. * @returns the current time step
  74926. */
  74927. getTimeStep(): number;
  74928. /**
  74929. * If delta time in navigation tick update is greater than the time step
  74930. * a number of sub iterations are done. If more iterations are need to reach deltatime
  74931. * they will be discarded.
  74932. * A value of 0 will set to no maximum and update will use as many substeps as needed
  74933. * @param newStepCount the maximum number of iterations
  74934. */
  74935. setMaximumSubStepCount(newStepCount: number): void;
  74936. /**
  74937. * Get the maximum number of iterations per navigation tick update
  74938. * @returns the maximum number of iterations
  74939. */
  74940. getMaximumSubStepCount(): number;
  74941. /**
  74942. * Release all resources
  74943. */
  74944. dispose(): void;
  74945. }
  74946. /**
  74947. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  74948. */
  74949. export interface ICrowd {
  74950. /**
  74951. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  74952. * You can attach anything to that node. The node position is updated in the scene update tick.
  74953. * @param pos world position that will be constrained by the navigation mesh
  74954. * @param parameters agent parameters
  74955. * @param transform hooked to the agent that will be update by the scene
  74956. * @returns agent index
  74957. */
  74958. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  74959. /**
  74960. * Returns the agent position in world space
  74961. * @param index agent index returned by addAgent
  74962. * @returns world space position
  74963. */
  74964. getAgentPosition(index: number): Vector3;
  74965. /**
  74966. * Gets the agent position result in world space
  74967. * @param index agent index returned by addAgent
  74968. * @param result output world space position
  74969. */
  74970. getAgentPositionToRef(index: number, result: Vector3): void;
  74971. /**
  74972. * Gets the agent velocity in world space
  74973. * @param index agent index returned by addAgent
  74974. * @returns world space velocity
  74975. */
  74976. getAgentVelocity(index: number): Vector3;
  74977. /**
  74978. * Gets the agent velocity result in world space
  74979. * @param index agent index returned by addAgent
  74980. * @param result output world space velocity
  74981. */
  74982. getAgentVelocityToRef(index: number, result: Vector3): void;
  74983. /**
  74984. * Gets the agent next target point on the path
  74985. * @param index agent index returned by addAgent
  74986. * @returns world space position
  74987. */
  74988. getAgentNextTargetPath(index: number): Vector3;
  74989. /**
  74990. * Gets the agent state
  74991. * @param index agent index returned by addAgent
  74992. * @returns agent state
  74993. */
  74994. getAgentState(index: number): number;
  74995. /**
  74996. * returns true if the agent in over an off mesh link connection
  74997. * @param index agent index returned by addAgent
  74998. * @returns true if over an off mesh link connection
  74999. */
  75000. overOffmeshConnection(index: number): boolean;
  75001. /**
  75002. * Gets the agent next target point on the path
  75003. * @param index agent index returned by addAgent
  75004. * @param result output world space position
  75005. */
  75006. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75007. /**
  75008. * remove a particular agent previously created
  75009. * @param index agent index returned by addAgent
  75010. */
  75011. removeAgent(index: number): void;
  75012. /**
  75013. * get the list of all agents attached to this crowd
  75014. * @returns list of agent indices
  75015. */
  75016. getAgents(): number[];
  75017. /**
  75018. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75019. * @param deltaTime in seconds
  75020. */
  75021. update(deltaTime: number): void;
  75022. /**
  75023. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75024. * @param index agent index returned by addAgent
  75025. * @param destination targeted world position
  75026. */
  75027. agentGoto(index: number, destination: Vector3): void;
  75028. /**
  75029. * Teleport the agent to a new position
  75030. * @param index agent index returned by addAgent
  75031. * @param destination targeted world position
  75032. */
  75033. agentTeleport(index: number, destination: Vector3): void;
  75034. /**
  75035. * Update agent parameters
  75036. * @param index agent index returned by addAgent
  75037. * @param parameters agent parameters
  75038. */
  75039. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75040. /**
  75041. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75042. * The queries will try to find a solution within those bounds
  75043. * default is (1,1,1)
  75044. * @param extent x,y,z value that define the extent around the queries point of reference
  75045. */
  75046. setDefaultQueryExtent(extent: Vector3): void;
  75047. /**
  75048. * Get the Bounding box extent specified by setDefaultQueryExtent
  75049. * @returns the box extent values
  75050. */
  75051. getDefaultQueryExtent(): Vector3;
  75052. /**
  75053. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75054. * @param result output the box extent values
  75055. */
  75056. getDefaultQueryExtentToRef(result: Vector3): void;
  75057. /**
  75058. * Release all resources
  75059. */
  75060. dispose(): void;
  75061. }
  75062. /**
  75063. * Configures an agent
  75064. */
  75065. export interface IAgentParameters {
  75066. /**
  75067. * Agent radius. [Limit: >= 0]
  75068. */
  75069. radius: number;
  75070. /**
  75071. * Agent height. [Limit: > 0]
  75072. */
  75073. height: number;
  75074. /**
  75075. * Maximum allowed acceleration. [Limit: >= 0]
  75076. */
  75077. maxAcceleration: number;
  75078. /**
  75079. * Maximum allowed speed. [Limit: >= 0]
  75080. */
  75081. maxSpeed: number;
  75082. /**
  75083. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  75084. */
  75085. collisionQueryRange: number;
  75086. /**
  75087. * The path visibility optimization range. [Limit: > 0]
  75088. */
  75089. pathOptimizationRange: number;
  75090. /**
  75091. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  75092. */
  75093. separationWeight: number;
  75094. }
  75095. /**
  75096. * Configures the navigation mesh creation
  75097. */
  75098. export interface INavMeshParameters {
  75099. /**
  75100. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  75101. */
  75102. cs: number;
  75103. /**
  75104. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  75105. */
  75106. ch: number;
  75107. /**
  75108. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  75109. */
  75110. walkableSlopeAngle: number;
  75111. /**
  75112. * Minimum floor to 'ceiling' height that will still allow the floor area to
  75113. * be considered walkable. [Limit: >= 3] [Units: vx]
  75114. */
  75115. walkableHeight: number;
  75116. /**
  75117. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  75118. */
  75119. walkableClimb: number;
  75120. /**
  75121. * The distance to erode/shrink the walkable area of the heightfield away from
  75122. * obstructions. [Limit: >=0] [Units: vx]
  75123. */
  75124. walkableRadius: number;
  75125. /**
  75126. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  75127. */
  75128. maxEdgeLen: number;
  75129. /**
  75130. * The maximum distance a simplfied contour's border edges should deviate
  75131. * the original raw contour. [Limit: >=0] [Units: vx]
  75132. */
  75133. maxSimplificationError: number;
  75134. /**
  75135. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  75136. */
  75137. minRegionArea: number;
  75138. /**
  75139. * Any regions with a span count smaller than this value will, if possible,
  75140. * be merged with larger regions. [Limit: >=0] [Units: vx]
  75141. */
  75142. mergeRegionArea: number;
  75143. /**
  75144. * The maximum number of vertices allowed for polygons generated during the
  75145. * contour to polygon conversion process. [Limit: >= 3]
  75146. */
  75147. maxVertsPerPoly: number;
  75148. /**
  75149. * Sets the sampling distance to use when generating the detail mesh.
  75150. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  75151. */
  75152. detailSampleDist: number;
  75153. /**
  75154. * The maximum distance the detail mesh surface should deviate from heightfield
  75155. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  75156. */
  75157. detailSampleMaxError: number;
  75158. }
  75159. }
  75160. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  75161. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  75162. import { Mesh } from "babylonjs/Meshes/mesh";
  75163. import { Scene } from "babylonjs/scene";
  75164. import { Vector3 } from "babylonjs/Maths/math";
  75165. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75166. /**
  75167. * RecastJS navigation plugin
  75168. */
  75169. export class RecastJSPlugin implements INavigationEnginePlugin {
  75170. /**
  75171. * Reference to the Recast library
  75172. */
  75173. bjsRECAST: any;
  75174. /**
  75175. * plugin name
  75176. */
  75177. name: string;
  75178. /**
  75179. * the first navmesh created. We might extend this to support multiple navmeshes
  75180. */
  75181. navMesh: any;
  75182. private _maximumSubStepCount;
  75183. private _timeStep;
  75184. /**
  75185. * Initializes the recastJS plugin
  75186. * @param recastInjection can be used to inject your own recast reference
  75187. */
  75188. constructor(recastInjection?: any);
  75189. /**
  75190. * Set the time step of the navigation tick update.
  75191. * Default is 1/60.
  75192. * A value of 0 will disable fixed time update
  75193. * @param newTimeStep the new timestep to apply to this world.
  75194. */
  75195. setTimeStep(newTimeStep?: number): void;
  75196. /**
  75197. * Get the time step of the navigation tick update.
  75198. * @returns the current time step
  75199. */
  75200. getTimeStep(): number;
  75201. /**
  75202. * If delta time in navigation tick update is greater than the time step
  75203. * a number of sub iterations are done. If more iterations are need to reach deltatime
  75204. * they will be discarded.
  75205. * A value of 0 will set to no maximum and update will use as many substeps as needed
  75206. * @param newStepCount the maximum number of iterations
  75207. */
  75208. setMaximumSubStepCount(newStepCount?: number): void;
  75209. /**
  75210. * Get the maximum number of iterations per navigation tick update
  75211. * @returns the maximum number of iterations
  75212. */
  75213. getMaximumSubStepCount(): number;
  75214. /**
  75215. * Creates a navigation mesh
  75216. * @param meshes array of all the geometry used to compute the navigatio mesh
  75217. * @param parameters bunch of parameters used to filter geometry
  75218. */
  75219. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  75220. /**
  75221. * Create a navigation mesh debug mesh
  75222. * @param scene is where the mesh will be added
  75223. * @returns debug display mesh
  75224. */
  75225. createDebugNavMesh(scene: Scene): Mesh;
  75226. /**
  75227. * Get a navigation mesh constrained position, closest to the parameter position
  75228. * @param position world position
  75229. * @returns the closest point to position constrained by the navigation mesh
  75230. */
  75231. getClosestPoint(position: Vector3): Vector3;
  75232. /**
  75233. * Get a navigation mesh constrained position, closest to the parameter position
  75234. * @param position world position
  75235. * @param result output the closest point to position constrained by the navigation mesh
  75236. */
  75237. getClosestPointToRef(position: Vector3, result: Vector3): void;
  75238. /**
  75239. * Get a navigation mesh constrained position, within a particular radius
  75240. * @param position world position
  75241. * @param maxRadius the maximum distance to the constrained world position
  75242. * @returns the closest point to position constrained by the navigation mesh
  75243. */
  75244. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  75245. /**
  75246. * Get a navigation mesh constrained position, within a particular radius
  75247. * @param position world position
  75248. * @param maxRadius the maximum distance to the constrained world position
  75249. * @param result output the closest point to position constrained by the navigation mesh
  75250. */
  75251. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  75252. /**
  75253. * Compute the final position from a segment made of destination-position
  75254. * @param position world position
  75255. * @param destination world position
  75256. * @returns the resulting point along the navmesh
  75257. */
  75258. moveAlong(position: Vector3, destination: Vector3): Vector3;
  75259. /**
  75260. * Compute the final position from a segment made of destination-position
  75261. * @param position world position
  75262. * @param destination world position
  75263. * @param result output the resulting point along the navmesh
  75264. */
  75265. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  75266. /**
  75267. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  75268. * @param start world position
  75269. * @param end world position
  75270. * @returns array containing world position composing the path
  75271. */
  75272. computePath(start: Vector3, end: Vector3): Vector3[];
  75273. /**
  75274. * Create a new Crowd so you can add agents
  75275. * @param maxAgents the maximum agent count in the crowd
  75276. * @param maxAgentRadius the maximum radius an agent can have
  75277. * @param scene to attach the crowd to
  75278. * @returns the crowd you can add agents to
  75279. */
  75280. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  75281. /**
  75282. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75283. * The queries will try to find a solution within those bounds
  75284. * default is (1,1,1)
  75285. * @param extent x,y,z value that define the extent around the queries point of reference
  75286. */
  75287. setDefaultQueryExtent(extent: Vector3): void;
  75288. /**
  75289. * Get the Bounding box extent specified by setDefaultQueryExtent
  75290. * @returns the box extent values
  75291. */
  75292. getDefaultQueryExtent(): Vector3;
  75293. /**
  75294. * build the navmesh from a previously saved state using getNavmeshData
  75295. * @param data the Uint8Array returned by getNavmeshData
  75296. */
  75297. buildFromNavmeshData(data: Uint8Array): void;
  75298. /**
  75299. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75300. * @returns data the Uint8Array that can be saved and reused
  75301. */
  75302. getNavmeshData(): Uint8Array;
  75303. /**
  75304. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75305. * @param result output the box extent values
  75306. */
  75307. getDefaultQueryExtentToRef(result: Vector3): void;
  75308. /**
  75309. * Disposes
  75310. */
  75311. dispose(): void;
  75312. /**
  75313. * If this plugin is supported
  75314. * @returns true if plugin is supported
  75315. */
  75316. isSupported(): boolean;
  75317. }
  75318. /**
  75319. * Recast detour crowd implementation
  75320. */
  75321. export class RecastJSCrowd implements ICrowd {
  75322. /**
  75323. * Recast/detour plugin
  75324. */
  75325. bjsRECASTPlugin: RecastJSPlugin;
  75326. /**
  75327. * Link to the detour crowd
  75328. */
  75329. recastCrowd: any;
  75330. /**
  75331. * One transform per agent
  75332. */
  75333. transforms: TransformNode[];
  75334. /**
  75335. * All agents created
  75336. */
  75337. agents: number[];
  75338. /**
  75339. * Link to the scene is kept to unregister the crowd from the scene
  75340. */
  75341. private _scene;
  75342. /**
  75343. * Observer for crowd updates
  75344. */
  75345. private _onBeforeAnimationsObserver;
  75346. /**
  75347. * Constructor
  75348. * @param plugin recastJS plugin
  75349. * @param maxAgents the maximum agent count in the crowd
  75350. * @param maxAgentRadius the maximum radius an agent can have
  75351. * @param scene to attach the crowd to
  75352. * @returns the crowd you can add agents to
  75353. */
  75354. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  75355. /**
  75356. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75357. * You can attach anything to that node. The node position is updated in the scene update tick.
  75358. * @param pos world position that will be constrained by the navigation mesh
  75359. * @param parameters agent parameters
  75360. * @param transform hooked to the agent that will be update by the scene
  75361. * @returns agent index
  75362. */
  75363. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75364. /**
  75365. * Returns the agent position in world space
  75366. * @param index agent index returned by addAgent
  75367. * @returns world space position
  75368. */
  75369. getAgentPosition(index: number): Vector3;
  75370. /**
  75371. * Returns the agent position result in world space
  75372. * @param index agent index returned by addAgent
  75373. * @param result output world space position
  75374. */
  75375. getAgentPositionToRef(index: number, result: Vector3): void;
  75376. /**
  75377. * Returns the agent velocity in world space
  75378. * @param index agent index returned by addAgent
  75379. * @returns world space velocity
  75380. */
  75381. getAgentVelocity(index: number): Vector3;
  75382. /**
  75383. * Returns the agent velocity result in world space
  75384. * @param index agent index returned by addAgent
  75385. * @param result output world space velocity
  75386. */
  75387. getAgentVelocityToRef(index: number, result: Vector3): void;
  75388. /**
  75389. * Returns the agent next target point on the path
  75390. * @param index agent index returned by addAgent
  75391. * @returns world space position
  75392. */
  75393. getAgentNextTargetPath(index: number): Vector3;
  75394. /**
  75395. * Returns the agent next target point on the path
  75396. * @param index agent index returned by addAgent
  75397. * @param result output world space position
  75398. */
  75399. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75400. /**
  75401. * Gets the agent state
  75402. * @param index agent index returned by addAgent
  75403. * @returns agent state
  75404. */
  75405. getAgentState(index: number): number;
  75406. /**
  75407. * returns true if the agent in over an off mesh link connection
  75408. * @param index agent index returned by addAgent
  75409. * @returns true if over an off mesh link connection
  75410. */
  75411. overOffmeshConnection(index: number): boolean;
  75412. /**
  75413. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75414. * @param index agent index returned by addAgent
  75415. * @param destination targeted world position
  75416. */
  75417. agentGoto(index: number, destination: Vector3): void;
  75418. /**
  75419. * Teleport the agent to a new position
  75420. * @param index agent index returned by addAgent
  75421. * @param destination targeted world position
  75422. */
  75423. agentTeleport(index: number, destination: Vector3): void;
  75424. /**
  75425. * Update agent parameters
  75426. * @param index agent index returned by addAgent
  75427. * @param parameters agent parameters
  75428. */
  75429. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75430. /**
  75431. * remove a particular agent previously created
  75432. * @param index agent index returned by addAgent
  75433. */
  75434. removeAgent(index: number): void;
  75435. /**
  75436. * get the list of all agents attached to this crowd
  75437. * @returns list of agent indices
  75438. */
  75439. getAgents(): number[];
  75440. /**
  75441. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75442. * @param deltaTime in seconds
  75443. */
  75444. update(deltaTime: number): void;
  75445. /**
  75446. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75447. * The queries will try to find a solution within those bounds
  75448. * default is (1,1,1)
  75449. * @param extent x,y,z value that define the extent around the queries point of reference
  75450. */
  75451. setDefaultQueryExtent(extent: Vector3): void;
  75452. /**
  75453. * Get the Bounding box extent specified by setDefaultQueryExtent
  75454. * @returns the box extent values
  75455. */
  75456. getDefaultQueryExtent(): Vector3;
  75457. /**
  75458. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75459. * @param result output the box extent values
  75460. */
  75461. getDefaultQueryExtentToRef(result: Vector3): void;
  75462. /**
  75463. * Release all resources
  75464. */
  75465. dispose(): void;
  75466. }
  75467. }
  75468. declare module "babylonjs/Navigation/Plugins/index" {
  75469. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  75470. }
  75471. declare module "babylonjs/Navigation/index" {
  75472. export * from "babylonjs/Navigation/INavigationEngine";
  75473. export * from "babylonjs/Navigation/Plugins/index";
  75474. }
  75475. declare module "babylonjs/Offline/database" {
  75476. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  75477. /**
  75478. * Class used to enable access to IndexedDB
  75479. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75480. */
  75481. export class Database implements IOfflineProvider {
  75482. private _callbackManifestChecked;
  75483. private _currentSceneUrl;
  75484. private _db;
  75485. private _enableSceneOffline;
  75486. private _enableTexturesOffline;
  75487. private _manifestVersionFound;
  75488. private _mustUpdateRessources;
  75489. private _hasReachedQuota;
  75490. private _isSupported;
  75491. private _idbFactory;
  75492. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  75493. private static IsUASupportingBlobStorage;
  75494. /**
  75495. * Gets a boolean indicating if Database storate is enabled (off by default)
  75496. */
  75497. static IDBStorageEnabled: boolean;
  75498. /**
  75499. * Gets a boolean indicating if scene must be saved in the database
  75500. */
  75501. get enableSceneOffline(): boolean;
  75502. /**
  75503. * Gets a boolean indicating if textures must be saved in the database
  75504. */
  75505. get enableTexturesOffline(): boolean;
  75506. /**
  75507. * Creates a new Database
  75508. * @param urlToScene defines the url to load the scene
  75509. * @param callbackManifestChecked defines the callback to use when manifest is checked
  75510. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  75511. */
  75512. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  75513. private static _ParseURL;
  75514. private static _ReturnFullUrlLocation;
  75515. private _checkManifestFile;
  75516. /**
  75517. * Open the database and make it available
  75518. * @param successCallback defines the callback to call on success
  75519. * @param errorCallback defines the callback to call on error
  75520. */
  75521. open(successCallback: () => void, errorCallback: () => void): void;
  75522. /**
  75523. * Loads an image from the database
  75524. * @param url defines the url to load from
  75525. * @param image defines the target DOM image
  75526. */
  75527. loadImage(url: string, image: HTMLImageElement): void;
  75528. private _loadImageFromDBAsync;
  75529. private _saveImageIntoDBAsync;
  75530. private _checkVersionFromDB;
  75531. private _loadVersionFromDBAsync;
  75532. private _saveVersionIntoDBAsync;
  75533. /**
  75534. * Loads a file from database
  75535. * @param url defines the URL to load from
  75536. * @param sceneLoaded defines a callback to call on success
  75537. * @param progressCallBack defines a callback to call when progress changed
  75538. * @param errorCallback defines a callback to call on error
  75539. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75540. */
  75541. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75542. private _loadFileAsync;
  75543. private _saveFileAsync;
  75544. /**
  75545. * Validates if xhr data is correct
  75546. * @param xhr defines the request to validate
  75547. * @param dataType defines the expected data type
  75548. * @returns true if data is correct
  75549. */
  75550. private static _ValidateXHRData;
  75551. }
  75552. }
  75553. declare module "babylonjs/Offline/index" {
  75554. export * from "babylonjs/Offline/database";
  75555. export * from "babylonjs/Offline/IOfflineProvider";
  75556. }
  75557. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  75558. /** @hidden */
  75559. export var gpuUpdateParticlesPixelShader: {
  75560. name: string;
  75561. shader: string;
  75562. };
  75563. }
  75564. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  75565. /** @hidden */
  75566. export var gpuUpdateParticlesVertexShader: {
  75567. name: string;
  75568. shader: string;
  75569. };
  75570. }
  75571. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  75572. /** @hidden */
  75573. export var clipPlaneFragmentDeclaration2: {
  75574. name: string;
  75575. shader: string;
  75576. };
  75577. }
  75578. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  75579. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  75580. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  75581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  75582. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  75583. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  75584. /** @hidden */
  75585. export var gpuRenderParticlesPixelShader: {
  75586. name: string;
  75587. shader: string;
  75588. };
  75589. }
  75590. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  75591. /** @hidden */
  75592. export var clipPlaneVertexDeclaration2: {
  75593. name: string;
  75594. shader: string;
  75595. };
  75596. }
  75597. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  75598. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  75599. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  75600. /** @hidden */
  75601. export var gpuRenderParticlesVertexShader: {
  75602. name: string;
  75603. shader: string;
  75604. };
  75605. }
  75606. declare module "babylonjs/Particles/gpuParticleSystem" {
  75607. import { Nullable } from "babylonjs/types";
  75608. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  75609. import { Observable } from "babylonjs/Misc/observable";
  75610. import { Matrix } from "babylonjs/Maths/math.vector";
  75611. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  75612. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75613. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  75614. import { IDisposable } from "babylonjs/scene";
  75615. import { Effect } from "babylonjs/Materials/effect";
  75616. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75617. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75618. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  75619. import { Scene } from "babylonjs/scene";
  75620. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  75621. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  75622. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  75623. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  75624. /**
  75625. * This represents a GPU particle system in Babylon
  75626. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  75627. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  75628. */
  75629. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  75630. /**
  75631. * The layer mask we are rendering the particles through.
  75632. */
  75633. layerMask: number;
  75634. private _capacity;
  75635. private _activeCount;
  75636. private _currentActiveCount;
  75637. private _accumulatedCount;
  75638. private _renderEffect;
  75639. private _updateEffect;
  75640. private _buffer0;
  75641. private _buffer1;
  75642. private _spriteBuffer;
  75643. private _updateVAO;
  75644. private _renderVAO;
  75645. private _targetIndex;
  75646. private _sourceBuffer;
  75647. private _targetBuffer;
  75648. private _currentRenderId;
  75649. private _started;
  75650. private _stopped;
  75651. private _timeDelta;
  75652. private _randomTexture;
  75653. private _randomTexture2;
  75654. private _attributesStrideSize;
  75655. private _updateEffectOptions;
  75656. private _randomTextureSize;
  75657. private _actualFrame;
  75658. private _customEffect;
  75659. private readonly _rawTextureWidth;
  75660. /**
  75661. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  75662. */
  75663. static get IsSupported(): boolean;
  75664. /**
  75665. * An event triggered when the system is disposed.
  75666. */
  75667. onDisposeObservable: Observable<IParticleSystem>;
  75668. /**
  75669. * An event triggered when the system is stopped
  75670. */
  75671. onStoppedObservable: Observable<IParticleSystem>;
  75672. /**
  75673. * Gets the maximum number of particles active at the same time.
  75674. * @returns The max number of active particles.
  75675. */
  75676. getCapacity(): number;
  75677. /**
  75678. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  75679. * to override the particles.
  75680. */
  75681. forceDepthWrite: boolean;
  75682. /**
  75683. * Gets or set the number of active particles
  75684. */
  75685. get activeParticleCount(): number;
  75686. set activeParticleCount(value: number);
  75687. private _preWarmDone;
  75688. /**
  75689. * Specifies if the particles are updated in emitter local space or world space.
  75690. */
  75691. isLocal: boolean;
  75692. /** Gets or sets a matrix to use to compute projection */
  75693. defaultProjectionMatrix: Matrix;
  75694. /**
  75695. * Is this system ready to be used/rendered
  75696. * @return true if the system is ready
  75697. */
  75698. isReady(): boolean;
  75699. /**
  75700. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75701. * @returns True if it has been started, otherwise false.
  75702. */
  75703. isStarted(): boolean;
  75704. /**
  75705. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  75706. * @returns True if it has been stopped, otherwise false.
  75707. */
  75708. isStopped(): boolean;
  75709. /**
  75710. * Gets a boolean indicating that the system is stopping
  75711. * @returns true if the system is currently stopping
  75712. */
  75713. isStopping(): boolean;
  75714. /**
  75715. * Gets the number of particles active at the same time.
  75716. * @returns The number of active particles.
  75717. */
  75718. getActiveCount(): number;
  75719. /**
  75720. * Starts the particle system and begins to emit
  75721. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75722. */
  75723. start(delay?: number): void;
  75724. /**
  75725. * Stops the particle system.
  75726. */
  75727. stop(): void;
  75728. /**
  75729. * Remove all active particles
  75730. */
  75731. reset(): void;
  75732. /**
  75733. * Returns the string "GPUParticleSystem"
  75734. * @returns a string containing the class name
  75735. */
  75736. getClassName(): string;
  75737. /**
  75738. * Gets the custom effect used to render the particles
  75739. * @param blendMode Blend mode for which the effect should be retrieved
  75740. * @returns The effect
  75741. */
  75742. getCustomEffect(blendMode?: number): Nullable<Effect>;
  75743. /**
  75744. * Sets the custom effect used to render the particles
  75745. * @param effect The effect to set
  75746. * @param blendMode Blend mode for which the effect should be set
  75747. */
  75748. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  75749. /** @hidden */
  75750. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  75751. /**
  75752. * Observable that will be called just before the particles are drawn
  75753. */
  75754. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  75755. /**
  75756. * Gets the name of the particle vertex shader
  75757. */
  75758. get vertexShaderName(): string;
  75759. private _colorGradientsTexture;
  75760. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  75761. /**
  75762. * Adds a new color gradient
  75763. * @param gradient defines the gradient to use (between 0 and 1)
  75764. * @param color1 defines the color to affect to the specified gradient
  75765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75766. * @returns the current particle system
  75767. */
  75768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  75769. private _refreshColorGradient;
  75770. /** Force the system to rebuild all gradients that need to be resync */
  75771. forceRefreshGradients(): void;
  75772. /**
  75773. * Remove a specific color gradient
  75774. * @param gradient defines the gradient to remove
  75775. * @returns the current particle system
  75776. */
  75777. removeColorGradient(gradient: number): GPUParticleSystem;
  75778. private _angularSpeedGradientsTexture;
  75779. private _sizeGradientsTexture;
  75780. private _velocityGradientsTexture;
  75781. private _limitVelocityGradientsTexture;
  75782. private _dragGradientsTexture;
  75783. private _addFactorGradient;
  75784. /**
  75785. * Adds a new size gradient
  75786. * @param gradient defines the gradient to use (between 0 and 1)
  75787. * @param factor defines the size factor to affect to the specified gradient
  75788. * @returns the current particle system
  75789. */
  75790. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  75791. /**
  75792. * Remove a specific size gradient
  75793. * @param gradient defines the gradient to remove
  75794. * @returns the current particle system
  75795. */
  75796. removeSizeGradient(gradient: number): GPUParticleSystem;
  75797. private _refreshFactorGradient;
  75798. /**
  75799. * Adds a new angular speed gradient
  75800. * @param gradient defines the gradient to use (between 0 and 1)
  75801. * @param factor defines the angular speed to affect to the specified gradient
  75802. * @returns the current particle system
  75803. */
  75804. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  75805. /**
  75806. * Remove a specific angular speed gradient
  75807. * @param gradient defines the gradient to remove
  75808. * @returns the current particle system
  75809. */
  75810. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  75811. /**
  75812. * Adds a new velocity gradient
  75813. * @param gradient defines the gradient to use (between 0 and 1)
  75814. * @param factor defines the velocity to affect to the specified gradient
  75815. * @returns the current particle system
  75816. */
  75817. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75818. /**
  75819. * Remove a specific velocity gradient
  75820. * @param gradient defines the gradient to remove
  75821. * @returns the current particle system
  75822. */
  75823. removeVelocityGradient(gradient: number): GPUParticleSystem;
  75824. /**
  75825. * Adds a new limit velocity gradient
  75826. * @param gradient defines the gradient to use (between 0 and 1)
  75827. * @param factor defines the limit velocity value to affect to the specified gradient
  75828. * @returns the current particle system
  75829. */
  75830. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75831. /**
  75832. * Remove a specific limit velocity gradient
  75833. * @param gradient defines the gradient to remove
  75834. * @returns the current particle system
  75835. */
  75836. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  75837. /**
  75838. * Adds a new drag gradient
  75839. * @param gradient defines the gradient to use (between 0 and 1)
  75840. * @param factor defines the drag value to affect to the specified gradient
  75841. * @returns the current particle system
  75842. */
  75843. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  75844. /**
  75845. * Remove a specific drag gradient
  75846. * @param gradient defines the gradient to remove
  75847. * @returns the current particle system
  75848. */
  75849. removeDragGradient(gradient: number): GPUParticleSystem;
  75850. /**
  75851. * Not supported by GPUParticleSystem
  75852. * @param gradient defines the gradient to use (between 0 and 1)
  75853. * @param factor defines the emit rate value to affect to the specified gradient
  75854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75855. * @returns the current particle system
  75856. */
  75857. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75858. /**
  75859. * Not supported by GPUParticleSystem
  75860. * @param gradient defines the gradient to remove
  75861. * @returns the current particle system
  75862. */
  75863. removeEmitRateGradient(gradient: number): IParticleSystem;
  75864. /**
  75865. * Not supported by GPUParticleSystem
  75866. * @param gradient defines the gradient to use (between 0 and 1)
  75867. * @param factor defines the start size value to affect to the specified gradient
  75868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75869. * @returns the current particle system
  75870. */
  75871. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75872. /**
  75873. * Not supported by GPUParticleSystem
  75874. * @param gradient defines the gradient to remove
  75875. * @returns the current particle system
  75876. */
  75877. removeStartSizeGradient(gradient: number): IParticleSystem;
  75878. /**
  75879. * Not supported by GPUParticleSystem
  75880. * @param gradient defines the gradient to use (between 0 and 1)
  75881. * @param min defines the color remap minimal range
  75882. * @param max defines the color remap maximal range
  75883. * @returns the current particle system
  75884. */
  75885. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75886. /**
  75887. * Not supported by GPUParticleSystem
  75888. * @param gradient defines the gradient to remove
  75889. * @returns the current particle system
  75890. */
  75891. removeColorRemapGradient(): IParticleSystem;
  75892. /**
  75893. * Not supported by GPUParticleSystem
  75894. * @param gradient defines the gradient to use (between 0 and 1)
  75895. * @param min defines the alpha remap minimal range
  75896. * @param max defines the alpha remap maximal range
  75897. * @returns the current particle system
  75898. */
  75899. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75900. /**
  75901. * Not supported by GPUParticleSystem
  75902. * @param gradient defines the gradient to remove
  75903. * @returns the current particle system
  75904. */
  75905. removeAlphaRemapGradient(): IParticleSystem;
  75906. /**
  75907. * Not supported by GPUParticleSystem
  75908. * @param gradient defines the gradient to use (between 0 and 1)
  75909. * @param color defines the color to affect to the specified gradient
  75910. * @returns the current particle system
  75911. */
  75912. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75913. /**
  75914. * Not supported by GPUParticleSystem
  75915. * @param gradient defines the gradient to remove
  75916. * @returns the current particle system
  75917. */
  75918. removeRampGradient(): IParticleSystem;
  75919. /**
  75920. * Not supported by GPUParticleSystem
  75921. * @returns the list of ramp gradients
  75922. */
  75923. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75924. /**
  75925. * Not supported by GPUParticleSystem
  75926. * Gets or sets a boolean indicating that ramp gradients must be used
  75927. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75928. */
  75929. get useRampGradients(): boolean;
  75930. set useRampGradients(value: boolean);
  75931. /**
  75932. * Not supported by GPUParticleSystem
  75933. * @param gradient defines the gradient to use (between 0 and 1)
  75934. * @param factor defines the life time factor to affect to the specified gradient
  75935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75936. * @returns the current particle system
  75937. */
  75938. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75939. /**
  75940. * Not supported by GPUParticleSystem
  75941. * @param gradient defines the gradient to remove
  75942. * @returns the current particle system
  75943. */
  75944. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75945. /**
  75946. * Instantiates a GPU particle system.
  75947. * 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.
  75948. * @param name The name of the particle system
  75949. * @param options The options used to create the system
  75950. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  75951. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75952. * @param customEffect a custom effect used to change the way particles are rendered by default
  75953. */
  75954. constructor(name: string, options: Partial<{
  75955. capacity: number;
  75956. randomTextureSize: number;
  75957. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  75958. protected _reset(): void;
  75959. private _createUpdateVAO;
  75960. private _createRenderVAO;
  75961. private _initialize;
  75962. /** @hidden */
  75963. _recreateUpdateEffect(): void;
  75964. private _getEffect;
  75965. /**
  75966. * Fill the defines array according to the current settings of the particle system
  75967. * @param defines Array to be updated
  75968. * @param blendMode blend mode to take into account when updating the array
  75969. */
  75970. fillDefines(defines: Array<string>, blendMode?: number): void;
  75971. /**
  75972. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  75973. * @param uniforms Uniforms array to fill
  75974. * @param attributes Attributes array to fill
  75975. * @param samplers Samplers array to fill
  75976. */
  75977. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  75978. /** @hidden */
  75979. _recreateRenderEffect(): Effect;
  75980. /**
  75981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75982. * @param preWarm defines if we are in the pre-warmimg phase
  75983. */
  75984. animate(preWarm?: boolean): void;
  75985. private _createFactorGradientTexture;
  75986. private _createSizeGradientTexture;
  75987. private _createAngularSpeedGradientTexture;
  75988. private _createVelocityGradientTexture;
  75989. private _createLimitVelocityGradientTexture;
  75990. private _createDragGradientTexture;
  75991. private _createColorGradientTexture;
  75992. /**
  75993. * Renders the particle system in its current state
  75994. * @param preWarm defines if the system should only update the particles but not render them
  75995. * @returns the current number of particles
  75996. */
  75997. render(preWarm?: boolean): number;
  75998. /**
  75999. * Rebuilds the particle system
  76000. */
  76001. rebuild(): void;
  76002. private _releaseBuffers;
  76003. private _releaseVAOs;
  76004. /**
  76005. * Disposes the particle system and free the associated resources
  76006. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76007. */
  76008. dispose(disposeTexture?: boolean): void;
  76009. /**
  76010. * Clones the particle system.
  76011. * @param name The name of the cloned object
  76012. * @param newEmitter The new emitter to use
  76013. * @returns the cloned particle system
  76014. */
  76015. clone(name: string, newEmitter: any): GPUParticleSystem;
  76016. /**
  76017. * Serializes the particle system to a JSON object
  76018. * @param serializeTexture defines if the texture must be serialized as well
  76019. * @returns the JSON object
  76020. */
  76021. serialize(serializeTexture?: boolean): any;
  76022. /**
  76023. * Parses a JSON object to create a GPU particle system.
  76024. * @param parsedParticleSystem The JSON object to parse
  76025. * @param sceneOrEngine The scene or the engine to create the particle system in
  76026. * @param rootUrl The root url to use to load external dependencies like texture
  76027. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  76028. * @returns the parsed GPU particle system
  76029. */
  76030. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  76031. }
  76032. }
  76033. declare module "babylonjs/Particles/particleSystemSet" {
  76034. import { Nullable } from "babylonjs/types";
  76035. import { Color3 } from "babylonjs/Maths/math.color";
  76036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76038. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76039. import { Scene, IDisposable } from "babylonjs/scene";
  76040. /**
  76041. * Represents a set of particle systems working together to create a specific effect
  76042. */
  76043. export class ParticleSystemSet implements IDisposable {
  76044. /**
  76045. * Gets or sets base Assets URL
  76046. */
  76047. static BaseAssetsUrl: string;
  76048. private _emitterCreationOptions;
  76049. private _emitterNode;
  76050. /**
  76051. * Gets the particle system list
  76052. */
  76053. systems: IParticleSystem[];
  76054. /**
  76055. * Gets the emitter node used with this set
  76056. */
  76057. get emitterNode(): Nullable<TransformNode>;
  76058. /**
  76059. * Creates a new emitter mesh as a sphere
  76060. * @param options defines the options used to create the sphere
  76061. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  76062. * @param scene defines the hosting scene
  76063. */
  76064. setEmitterAsSphere(options: {
  76065. diameter: number;
  76066. segments: number;
  76067. color: Color3;
  76068. }, renderingGroupId: number, scene: Scene): void;
  76069. /**
  76070. * Starts all particle systems of the set
  76071. * @param emitter defines an optional mesh to use as emitter for the particle systems
  76072. */
  76073. start(emitter?: AbstractMesh): void;
  76074. /**
  76075. * Release all associated resources
  76076. */
  76077. dispose(): void;
  76078. /**
  76079. * Serialize the set into a JSON compatible object
  76080. * @param serializeTexture defines if the texture must be serialized as well
  76081. * @returns a JSON compatible representation of the set
  76082. */
  76083. serialize(serializeTexture?: boolean): any;
  76084. /**
  76085. * Parse a new ParticleSystemSet from a serialized source
  76086. * @param data defines a JSON compatible representation of the set
  76087. * @param scene defines the hosting scene
  76088. * @param gpu defines if we want GPU particles or CPU particles
  76089. * @returns a new ParticleSystemSet
  76090. */
  76091. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  76092. }
  76093. }
  76094. declare module "babylonjs/Particles/particleHelper" {
  76095. import { Nullable } from "babylonjs/types";
  76096. import { Scene } from "babylonjs/scene";
  76097. import { Vector3 } from "babylonjs/Maths/math.vector";
  76098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76100. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  76101. /**
  76102. * This class is made for on one-liner static method to help creating particle system set.
  76103. */
  76104. export class ParticleHelper {
  76105. /**
  76106. * Gets or sets base Assets URL
  76107. */
  76108. static BaseAssetsUrl: string;
  76109. /** Define the Url to load snippets */
  76110. static SnippetUrl: string;
  76111. /**
  76112. * Create a default particle system that you can tweak
  76113. * @param emitter defines the emitter to use
  76114. * @param capacity defines the system capacity (default is 500 particles)
  76115. * @param scene defines the hosting scene
  76116. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  76117. * @returns the new Particle system
  76118. */
  76119. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  76120. /**
  76121. * This is the main static method (one-liner) of this helper to create different particle systems
  76122. * @param type This string represents the type to the particle system to create
  76123. * @param scene The scene where the particle system should live
  76124. * @param gpu If the system will use gpu
  76125. * @returns the ParticleSystemSet created
  76126. */
  76127. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  76128. /**
  76129. * Static function used to export a particle system to a ParticleSystemSet variable.
  76130. * Please note that the emitter shape is not exported
  76131. * @param systems defines the particle systems to export
  76132. * @returns the created particle system set
  76133. */
  76134. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  76135. /**
  76136. * Creates a particle system from a snippet saved in a remote file
  76137. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  76138. * @param url defines the url to load from
  76139. * @param scene defines the hosting scene
  76140. * @param gpu If the system will use gpu
  76141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76142. * @returns a promise that will resolve to the new particle system
  76143. */
  76144. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76145. /**
  76146. * Creates a particle system from a snippet saved by the particle system editor
  76147. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  76148. * @param scene defines the hosting scene
  76149. * @param gpu If the system will use gpu
  76150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76151. * @returns a promise that will resolve to the new particle system
  76152. */
  76153. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76154. }
  76155. }
  76156. declare module "babylonjs/Particles/particleSystemComponent" {
  76157. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76158. import { Effect } from "babylonjs/Materials/effect";
  76159. import "babylonjs/Shaders/particles.vertex";
  76160. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  76161. module "babylonjs/Engines/engine" {
  76162. interface Engine {
  76163. /**
  76164. * Create an effect to use with particle systems.
  76165. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  76166. * the particle system for which you want to create a custom effect in the last parameter
  76167. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  76168. * @param uniformsNames defines a list of attribute names
  76169. * @param samplers defines an array of string used to represent textures
  76170. * @param defines defines the string containing the defines to use to compile the shaders
  76171. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  76172. * @param onCompiled defines a function to call when the effect creation is successful
  76173. * @param onError defines a function to call when the effect creation has failed
  76174. * @param particleSystem the particle system you want to create the effect for
  76175. * @returns the new Effect
  76176. */
  76177. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  76178. }
  76179. }
  76180. module "babylonjs/Meshes/mesh" {
  76181. interface Mesh {
  76182. /**
  76183. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  76184. * @returns an array of IParticleSystem
  76185. */
  76186. getEmittedParticleSystems(): IParticleSystem[];
  76187. /**
  76188. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  76189. * @returns an array of IParticleSystem
  76190. */
  76191. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  76192. }
  76193. }
  76194. }
  76195. declare module "babylonjs/Particles/pointsCloudSystem" {
  76196. import { Color4 } from "babylonjs/Maths/math";
  76197. import { Mesh } from "babylonjs/Meshes/mesh";
  76198. import { Scene, IDisposable } from "babylonjs/scene";
  76199. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  76200. /** Defines the 4 color options */
  76201. export enum PointColor {
  76202. /** color value */
  76203. Color = 2,
  76204. /** uv value */
  76205. UV = 1,
  76206. /** random value */
  76207. Random = 0,
  76208. /** stated value */
  76209. Stated = 3
  76210. }
  76211. /**
  76212. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  76213. * 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.
  76214. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  76215. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  76216. *
  76217. * Full documentation here : TO BE ENTERED
  76218. */
  76219. export class PointsCloudSystem implements IDisposable {
  76220. /**
  76221. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  76222. * Example : var p = SPS.particles[i];
  76223. */
  76224. particles: CloudPoint[];
  76225. /**
  76226. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  76227. */
  76228. nbParticles: number;
  76229. /**
  76230. * This a counter for your own usage. It's not set by any SPS functions.
  76231. */
  76232. counter: number;
  76233. /**
  76234. * The PCS name. This name is also given to the underlying mesh.
  76235. */
  76236. name: string;
  76237. /**
  76238. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  76239. */
  76240. mesh: Mesh;
  76241. /**
  76242. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  76243. * Please read :
  76244. */
  76245. vars: any;
  76246. /**
  76247. * @hidden
  76248. */
  76249. _size: number;
  76250. private _scene;
  76251. private _promises;
  76252. private _positions;
  76253. private _indices;
  76254. private _normals;
  76255. private _colors;
  76256. private _uvs;
  76257. private _indices32;
  76258. private _positions32;
  76259. private _colors32;
  76260. private _uvs32;
  76261. private _updatable;
  76262. private _isVisibilityBoxLocked;
  76263. private _alwaysVisible;
  76264. private _groups;
  76265. private _groupCounter;
  76266. private _computeParticleColor;
  76267. private _computeParticleTexture;
  76268. private _computeParticleRotation;
  76269. private _computeBoundingBox;
  76270. private _isReady;
  76271. /**
  76272. * Creates a PCS (Points Cloud System) object
  76273. * @param name (String) is the PCS name, this will be the underlying mesh name
  76274. * @param pointSize (number) is the size for each point
  76275. * @param scene (Scene) is the scene in which the PCS is added
  76276. * @param options defines the options of the PCS e.g.
  76277. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  76278. */
  76279. constructor(name: string, pointSize: number, scene: Scene, options?: {
  76280. updatable?: boolean;
  76281. });
  76282. /**
  76283. * Builds the PCS underlying mesh. Returns a standard Mesh.
  76284. * If no points were added to the PCS, the returned mesh is just a single point.
  76285. * @returns a promise for the created mesh
  76286. */
  76287. buildMeshAsync(): Promise<Mesh>;
  76288. /**
  76289. * @hidden
  76290. */
  76291. private _buildMesh;
  76292. private _addParticle;
  76293. private _randomUnitVector;
  76294. private _getColorIndicesForCoord;
  76295. private _setPointsColorOrUV;
  76296. private _colorFromTexture;
  76297. private _calculateDensity;
  76298. /**
  76299. * Adds points to the PCS in random positions within a unit sphere
  76300. * @param nb (positive integer) the number of particles to be created from this model
  76301. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  76302. * @returns the number of groups in the system
  76303. */
  76304. addPoints(nb: number, pointFunction?: any): number;
  76305. /**
  76306. * Adds points to the PCS from the surface of the model shape
  76307. * @param mesh is any Mesh object that will be used as a surface model for the points
  76308. * @param nb (positive integer) the number of particles to be created from this model
  76309. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76310. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76311. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76312. * @returns the number of groups in the system
  76313. */
  76314. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76315. /**
  76316. * Adds points to the PCS inside the model shape
  76317. * @param mesh is any Mesh object that will be used as a surface model for the points
  76318. * @param nb (positive integer) the number of particles to be created from this model
  76319. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76320. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76321. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76322. * @returns the number of groups in the system
  76323. */
  76324. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76325. /**
  76326. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  76327. * This method calls `updateParticle()` for each particle of the SPS.
  76328. * For an animated SPS, it is usually called within the render loop.
  76329. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  76330. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  76331. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  76332. * @returns the PCS.
  76333. */
  76334. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  76335. /**
  76336. * Disposes the PCS.
  76337. */
  76338. dispose(): void;
  76339. /**
  76340. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  76341. * doc :
  76342. * @returns the PCS.
  76343. */
  76344. refreshVisibleSize(): PointsCloudSystem;
  76345. /**
  76346. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  76347. * @param size the size (float) of the visibility box
  76348. * note : this doesn't lock the PCS mesh bounding box.
  76349. * doc :
  76350. */
  76351. setVisibilityBox(size: number): void;
  76352. /**
  76353. * Gets whether the PCS is always visible or not
  76354. * doc :
  76355. */
  76356. get isAlwaysVisible(): boolean;
  76357. /**
  76358. * Sets the PCS as always visible or not
  76359. * doc :
  76360. */
  76361. set isAlwaysVisible(val: boolean);
  76362. /**
  76363. * Tells to `setParticles()` to compute the particle rotations or not
  76364. * Default value : false. The PCS is faster when it's set to false
  76365. * Note : particle rotations are only applied to parent particles
  76366. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  76367. */
  76368. set computeParticleRotation(val: boolean);
  76369. /**
  76370. * Tells to `setParticles()` to compute the particle colors or not.
  76371. * Default value : true. The PCS is faster when it's set to false.
  76372. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76373. */
  76374. set computeParticleColor(val: boolean);
  76375. set computeParticleTexture(val: boolean);
  76376. /**
  76377. * Gets if `setParticles()` computes the particle colors or not.
  76378. * Default value : false. The PCS is faster when it's set to false.
  76379. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76380. */
  76381. get computeParticleColor(): boolean;
  76382. /**
  76383. * Gets if `setParticles()` computes the particle textures or not.
  76384. * Default value : false. The PCS is faster when it's set to false.
  76385. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  76386. */
  76387. get computeParticleTexture(): boolean;
  76388. /**
  76389. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  76390. */
  76391. set computeBoundingBox(val: boolean);
  76392. /**
  76393. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  76394. */
  76395. get computeBoundingBox(): boolean;
  76396. /**
  76397. * This function does nothing. It may be overwritten to set all the particle first values.
  76398. * The PCS doesn't call this function, you may have to call it by your own.
  76399. * doc :
  76400. */
  76401. initParticles(): void;
  76402. /**
  76403. * This function does nothing. It may be overwritten to recycle a particle
  76404. * The PCS doesn't call this function, you can to call it
  76405. * doc :
  76406. * @param particle The particle to recycle
  76407. * @returns the recycled particle
  76408. */
  76409. recycleParticle(particle: CloudPoint): CloudPoint;
  76410. /**
  76411. * Updates a particle : this function should be overwritten by the user.
  76412. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  76413. * doc :
  76414. * @example : just set a particle position or velocity and recycle conditions
  76415. * @param particle The particle to update
  76416. * @returns the updated particle
  76417. */
  76418. updateParticle(particle: CloudPoint): CloudPoint;
  76419. /**
  76420. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  76421. * This does nothing and may be overwritten by the user.
  76422. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76423. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76424. * @param update the boolean update value actually passed to setParticles()
  76425. */
  76426. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76427. /**
  76428. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  76429. * This will be passed three parameters.
  76430. * This does nothing and may be overwritten by the user.
  76431. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76432. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76433. * @param update the boolean update value actually passed to setParticles()
  76434. */
  76435. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76436. }
  76437. }
  76438. declare module "babylonjs/Particles/cloudPoint" {
  76439. import { Nullable } from "babylonjs/types";
  76440. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  76441. import { Mesh } from "babylonjs/Meshes/mesh";
  76442. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  76443. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  76444. /**
  76445. * Represents one particle of a points cloud system.
  76446. */
  76447. export class CloudPoint {
  76448. /**
  76449. * particle global index
  76450. */
  76451. idx: number;
  76452. /**
  76453. * The color of the particle
  76454. */
  76455. color: Nullable<Color4>;
  76456. /**
  76457. * The world space position of the particle.
  76458. */
  76459. position: Vector3;
  76460. /**
  76461. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  76462. */
  76463. rotation: Vector3;
  76464. /**
  76465. * The world space rotation quaternion of the particle.
  76466. */
  76467. rotationQuaternion: Nullable<Quaternion>;
  76468. /**
  76469. * The uv of the particle.
  76470. */
  76471. uv: Nullable<Vector2>;
  76472. /**
  76473. * The current speed of the particle.
  76474. */
  76475. velocity: Vector3;
  76476. /**
  76477. * The pivot point in the particle local space.
  76478. */
  76479. pivot: Vector3;
  76480. /**
  76481. * Must the particle be translated from its pivot point in its local space ?
  76482. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  76483. * Default : false
  76484. */
  76485. translateFromPivot: boolean;
  76486. /**
  76487. * Index of this particle in the global "positions" array (Internal use)
  76488. * @hidden
  76489. */
  76490. _pos: number;
  76491. /**
  76492. * @hidden Index of this particle in the global "indices" array (Internal use)
  76493. */
  76494. _ind: number;
  76495. /**
  76496. * Group this particle belongs to
  76497. */
  76498. _group: PointsGroup;
  76499. /**
  76500. * Group id of this particle
  76501. */
  76502. groupId: number;
  76503. /**
  76504. * Index of the particle in its group id (Internal use)
  76505. */
  76506. idxInGroup: number;
  76507. /**
  76508. * @hidden Particle BoundingInfo object (Internal use)
  76509. */
  76510. _boundingInfo: BoundingInfo;
  76511. /**
  76512. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  76513. */
  76514. _pcs: PointsCloudSystem;
  76515. /**
  76516. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  76517. */
  76518. _stillInvisible: boolean;
  76519. /**
  76520. * @hidden Last computed particle rotation matrix
  76521. */
  76522. _rotationMatrix: number[];
  76523. /**
  76524. * Parent particle Id, if any.
  76525. * Default null.
  76526. */
  76527. parentId: Nullable<number>;
  76528. /**
  76529. * @hidden Internal global position in the PCS.
  76530. */
  76531. _globalPosition: Vector3;
  76532. /**
  76533. * Creates a Point Cloud object.
  76534. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  76535. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  76536. * @param group (PointsGroup) is the group the particle belongs to
  76537. * @param groupId (integer) is the group identifier in the PCS.
  76538. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  76539. * @param pcs defines the PCS it is associated to
  76540. */
  76541. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  76542. /**
  76543. * get point size
  76544. */
  76545. get size(): Vector3;
  76546. /**
  76547. * Set point size
  76548. */
  76549. set size(scale: Vector3);
  76550. /**
  76551. * Legacy support, changed quaternion to rotationQuaternion
  76552. */
  76553. get quaternion(): Nullable<Quaternion>;
  76554. /**
  76555. * Legacy support, changed quaternion to rotationQuaternion
  76556. */
  76557. set quaternion(q: Nullable<Quaternion>);
  76558. /**
  76559. * Returns a boolean. True if the particle intersects a mesh, else false
  76560. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  76561. * @param target is the object (point or mesh) what the intersection is computed against
  76562. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  76563. * @returns true if it intersects
  76564. */
  76565. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  76566. /**
  76567. * get the rotation matrix of the particle
  76568. * @hidden
  76569. */
  76570. getRotationMatrix(m: Matrix): void;
  76571. }
  76572. /**
  76573. * Represents a group of points in a points cloud system
  76574. * * PCS internal tool, don't use it manually.
  76575. */
  76576. export class PointsGroup {
  76577. /**
  76578. * The group id
  76579. * @hidden
  76580. */
  76581. groupID: number;
  76582. /**
  76583. * image data for group (internal use)
  76584. * @hidden
  76585. */
  76586. _groupImageData: Nullable<ArrayBufferView>;
  76587. /**
  76588. * Image Width (internal use)
  76589. * @hidden
  76590. */
  76591. _groupImgWidth: number;
  76592. /**
  76593. * Image Height (internal use)
  76594. * @hidden
  76595. */
  76596. _groupImgHeight: number;
  76597. /**
  76598. * Custom position function (internal use)
  76599. * @hidden
  76600. */
  76601. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  76602. /**
  76603. * density per facet for surface points
  76604. * @hidden
  76605. */
  76606. _groupDensity: number[];
  76607. /**
  76608. * Only when points are colored by texture carries pointer to texture list array
  76609. * @hidden
  76610. */
  76611. _textureNb: number;
  76612. /**
  76613. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  76614. * PCS internal tool, don't use it manually.
  76615. * @hidden
  76616. */
  76617. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  76618. }
  76619. }
  76620. declare module "babylonjs/Particles/index" {
  76621. export * from "babylonjs/Particles/baseParticleSystem";
  76622. export * from "babylonjs/Particles/EmitterTypes/index";
  76623. export * from "babylonjs/Particles/gpuParticleSystem";
  76624. export * from "babylonjs/Particles/IParticleSystem";
  76625. export * from "babylonjs/Particles/particle";
  76626. export * from "babylonjs/Particles/particleHelper";
  76627. export * from "babylonjs/Particles/particleSystem";
  76628. import "babylonjs/Particles/particleSystemComponent";
  76629. export * from "babylonjs/Particles/particleSystemComponent";
  76630. export * from "babylonjs/Particles/particleSystemSet";
  76631. export * from "babylonjs/Particles/solidParticle";
  76632. export * from "babylonjs/Particles/solidParticleSystem";
  76633. export * from "babylonjs/Particles/cloudPoint";
  76634. export * from "babylonjs/Particles/pointsCloudSystem";
  76635. export * from "babylonjs/Particles/subEmitter";
  76636. }
  76637. declare module "babylonjs/Physics/physicsEngineComponent" {
  76638. import { Nullable } from "babylonjs/types";
  76639. import { Observable, Observer } from "babylonjs/Misc/observable";
  76640. import { Vector3 } from "babylonjs/Maths/math.vector";
  76641. import { Mesh } from "babylonjs/Meshes/mesh";
  76642. import { ISceneComponent } from "babylonjs/sceneComponent";
  76643. import { Scene } from "babylonjs/scene";
  76644. import { Node } from "babylonjs/node";
  76645. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  76646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76647. module "babylonjs/scene" {
  76648. interface Scene {
  76649. /** @hidden (Backing field) */
  76650. _physicsEngine: Nullable<IPhysicsEngine>;
  76651. /** @hidden */
  76652. _physicsTimeAccumulator: number;
  76653. /**
  76654. * Gets the current physics engine
  76655. * @returns a IPhysicsEngine or null if none attached
  76656. */
  76657. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  76658. /**
  76659. * Enables physics to the current scene
  76660. * @param gravity defines the scene's gravity for the physics engine
  76661. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  76662. * @return a boolean indicating if the physics engine was initialized
  76663. */
  76664. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  76665. /**
  76666. * Disables and disposes the physics engine associated with the scene
  76667. */
  76668. disablePhysicsEngine(): void;
  76669. /**
  76670. * Gets a boolean indicating if there is an active physics engine
  76671. * @returns a boolean indicating if there is an active physics engine
  76672. */
  76673. isPhysicsEnabled(): boolean;
  76674. /**
  76675. * Deletes a physics compound impostor
  76676. * @param compound defines the compound to delete
  76677. */
  76678. deleteCompoundImpostor(compound: any): void;
  76679. /**
  76680. * An event triggered when physic simulation is about to be run
  76681. */
  76682. onBeforePhysicsObservable: Observable<Scene>;
  76683. /**
  76684. * An event triggered when physic simulation has been done
  76685. */
  76686. onAfterPhysicsObservable: Observable<Scene>;
  76687. }
  76688. }
  76689. module "babylonjs/Meshes/abstractMesh" {
  76690. interface AbstractMesh {
  76691. /** @hidden */
  76692. _physicsImpostor: Nullable<PhysicsImpostor>;
  76693. /**
  76694. * Gets or sets impostor used for physic simulation
  76695. * @see https://doc.babylonjs.com/features/physics_engine
  76696. */
  76697. physicsImpostor: Nullable<PhysicsImpostor>;
  76698. /**
  76699. * Gets the current physics impostor
  76700. * @see https://doc.babylonjs.com/features/physics_engine
  76701. * @returns a physics impostor or null
  76702. */
  76703. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  76704. /** Apply a physic impulse to the mesh
  76705. * @param force defines the force to apply
  76706. * @param contactPoint defines where to apply the force
  76707. * @returns the current mesh
  76708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76709. */
  76710. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  76711. /**
  76712. * Creates a physic joint between two meshes
  76713. * @param otherMesh defines the other mesh to use
  76714. * @param pivot1 defines the pivot to use on this mesh
  76715. * @param pivot2 defines the pivot to use on the other mesh
  76716. * @param options defines additional options (can be plugin dependent)
  76717. * @returns the current mesh
  76718. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  76719. */
  76720. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  76721. /** @hidden */
  76722. _disposePhysicsObserver: Nullable<Observer<Node>>;
  76723. }
  76724. }
  76725. /**
  76726. * Defines the physics engine scene component responsible to manage a physics engine
  76727. */
  76728. export class PhysicsEngineSceneComponent implements ISceneComponent {
  76729. /**
  76730. * The component name helpful to identify the component in the list of scene components.
  76731. */
  76732. readonly name: string;
  76733. /**
  76734. * The scene the component belongs to.
  76735. */
  76736. scene: Scene;
  76737. /**
  76738. * Creates a new instance of the component for the given scene
  76739. * @param scene Defines the scene to register the component in
  76740. */
  76741. constructor(scene: Scene);
  76742. /**
  76743. * Registers the component in a given scene
  76744. */
  76745. register(): void;
  76746. /**
  76747. * Rebuilds the elements related to this component in case of
  76748. * context lost for instance.
  76749. */
  76750. rebuild(): void;
  76751. /**
  76752. * Disposes the component and the associated ressources
  76753. */
  76754. dispose(): void;
  76755. }
  76756. }
  76757. declare module "babylonjs/Physics/physicsHelper" {
  76758. import { Nullable } from "babylonjs/types";
  76759. import { Vector3 } from "babylonjs/Maths/math.vector";
  76760. import { Mesh } from "babylonjs/Meshes/mesh";
  76761. import { Scene } from "babylonjs/scene";
  76762. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76763. /**
  76764. * A helper for physics simulations
  76765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76766. */
  76767. export class PhysicsHelper {
  76768. private _scene;
  76769. private _physicsEngine;
  76770. /**
  76771. * Initializes the Physics helper
  76772. * @param scene Babylon.js scene
  76773. */
  76774. constructor(scene: Scene);
  76775. /**
  76776. * Applies a radial explosion impulse
  76777. * @param origin the origin of the explosion
  76778. * @param radiusOrEventOptions the radius or the options of radial explosion
  76779. * @param strength the explosion strength
  76780. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76781. * @returns A physics radial explosion event, or null
  76782. */
  76783. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76784. /**
  76785. * Applies a radial explosion force
  76786. * @param origin the origin of the explosion
  76787. * @param radiusOrEventOptions the radius or the options of radial explosion
  76788. * @param strength the explosion strength
  76789. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76790. * @returns A physics radial explosion event, or null
  76791. */
  76792. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76793. /**
  76794. * Creates a gravitational field
  76795. * @param origin the origin of the explosion
  76796. * @param radiusOrEventOptions the radius or the options of radial explosion
  76797. * @param strength the explosion strength
  76798. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76799. * @returns A physics gravitational field event, or null
  76800. */
  76801. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  76802. /**
  76803. * Creates a physics updraft event
  76804. * @param origin the origin of the updraft
  76805. * @param radiusOrEventOptions the radius or the options of the updraft
  76806. * @param strength the strength of the updraft
  76807. * @param height the height of the updraft
  76808. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  76809. * @returns A physics updraft event, or null
  76810. */
  76811. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  76812. /**
  76813. * Creates a physics vortex event
  76814. * @param origin the of the vortex
  76815. * @param radiusOrEventOptions the radius or the options of the vortex
  76816. * @param strength the strength of the vortex
  76817. * @param height the height of the vortex
  76818. * @returns a Physics vortex event, or null
  76819. * A physics vortex event or null
  76820. */
  76821. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  76822. }
  76823. /**
  76824. * Represents a physics radial explosion event
  76825. */
  76826. class PhysicsRadialExplosionEvent {
  76827. private _scene;
  76828. private _options;
  76829. private _sphere;
  76830. private _dataFetched;
  76831. /**
  76832. * Initializes a radial explosioin event
  76833. * @param _scene BabylonJS scene
  76834. * @param _options The options for the vortex event
  76835. */
  76836. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  76837. /**
  76838. * Returns the data related to the radial explosion event (sphere).
  76839. * @returns The radial explosion event data
  76840. */
  76841. getData(): PhysicsRadialExplosionEventData;
  76842. /**
  76843. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  76844. * @param impostor A physics imposter
  76845. * @param origin the origin of the explosion
  76846. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  76847. */
  76848. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  76849. /**
  76850. * Triggers affecterd impostors callbacks
  76851. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  76852. */
  76853. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  76854. /**
  76855. * Disposes the sphere.
  76856. * @param force Specifies if the sphere should be disposed by force
  76857. */
  76858. dispose(force?: boolean): void;
  76859. /*** Helpers ***/
  76860. private _prepareSphere;
  76861. private _intersectsWithSphere;
  76862. }
  76863. /**
  76864. * Represents a gravitational field event
  76865. */
  76866. class PhysicsGravitationalFieldEvent {
  76867. private _physicsHelper;
  76868. private _scene;
  76869. private _origin;
  76870. private _options;
  76871. private _tickCallback;
  76872. private _sphere;
  76873. private _dataFetched;
  76874. /**
  76875. * Initializes the physics gravitational field event
  76876. * @param _physicsHelper A physics helper
  76877. * @param _scene BabylonJS scene
  76878. * @param _origin The origin position of the gravitational field event
  76879. * @param _options The options for the vortex event
  76880. */
  76881. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  76882. /**
  76883. * Returns the data related to the gravitational field event (sphere).
  76884. * @returns A gravitational field event
  76885. */
  76886. getData(): PhysicsGravitationalFieldEventData;
  76887. /**
  76888. * Enables the gravitational field.
  76889. */
  76890. enable(): void;
  76891. /**
  76892. * Disables the gravitational field.
  76893. */
  76894. disable(): void;
  76895. /**
  76896. * Disposes the sphere.
  76897. * @param force The force to dispose from the gravitational field event
  76898. */
  76899. dispose(force?: boolean): void;
  76900. private _tick;
  76901. }
  76902. /**
  76903. * Represents a physics updraft event
  76904. */
  76905. class PhysicsUpdraftEvent {
  76906. private _scene;
  76907. private _origin;
  76908. private _options;
  76909. private _physicsEngine;
  76910. private _originTop;
  76911. private _originDirection;
  76912. private _tickCallback;
  76913. private _cylinder;
  76914. private _cylinderPosition;
  76915. private _dataFetched;
  76916. /**
  76917. * Initializes the physics updraft event
  76918. * @param _scene BabylonJS scene
  76919. * @param _origin The origin position of the updraft
  76920. * @param _options The options for the updraft event
  76921. */
  76922. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  76923. /**
  76924. * Returns the data related to the updraft event (cylinder).
  76925. * @returns A physics updraft event
  76926. */
  76927. getData(): PhysicsUpdraftEventData;
  76928. /**
  76929. * Enables the updraft.
  76930. */
  76931. enable(): void;
  76932. /**
  76933. * Disables the updraft.
  76934. */
  76935. disable(): void;
  76936. /**
  76937. * Disposes the cylinder.
  76938. * @param force Specifies if the updraft should be disposed by force
  76939. */
  76940. dispose(force?: boolean): void;
  76941. private getImpostorHitData;
  76942. private _tick;
  76943. /*** Helpers ***/
  76944. private _prepareCylinder;
  76945. private _intersectsWithCylinder;
  76946. }
  76947. /**
  76948. * Represents a physics vortex event
  76949. */
  76950. class PhysicsVortexEvent {
  76951. private _scene;
  76952. private _origin;
  76953. private _options;
  76954. private _physicsEngine;
  76955. private _originTop;
  76956. private _tickCallback;
  76957. private _cylinder;
  76958. private _cylinderPosition;
  76959. private _dataFetched;
  76960. /**
  76961. * Initializes the physics vortex event
  76962. * @param _scene The BabylonJS scene
  76963. * @param _origin The origin position of the vortex
  76964. * @param _options The options for the vortex event
  76965. */
  76966. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  76967. /**
  76968. * Returns the data related to the vortex event (cylinder).
  76969. * @returns The physics vortex event data
  76970. */
  76971. getData(): PhysicsVortexEventData;
  76972. /**
  76973. * Enables the vortex.
  76974. */
  76975. enable(): void;
  76976. /**
  76977. * Disables the cortex.
  76978. */
  76979. disable(): void;
  76980. /**
  76981. * Disposes the sphere.
  76982. * @param force
  76983. */
  76984. dispose(force?: boolean): void;
  76985. private getImpostorHitData;
  76986. private _tick;
  76987. /*** Helpers ***/
  76988. private _prepareCylinder;
  76989. private _intersectsWithCylinder;
  76990. }
  76991. /**
  76992. * Options fot the radial explosion event
  76993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76994. */
  76995. export class PhysicsRadialExplosionEventOptions {
  76996. /**
  76997. * The radius of the sphere for the radial explosion.
  76998. */
  76999. radius: number;
  77000. /**
  77001. * The strenth of the explosion.
  77002. */
  77003. strength: number;
  77004. /**
  77005. * The strenght of the force in correspondence to the distance of the affected object
  77006. */
  77007. falloff: PhysicsRadialImpulseFalloff;
  77008. /**
  77009. * Sphere options for the radial explosion.
  77010. */
  77011. sphere: {
  77012. segments: number;
  77013. diameter: number;
  77014. };
  77015. /**
  77016. * Sphere options for the radial explosion.
  77017. */
  77018. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  77019. }
  77020. /**
  77021. * Options fot the updraft event
  77022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77023. */
  77024. export class PhysicsUpdraftEventOptions {
  77025. /**
  77026. * The radius of the cylinder for the vortex
  77027. */
  77028. radius: number;
  77029. /**
  77030. * The strenth of the updraft.
  77031. */
  77032. strength: number;
  77033. /**
  77034. * The height of the cylinder for the updraft.
  77035. */
  77036. height: number;
  77037. /**
  77038. * The mode for the the updraft.
  77039. */
  77040. updraftMode: PhysicsUpdraftMode;
  77041. }
  77042. /**
  77043. * Options fot the vortex event
  77044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77045. */
  77046. export class PhysicsVortexEventOptions {
  77047. /**
  77048. * The radius of the cylinder for the vortex
  77049. */
  77050. radius: number;
  77051. /**
  77052. * The strenth of the vortex.
  77053. */
  77054. strength: number;
  77055. /**
  77056. * The height of the cylinder for the vortex.
  77057. */
  77058. height: number;
  77059. /**
  77060. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  77061. */
  77062. centripetalForceThreshold: number;
  77063. /**
  77064. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  77065. */
  77066. centripetalForceMultiplier: number;
  77067. /**
  77068. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  77069. */
  77070. centrifugalForceMultiplier: number;
  77071. /**
  77072. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  77073. */
  77074. updraftForceMultiplier: number;
  77075. }
  77076. /**
  77077. * The strenght of the force in correspondence to the distance of the affected object
  77078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77079. */
  77080. export enum PhysicsRadialImpulseFalloff {
  77081. /** Defines that impulse is constant in strength across it's whole radius */
  77082. Constant = 0,
  77083. /** Defines that impulse gets weaker if it's further from the origin */
  77084. Linear = 1
  77085. }
  77086. /**
  77087. * The strength of the force in correspondence to the distance of the affected object
  77088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77089. */
  77090. export enum PhysicsUpdraftMode {
  77091. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  77092. Center = 0,
  77093. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  77094. Perpendicular = 1
  77095. }
  77096. /**
  77097. * Interface for a physics hit data
  77098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77099. */
  77100. export interface PhysicsHitData {
  77101. /**
  77102. * The force applied at the contact point
  77103. */
  77104. force: Vector3;
  77105. /**
  77106. * The contact point
  77107. */
  77108. contactPoint: Vector3;
  77109. /**
  77110. * The distance from the origin to the contact point
  77111. */
  77112. distanceFromOrigin: number;
  77113. }
  77114. /**
  77115. * Interface for radial explosion event data
  77116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77117. */
  77118. export interface PhysicsRadialExplosionEventData {
  77119. /**
  77120. * A sphere used for the radial explosion event
  77121. */
  77122. sphere: Mesh;
  77123. }
  77124. /**
  77125. * Interface for gravitational field event data
  77126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77127. */
  77128. export interface PhysicsGravitationalFieldEventData {
  77129. /**
  77130. * A sphere mesh used for the gravitational field event
  77131. */
  77132. sphere: Mesh;
  77133. }
  77134. /**
  77135. * Interface for updraft event data
  77136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77137. */
  77138. export interface PhysicsUpdraftEventData {
  77139. /**
  77140. * A cylinder used for the updraft event
  77141. */
  77142. cylinder: Mesh;
  77143. }
  77144. /**
  77145. * Interface for vortex event data
  77146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77147. */
  77148. export interface PhysicsVortexEventData {
  77149. /**
  77150. * A cylinder used for the vortex event
  77151. */
  77152. cylinder: Mesh;
  77153. }
  77154. /**
  77155. * Interface for an affected physics impostor
  77156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77157. */
  77158. export interface PhysicsAffectedImpostorWithData {
  77159. /**
  77160. * The impostor affected by the effect
  77161. */
  77162. impostor: PhysicsImpostor;
  77163. /**
  77164. * The data about the hit/horce from the explosion
  77165. */
  77166. hitData: PhysicsHitData;
  77167. }
  77168. }
  77169. declare module "babylonjs/Physics/Plugins/index" {
  77170. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  77171. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  77172. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  77173. }
  77174. declare module "babylonjs/Physics/index" {
  77175. export * from "babylonjs/Physics/IPhysicsEngine";
  77176. export * from "babylonjs/Physics/physicsEngine";
  77177. export * from "babylonjs/Physics/physicsEngineComponent";
  77178. export * from "babylonjs/Physics/physicsHelper";
  77179. export * from "babylonjs/Physics/physicsImpostor";
  77180. export * from "babylonjs/Physics/physicsJoint";
  77181. export * from "babylonjs/Physics/Plugins/index";
  77182. }
  77183. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  77184. /** @hidden */
  77185. export var blackAndWhitePixelShader: {
  77186. name: string;
  77187. shader: string;
  77188. };
  77189. }
  77190. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  77191. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77192. import { Camera } from "babylonjs/Cameras/camera";
  77193. import { Engine } from "babylonjs/Engines/engine";
  77194. import "babylonjs/Shaders/blackAndWhite.fragment";
  77195. import { Nullable } from "babylonjs/types";
  77196. import { Scene } from "babylonjs/scene";
  77197. /**
  77198. * Post process used to render in black and white
  77199. */
  77200. export class BlackAndWhitePostProcess extends PostProcess {
  77201. /**
  77202. * Linear about to convert he result to black and white (default: 1)
  77203. */
  77204. degree: number;
  77205. /**
  77206. * Gets a string identifying the name of the class
  77207. * @returns "BlackAndWhitePostProcess" string
  77208. */
  77209. getClassName(): string;
  77210. /**
  77211. * Creates a black and white post process
  77212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  77213. * @param name The name of the effect.
  77214. * @param options The required width/height ratio to downsize to before computing the render pass.
  77215. * @param camera The camera to apply the render pass to.
  77216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77217. * @param engine The engine which the post process will be applied. (default: current engine)
  77218. * @param reusable If the post process can be reused on the same frame. (default: false)
  77219. */
  77220. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77221. /** @hidden */
  77222. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  77223. }
  77224. }
  77225. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  77226. import { Nullable } from "babylonjs/types";
  77227. import { Camera } from "babylonjs/Cameras/camera";
  77228. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77229. import { Engine } from "babylonjs/Engines/engine";
  77230. /**
  77231. * This represents a set of one or more post processes in Babylon.
  77232. * A post process can be used to apply a shader to a texture after it is rendered.
  77233. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  77234. */
  77235. export class PostProcessRenderEffect {
  77236. private _postProcesses;
  77237. private _getPostProcesses;
  77238. private _singleInstance;
  77239. private _cameras;
  77240. private _indicesForCamera;
  77241. /**
  77242. * Name of the effect
  77243. * @hidden
  77244. */
  77245. _name: string;
  77246. /**
  77247. * Instantiates a post process render effect.
  77248. * A post process can be used to apply a shader to a texture after it is rendered.
  77249. * @param engine The engine the effect is tied to
  77250. * @param name The name of the effect
  77251. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  77252. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  77253. */
  77254. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  77255. /**
  77256. * Checks if all the post processes in the effect are supported.
  77257. */
  77258. get isSupported(): boolean;
  77259. /**
  77260. * Updates the current state of the effect
  77261. * @hidden
  77262. */
  77263. _update(): void;
  77264. /**
  77265. * Attaches the effect on cameras
  77266. * @param cameras The camera to attach to.
  77267. * @hidden
  77268. */
  77269. _attachCameras(cameras: Camera): void;
  77270. /**
  77271. * Attaches the effect on cameras
  77272. * @param cameras The camera to attach to.
  77273. * @hidden
  77274. */
  77275. _attachCameras(cameras: Camera[]): void;
  77276. /**
  77277. * Detaches the effect on cameras
  77278. * @param cameras The camera to detatch from.
  77279. * @hidden
  77280. */
  77281. _detachCameras(cameras: Camera): void;
  77282. /**
  77283. * Detatches the effect on cameras
  77284. * @param cameras The camera to detatch from.
  77285. * @hidden
  77286. */
  77287. _detachCameras(cameras: Camera[]): void;
  77288. /**
  77289. * Enables the effect on given cameras
  77290. * @param cameras The camera to enable.
  77291. * @hidden
  77292. */
  77293. _enable(cameras: Camera): void;
  77294. /**
  77295. * Enables the effect on given cameras
  77296. * @param cameras The camera to enable.
  77297. * @hidden
  77298. */
  77299. _enable(cameras: Nullable<Camera[]>): void;
  77300. /**
  77301. * Disables the effect on the given cameras
  77302. * @param cameras The camera to disable.
  77303. * @hidden
  77304. */
  77305. _disable(cameras: Camera): void;
  77306. /**
  77307. * Disables the effect on the given cameras
  77308. * @param cameras The camera to disable.
  77309. * @hidden
  77310. */
  77311. _disable(cameras: Nullable<Camera[]>): void;
  77312. /**
  77313. * Gets a list of the post processes contained in the effect.
  77314. * @param camera The camera to get the post processes on.
  77315. * @returns The list of the post processes in the effect.
  77316. */
  77317. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  77318. }
  77319. }
  77320. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  77321. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77322. /** @hidden */
  77323. export var extractHighlightsPixelShader: {
  77324. name: string;
  77325. shader: string;
  77326. };
  77327. }
  77328. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  77329. import { Nullable } from "babylonjs/types";
  77330. import { Camera } from "babylonjs/Cameras/camera";
  77331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77332. import { Engine } from "babylonjs/Engines/engine";
  77333. import "babylonjs/Shaders/extractHighlights.fragment";
  77334. /**
  77335. * 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.
  77336. */
  77337. export class ExtractHighlightsPostProcess extends PostProcess {
  77338. /**
  77339. * The luminance threshold, pixels below this value will be set to black.
  77340. */
  77341. threshold: number;
  77342. /** @hidden */
  77343. _exposure: number;
  77344. /**
  77345. * Post process which has the input texture to be used when performing highlight extraction
  77346. * @hidden
  77347. */
  77348. _inputPostProcess: Nullable<PostProcess>;
  77349. /**
  77350. * Gets a string identifying the name of the class
  77351. * @returns "ExtractHighlightsPostProcess" string
  77352. */
  77353. getClassName(): string;
  77354. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77355. }
  77356. }
  77357. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  77358. /** @hidden */
  77359. export var bloomMergePixelShader: {
  77360. name: string;
  77361. shader: string;
  77362. };
  77363. }
  77364. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  77365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77366. import { Nullable } from "babylonjs/types";
  77367. import { Engine } from "babylonjs/Engines/engine";
  77368. import { Camera } from "babylonjs/Cameras/camera";
  77369. import "babylonjs/Shaders/bloomMerge.fragment";
  77370. /**
  77371. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77372. */
  77373. export class BloomMergePostProcess extends PostProcess {
  77374. /** Weight of the bloom to be added to the original input. */
  77375. weight: number;
  77376. /**
  77377. * Gets a string identifying the name of the class
  77378. * @returns "BloomMergePostProcess" string
  77379. */
  77380. getClassName(): string;
  77381. /**
  77382. * Creates a new instance of @see BloomMergePostProcess
  77383. * @param name The name of the effect.
  77384. * @param originalFromInput Post process which's input will be used for the merge.
  77385. * @param blurred Blurred highlights post process which's output will be used.
  77386. * @param weight Weight of the bloom to be added to the original input.
  77387. * @param options The required width/height ratio to downsize to before computing the render pass.
  77388. * @param camera The camera to apply the render pass to.
  77389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77390. * @param engine The engine which the post process will be applied. (default: current engine)
  77391. * @param reusable If the post process can be reused on the same frame. (default: false)
  77392. * @param textureType Type of textures used when performing the post process. (default: 0)
  77393. * @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)
  77394. */
  77395. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  77396. /** Weight of the bloom to be added to the original input. */
  77397. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77398. }
  77399. }
  77400. declare module "babylonjs/PostProcesses/bloomEffect" {
  77401. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77403. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77404. import { Camera } from "babylonjs/Cameras/camera";
  77405. import { Scene } from "babylonjs/scene";
  77406. /**
  77407. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  77408. */
  77409. export class BloomEffect extends PostProcessRenderEffect {
  77410. private bloomScale;
  77411. /**
  77412. * @hidden Internal
  77413. */
  77414. _effects: Array<PostProcess>;
  77415. /**
  77416. * @hidden Internal
  77417. */
  77418. _downscale: ExtractHighlightsPostProcess;
  77419. private _blurX;
  77420. private _blurY;
  77421. private _merge;
  77422. /**
  77423. * The luminance threshold to find bright areas of the image to bloom.
  77424. */
  77425. get threshold(): number;
  77426. set threshold(value: number);
  77427. /**
  77428. * The strength of the bloom.
  77429. */
  77430. get weight(): number;
  77431. set weight(value: number);
  77432. /**
  77433. * Specifies the size of the bloom blur kernel, relative to the final output size
  77434. */
  77435. get kernel(): number;
  77436. set kernel(value: number);
  77437. /**
  77438. * Creates a new instance of @see BloomEffect
  77439. * @param scene The scene the effect belongs to.
  77440. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  77441. * @param bloomKernel The size of the kernel to be used when applying the blur.
  77442. * @param bloomWeight The the strength of bloom.
  77443. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77444. * @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)
  77445. */
  77446. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  77447. /**
  77448. * Disposes each of the internal effects for a given camera.
  77449. * @param camera The camera to dispose the effect on.
  77450. */
  77451. disposeEffects(camera: Camera): void;
  77452. /**
  77453. * @hidden Internal
  77454. */
  77455. _updateEffects(): void;
  77456. /**
  77457. * Internal
  77458. * @returns if all the contained post processes are ready.
  77459. * @hidden
  77460. */
  77461. _isReady(): boolean;
  77462. }
  77463. }
  77464. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  77465. /** @hidden */
  77466. export var chromaticAberrationPixelShader: {
  77467. name: string;
  77468. shader: string;
  77469. };
  77470. }
  77471. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  77472. import { Vector2 } from "babylonjs/Maths/math.vector";
  77473. import { Nullable } from "babylonjs/types";
  77474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77475. import { Camera } from "babylonjs/Cameras/camera";
  77476. import { Engine } from "babylonjs/Engines/engine";
  77477. import "babylonjs/Shaders/chromaticAberration.fragment";
  77478. import { Scene } from "babylonjs/scene";
  77479. /**
  77480. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  77481. */
  77482. export class ChromaticAberrationPostProcess extends PostProcess {
  77483. /**
  77484. * The amount of seperation of rgb channels (default: 30)
  77485. */
  77486. aberrationAmount: number;
  77487. /**
  77488. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  77489. */
  77490. radialIntensity: number;
  77491. /**
  77492. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  77493. */
  77494. direction: Vector2;
  77495. /**
  77496. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  77497. */
  77498. centerPosition: Vector2;
  77499. /** The width of the screen to apply the effect on */
  77500. screenWidth: number;
  77501. /** The height of the screen to apply the effect on */
  77502. screenHeight: number;
  77503. /**
  77504. * Gets a string identifying the name of the class
  77505. * @returns "ChromaticAberrationPostProcess" string
  77506. */
  77507. getClassName(): string;
  77508. /**
  77509. * Creates a new instance ChromaticAberrationPostProcess
  77510. * @param name The name of the effect.
  77511. * @param screenWidth The width of the screen to apply the effect on.
  77512. * @param screenHeight The height of the screen to apply the effect on.
  77513. * @param options The required width/height ratio to downsize to before computing the render pass.
  77514. * @param camera The camera to apply the render pass to.
  77515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77516. * @param engine The engine which the post process will be applied. (default: current engine)
  77517. * @param reusable If the post process can be reused on the same frame. (default: false)
  77518. * @param textureType Type of textures used when performing the post process. (default: 0)
  77519. * @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)
  77520. */
  77521. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77522. /** @hidden */
  77523. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  77524. }
  77525. }
  77526. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  77527. /** @hidden */
  77528. export var circleOfConfusionPixelShader: {
  77529. name: string;
  77530. shader: string;
  77531. };
  77532. }
  77533. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  77534. import { Nullable } from "babylonjs/types";
  77535. import { Engine } from "babylonjs/Engines/engine";
  77536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77538. import { Camera } from "babylonjs/Cameras/camera";
  77539. import "babylonjs/Shaders/circleOfConfusion.fragment";
  77540. /**
  77541. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  77542. */
  77543. export class CircleOfConfusionPostProcess extends PostProcess {
  77544. /**
  77545. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  77546. */
  77547. lensSize: number;
  77548. /**
  77549. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77550. */
  77551. fStop: number;
  77552. /**
  77553. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77554. */
  77555. focusDistance: number;
  77556. /**
  77557. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  77558. */
  77559. focalLength: number;
  77560. /**
  77561. * Gets a string identifying the name of the class
  77562. * @returns "CircleOfConfusionPostProcess" string
  77563. */
  77564. getClassName(): string;
  77565. private _depthTexture;
  77566. /**
  77567. * Creates a new instance CircleOfConfusionPostProcess
  77568. * @param name The name of the effect.
  77569. * @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.
  77570. * @param options The required width/height ratio to downsize to before computing the render pass.
  77571. * @param camera The camera to apply the render pass to.
  77572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77573. * @param engine The engine which the post process will be applied. (default: current engine)
  77574. * @param reusable If the post process can be reused on the same frame. (default: false)
  77575. * @param textureType Type of textures used when performing the post process. (default: 0)
  77576. * @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)
  77577. */
  77578. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77579. /**
  77580. * 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.
  77581. */
  77582. set depthTexture(value: RenderTargetTexture);
  77583. }
  77584. }
  77585. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  77586. /** @hidden */
  77587. export var colorCorrectionPixelShader: {
  77588. name: string;
  77589. shader: string;
  77590. };
  77591. }
  77592. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  77593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77594. import { Engine } from "babylonjs/Engines/engine";
  77595. import { Camera } from "babylonjs/Cameras/camera";
  77596. import "babylonjs/Shaders/colorCorrection.fragment";
  77597. import { Nullable } from "babylonjs/types";
  77598. import { Scene } from "babylonjs/scene";
  77599. /**
  77600. *
  77601. * This post-process allows the modification of rendered colors by using
  77602. * a 'look-up table' (LUT). This effect is also called Color Grading.
  77603. *
  77604. * The object needs to be provided an url to a texture containing the color
  77605. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  77606. * Use an image editing software to tweak the LUT to match your needs.
  77607. *
  77608. * For an example of a color LUT, see here:
  77609. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  77610. * For explanations on color grading, see here:
  77611. * @see http://udn.epicgames.com/Three/ColorGrading.html
  77612. *
  77613. */
  77614. export class ColorCorrectionPostProcess extends PostProcess {
  77615. private _colorTableTexture;
  77616. /**
  77617. * Gets the color table url used to create the LUT texture
  77618. */
  77619. colorTableUrl: string;
  77620. /**
  77621. * Gets a string identifying the name of the class
  77622. * @returns "ColorCorrectionPostProcess" string
  77623. */
  77624. getClassName(): string;
  77625. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77626. /** @hidden */
  77627. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  77628. }
  77629. }
  77630. declare module "babylonjs/Shaders/convolution.fragment" {
  77631. /** @hidden */
  77632. export var convolutionPixelShader: {
  77633. name: string;
  77634. shader: string;
  77635. };
  77636. }
  77637. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  77638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77639. import { Nullable } from "babylonjs/types";
  77640. import { Camera } from "babylonjs/Cameras/camera";
  77641. import { Engine } from "babylonjs/Engines/engine";
  77642. import "babylonjs/Shaders/convolution.fragment";
  77643. import { Scene } from "babylonjs/scene";
  77644. /**
  77645. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  77646. * input texture to perform effects such as edge detection or sharpening
  77647. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  77648. */
  77649. export class ConvolutionPostProcess extends PostProcess {
  77650. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  77651. kernel: number[];
  77652. /**
  77653. * Gets a string identifying the name of the class
  77654. * @returns "ConvolutionPostProcess" string
  77655. */
  77656. getClassName(): string;
  77657. /**
  77658. * Creates a new instance ConvolutionPostProcess
  77659. * @param name The name of the effect.
  77660. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  77661. * @param options The required width/height ratio to downsize to before computing the render pass.
  77662. * @param camera The camera to apply the render pass to.
  77663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77664. * @param engine The engine which the post process will be applied. (default: current engine)
  77665. * @param reusable If the post process can be reused on the same frame. (default: false)
  77666. * @param textureType Type of textures used when performing the post process. (default: 0)
  77667. */
  77668. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77669. /** @hidden */
  77670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  77671. /**
  77672. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77673. */
  77674. static EdgeDetect0Kernel: number[];
  77675. /**
  77676. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77677. */
  77678. static EdgeDetect1Kernel: number[];
  77679. /**
  77680. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77681. */
  77682. static EdgeDetect2Kernel: number[];
  77683. /**
  77684. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77685. */
  77686. static SharpenKernel: number[];
  77687. /**
  77688. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77689. */
  77690. static EmbossKernel: number[];
  77691. /**
  77692. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77693. */
  77694. static GaussianKernel: number[];
  77695. }
  77696. }
  77697. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  77698. import { Nullable } from "babylonjs/types";
  77699. import { Vector2 } from "babylonjs/Maths/math.vector";
  77700. import { Camera } from "babylonjs/Cameras/camera";
  77701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77702. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  77703. import { Engine } from "babylonjs/Engines/engine";
  77704. import { Scene } from "babylonjs/scene";
  77705. /**
  77706. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  77707. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  77708. * based on samples that have a large difference in distance than the center pixel.
  77709. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  77710. */
  77711. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  77712. /**
  77713. * The direction the blur should be applied
  77714. */
  77715. direction: Vector2;
  77716. /**
  77717. * Gets a string identifying the name of the class
  77718. * @returns "DepthOfFieldBlurPostProcess" string
  77719. */
  77720. getClassName(): string;
  77721. /**
  77722. * Creates a new instance CircleOfConfusionPostProcess
  77723. * @param name The name of the effect.
  77724. * @param scene The scene the effect belongs to.
  77725. * @param direction The direction the blur should be applied.
  77726. * @param kernel The size of the kernel used to blur.
  77727. * @param options The required width/height ratio to downsize to before computing the render pass.
  77728. * @param camera The camera to apply the render pass to.
  77729. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  77730. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  77731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77732. * @param engine The engine which the post process will be applied. (default: current engine)
  77733. * @param reusable If the post process can be reused on the same frame. (default: false)
  77734. * @param textureType Type of textures used when performing the post process. (default: 0)
  77735. * @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)
  77736. */
  77737. 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);
  77738. }
  77739. }
  77740. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  77741. /** @hidden */
  77742. export var depthOfFieldMergePixelShader: {
  77743. name: string;
  77744. shader: string;
  77745. };
  77746. }
  77747. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  77748. import { Nullable } from "babylonjs/types";
  77749. import { Camera } from "babylonjs/Cameras/camera";
  77750. import { Effect } from "babylonjs/Materials/effect";
  77751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77752. import { Engine } from "babylonjs/Engines/engine";
  77753. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  77754. /**
  77755. * Options to be set when merging outputs from the default pipeline.
  77756. */
  77757. export class DepthOfFieldMergePostProcessOptions {
  77758. /**
  77759. * The original image to merge on top of
  77760. */
  77761. originalFromInput: PostProcess;
  77762. /**
  77763. * Parameters to perform the merge of the depth of field effect
  77764. */
  77765. depthOfField?: {
  77766. circleOfConfusion: PostProcess;
  77767. blurSteps: Array<PostProcess>;
  77768. };
  77769. /**
  77770. * Parameters to perform the merge of bloom effect
  77771. */
  77772. bloom?: {
  77773. blurred: PostProcess;
  77774. weight: number;
  77775. };
  77776. }
  77777. /**
  77778. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77779. */
  77780. export class DepthOfFieldMergePostProcess extends PostProcess {
  77781. private blurSteps;
  77782. /**
  77783. * Gets a string identifying the name of the class
  77784. * @returns "DepthOfFieldMergePostProcess" string
  77785. */
  77786. getClassName(): string;
  77787. /**
  77788. * Creates a new instance of DepthOfFieldMergePostProcess
  77789. * @param name The name of the effect.
  77790. * @param originalFromInput Post process which's input will be used for the merge.
  77791. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  77792. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  77793. * @param options The required width/height ratio to downsize to before computing the render pass.
  77794. * @param camera The camera to apply the render pass to.
  77795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77796. * @param engine The engine which the post process will be applied. (default: current engine)
  77797. * @param reusable If the post process can be reused on the same frame. (default: false)
  77798. * @param textureType Type of textures used when performing the post process. (default: 0)
  77799. * @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)
  77800. */
  77801. 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);
  77802. /**
  77803. * Updates the effect with the current post process compile time values and recompiles the shader.
  77804. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  77805. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  77806. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  77807. * @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
  77808. * @param onCompiled Called when the shader has been compiled.
  77809. * @param onError Called if there is an error when compiling a shader.
  77810. */
  77811. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  77812. }
  77813. }
  77814. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  77815. import { Nullable } from "babylonjs/types";
  77816. import { Camera } from "babylonjs/Cameras/camera";
  77817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77819. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77820. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77821. import { Scene } from "babylonjs/scene";
  77822. /**
  77823. * Specifies the level of max blur that should be applied when using the depth of field effect
  77824. */
  77825. export enum DepthOfFieldEffectBlurLevel {
  77826. /**
  77827. * Subtle blur
  77828. */
  77829. Low = 0,
  77830. /**
  77831. * Medium blur
  77832. */
  77833. Medium = 1,
  77834. /**
  77835. * Large blur
  77836. */
  77837. High = 2
  77838. }
  77839. /**
  77840. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  77841. */
  77842. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  77843. private _circleOfConfusion;
  77844. /**
  77845. * @hidden Internal, blurs from high to low
  77846. */
  77847. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  77848. private _depthOfFieldBlurY;
  77849. private _dofMerge;
  77850. /**
  77851. * @hidden Internal post processes in depth of field effect
  77852. */
  77853. _effects: Array<PostProcess>;
  77854. /**
  77855. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  77856. */
  77857. set focalLength(value: number);
  77858. get focalLength(): number;
  77859. /**
  77860. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77861. */
  77862. set fStop(value: number);
  77863. get fStop(): number;
  77864. /**
  77865. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77866. */
  77867. set focusDistance(value: number);
  77868. get focusDistance(): number;
  77869. /**
  77870. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  77871. */
  77872. set lensSize(value: number);
  77873. get lensSize(): number;
  77874. /**
  77875. * Creates a new instance DepthOfFieldEffect
  77876. * @param scene The scene the effect belongs to.
  77877. * @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.
  77878. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77879. * @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)
  77880. */
  77881. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  77882. /**
  77883. * Get the current class name of the current effet
  77884. * @returns "DepthOfFieldEffect"
  77885. */
  77886. getClassName(): string;
  77887. /**
  77888. * 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.
  77889. */
  77890. set depthTexture(value: RenderTargetTexture);
  77891. /**
  77892. * Disposes each of the internal effects for a given camera.
  77893. * @param camera The camera to dispose the effect on.
  77894. */
  77895. disposeEffects(camera: Camera): void;
  77896. /**
  77897. * @hidden Internal
  77898. */
  77899. _updateEffects(): void;
  77900. /**
  77901. * Internal
  77902. * @returns if all the contained post processes are ready.
  77903. * @hidden
  77904. */
  77905. _isReady(): boolean;
  77906. }
  77907. }
  77908. declare module "babylonjs/Shaders/displayPass.fragment" {
  77909. /** @hidden */
  77910. export var displayPassPixelShader: {
  77911. name: string;
  77912. shader: string;
  77913. };
  77914. }
  77915. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  77916. import { Nullable } from "babylonjs/types";
  77917. import { Camera } from "babylonjs/Cameras/camera";
  77918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77919. import { Engine } from "babylonjs/Engines/engine";
  77920. import "babylonjs/Shaders/displayPass.fragment";
  77921. import { Scene } from "babylonjs/scene";
  77922. /**
  77923. * DisplayPassPostProcess which produces an output the same as it's input
  77924. */
  77925. export class DisplayPassPostProcess extends PostProcess {
  77926. /**
  77927. * Gets a string identifying the name of the class
  77928. * @returns "DisplayPassPostProcess" string
  77929. */
  77930. getClassName(): string;
  77931. /**
  77932. * Creates the DisplayPassPostProcess
  77933. * @param name The name of the effect.
  77934. * @param options The required width/height ratio to downsize to before computing the render pass.
  77935. * @param camera The camera to apply the render pass to.
  77936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77937. * @param engine The engine which the post process will be applied. (default: current engine)
  77938. * @param reusable If the post process can be reused on the same frame. (default: false)
  77939. */
  77940. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77941. /** @hidden */
  77942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  77943. }
  77944. }
  77945. declare module "babylonjs/Shaders/filter.fragment" {
  77946. /** @hidden */
  77947. export var filterPixelShader: {
  77948. name: string;
  77949. shader: string;
  77950. };
  77951. }
  77952. declare module "babylonjs/PostProcesses/filterPostProcess" {
  77953. import { Nullable } from "babylonjs/types";
  77954. import { Matrix } from "babylonjs/Maths/math.vector";
  77955. import { Camera } from "babylonjs/Cameras/camera";
  77956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77957. import { Engine } from "babylonjs/Engines/engine";
  77958. import "babylonjs/Shaders/filter.fragment";
  77959. import { Scene } from "babylonjs/scene";
  77960. /**
  77961. * Applies a kernel filter to the image
  77962. */
  77963. export class FilterPostProcess extends PostProcess {
  77964. /** The matrix to be applied to the image */
  77965. kernelMatrix: Matrix;
  77966. /**
  77967. * Gets a string identifying the name of the class
  77968. * @returns "FilterPostProcess" string
  77969. */
  77970. getClassName(): string;
  77971. /**
  77972. *
  77973. * @param name The name of the effect.
  77974. * @param kernelMatrix The matrix to be applied to the image
  77975. * @param options The required width/height ratio to downsize to before computing the render pass.
  77976. * @param camera The camera to apply the render pass to.
  77977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77978. * @param engine The engine which the post process will be applied. (default: current engine)
  77979. * @param reusable If the post process can be reused on the same frame. (default: false)
  77980. */
  77981. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77982. /** @hidden */
  77983. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  77984. }
  77985. }
  77986. declare module "babylonjs/Shaders/fxaa.fragment" {
  77987. /** @hidden */
  77988. export var fxaaPixelShader: {
  77989. name: string;
  77990. shader: string;
  77991. };
  77992. }
  77993. declare module "babylonjs/Shaders/fxaa.vertex" {
  77994. /** @hidden */
  77995. export var fxaaVertexShader: {
  77996. name: string;
  77997. shader: string;
  77998. };
  77999. }
  78000. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  78001. import { Nullable } from "babylonjs/types";
  78002. import { Camera } from "babylonjs/Cameras/camera";
  78003. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78004. import { Engine } from "babylonjs/Engines/engine";
  78005. import "babylonjs/Shaders/fxaa.fragment";
  78006. import "babylonjs/Shaders/fxaa.vertex";
  78007. import { Scene } from "babylonjs/scene";
  78008. /**
  78009. * Fxaa post process
  78010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  78011. */
  78012. export class FxaaPostProcess extends PostProcess {
  78013. /**
  78014. * Gets a string identifying the name of the class
  78015. * @returns "FxaaPostProcess" string
  78016. */
  78017. getClassName(): string;
  78018. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78019. private _getDefines;
  78020. /** @hidden */
  78021. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  78022. }
  78023. }
  78024. declare module "babylonjs/Shaders/grain.fragment" {
  78025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  78026. /** @hidden */
  78027. export var grainPixelShader: {
  78028. name: string;
  78029. shader: string;
  78030. };
  78031. }
  78032. declare module "babylonjs/PostProcesses/grainPostProcess" {
  78033. import { Nullable } from "babylonjs/types";
  78034. import { Camera } from "babylonjs/Cameras/camera";
  78035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78036. import { Engine } from "babylonjs/Engines/engine";
  78037. import "babylonjs/Shaders/grain.fragment";
  78038. import { Scene } from "babylonjs/scene";
  78039. /**
  78040. * The GrainPostProcess adds noise to the image at mid luminance levels
  78041. */
  78042. export class GrainPostProcess extends PostProcess {
  78043. /**
  78044. * The intensity of the grain added (default: 30)
  78045. */
  78046. intensity: number;
  78047. /**
  78048. * If the grain should be randomized on every frame
  78049. */
  78050. animated: boolean;
  78051. /**
  78052. * Gets a string identifying the name of the class
  78053. * @returns "GrainPostProcess" string
  78054. */
  78055. getClassName(): string;
  78056. /**
  78057. * Creates a new instance of @see GrainPostProcess
  78058. * @param name The name of the effect.
  78059. * @param options The required width/height ratio to downsize to before computing the render pass.
  78060. * @param camera The camera to apply the render pass to.
  78061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78062. * @param engine The engine which the post process will be applied. (default: current engine)
  78063. * @param reusable If the post process can be reused on the same frame. (default: false)
  78064. * @param textureType Type of textures used when performing the post process. (default: 0)
  78065. * @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)
  78066. */
  78067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78068. /** @hidden */
  78069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  78070. }
  78071. }
  78072. declare module "babylonjs/Shaders/highlights.fragment" {
  78073. /** @hidden */
  78074. export var highlightsPixelShader: {
  78075. name: string;
  78076. shader: string;
  78077. };
  78078. }
  78079. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  78080. import { Nullable } from "babylonjs/types";
  78081. import { Camera } from "babylonjs/Cameras/camera";
  78082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78083. import { Engine } from "babylonjs/Engines/engine";
  78084. import "babylonjs/Shaders/highlights.fragment";
  78085. /**
  78086. * Extracts highlights from the image
  78087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78088. */
  78089. export class HighlightsPostProcess extends PostProcess {
  78090. /**
  78091. * Gets a string identifying the name of the class
  78092. * @returns "HighlightsPostProcess" string
  78093. */
  78094. getClassName(): string;
  78095. /**
  78096. * Extracts highlights from the image
  78097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78098. * @param name The name of the effect.
  78099. * @param options The required width/height ratio to downsize to before computing the render pass.
  78100. * @param camera The camera to apply the render pass to.
  78101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78102. * @param engine The engine which the post process will be applied. (default: current engine)
  78103. * @param reusable If the post process can be reused on the same frame. (default: false)
  78104. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  78105. */
  78106. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78107. }
  78108. }
  78109. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  78110. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  78111. /**
  78112. * Contains all parameters needed for the prepass to perform
  78113. * motion blur
  78114. */
  78115. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  78116. /**
  78117. * Is motion blur enabled
  78118. */
  78119. enabled: boolean;
  78120. /**
  78121. * Name of the configuration
  78122. */
  78123. name: string;
  78124. /**
  78125. * Textures that should be present in the MRT for this effect to work
  78126. */
  78127. readonly texturesRequired: number[];
  78128. }
  78129. }
  78130. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  78131. import { Nullable } from "babylonjs/types";
  78132. import { Scene } from "babylonjs/scene";
  78133. import { ISceneComponent } from "babylonjs/sceneComponent";
  78134. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  78135. module "babylonjs/scene" {
  78136. interface Scene {
  78137. /** @hidden (Backing field) */
  78138. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78139. /**
  78140. * Gets or Sets the current geometry buffer associated to the scene.
  78141. */
  78142. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78143. /**
  78144. * Enables a GeometryBufferRender and associates it with the scene
  78145. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  78146. * @returns the GeometryBufferRenderer
  78147. */
  78148. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  78149. /**
  78150. * Disables the GeometryBufferRender associated with the scene
  78151. */
  78152. disableGeometryBufferRenderer(): void;
  78153. }
  78154. }
  78155. /**
  78156. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  78157. * in several rendering techniques.
  78158. */
  78159. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  78160. /**
  78161. * The component name helpful to identify the component in the list of scene components.
  78162. */
  78163. readonly name: string;
  78164. /**
  78165. * The scene the component belongs to.
  78166. */
  78167. scene: Scene;
  78168. /**
  78169. * Creates a new instance of the component for the given scene
  78170. * @param scene Defines the scene to register the component in
  78171. */
  78172. constructor(scene: Scene);
  78173. /**
  78174. * Registers the component in a given scene
  78175. */
  78176. register(): void;
  78177. /**
  78178. * Rebuilds the elements related to this component in case of
  78179. * context lost for instance.
  78180. */
  78181. rebuild(): void;
  78182. /**
  78183. * Disposes the component and the associated ressources
  78184. */
  78185. dispose(): void;
  78186. private _gatherRenderTargets;
  78187. }
  78188. }
  78189. declare module "babylonjs/Shaders/motionBlur.fragment" {
  78190. /** @hidden */
  78191. export var motionBlurPixelShader: {
  78192. name: string;
  78193. shader: string;
  78194. };
  78195. }
  78196. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  78197. import { Nullable } from "babylonjs/types";
  78198. import { Camera } from "babylonjs/Cameras/camera";
  78199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78201. import "babylonjs/Animations/animatable";
  78202. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  78203. import "babylonjs/Shaders/motionBlur.fragment";
  78204. import { Engine } from "babylonjs/Engines/engine";
  78205. import { Scene } from "babylonjs/scene";
  78206. /**
  78207. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  78208. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  78209. * As an example, all you have to do is to create the post-process:
  78210. * var mb = new BABYLON.MotionBlurPostProcess(
  78211. * 'mb', // The name of the effect.
  78212. * scene, // The scene containing the objects to blur according to their velocity.
  78213. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  78214. * camera // The camera to apply the render pass to.
  78215. * );
  78216. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  78217. */
  78218. export class MotionBlurPostProcess extends PostProcess {
  78219. /**
  78220. * Defines how much the image is blurred by the movement. Default value is equal to 1
  78221. */
  78222. motionStrength: number;
  78223. /**
  78224. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  78225. */
  78226. get motionBlurSamples(): number;
  78227. /**
  78228. * Sets the number of iterations to be used for motion blur quality
  78229. */
  78230. set motionBlurSamples(samples: number);
  78231. private _motionBlurSamples;
  78232. /**
  78233. * Gets wether or not the motion blur post-process is in object based mode.
  78234. */
  78235. get isObjectBased(): boolean;
  78236. /**
  78237. * Sets wether or not the motion blur post-process is in object based mode.
  78238. */
  78239. set isObjectBased(value: boolean);
  78240. private _isObjectBased;
  78241. private _forceGeometryBuffer;
  78242. private _geometryBufferRenderer;
  78243. private _prePassRenderer;
  78244. private _invViewProjection;
  78245. private _previousViewProjection;
  78246. /**
  78247. * Gets a string identifying the name of the class
  78248. * @returns "MotionBlurPostProcess" string
  78249. */
  78250. getClassName(): string;
  78251. /**
  78252. * Creates a new instance MotionBlurPostProcess
  78253. * @param name The name of the effect.
  78254. * @param scene The scene containing the objects to blur according to their velocity.
  78255. * @param options The required width/height ratio to downsize to before computing the render pass.
  78256. * @param camera The camera to apply the render pass to.
  78257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78258. * @param engine The engine which the post process will be applied. (default: current engine)
  78259. * @param reusable If the post process can be reused on the same frame. (default: false)
  78260. * @param textureType Type of textures used when performing the post process. (default: 0)
  78261. * @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)
  78262. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  78263. */
  78264. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  78265. /**
  78266. * Excludes the given skinned mesh from computing bones velocities.
  78267. * 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.
  78268. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  78269. */
  78270. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78271. /**
  78272. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  78273. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  78274. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  78275. */
  78276. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78277. /**
  78278. * Disposes the post process.
  78279. * @param camera The camera to dispose the post process on.
  78280. */
  78281. dispose(camera?: Camera): void;
  78282. /**
  78283. * Called on the mode changed (object based or screen based).
  78284. */
  78285. private _applyMode;
  78286. /**
  78287. * Called on the effect is applied when the motion blur post-process is in object based mode.
  78288. */
  78289. private _onApplyObjectBased;
  78290. /**
  78291. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  78292. */
  78293. private _onApplyScreenBased;
  78294. /**
  78295. * Called on the effect must be updated (changed mode, samples count, etc.).
  78296. */
  78297. private _updateEffect;
  78298. /** @hidden */
  78299. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  78300. }
  78301. }
  78302. declare module "babylonjs/Shaders/refraction.fragment" {
  78303. /** @hidden */
  78304. export var refractionPixelShader: {
  78305. name: string;
  78306. shader: string;
  78307. };
  78308. }
  78309. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  78310. import { Color3 } from "babylonjs/Maths/math.color";
  78311. import { Camera } from "babylonjs/Cameras/camera";
  78312. import { Texture } from "babylonjs/Materials/Textures/texture";
  78313. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78314. import { Engine } from "babylonjs/Engines/engine";
  78315. import "babylonjs/Shaders/refraction.fragment";
  78316. import { Scene } from "babylonjs/scene";
  78317. /**
  78318. * Post process which applies a refractin texture
  78319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78320. */
  78321. export class RefractionPostProcess extends PostProcess {
  78322. private _refTexture;
  78323. private _ownRefractionTexture;
  78324. /** the base color of the refraction (used to taint the rendering) */
  78325. color: Color3;
  78326. /** simulated refraction depth */
  78327. depth: number;
  78328. /** the coefficient of the base color (0 to remove base color tainting) */
  78329. colorLevel: number;
  78330. /** Gets the url used to load the refraction texture */
  78331. refractionTextureUrl: string;
  78332. /**
  78333. * Gets or sets the refraction texture
  78334. * Please note that you are responsible for disposing the texture if you set it manually
  78335. */
  78336. get refractionTexture(): Texture;
  78337. set refractionTexture(value: Texture);
  78338. /**
  78339. * Gets a string identifying the name of the class
  78340. * @returns "RefractionPostProcess" string
  78341. */
  78342. getClassName(): string;
  78343. /**
  78344. * Initializes the RefractionPostProcess
  78345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78346. * @param name The name of the effect.
  78347. * @param refractionTextureUrl Url of the refraction texture to use
  78348. * @param color the base color of the refraction (used to taint the rendering)
  78349. * @param depth simulated refraction depth
  78350. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  78351. * @param camera The camera to apply the render pass to.
  78352. * @param options The required width/height ratio to downsize to before computing the render pass.
  78353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78354. * @param engine The engine which the post process will be applied. (default: current engine)
  78355. * @param reusable If the post process can be reused on the same frame. (default: false)
  78356. */
  78357. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78358. /**
  78359. * Disposes of the post process
  78360. * @param camera Camera to dispose post process on
  78361. */
  78362. dispose(camera: Camera): void;
  78363. /** @hidden */
  78364. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  78365. }
  78366. }
  78367. declare module "babylonjs/Shaders/sharpen.fragment" {
  78368. /** @hidden */
  78369. export var sharpenPixelShader: {
  78370. name: string;
  78371. shader: string;
  78372. };
  78373. }
  78374. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  78375. import { Nullable } from "babylonjs/types";
  78376. import { Camera } from "babylonjs/Cameras/camera";
  78377. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78378. import "babylonjs/Shaders/sharpen.fragment";
  78379. import { Engine } from "babylonjs/Engines/engine";
  78380. import { Scene } from "babylonjs/scene";
  78381. /**
  78382. * The SharpenPostProcess applies a sharpen kernel to every pixel
  78383. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78384. */
  78385. export class SharpenPostProcess extends PostProcess {
  78386. /**
  78387. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  78388. */
  78389. colorAmount: number;
  78390. /**
  78391. * How much sharpness should be applied (default: 0.3)
  78392. */
  78393. edgeAmount: number;
  78394. /**
  78395. * Gets a string identifying the name of the class
  78396. * @returns "SharpenPostProcess" string
  78397. */
  78398. getClassName(): string;
  78399. /**
  78400. * Creates a new instance ConvolutionPostProcess
  78401. * @param name The name of the effect.
  78402. * @param options The required width/height ratio to downsize to before computing the render pass.
  78403. * @param camera The camera to apply the render pass to.
  78404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78405. * @param engine The engine which the post process will be applied. (default: current engine)
  78406. * @param reusable If the post process can be reused on the same frame. (default: false)
  78407. * @param textureType Type of textures used when performing the post process. (default: 0)
  78408. * @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)
  78409. */
  78410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78411. /** @hidden */
  78412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  78413. }
  78414. }
  78415. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  78416. import { Nullable } from "babylonjs/types";
  78417. import { Camera } from "babylonjs/Cameras/camera";
  78418. import { Engine } from "babylonjs/Engines/engine";
  78419. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78420. import { IInspectable } from "babylonjs/Misc/iInspectable";
  78421. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  78422. /**
  78423. * PostProcessRenderPipeline
  78424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78425. */
  78426. export class PostProcessRenderPipeline {
  78427. private engine;
  78428. private _renderEffects;
  78429. private _renderEffectsForIsolatedPass;
  78430. /**
  78431. * List of inspectable custom properties (used by the Inspector)
  78432. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78433. */
  78434. inspectableCustomProperties: IInspectable[];
  78435. /**
  78436. * @hidden
  78437. */
  78438. protected _cameras: Camera[];
  78439. /** @hidden */
  78440. _name: string;
  78441. /**
  78442. * Gets pipeline name
  78443. */
  78444. get name(): string;
  78445. /** Gets the list of attached cameras */
  78446. get cameras(): Camera[];
  78447. /**
  78448. * Initializes a PostProcessRenderPipeline
  78449. * @param engine engine to add the pipeline to
  78450. * @param name name of the pipeline
  78451. */
  78452. constructor(engine: Engine, name: string);
  78453. /**
  78454. * Gets the class name
  78455. * @returns "PostProcessRenderPipeline"
  78456. */
  78457. getClassName(): string;
  78458. /**
  78459. * If all the render effects in the pipeline are supported
  78460. */
  78461. get isSupported(): boolean;
  78462. /**
  78463. * Adds an effect to the pipeline
  78464. * @param renderEffect the effect to add
  78465. */
  78466. addEffect(renderEffect: PostProcessRenderEffect): void;
  78467. /** @hidden */
  78468. _rebuild(): void;
  78469. /** @hidden */
  78470. _enableEffect(renderEffectName: string, cameras: Camera): void;
  78471. /** @hidden */
  78472. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  78473. /** @hidden */
  78474. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78475. /** @hidden */
  78476. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78477. /** @hidden */
  78478. _attachCameras(cameras: Camera, unique: boolean): void;
  78479. /** @hidden */
  78480. _attachCameras(cameras: Camera[], unique: boolean): void;
  78481. /** @hidden */
  78482. _detachCameras(cameras: Camera): void;
  78483. /** @hidden */
  78484. _detachCameras(cameras: Nullable<Camera[]>): void;
  78485. /** @hidden */
  78486. _update(): void;
  78487. /** @hidden */
  78488. _reset(): void;
  78489. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  78490. /**
  78491. * Sets the required values to the prepass renderer.
  78492. * @param prePassRenderer defines the prepass renderer to setup.
  78493. * @returns true if the pre pass is needed.
  78494. */
  78495. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  78496. /**
  78497. * Disposes of the pipeline
  78498. */
  78499. dispose(): void;
  78500. }
  78501. }
  78502. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  78503. import { Camera } from "babylonjs/Cameras/camera";
  78504. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78505. /**
  78506. * PostProcessRenderPipelineManager class
  78507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78508. */
  78509. export class PostProcessRenderPipelineManager {
  78510. private _renderPipelines;
  78511. /**
  78512. * Initializes a PostProcessRenderPipelineManager
  78513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78514. */
  78515. constructor();
  78516. /**
  78517. * Gets the list of supported render pipelines
  78518. */
  78519. get supportedPipelines(): PostProcessRenderPipeline[];
  78520. /**
  78521. * Adds a pipeline to the manager
  78522. * @param renderPipeline The pipeline to add
  78523. */
  78524. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  78525. /**
  78526. * Attaches a camera to the pipeline
  78527. * @param renderPipelineName The name of the pipeline to attach to
  78528. * @param cameras the camera to attach
  78529. * @param unique if the camera can be attached multiple times to the pipeline
  78530. */
  78531. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  78532. /**
  78533. * Detaches a camera from the pipeline
  78534. * @param renderPipelineName The name of the pipeline to detach from
  78535. * @param cameras the camera to detach
  78536. */
  78537. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  78538. /**
  78539. * Enables an effect by name on a pipeline
  78540. * @param renderPipelineName the name of the pipeline to enable the effect in
  78541. * @param renderEffectName the name of the effect to enable
  78542. * @param cameras the cameras that the effect should be enabled on
  78543. */
  78544. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78545. /**
  78546. * Disables an effect by name on a pipeline
  78547. * @param renderPipelineName the name of the pipeline to disable the effect in
  78548. * @param renderEffectName the name of the effect to disable
  78549. * @param cameras the cameras that the effect should be disabled on
  78550. */
  78551. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78552. /**
  78553. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  78554. */
  78555. update(): void;
  78556. /** @hidden */
  78557. _rebuild(): void;
  78558. /**
  78559. * Disposes of the manager and pipelines
  78560. */
  78561. dispose(): void;
  78562. }
  78563. }
  78564. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  78565. import { ISceneComponent } from "babylonjs/sceneComponent";
  78566. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  78567. import { Scene } from "babylonjs/scene";
  78568. module "babylonjs/scene" {
  78569. interface Scene {
  78570. /** @hidden (Backing field) */
  78571. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78572. /**
  78573. * Gets the postprocess render pipeline manager
  78574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78575. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78576. */
  78577. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78578. }
  78579. }
  78580. /**
  78581. * Defines the Render Pipeline scene component responsible to rendering pipelines
  78582. */
  78583. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  78584. /**
  78585. * The component name helpfull to identify the component in the list of scene components.
  78586. */
  78587. readonly name: string;
  78588. /**
  78589. * The scene the component belongs to.
  78590. */
  78591. scene: Scene;
  78592. /**
  78593. * Creates a new instance of the component for the given scene
  78594. * @param scene Defines the scene to register the component in
  78595. */
  78596. constructor(scene: Scene);
  78597. /**
  78598. * Registers the component in a given scene
  78599. */
  78600. register(): void;
  78601. /**
  78602. * Rebuilds the elements related to this component in case of
  78603. * context lost for instance.
  78604. */
  78605. rebuild(): void;
  78606. /**
  78607. * Disposes the component and the associated ressources
  78608. */
  78609. dispose(): void;
  78610. private _gatherRenderTargets;
  78611. }
  78612. }
  78613. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  78614. import { Nullable } from "babylonjs/types";
  78615. import { Observable } from "babylonjs/Misc/observable";
  78616. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  78617. import { Camera } from "babylonjs/Cameras/camera";
  78618. import { IDisposable } from "babylonjs/scene";
  78619. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  78620. import { Scene } from "babylonjs/scene";
  78621. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  78622. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  78623. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  78624. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  78625. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  78626. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78627. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  78628. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78629. import { Animation } from "babylonjs/Animations/animation";
  78630. /**
  78631. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  78632. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78633. */
  78634. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  78635. private _scene;
  78636. private _camerasToBeAttached;
  78637. /**
  78638. * ID of the sharpen post process,
  78639. */
  78640. private readonly SharpenPostProcessId;
  78641. /**
  78642. * @ignore
  78643. * ID of the image processing post process;
  78644. */
  78645. readonly ImageProcessingPostProcessId: string;
  78646. /**
  78647. * @ignore
  78648. * ID of the Fast Approximate Anti-Aliasing post process;
  78649. */
  78650. readonly FxaaPostProcessId: string;
  78651. /**
  78652. * ID of the chromatic aberration post process,
  78653. */
  78654. private readonly ChromaticAberrationPostProcessId;
  78655. /**
  78656. * ID of the grain post process
  78657. */
  78658. private readonly GrainPostProcessId;
  78659. /**
  78660. * Sharpen post process which will apply a sharpen convolution to enhance edges
  78661. */
  78662. sharpen: SharpenPostProcess;
  78663. private _sharpenEffect;
  78664. private bloom;
  78665. /**
  78666. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  78667. */
  78668. depthOfField: DepthOfFieldEffect;
  78669. /**
  78670. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  78671. */
  78672. fxaa: FxaaPostProcess;
  78673. /**
  78674. * Image post processing pass used to perform operations such as tone mapping or color grading.
  78675. */
  78676. imageProcessing: ImageProcessingPostProcess;
  78677. /**
  78678. * Chromatic aberration post process which will shift rgb colors in the image
  78679. */
  78680. chromaticAberration: ChromaticAberrationPostProcess;
  78681. private _chromaticAberrationEffect;
  78682. /**
  78683. * Grain post process which add noise to the image
  78684. */
  78685. grain: GrainPostProcess;
  78686. private _grainEffect;
  78687. /**
  78688. * Glow post process which adds a glow to emissive areas of the image
  78689. */
  78690. private _glowLayer;
  78691. /**
  78692. * Animations which can be used to tweak settings over a period of time
  78693. */
  78694. animations: Animation[];
  78695. private _imageProcessingConfigurationObserver;
  78696. private _sharpenEnabled;
  78697. private _bloomEnabled;
  78698. private _depthOfFieldEnabled;
  78699. private _depthOfFieldBlurLevel;
  78700. private _fxaaEnabled;
  78701. private _imageProcessingEnabled;
  78702. private _defaultPipelineTextureType;
  78703. private _bloomScale;
  78704. private _chromaticAberrationEnabled;
  78705. private _grainEnabled;
  78706. private _buildAllowed;
  78707. /**
  78708. * This is triggered each time the pipeline has been built.
  78709. */
  78710. onBuildObservable: Observable<DefaultRenderingPipeline>;
  78711. /**
  78712. * Gets active scene
  78713. */
  78714. get scene(): Scene;
  78715. /**
  78716. * Enable or disable the sharpen process from the pipeline
  78717. */
  78718. set sharpenEnabled(enabled: boolean);
  78719. get sharpenEnabled(): boolean;
  78720. private _resizeObserver;
  78721. private _hardwareScaleLevel;
  78722. private _bloomKernel;
  78723. /**
  78724. * Specifies the size of the bloom blur kernel, relative to the final output size
  78725. */
  78726. get bloomKernel(): number;
  78727. set bloomKernel(value: number);
  78728. /**
  78729. * Specifies the weight of the bloom in the final rendering
  78730. */
  78731. private _bloomWeight;
  78732. /**
  78733. * Specifies the luma threshold for the area that will be blurred by the bloom
  78734. */
  78735. private _bloomThreshold;
  78736. private _hdr;
  78737. /**
  78738. * The strength of the bloom.
  78739. */
  78740. set bloomWeight(value: number);
  78741. get bloomWeight(): number;
  78742. /**
  78743. * The strength of the bloom.
  78744. */
  78745. set bloomThreshold(value: number);
  78746. get bloomThreshold(): number;
  78747. /**
  78748. * The scale of the bloom, lower value will provide better performance.
  78749. */
  78750. set bloomScale(value: number);
  78751. get bloomScale(): number;
  78752. /**
  78753. * Enable or disable the bloom from the pipeline
  78754. */
  78755. set bloomEnabled(enabled: boolean);
  78756. get bloomEnabled(): boolean;
  78757. private _rebuildBloom;
  78758. /**
  78759. * If the depth of field is enabled.
  78760. */
  78761. get depthOfFieldEnabled(): boolean;
  78762. set depthOfFieldEnabled(enabled: boolean);
  78763. /**
  78764. * Blur level of the depth of field effect. (Higher blur will effect performance)
  78765. */
  78766. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  78767. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  78768. /**
  78769. * If the anti aliasing is enabled.
  78770. */
  78771. set fxaaEnabled(enabled: boolean);
  78772. get fxaaEnabled(): boolean;
  78773. private _samples;
  78774. /**
  78775. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  78776. */
  78777. set samples(sampleCount: number);
  78778. get samples(): number;
  78779. /**
  78780. * If image processing is enabled.
  78781. */
  78782. set imageProcessingEnabled(enabled: boolean);
  78783. get imageProcessingEnabled(): boolean;
  78784. /**
  78785. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  78786. */
  78787. set glowLayerEnabled(enabled: boolean);
  78788. get glowLayerEnabled(): boolean;
  78789. /**
  78790. * Gets the glow layer (or null if not defined)
  78791. */
  78792. get glowLayer(): Nullable<GlowLayer>;
  78793. /**
  78794. * Enable or disable the chromaticAberration process from the pipeline
  78795. */
  78796. set chromaticAberrationEnabled(enabled: boolean);
  78797. get chromaticAberrationEnabled(): boolean;
  78798. /**
  78799. * Enable or disable the grain process from the pipeline
  78800. */
  78801. set grainEnabled(enabled: boolean);
  78802. get grainEnabled(): boolean;
  78803. /**
  78804. * @constructor
  78805. * @param name - The rendering pipeline name (default: "")
  78806. * @param hdr - If high dynamic range textures should be used (default: true)
  78807. * @param scene - The scene linked to this pipeline (default: the last created scene)
  78808. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  78809. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  78810. */
  78811. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  78812. /**
  78813. * Get the class name
  78814. * @returns "DefaultRenderingPipeline"
  78815. */
  78816. getClassName(): string;
  78817. /**
  78818. * Force the compilation of the entire pipeline.
  78819. */
  78820. prepare(): void;
  78821. private _hasCleared;
  78822. private _prevPostProcess;
  78823. private _prevPrevPostProcess;
  78824. private _setAutoClearAndTextureSharing;
  78825. private _depthOfFieldSceneObserver;
  78826. private _buildPipeline;
  78827. private _disposePostProcesses;
  78828. /**
  78829. * Adds a camera to the pipeline
  78830. * @param camera the camera to be added
  78831. */
  78832. addCamera(camera: Camera): void;
  78833. /**
  78834. * Removes a camera from the pipeline
  78835. * @param camera the camera to remove
  78836. */
  78837. removeCamera(camera: Camera): void;
  78838. /**
  78839. * Dispose of the pipeline and stop all post processes
  78840. */
  78841. dispose(): void;
  78842. /**
  78843. * Serialize the rendering pipeline (Used when exporting)
  78844. * @returns the serialized object
  78845. */
  78846. serialize(): any;
  78847. /**
  78848. * Parse the serialized pipeline
  78849. * @param source Source pipeline.
  78850. * @param scene The scene to load the pipeline to.
  78851. * @param rootUrl The URL of the serialized pipeline.
  78852. * @returns An instantiated pipeline from the serialized object.
  78853. */
  78854. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  78855. }
  78856. }
  78857. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  78858. /** @hidden */
  78859. export var lensHighlightsPixelShader: {
  78860. name: string;
  78861. shader: string;
  78862. };
  78863. }
  78864. declare module "babylonjs/Shaders/depthOfField.fragment" {
  78865. /** @hidden */
  78866. export var depthOfFieldPixelShader: {
  78867. name: string;
  78868. shader: string;
  78869. };
  78870. }
  78871. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  78872. import { Camera } from "babylonjs/Cameras/camera";
  78873. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78874. import { Scene } from "babylonjs/scene";
  78875. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78876. import "babylonjs/Shaders/chromaticAberration.fragment";
  78877. import "babylonjs/Shaders/lensHighlights.fragment";
  78878. import "babylonjs/Shaders/depthOfField.fragment";
  78879. /**
  78880. * BABYLON.JS Chromatic Aberration GLSL Shader
  78881. * Author: Olivier Guyot
  78882. * Separates very slightly R, G and B colors on the edges of the screen
  78883. * Inspired by Francois Tarlier & Martins Upitis
  78884. */
  78885. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  78886. /**
  78887. * @ignore
  78888. * The chromatic aberration PostProcess id in the pipeline
  78889. */
  78890. LensChromaticAberrationEffect: string;
  78891. /**
  78892. * @ignore
  78893. * The highlights enhancing PostProcess id in the pipeline
  78894. */
  78895. HighlightsEnhancingEffect: string;
  78896. /**
  78897. * @ignore
  78898. * The depth-of-field PostProcess id in the pipeline
  78899. */
  78900. LensDepthOfFieldEffect: string;
  78901. private _scene;
  78902. private _depthTexture;
  78903. private _grainTexture;
  78904. private _chromaticAberrationPostProcess;
  78905. private _highlightsPostProcess;
  78906. private _depthOfFieldPostProcess;
  78907. private _edgeBlur;
  78908. private _grainAmount;
  78909. private _chromaticAberration;
  78910. private _distortion;
  78911. private _highlightsGain;
  78912. private _highlightsThreshold;
  78913. private _dofDistance;
  78914. private _dofAperture;
  78915. private _dofDarken;
  78916. private _dofPentagon;
  78917. private _blurNoise;
  78918. /**
  78919. * @constructor
  78920. *
  78921. * Effect parameters are as follow:
  78922. * {
  78923. * chromatic_aberration: number; // from 0 to x (1 for realism)
  78924. * edge_blur: number; // from 0 to x (1 for realism)
  78925. * distortion: number; // from 0 to x (1 for realism)
  78926. * grain_amount: number; // from 0 to 1
  78927. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  78928. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  78929. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  78930. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  78931. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  78932. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  78933. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  78934. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  78935. * }
  78936. * Note: if an effect parameter is unset, effect is disabled
  78937. *
  78938. * @param name The rendering pipeline name
  78939. * @param parameters - An object containing all parameters (see above)
  78940. * @param scene The scene linked to this pipeline
  78941. * @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)
  78942. * @param cameras The array of cameras that the rendering pipeline will be attached to
  78943. */
  78944. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  78945. /**
  78946. * Get the class name
  78947. * @returns "LensRenderingPipeline"
  78948. */
  78949. getClassName(): string;
  78950. /**
  78951. * Gets associated scene
  78952. */
  78953. get scene(): Scene;
  78954. /**
  78955. * Gets or sets the edge blur
  78956. */
  78957. get edgeBlur(): number;
  78958. set edgeBlur(value: number);
  78959. /**
  78960. * Gets or sets the grain amount
  78961. */
  78962. get grainAmount(): number;
  78963. set grainAmount(value: number);
  78964. /**
  78965. * Gets or sets the chromatic aberration amount
  78966. */
  78967. get chromaticAberration(): number;
  78968. set chromaticAberration(value: number);
  78969. /**
  78970. * Gets or sets the depth of field aperture
  78971. */
  78972. get dofAperture(): number;
  78973. set dofAperture(value: number);
  78974. /**
  78975. * Gets or sets the edge distortion
  78976. */
  78977. get edgeDistortion(): number;
  78978. set edgeDistortion(value: number);
  78979. /**
  78980. * Gets or sets the depth of field distortion
  78981. */
  78982. get dofDistortion(): number;
  78983. set dofDistortion(value: number);
  78984. /**
  78985. * Gets or sets the darken out of focus amount
  78986. */
  78987. get darkenOutOfFocus(): number;
  78988. set darkenOutOfFocus(value: number);
  78989. /**
  78990. * Gets or sets a boolean indicating if blur noise is enabled
  78991. */
  78992. get blurNoise(): boolean;
  78993. set blurNoise(value: boolean);
  78994. /**
  78995. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  78996. */
  78997. get pentagonBokeh(): boolean;
  78998. set pentagonBokeh(value: boolean);
  78999. /**
  79000. * Gets or sets the highlight grain amount
  79001. */
  79002. get highlightsGain(): number;
  79003. set highlightsGain(value: number);
  79004. /**
  79005. * Gets or sets the highlight threshold
  79006. */
  79007. get highlightsThreshold(): number;
  79008. set highlightsThreshold(value: number);
  79009. /**
  79010. * Sets the amount of blur at the edges
  79011. * @param amount blur amount
  79012. */
  79013. setEdgeBlur(amount: number): void;
  79014. /**
  79015. * Sets edge blur to 0
  79016. */
  79017. disableEdgeBlur(): void;
  79018. /**
  79019. * Sets the amout of grain
  79020. * @param amount Amount of grain
  79021. */
  79022. setGrainAmount(amount: number): void;
  79023. /**
  79024. * Set grain amount to 0
  79025. */
  79026. disableGrain(): void;
  79027. /**
  79028. * Sets the chromatic aberration amount
  79029. * @param amount amount of chromatic aberration
  79030. */
  79031. setChromaticAberration(amount: number): void;
  79032. /**
  79033. * Sets chromatic aberration amount to 0
  79034. */
  79035. disableChromaticAberration(): void;
  79036. /**
  79037. * Sets the EdgeDistortion amount
  79038. * @param amount amount of EdgeDistortion
  79039. */
  79040. setEdgeDistortion(amount: number): void;
  79041. /**
  79042. * Sets edge distortion to 0
  79043. */
  79044. disableEdgeDistortion(): void;
  79045. /**
  79046. * Sets the FocusDistance amount
  79047. * @param amount amount of FocusDistance
  79048. */
  79049. setFocusDistance(amount: number): void;
  79050. /**
  79051. * Disables depth of field
  79052. */
  79053. disableDepthOfField(): void;
  79054. /**
  79055. * Sets the Aperture amount
  79056. * @param amount amount of Aperture
  79057. */
  79058. setAperture(amount: number): void;
  79059. /**
  79060. * Sets the DarkenOutOfFocus amount
  79061. * @param amount amount of DarkenOutOfFocus
  79062. */
  79063. setDarkenOutOfFocus(amount: number): void;
  79064. private _pentagonBokehIsEnabled;
  79065. /**
  79066. * Creates a pentagon bokeh effect
  79067. */
  79068. enablePentagonBokeh(): void;
  79069. /**
  79070. * Disables the pentagon bokeh effect
  79071. */
  79072. disablePentagonBokeh(): void;
  79073. /**
  79074. * Enables noise blur
  79075. */
  79076. enableNoiseBlur(): void;
  79077. /**
  79078. * Disables noise blur
  79079. */
  79080. disableNoiseBlur(): void;
  79081. /**
  79082. * Sets the HighlightsGain amount
  79083. * @param amount amount of HighlightsGain
  79084. */
  79085. setHighlightsGain(amount: number): void;
  79086. /**
  79087. * Sets the HighlightsThreshold amount
  79088. * @param amount amount of HighlightsThreshold
  79089. */
  79090. setHighlightsThreshold(amount: number): void;
  79091. /**
  79092. * Disables highlights
  79093. */
  79094. disableHighlights(): void;
  79095. /**
  79096. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  79097. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  79098. */
  79099. dispose(disableDepthRender?: boolean): void;
  79100. private _createChromaticAberrationPostProcess;
  79101. private _createHighlightsPostProcess;
  79102. private _createDepthOfFieldPostProcess;
  79103. private _createGrainTexture;
  79104. }
  79105. }
  79106. declare module "babylonjs/Rendering/ssao2Configuration" {
  79107. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79108. /**
  79109. * Contains all parameters needed for the prepass to perform
  79110. * screen space subsurface scattering
  79111. */
  79112. export class SSAO2Configuration implements PrePassEffectConfiguration {
  79113. /**
  79114. * Is subsurface enabled
  79115. */
  79116. enabled: boolean;
  79117. /**
  79118. * Name of the configuration
  79119. */
  79120. name: string;
  79121. /**
  79122. * Textures that should be present in the MRT for this effect to work
  79123. */
  79124. readonly texturesRequired: number[];
  79125. }
  79126. }
  79127. declare module "babylonjs/Shaders/ssao2.fragment" {
  79128. /** @hidden */
  79129. export var ssao2PixelShader: {
  79130. name: string;
  79131. shader: string;
  79132. };
  79133. }
  79134. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  79135. /** @hidden */
  79136. export var ssaoCombinePixelShader: {
  79137. name: string;
  79138. shader: string;
  79139. };
  79140. }
  79141. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  79142. import { Camera } from "babylonjs/Cameras/camera";
  79143. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79144. import { Scene } from "babylonjs/scene";
  79145. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79146. import "babylonjs/Shaders/ssao2.fragment";
  79147. import "babylonjs/Shaders/ssaoCombine.fragment";
  79148. /**
  79149. * Render pipeline to produce ssao effect
  79150. */
  79151. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  79152. /**
  79153. * @ignore
  79154. * The PassPostProcess id in the pipeline that contains the original scene color
  79155. */
  79156. SSAOOriginalSceneColorEffect: string;
  79157. /**
  79158. * @ignore
  79159. * The SSAO PostProcess id in the pipeline
  79160. */
  79161. SSAORenderEffect: string;
  79162. /**
  79163. * @ignore
  79164. * The horizontal blur PostProcess id in the pipeline
  79165. */
  79166. SSAOBlurHRenderEffect: string;
  79167. /**
  79168. * @ignore
  79169. * The vertical blur PostProcess id in the pipeline
  79170. */
  79171. SSAOBlurVRenderEffect: string;
  79172. /**
  79173. * @ignore
  79174. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79175. */
  79176. SSAOCombineRenderEffect: string;
  79177. /**
  79178. * The output strength of the SSAO post-process. Default value is 1.0.
  79179. */
  79180. totalStrength: number;
  79181. /**
  79182. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  79183. */
  79184. maxZ: number;
  79185. /**
  79186. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  79187. */
  79188. minZAspect: number;
  79189. private _samples;
  79190. /**
  79191. * Number of samples used for the SSAO calculations. Default value is 8
  79192. */
  79193. set samples(n: number);
  79194. get samples(): number;
  79195. private _textureSamples;
  79196. /**
  79197. * Number of samples to use for antialiasing
  79198. */
  79199. set textureSamples(n: number);
  79200. get textureSamples(): number;
  79201. /**
  79202. * Force rendering the geometry through geometry buffer
  79203. */
  79204. private _forceGeometryBuffer;
  79205. /**
  79206. * Ratio object used for SSAO ratio and blur ratio
  79207. */
  79208. private _ratio;
  79209. /**
  79210. * Dynamically generated sphere sampler.
  79211. */
  79212. private _sampleSphere;
  79213. /**
  79214. * Blur filter offsets
  79215. */
  79216. private _samplerOffsets;
  79217. private _expensiveBlur;
  79218. /**
  79219. * If bilateral blur should be used
  79220. */
  79221. set expensiveBlur(b: boolean);
  79222. get expensiveBlur(): boolean;
  79223. /**
  79224. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  79225. */
  79226. radius: number;
  79227. /**
  79228. * The base color of the SSAO post-process
  79229. * The final result is "base + ssao" between [0, 1]
  79230. */
  79231. base: number;
  79232. /**
  79233. * Support test.
  79234. */
  79235. static get IsSupported(): boolean;
  79236. private _scene;
  79237. private _randomTexture;
  79238. private _originalColorPostProcess;
  79239. private _ssaoPostProcess;
  79240. private _blurHPostProcess;
  79241. private _blurVPostProcess;
  79242. private _ssaoCombinePostProcess;
  79243. private _prePassRenderer;
  79244. /**
  79245. * Gets active scene
  79246. */
  79247. get scene(): Scene;
  79248. /**
  79249. * @constructor
  79250. * @param name The rendering pipeline name
  79251. * @param scene The scene linked to this pipeline
  79252. * @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 }
  79253. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79254. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  79255. */
  79256. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  79257. /**
  79258. * Get the class name
  79259. * @returns "SSAO2RenderingPipeline"
  79260. */
  79261. getClassName(): string;
  79262. /**
  79263. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79264. */
  79265. dispose(disableGeometryBufferRenderer?: boolean): void;
  79266. private _createBlurPostProcess;
  79267. /** @hidden */
  79268. _rebuild(): void;
  79269. private _bits;
  79270. private _radicalInverse_VdC;
  79271. private _hammersley;
  79272. private _hemisphereSample_uniform;
  79273. private _generateHemisphere;
  79274. private _getDefinesForSSAO;
  79275. private static readonly ORTHO_DEPTH_PROJECTION;
  79276. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  79277. private _createSSAOPostProcess;
  79278. private _createSSAOCombinePostProcess;
  79279. private _createRandomTexture;
  79280. /**
  79281. * Serialize the rendering pipeline (Used when exporting)
  79282. * @returns the serialized object
  79283. */
  79284. serialize(): any;
  79285. /**
  79286. * Parse the serialized pipeline
  79287. * @param source Source pipeline.
  79288. * @param scene The scene to load the pipeline to.
  79289. * @param rootUrl The URL of the serialized pipeline.
  79290. * @returns An instantiated pipeline from the serialized object.
  79291. */
  79292. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  79293. }
  79294. }
  79295. declare module "babylonjs/Shaders/ssao.fragment" {
  79296. /** @hidden */
  79297. export var ssaoPixelShader: {
  79298. name: string;
  79299. shader: string;
  79300. };
  79301. }
  79302. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  79303. import { Camera } from "babylonjs/Cameras/camera";
  79304. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79305. import { Scene } from "babylonjs/scene";
  79306. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79307. import "babylonjs/Shaders/ssao.fragment";
  79308. import "babylonjs/Shaders/ssaoCombine.fragment";
  79309. /**
  79310. * Render pipeline to produce ssao effect
  79311. */
  79312. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  79313. /**
  79314. * @ignore
  79315. * The PassPostProcess id in the pipeline that contains the original scene color
  79316. */
  79317. SSAOOriginalSceneColorEffect: string;
  79318. /**
  79319. * @ignore
  79320. * The SSAO PostProcess id in the pipeline
  79321. */
  79322. SSAORenderEffect: string;
  79323. /**
  79324. * @ignore
  79325. * The horizontal blur PostProcess id in the pipeline
  79326. */
  79327. SSAOBlurHRenderEffect: string;
  79328. /**
  79329. * @ignore
  79330. * The vertical blur PostProcess id in the pipeline
  79331. */
  79332. SSAOBlurVRenderEffect: string;
  79333. /**
  79334. * @ignore
  79335. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79336. */
  79337. SSAOCombineRenderEffect: string;
  79338. /**
  79339. * The output strength of the SSAO post-process. Default value is 1.0.
  79340. */
  79341. totalStrength: number;
  79342. /**
  79343. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  79344. */
  79345. radius: number;
  79346. /**
  79347. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  79348. * Must not be equal to fallOff and superior to fallOff.
  79349. * Default value is 0.0075
  79350. */
  79351. area: number;
  79352. /**
  79353. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  79354. * Must not be equal to area and inferior to area.
  79355. * Default value is 0.000001
  79356. */
  79357. fallOff: number;
  79358. /**
  79359. * The base color of the SSAO post-process
  79360. * The final result is "base + ssao" between [0, 1]
  79361. */
  79362. base: number;
  79363. private _scene;
  79364. private _depthTexture;
  79365. private _randomTexture;
  79366. private _originalColorPostProcess;
  79367. private _ssaoPostProcess;
  79368. private _blurHPostProcess;
  79369. private _blurVPostProcess;
  79370. private _ssaoCombinePostProcess;
  79371. private _firstUpdate;
  79372. /**
  79373. * Gets active scene
  79374. */
  79375. get scene(): Scene;
  79376. /**
  79377. * @constructor
  79378. * @param name - The rendering pipeline name
  79379. * @param scene - The scene linked to this pipeline
  79380. * @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 }
  79381. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  79382. */
  79383. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  79384. /**
  79385. * Get the class name
  79386. * @returns "SSAORenderingPipeline"
  79387. */
  79388. getClassName(): string;
  79389. /**
  79390. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79391. */
  79392. dispose(disableDepthRender?: boolean): void;
  79393. private _createBlurPostProcess;
  79394. /** @hidden */
  79395. _rebuild(): void;
  79396. private _createSSAOPostProcess;
  79397. private _createSSAOCombinePostProcess;
  79398. private _createRandomTexture;
  79399. }
  79400. }
  79401. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  79402. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79403. /**
  79404. * Contains all parameters needed for the prepass to perform
  79405. * screen space reflections
  79406. */
  79407. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  79408. /**
  79409. * Is ssr enabled
  79410. */
  79411. enabled: boolean;
  79412. /**
  79413. * Name of the configuration
  79414. */
  79415. name: string;
  79416. /**
  79417. * Textures that should be present in the MRT for this effect to work
  79418. */
  79419. readonly texturesRequired: number[];
  79420. }
  79421. }
  79422. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  79423. /** @hidden */
  79424. export var screenSpaceReflectionPixelShader: {
  79425. name: string;
  79426. shader: string;
  79427. };
  79428. }
  79429. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  79430. import { Nullable } from "babylonjs/types";
  79431. import { Camera } from "babylonjs/Cameras/camera";
  79432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79433. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  79434. import { Engine } from "babylonjs/Engines/engine";
  79435. import { Scene } from "babylonjs/scene";
  79436. /**
  79437. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  79438. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  79439. */
  79440. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  79441. /**
  79442. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  79443. */
  79444. threshold: number;
  79445. /**
  79446. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  79447. */
  79448. strength: number;
  79449. /**
  79450. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  79451. */
  79452. reflectionSpecularFalloffExponent: number;
  79453. /**
  79454. * 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]
  79455. */
  79456. step: number;
  79457. /**
  79458. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  79459. */
  79460. roughnessFactor: number;
  79461. private _forceGeometryBuffer;
  79462. private _geometryBufferRenderer;
  79463. private _prePassRenderer;
  79464. private _enableSmoothReflections;
  79465. private _reflectionSamples;
  79466. private _smoothSteps;
  79467. /**
  79468. * Gets a string identifying the name of the class
  79469. * @returns "ScreenSpaceReflectionPostProcess" string
  79470. */
  79471. getClassName(): string;
  79472. /**
  79473. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  79474. * @param name The name of the effect.
  79475. * @param scene The scene containing the objects to calculate reflections.
  79476. * @param options The required width/height ratio to downsize to before computing the render pass.
  79477. * @param camera The camera to apply the render pass to.
  79478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79479. * @param engine The engine which the post process will be applied. (default: current engine)
  79480. * @param reusable If the post process can be reused on the same frame. (default: false)
  79481. * @param textureType Type of textures used when performing the post process. (default: 0)
  79482. * @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)
  79483. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  79484. */
  79485. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  79486. /**
  79487. * Gets wether or not smoothing reflections is enabled.
  79488. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79489. */
  79490. get enableSmoothReflections(): boolean;
  79491. /**
  79492. * Sets wether or not smoothing reflections is enabled.
  79493. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79494. */
  79495. set enableSmoothReflections(enabled: boolean);
  79496. /**
  79497. * Gets the number of samples taken while computing reflections. More samples count is high,
  79498. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79499. */
  79500. get reflectionSamples(): number;
  79501. /**
  79502. * Sets the number of samples taken while computing reflections. More samples count is high,
  79503. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79504. */
  79505. set reflectionSamples(samples: number);
  79506. /**
  79507. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  79508. * more the post-process will require GPU power and can generate a drop in FPS.
  79509. * Default value (5.0) work pretty well in all cases but can be adjusted.
  79510. */
  79511. get smoothSteps(): number;
  79512. set smoothSteps(steps: number);
  79513. private _updateEffectDefines;
  79514. /** @hidden */
  79515. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  79516. }
  79517. }
  79518. declare module "babylonjs/Shaders/standard.fragment" {
  79519. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  79520. /** @hidden */
  79521. export var standardPixelShader: {
  79522. name: string;
  79523. shader: string;
  79524. };
  79525. }
  79526. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  79527. import { Nullable } from "babylonjs/types";
  79528. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  79529. import { Camera } from "babylonjs/Cameras/camera";
  79530. import { Texture } from "babylonjs/Materials/Textures/texture";
  79531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79532. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79533. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  79534. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  79535. import { IDisposable } from "babylonjs/scene";
  79536. import { SpotLight } from "babylonjs/Lights/spotLight";
  79537. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  79538. import { Scene } from "babylonjs/scene";
  79539. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79540. import { Animation } from "babylonjs/Animations/animation";
  79541. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79542. import "babylonjs/Shaders/standard.fragment";
  79543. /**
  79544. * Standard rendering pipeline
  79545. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79546. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  79547. */
  79548. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  79549. /**
  79550. * Public members
  79551. */
  79552. /**
  79553. * Post-process which contains the original scene color before the pipeline applies all the effects
  79554. */
  79555. originalPostProcess: Nullable<PostProcess>;
  79556. /**
  79557. * Post-process used to down scale an image x4
  79558. */
  79559. downSampleX4PostProcess: Nullable<PostProcess>;
  79560. /**
  79561. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  79562. */
  79563. brightPassPostProcess: Nullable<PostProcess>;
  79564. /**
  79565. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  79566. */
  79567. blurHPostProcesses: PostProcess[];
  79568. /**
  79569. * Post-process array storing all the vertical blur post-processes used by the pipeline
  79570. */
  79571. blurVPostProcesses: PostProcess[];
  79572. /**
  79573. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  79574. */
  79575. textureAdderPostProcess: Nullable<PostProcess>;
  79576. /**
  79577. * Post-process used to create volumetric lighting effect
  79578. */
  79579. volumetricLightPostProcess: Nullable<PostProcess>;
  79580. /**
  79581. * Post-process used to smooth the previous volumetric light post-process on the X axis
  79582. */
  79583. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  79584. /**
  79585. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  79586. */
  79587. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  79588. /**
  79589. * Post-process used to merge the volumetric light effect and the real scene color
  79590. */
  79591. volumetricLightMergePostProces: Nullable<PostProcess>;
  79592. /**
  79593. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  79594. */
  79595. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  79596. /**
  79597. * Base post-process used to calculate the average luminance of the final image for HDR
  79598. */
  79599. luminancePostProcess: Nullable<PostProcess>;
  79600. /**
  79601. * Post-processes used to create down sample post-processes in order to get
  79602. * the average luminance of the final image for HDR
  79603. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  79604. */
  79605. luminanceDownSamplePostProcesses: PostProcess[];
  79606. /**
  79607. * Post-process used to create a HDR effect (light adaptation)
  79608. */
  79609. hdrPostProcess: Nullable<PostProcess>;
  79610. /**
  79611. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  79612. */
  79613. textureAdderFinalPostProcess: Nullable<PostProcess>;
  79614. /**
  79615. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  79616. */
  79617. lensFlareFinalPostProcess: Nullable<PostProcess>;
  79618. /**
  79619. * Post-process used to merge the final HDR post-process and the real scene color
  79620. */
  79621. hdrFinalPostProcess: Nullable<PostProcess>;
  79622. /**
  79623. * Post-process used to create a lens flare effect
  79624. */
  79625. lensFlarePostProcess: Nullable<PostProcess>;
  79626. /**
  79627. * Post-process that merges the result of the lens flare post-process and the real scene color
  79628. */
  79629. lensFlareComposePostProcess: Nullable<PostProcess>;
  79630. /**
  79631. * Post-process used to create a motion blur effect
  79632. */
  79633. motionBlurPostProcess: Nullable<PostProcess>;
  79634. /**
  79635. * Post-process used to create a depth of field effect
  79636. */
  79637. depthOfFieldPostProcess: Nullable<PostProcess>;
  79638. /**
  79639. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  79640. */
  79641. fxaaPostProcess: Nullable<FxaaPostProcess>;
  79642. /**
  79643. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  79644. */
  79645. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  79646. /**
  79647. * Represents the brightness threshold in order to configure the illuminated surfaces
  79648. */
  79649. brightThreshold: number;
  79650. /**
  79651. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  79652. */
  79653. blurWidth: number;
  79654. /**
  79655. * Sets if the blur for highlighted surfaces must be only horizontal
  79656. */
  79657. horizontalBlur: boolean;
  79658. /**
  79659. * Gets the overall exposure used by the pipeline
  79660. */
  79661. get exposure(): number;
  79662. /**
  79663. * Sets the overall exposure used by the pipeline
  79664. */
  79665. set exposure(value: number);
  79666. /**
  79667. * Texture used typically to simulate "dirty" on camera lens
  79668. */
  79669. lensTexture: Nullable<Texture>;
  79670. /**
  79671. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  79672. */
  79673. volumetricLightCoefficient: number;
  79674. /**
  79675. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  79676. */
  79677. volumetricLightPower: number;
  79678. /**
  79679. * Used the set the blur intensity to smooth the volumetric lights
  79680. */
  79681. volumetricLightBlurScale: number;
  79682. /**
  79683. * Light (spot or directional) used to generate the volumetric lights rays
  79684. * The source light must have a shadow generate so the pipeline can get its
  79685. * depth map
  79686. */
  79687. sourceLight: Nullable<SpotLight | DirectionalLight>;
  79688. /**
  79689. * For eye adaptation, represents the minimum luminance the eye can see
  79690. */
  79691. hdrMinimumLuminance: number;
  79692. /**
  79693. * For eye adaptation, represents the decrease luminance speed
  79694. */
  79695. hdrDecreaseRate: number;
  79696. /**
  79697. * For eye adaptation, represents the increase luminance speed
  79698. */
  79699. hdrIncreaseRate: number;
  79700. /**
  79701. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79702. */
  79703. get hdrAutoExposure(): boolean;
  79704. /**
  79705. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79706. */
  79707. set hdrAutoExposure(value: boolean);
  79708. /**
  79709. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  79710. */
  79711. lensColorTexture: Nullable<Texture>;
  79712. /**
  79713. * The overall strengh for the lens flare effect
  79714. */
  79715. lensFlareStrength: number;
  79716. /**
  79717. * Dispersion coefficient for lens flare ghosts
  79718. */
  79719. lensFlareGhostDispersal: number;
  79720. /**
  79721. * Main lens flare halo width
  79722. */
  79723. lensFlareHaloWidth: number;
  79724. /**
  79725. * Based on the lens distortion effect, defines how much the lens flare result
  79726. * is distorted
  79727. */
  79728. lensFlareDistortionStrength: number;
  79729. /**
  79730. * Configures the blur intensity used for for lens flare (halo)
  79731. */
  79732. lensFlareBlurWidth: number;
  79733. /**
  79734. * Lens star texture must be used to simulate rays on the flares and is available
  79735. * in the documentation
  79736. */
  79737. lensStarTexture: Nullable<Texture>;
  79738. /**
  79739. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  79740. * flare effect by taking account of the dirt texture
  79741. */
  79742. lensFlareDirtTexture: Nullable<Texture>;
  79743. /**
  79744. * Represents the focal length for the depth of field effect
  79745. */
  79746. depthOfFieldDistance: number;
  79747. /**
  79748. * Represents the blur intensity for the blurred part of the depth of field effect
  79749. */
  79750. depthOfFieldBlurWidth: number;
  79751. /**
  79752. * Gets how much the image is blurred by the movement while using the motion blur post-process
  79753. */
  79754. get motionStrength(): number;
  79755. /**
  79756. * Sets how much the image is blurred by the movement while using the motion blur post-process
  79757. */
  79758. set motionStrength(strength: number);
  79759. /**
  79760. * Gets wether or not the motion blur post-process is object based or screen based.
  79761. */
  79762. get objectBasedMotionBlur(): boolean;
  79763. /**
  79764. * Sets wether or not the motion blur post-process should be object based or screen based
  79765. */
  79766. set objectBasedMotionBlur(value: boolean);
  79767. /**
  79768. * List of animations for the pipeline (IAnimatable implementation)
  79769. */
  79770. animations: Animation[];
  79771. /**
  79772. * Private members
  79773. */
  79774. private _scene;
  79775. private _currentDepthOfFieldSource;
  79776. private _basePostProcess;
  79777. private _fixedExposure;
  79778. private _currentExposure;
  79779. private _hdrAutoExposure;
  79780. private _hdrCurrentLuminance;
  79781. private _motionStrength;
  79782. private _isObjectBasedMotionBlur;
  79783. private _floatTextureType;
  79784. private _camerasToBeAttached;
  79785. private _ratio;
  79786. private _bloomEnabled;
  79787. private _depthOfFieldEnabled;
  79788. private _vlsEnabled;
  79789. private _lensFlareEnabled;
  79790. private _hdrEnabled;
  79791. private _motionBlurEnabled;
  79792. private _fxaaEnabled;
  79793. private _screenSpaceReflectionsEnabled;
  79794. private _motionBlurSamples;
  79795. private _volumetricLightStepsCount;
  79796. private _samples;
  79797. /**
  79798. * @ignore
  79799. * Specifies if the bloom pipeline is enabled
  79800. */
  79801. get BloomEnabled(): boolean;
  79802. set BloomEnabled(enabled: boolean);
  79803. /**
  79804. * @ignore
  79805. * Specifies if the depth of field pipeline is enabed
  79806. */
  79807. get DepthOfFieldEnabled(): boolean;
  79808. set DepthOfFieldEnabled(enabled: boolean);
  79809. /**
  79810. * @ignore
  79811. * Specifies if the lens flare pipeline is enabed
  79812. */
  79813. get LensFlareEnabled(): boolean;
  79814. set LensFlareEnabled(enabled: boolean);
  79815. /**
  79816. * @ignore
  79817. * Specifies if the HDR pipeline is enabled
  79818. */
  79819. get HDREnabled(): boolean;
  79820. set HDREnabled(enabled: boolean);
  79821. /**
  79822. * @ignore
  79823. * Specifies if the volumetric lights scattering effect is enabled
  79824. */
  79825. get VLSEnabled(): boolean;
  79826. set VLSEnabled(enabled: boolean);
  79827. /**
  79828. * @ignore
  79829. * Specifies if the motion blur effect is enabled
  79830. */
  79831. get MotionBlurEnabled(): boolean;
  79832. set MotionBlurEnabled(enabled: boolean);
  79833. /**
  79834. * Specifies if anti-aliasing is enabled
  79835. */
  79836. get fxaaEnabled(): boolean;
  79837. set fxaaEnabled(enabled: boolean);
  79838. /**
  79839. * Specifies if screen space reflections are enabled.
  79840. */
  79841. get screenSpaceReflectionsEnabled(): boolean;
  79842. set screenSpaceReflectionsEnabled(enabled: boolean);
  79843. /**
  79844. * Specifies the number of steps used to calculate the volumetric lights
  79845. * Typically in interval [50, 200]
  79846. */
  79847. get volumetricLightStepsCount(): number;
  79848. set volumetricLightStepsCount(count: number);
  79849. /**
  79850. * Specifies the number of samples used for the motion blur effect
  79851. * Typically in interval [16, 64]
  79852. */
  79853. get motionBlurSamples(): number;
  79854. set motionBlurSamples(samples: number);
  79855. /**
  79856. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  79857. */
  79858. get samples(): number;
  79859. set samples(sampleCount: number);
  79860. /**
  79861. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79862. * @constructor
  79863. * @param name The rendering pipeline name
  79864. * @param scene The scene linked to this pipeline
  79865. * @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)
  79866. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  79867. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79868. */
  79869. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  79870. private _buildPipeline;
  79871. private _createDownSampleX4PostProcess;
  79872. private _createBrightPassPostProcess;
  79873. private _createBlurPostProcesses;
  79874. private _createTextureAdderPostProcess;
  79875. private _createVolumetricLightPostProcess;
  79876. private _createLuminancePostProcesses;
  79877. private _createHdrPostProcess;
  79878. private _createLensFlarePostProcess;
  79879. private _createDepthOfFieldPostProcess;
  79880. private _createMotionBlurPostProcess;
  79881. private _getDepthTexture;
  79882. private _disposePostProcesses;
  79883. /**
  79884. * Dispose of the pipeline and stop all post processes
  79885. */
  79886. dispose(): void;
  79887. /**
  79888. * Serialize the rendering pipeline (Used when exporting)
  79889. * @returns the serialized object
  79890. */
  79891. serialize(): any;
  79892. /**
  79893. * Parse the serialized pipeline
  79894. * @param source Source pipeline.
  79895. * @param scene The scene to load the pipeline to.
  79896. * @param rootUrl The URL of the serialized pipeline.
  79897. * @returns An instantiated pipeline from the serialized object.
  79898. */
  79899. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  79900. /**
  79901. * Luminance steps
  79902. */
  79903. static LuminanceSteps: number;
  79904. }
  79905. }
  79906. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  79907. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  79908. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  79909. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  79910. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  79911. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  79912. }
  79913. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  79914. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  79915. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  79916. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79917. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  79918. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79919. }
  79920. declare module "babylonjs/Shaders/tonemap.fragment" {
  79921. /** @hidden */
  79922. export var tonemapPixelShader: {
  79923. name: string;
  79924. shader: string;
  79925. };
  79926. }
  79927. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  79928. import { Camera } from "babylonjs/Cameras/camera";
  79929. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79930. import "babylonjs/Shaders/tonemap.fragment";
  79931. import { Engine } from "babylonjs/Engines/engine";
  79932. /** Defines operator used for tonemapping */
  79933. export enum TonemappingOperator {
  79934. /** Hable */
  79935. Hable = 0,
  79936. /** Reinhard */
  79937. Reinhard = 1,
  79938. /** HejiDawson */
  79939. HejiDawson = 2,
  79940. /** Photographic */
  79941. Photographic = 3
  79942. }
  79943. /**
  79944. * Defines a post process to apply tone mapping
  79945. */
  79946. export class TonemapPostProcess extends PostProcess {
  79947. private _operator;
  79948. /** Defines the required exposure adjustement */
  79949. exposureAdjustment: number;
  79950. /**
  79951. * Gets a string identifying the name of the class
  79952. * @returns "TonemapPostProcess" string
  79953. */
  79954. getClassName(): string;
  79955. /**
  79956. * Creates a new TonemapPostProcess
  79957. * @param name defines the name of the postprocess
  79958. * @param _operator defines the operator to use
  79959. * @param exposureAdjustment defines the required exposure adjustement
  79960. * @param camera defines the camera to use (can be null)
  79961. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  79962. * @param engine defines the hosting engine (can be ignore if camera is set)
  79963. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79964. */
  79965. constructor(name: string, _operator: TonemappingOperator,
  79966. /** Defines the required exposure adjustement */
  79967. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  79968. }
  79969. }
  79970. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  79971. /** @hidden */
  79972. export var volumetricLightScatteringPixelShader: {
  79973. name: string;
  79974. shader: string;
  79975. };
  79976. }
  79977. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  79978. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  79979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  79980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  79981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  79982. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  79983. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  79984. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  79985. /** @hidden */
  79986. export var volumetricLightScatteringPassVertexShader: {
  79987. name: string;
  79988. shader: string;
  79989. };
  79990. }
  79991. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  79992. /** @hidden */
  79993. export var volumetricLightScatteringPassPixelShader: {
  79994. name: string;
  79995. shader: string;
  79996. };
  79997. }
  79998. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  79999. import { Vector3 } from "babylonjs/Maths/math.vector";
  80000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80001. import { Mesh } from "babylonjs/Meshes/mesh";
  80002. import { Camera } from "babylonjs/Cameras/camera";
  80003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  80004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80005. import { Scene } from "babylonjs/scene";
  80006. import "babylonjs/Meshes/Builders/planeBuilder";
  80007. import "babylonjs/Shaders/depth.vertex";
  80008. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  80009. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  80010. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  80011. import { Engine } from "babylonjs/Engines/engine";
  80012. /**
  80013. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  80014. */
  80015. export class VolumetricLightScatteringPostProcess extends PostProcess {
  80016. private _volumetricLightScatteringPass;
  80017. private _volumetricLightScatteringRTT;
  80018. private _viewPort;
  80019. private _screenCoordinates;
  80020. private _cachedDefines;
  80021. /**
  80022. * If not undefined, the mesh position is computed from the attached node position
  80023. */
  80024. attachedNode: {
  80025. position: Vector3;
  80026. };
  80027. /**
  80028. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  80029. */
  80030. customMeshPosition: Vector3;
  80031. /**
  80032. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  80033. */
  80034. useCustomMeshPosition: boolean;
  80035. /**
  80036. * If the post-process should inverse the light scattering direction
  80037. */
  80038. invert: boolean;
  80039. /**
  80040. * The internal mesh used by the post-process
  80041. */
  80042. mesh: Mesh;
  80043. /**
  80044. * @hidden
  80045. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  80046. */
  80047. get useDiffuseColor(): boolean;
  80048. set useDiffuseColor(useDiffuseColor: boolean);
  80049. /**
  80050. * Array containing the excluded meshes not rendered in the internal pass
  80051. */
  80052. excludedMeshes: AbstractMesh[];
  80053. /**
  80054. * Controls the overall intensity of the post-process
  80055. */
  80056. exposure: number;
  80057. /**
  80058. * Dissipates each sample's contribution in range [0, 1]
  80059. */
  80060. decay: number;
  80061. /**
  80062. * Controls the overall intensity of each sample
  80063. */
  80064. weight: number;
  80065. /**
  80066. * Controls the density of each sample
  80067. */
  80068. density: number;
  80069. /**
  80070. * @constructor
  80071. * @param name The post-process name
  80072. * @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)
  80073. * @param camera The camera that the post-process will be attached to
  80074. * @param mesh The mesh used to create the light scattering
  80075. * @param samples The post-process quality, default 100
  80076. * @param samplingModeThe post-process filtering mode
  80077. * @param engine The babylon engine
  80078. * @param reusable If the post-process is reusable
  80079. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  80080. */
  80081. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  80082. /**
  80083. * Returns the string "VolumetricLightScatteringPostProcess"
  80084. * @returns "VolumetricLightScatteringPostProcess"
  80085. */
  80086. getClassName(): string;
  80087. private _isReady;
  80088. /**
  80089. * Sets the new light position for light scattering effect
  80090. * @param position The new custom light position
  80091. */
  80092. setCustomMeshPosition(position: Vector3): void;
  80093. /**
  80094. * Returns the light position for light scattering effect
  80095. * @return Vector3 The custom light position
  80096. */
  80097. getCustomMeshPosition(): Vector3;
  80098. /**
  80099. * Disposes the internal assets and detaches the post-process from the camera
  80100. */
  80101. dispose(camera: Camera): void;
  80102. /**
  80103. * Returns the render target texture used by the post-process
  80104. * @return the render target texture used by the post-process
  80105. */
  80106. getPass(): RenderTargetTexture;
  80107. private _meshExcluded;
  80108. private _createPass;
  80109. private _updateMeshScreenCoordinates;
  80110. /**
  80111. * Creates a default mesh for the Volumeric Light Scattering post-process
  80112. * @param name The mesh name
  80113. * @param scene The scene where to create the mesh
  80114. * @return the default mesh
  80115. */
  80116. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  80117. }
  80118. }
  80119. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  80120. /** @hidden */
  80121. export var screenSpaceCurvaturePixelShader: {
  80122. name: string;
  80123. shader: string;
  80124. };
  80125. }
  80126. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  80127. import { Nullable } from "babylonjs/types";
  80128. import { Camera } from "babylonjs/Cameras/camera";
  80129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80130. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80131. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  80132. import { Engine } from "babylonjs/Engines/engine";
  80133. import { Scene } from "babylonjs/scene";
  80134. /**
  80135. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  80136. */
  80137. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  80138. /**
  80139. * Defines how much ridge the curvature effect displays.
  80140. */
  80141. ridge: number;
  80142. /**
  80143. * Defines how much valley the curvature effect displays.
  80144. */
  80145. valley: number;
  80146. private _geometryBufferRenderer;
  80147. /**
  80148. * Gets a string identifying the name of the class
  80149. * @returns "ScreenSpaceCurvaturePostProcess" string
  80150. */
  80151. getClassName(): string;
  80152. /**
  80153. * Creates a new instance ScreenSpaceCurvaturePostProcess
  80154. * @param name The name of the effect.
  80155. * @param scene The scene containing the objects to blur according to their velocity.
  80156. * @param options The required width/height ratio to downsize to before computing the render pass.
  80157. * @param camera The camera to apply the render pass to.
  80158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80159. * @param engine The engine which the post process will be applied. (default: current engine)
  80160. * @param reusable If the post process can be reused on the same frame. (default: false)
  80161. * @param textureType Type of textures used when performing the post process. (default: 0)
  80162. * @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)
  80163. */
  80164. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  80165. /**
  80166. * Support test.
  80167. */
  80168. static get IsSupported(): boolean;
  80169. /** @hidden */
  80170. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  80171. }
  80172. }
  80173. declare module "babylonjs/PostProcesses/index" {
  80174. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  80175. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  80176. export * from "babylonjs/PostProcesses/bloomEffect";
  80177. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  80178. export * from "babylonjs/PostProcesses/blurPostProcess";
  80179. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  80180. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  80181. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  80182. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  80183. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  80184. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  80185. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  80186. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  80187. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  80188. export * from "babylonjs/PostProcesses/filterPostProcess";
  80189. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  80190. export * from "babylonjs/PostProcesses/grainPostProcess";
  80191. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  80192. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  80193. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  80194. export * from "babylonjs/PostProcesses/passPostProcess";
  80195. export * from "babylonjs/PostProcesses/postProcess";
  80196. export * from "babylonjs/PostProcesses/postProcessManager";
  80197. export * from "babylonjs/PostProcesses/refractionPostProcess";
  80198. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  80199. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  80200. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  80201. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  80202. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  80203. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  80204. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  80205. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  80206. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  80207. }
  80208. declare module "babylonjs/Probes/index" {
  80209. export * from "babylonjs/Probes/reflectionProbe";
  80210. }
  80211. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  80212. import { Scene } from "babylonjs/scene";
  80213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80214. import { SmartArray } from "babylonjs/Misc/smartArray";
  80215. import { ISceneComponent } from "babylonjs/sceneComponent";
  80216. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  80217. import "babylonjs/Meshes/Builders/boxBuilder";
  80218. import "babylonjs/Shaders/color.fragment";
  80219. import "babylonjs/Shaders/color.vertex";
  80220. import { Color3 } from "babylonjs/Maths/math.color";
  80221. import { Observable } from "babylonjs/Misc/observable";
  80222. module "babylonjs/scene" {
  80223. interface Scene {
  80224. /** @hidden (Backing field) */
  80225. _boundingBoxRenderer: BoundingBoxRenderer;
  80226. /** @hidden (Backing field) */
  80227. _forceShowBoundingBoxes: boolean;
  80228. /**
  80229. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  80230. */
  80231. forceShowBoundingBoxes: boolean;
  80232. /**
  80233. * Gets the bounding box renderer associated with the scene
  80234. * @returns a BoundingBoxRenderer
  80235. */
  80236. getBoundingBoxRenderer(): BoundingBoxRenderer;
  80237. }
  80238. }
  80239. module "babylonjs/Meshes/abstractMesh" {
  80240. interface AbstractMesh {
  80241. /** @hidden (Backing field) */
  80242. _showBoundingBox: boolean;
  80243. /**
  80244. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  80245. */
  80246. showBoundingBox: boolean;
  80247. }
  80248. }
  80249. /**
  80250. * Component responsible of rendering the bounding box of the meshes in a scene.
  80251. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  80252. */
  80253. export class BoundingBoxRenderer implements ISceneComponent {
  80254. /**
  80255. * The component name helpfull to identify the component in the list of scene components.
  80256. */
  80257. readonly name: string;
  80258. /**
  80259. * The scene the component belongs to.
  80260. */
  80261. scene: Scene;
  80262. /**
  80263. * Color of the bounding box lines placed in front of an object
  80264. */
  80265. frontColor: Color3;
  80266. /**
  80267. * Color of the bounding box lines placed behind an object
  80268. */
  80269. backColor: Color3;
  80270. /**
  80271. * Defines if the renderer should show the back lines or not
  80272. */
  80273. showBackLines: boolean;
  80274. /**
  80275. * Observable raised before rendering a bounding box
  80276. */
  80277. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  80278. /**
  80279. * Observable raised after rendering a bounding box
  80280. */
  80281. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  80282. /**
  80283. * Observable raised after resources are created
  80284. */
  80285. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  80286. /**
  80287. * When false, no bounding boxes will be rendered
  80288. */
  80289. enabled: boolean;
  80290. /**
  80291. * @hidden
  80292. */
  80293. renderList: SmartArray<BoundingBox>;
  80294. private _colorShader;
  80295. private _vertexBuffers;
  80296. private _indexBuffer;
  80297. private _fillIndexBuffer;
  80298. private _fillIndexData;
  80299. /**
  80300. * Instantiates a new bounding box renderer in a scene.
  80301. * @param scene the scene the renderer renders in
  80302. */
  80303. constructor(scene: Scene);
  80304. /**
  80305. * Registers the component in a given scene
  80306. */
  80307. register(): void;
  80308. private _evaluateSubMesh;
  80309. private _preActiveMesh;
  80310. private _prepareResources;
  80311. private _createIndexBuffer;
  80312. /**
  80313. * Rebuilds the elements related to this component in case of
  80314. * context lost for instance.
  80315. */
  80316. rebuild(): void;
  80317. /**
  80318. * @hidden
  80319. */
  80320. reset(): void;
  80321. /**
  80322. * Render the bounding boxes of a specific rendering group
  80323. * @param renderingGroupId defines the rendering group to render
  80324. */
  80325. render(renderingGroupId: number): void;
  80326. /**
  80327. * In case of occlusion queries, we can render the occlusion bounding box through this method
  80328. * @param mesh Define the mesh to render the occlusion bounding box for
  80329. */
  80330. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  80331. /**
  80332. * Dispose and release the resources attached to this renderer.
  80333. */
  80334. dispose(): void;
  80335. }
  80336. }
  80337. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  80338. import { Nullable } from "babylonjs/types";
  80339. import { Scene } from "babylonjs/scene";
  80340. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  80341. import { Camera } from "babylonjs/Cameras/camera";
  80342. import { ISceneComponent } from "babylonjs/sceneComponent";
  80343. module "babylonjs/scene" {
  80344. interface Scene {
  80345. /** @hidden (Backing field) */
  80346. _depthRenderer: {
  80347. [id: string]: DepthRenderer;
  80348. };
  80349. /**
  80350. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  80351. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  80352. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  80353. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  80354. * @returns the created depth renderer
  80355. */
  80356. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  80357. /**
  80358. * Disables a depth renderer for a given camera
  80359. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  80360. */
  80361. disableDepthRenderer(camera?: Nullable<Camera>): void;
  80362. }
  80363. }
  80364. /**
  80365. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  80366. * in several rendering techniques.
  80367. */
  80368. export class DepthRendererSceneComponent implements ISceneComponent {
  80369. /**
  80370. * The component name helpfull to identify the component in the list of scene components.
  80371. */
  80372. readonly name: string;
  80373. /**
  80374. * The scene the component belongs to.
  80375. */
  80376. scene: Scene;
  80377. /**
  80378. * Creates a new instance of the component for the given scene
  80379. * @param scene Defines the scene to register the component in
  80380. */
  80381. constructor(scene: Scene);
  80382. /**
  80383. * Registers the component in a given scene
  80384. */
  80385. register(): void;
  80386. /**
  80387. * Rebuilds the elements related to this component in case of
  80388. * context lost for instance.
  80389. */
  80390. rebuild(): void;
  80391. /**
  80392. * Disposes the component and the associated ressources
  80393. */
  80394. dispose(): void;
  80395. private _gatherRenderTargets;
  80396. private _gatherActiveCameraRenderTargets;
  80397. }
  80398. }
  80399. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  80400. import { Nullable } from "babylonjs/types";
  80401. import { Scene } from "babylonjs/scene";
  80402. import { ISceneComponent } from "babylonjs/sceneComponent";
  80403. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  80404. module "babylonjs/abstractScene" {
  80405. interface AbstractScene {
  80406. /** @hidden (Backing field) */
  80407. _prePassRenderer: Nullable<PrePassRenderer>;
  80408. /**
  80409. * Gets or Sets the current prepass renderer associated to the scene.
  80410. */
  80411. prePassRenderer: Nullable<PrePassRenderer>;
  80412. /**
  80413. * Enables the prepass and associates it with the scene
  80414. * @returns the PrePassRenderer
  80415. */
  80416. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  80417. /**
  80418. * Disables the prepass associated with the scene
  80419. */
  80420. disablePrePassRenderer(): void;
  80421. }
  80422. }
  80423. /**
  80424. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80425. * in several rendering techniques.
  80426. */
  80427. export class PrePassRendererSceneComponent implements ISceneComponent {
  80428. /**
  80429. * The component name helpful to identify the component in the list of scene components.
  80430. */
  80431. readonly name: string;
  80432. /**
  80433. * The scene the component belongs to.
  80434. */
  80435. scene: Scene;
  80436. /**
  80437. * Creates a new instance of the component for the given scene
  80438. * @param scene Defines the scene to register the component in
  80439. */
  80440. constructor(scene: Scene);
  80441. /**
  80442. * Registers the component in a given scene
  80443. */
  80444. register(): void;
  80445. private _beforeCameraDraw;
  80446. private _afterCameraDraw;
  80447. private _beforeClearStage;
  80448. private _beforeRenderingMeshStage;
  80449. private _afterRenderingMeshStage;
  80450. /**
  80451. * Rebuilds the elements related to this component in case of
  80452. * context lost for instance.
  80453. */
  80454. rebuild(): void;
  80455. /**
  80456. * Disposes the component and the associated ressources
  80457. */
  80458. dispose(): void;
  80459. }
  80460. }
  80461. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  80462. /** @hidden */
  80463. export var fibonacci: {
  80464. name: string;
  80465. shader: string;
  80466. };
  80467. }
  80468. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  80469. /** @hidden */
  80470. export var diffusionProfile: {
  80471. name: string;
  80472. shader: string;
  80473. };
  80474. }
  80475. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  80476. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  80477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  80478. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  80479. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  80480. /** @hidden */
  80481. export var subSurfaceScatteringPixelShader: {
  80482. name: string;
  80483. shader: string;
  80484. };
  80485. }
  80486. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  80487. import { Nullable } from "babylonjs/types";
  80488. import { Camera } from "babylonjs/Cameras/camera";
  80489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80490. import { Engine } from "babylonjs/Engines/engine";
  80491. import { Scene } from "babylonjs/scene";
  80492. import "babylonjs/Shaders/imageProcessing.fragment";
  80493. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  80494. import "babylonjs/Shaders/postprocess.vertex";
  80495. /**
  80496. * Sub surface scattering post process
  80497. */
  80498. export class SubSurfaceScatteringPostProcess extends PostProcess {
  80499. /**
  80500. * Gets a string identifying the name of the class
  80501. * @returns "SubSurfaceScatteringPostProcess" string
  80502. */
  80503. getClassName(): string;
  80504. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  80505. }
  80506. }
  80507. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  80508. import { Scene } from "babylonjs/scene";
  80509. import { Color3 } from "babylonjs/Maths/math.color";
  80510. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  80511. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  80512. /**
  80513. * Contains all parameters needed for the prepass to perform
  80514. * screen space subsurface scattering
  80515. */
  80516. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  80517. /** @hidden */
  80518. static _SceneComponentInitialization: (scene: Scene) => void;
  80519. private _ssDiffusionS;
  80520. private _ssFilterRadii;
  80521. private _ssDiffusionD;
  80522. /**
  80523. * Post process to attach for screen space subsurface scattering
  80524. */
  80525. postProcess: SubSurfaceScatteringPostProcess;
  80526. /**
  80527. * Diffusion profile color for subsurface scattering
  80528. */
  80529. get ssDiffusionS(): number[];
  80530. /**
  80531. * Diffusion profile max color channel value for subsurface scattering
  80532. */
  80533. get ssDiffusionD(): number[];
  80534. /**
  80535. * Diffusion profile filter radius for subsurface scattering
  80536. */
  80537. get ssFilterRadii(): number[];
  80538. /**
  80539. * Is subsurface enabled
  80540. */
  80541. enabled: boolean;
  80542. /**
  80543. * Name of the configuration
  80544. */
  80545. name: string;
  80546. /**
  80547. * Diffusion profile colors for subsurface scattering
  80548. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  80549. * See ...
  80550. * Note that you can only store up to 5 of them
  80551. */
  80552. ssDiffusionProfileColors: Color3[];
  80553. /**
  80554. * Defines the ratio real world => scene units.
  80555. * Used for subsurface scattering
  80556. */
  80557. metersPerUnit: number;
  80558. /**
  80559. * Textures that should be present in the MRT for this effect to work
  80560. */
  80561. readonly texturesRequired: number[];
  80562. private _scene;
  80563. /**
  80564. * Builds a subsurface configuration object
  80565. * @param scene The scene
  80566. */
  80567. constructor(scene: Scene);
  80568. /**
  80569. * Adds a new diffusion profile.
  80570. * Useful for more realistic subsurface scattering on diverse materials.
  80571. * @param color The color of the diffusion profile. Should be the average color of the material.
  80572. * @return The index of the diffusion profile for the material subsurface configuration
  80573. */
  80574. addDiffusionProfile(color: Color3): number;
  80575. /**
  80576. * Creates the sss post process
  80577. * @return The created post process
  80578. */
  80579. createPostProcess(): SubSurfaceScatteringPostProcess;
  80580. /**
  80581. * Deletes all diffusion profiles.
  80582. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  80583. */
  80584. clearAllDiffusionProfiles(): void;
  80585. /**
  80586. * Disposes this object
  80587. */
  80588. dispose(): void;
  80589. /**
  80590. * @hidden
  80591. * https://zero-radiance.github.io/post/sampling-diffusion/
  80592. *
  80593. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  80594. * ------------------------------------------------------------------------------------
  80595. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  80596. * PDF[r, phi, s] = r * R[r, phi, s]
  80597. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  80598. * ------------------------------------------------------------------------------------
  80599. * We importance sample the color channel with the widest scattering distance.
  80600. */
  80601. getDiffusionProfileParameters(color: Color3): number;
  80602. /**
  80603. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  80604. * 'u' is the random number (the value of the CDF): [0, 1).
  80605. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  80606. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  80607. */
  80608. private _sampleBurleyDiffusionProfile;
  80609. }
  80610. }
  80611. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  80612. import { Nullable } from "babylonjs/types";
  80613. import { Scene } from "babylonjs/scene";
  80614. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  80615. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  80616. import { AbstractScene } from "babylonjs/abstractScene";
  80617. module "babylonjs/abstractScene" {
  80618. interface AbstractScene {
  80619. /** @hidden (Backing field) */
  80620. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80621. /**
  80622. * Gets or Sets the current prepass renderer associated to the scene.
  80623. */
  80624. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80625. /**
  80626. * Enables the subsurface effect for prepass
  80627. * @returns the SubSurfaceConfiguration
  80628. */
  80629. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  80630. /**
  80631. * Disables the subsurface effect for prepass
  80632. */
  80633. disableSubSurfaceForPrePass(): void;
  80634. }
  80635. }
  80636. /**
  80637. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80638. * in several rendering techniques.
  80639. */
  80640. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  80641. /**
  80642. * The component name helpful to identify the component in the list of scene components.
  80643. */
  80644. readonly name: string;
  80645. /**
  80646. * The scene the component belongs to.
  80647. */
  80648. scene: Scene;
  80649. /**
  80650. * Creates a new instance of the component for the given scene
  80651. * @param scene Defines the scene to register the component in
  80652. */
  80653. constructor(scene: Scene);
  80654. /**
  80655. * Registers the component in a given scene
  80656. */
  80657. register(): void;
  80658. /**
  80659. * Serializes the component data to the specified json object
  80660. * @param serializationObject The object to serialize to
  80661. */
  80662. serialize(serializationObject: any): void;
  80663. /**
  80664. * Adds all the elements from the container to the scene
  80665. * @param container the container holding the elements
  80666. */
  80667. addFromContainer(container: AbstractScene): void;
  80668. /**
  80669. * Removes all the elements in the container from the scene
  80670. * @param container contains the elements to remove
  80671. * @param dispose if the removed element should be disposed (default: false)
  80672. */
  80673. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80674. /**
  80675. * Rebuilds the elements related to this component in case of
  80676. * context lost for instance.
  80677. */
  80678. rebuild(): void;
  80679. /**
  80680. * Disposes the component and the associated ressources
  80681. */
  80682. dispose(): void;
  80683. }
  80684. }
  80685. declare module "babylonjs/Shaders/outline.fragment" {
  80686. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80687. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  80688. /** @hidden */
  80689. export var outlinePixelShader: {
  80690. name: string;
  80691. shader: string;
  80692. };
  80693. }
  80694. declare module "babylonjs/Shaders/outline.vertex" {
  80695. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80696. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80698. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80699. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80700. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80701. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80702. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80703. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  80704. /** @hidden */
  80705. export var outlineVertexShader: {
  80706. name: string;
  80707. shader: string;
  80708. };
  80709. }
  80710. declare module "babylonjs/Rendering/outlineRenderer" {
  80711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  80712. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  80713. import { Scene } from "babylonjs/scene";
  80714. import { ISceneComponent } from "babylonjs/sceneComponent";
  80715. import "babylonjs/Shaders/outline.fragment";
  80716. import "babylonjs/Shaders/outline.vertex";
  80717. module "babylonjs/scene" {
  80718. interface Scene {
  80719. /** @hidden */
  80720. _outlineRenderer: OutlineRenderer;
  80721. /**
  80722. * Gets the outline renderer associated with the scene
  80723. * @returns a OutlineRenderer
  80724. */
  80725. getOutlineRenderer(): OutlineRenderer;
  80726. }
  80727. }
  80728. module "babylonjs/Meshes/abstractMesh" {
  80729. interface AbstractMesh {
  80730. /** @hidden (Backing field) */
  80731. _renderOutline: boolean;
  80732. /**
  80733. * Gets or sets a boolean indicating if the outline must be rendered as well
  80734. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  80735. */
  80736. renderOutline: boolean;
  80737. /** @hidden (Backing field) */
  80738. _renderOverlay: boolean;
  80739. /**
  80740. * Gets or sets a boolean indicating if the overlay must be rendered as well
  80741. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  80742. */
  80743. renderOverlay: boolean;
  80744. }
  80745. }
  80746. /**
  80747. * This class is responsible to draw bothe outline/overlay of meshes.
  80748. * It should not be used directly but through the available method on mesh.
  80749. */
  80750. export class OutlineRenderer implements ISceneComponent {
  80751. /**
  80752. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  80753. */
  80754. private static _StencilReference;
  80755. /**
  80756. * The name of the component. Each component must have a unique name.
  80757. */
  80758. name: string;
  80759. /**
  80760. * The scene the component belongs to.
  80761. */
  80762. scene: Scene;
  80763. /**
  80764. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  80765. */
  80766. zOffset: number;
  80767. private _engine;
  80768. private _effect;
  80769. private _cachedDefines;
  80770. private _savedDepthWrite;
  80771. /**
  80772. * Instantiates a new outline renderer. (There could be only one per scene).
  80773. * @param scene Defines the scene it belongs to
  80774. */
  80775. constructor(scene: Scene);
  80776. /**
  80777. * Register the component to one instance of a scene.
  80778. */
  80779. register(): void;
  80780. /**
  80781. * Rebuilds the elements related to this component in case of
  80782. * context lost for instance.
  80783. */
  80784. rebuild(): void;
  80785. /**
  80786. * Disposes the component and the associated ressources.
  80787. */
  80788. dispose(): void;
  80789. /**
  80790. * Renders the outline in the canvas.
  80791. * @param subMesh Defines the sumesh to render
  80792. * @param batch Defines the batch of meshes in case of instances
  80793. * @param useOverlay Defines if the rendering is for the overlay or the outline
  80794. */
  80795. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  80796. /**
  80797. * Returns whether or not the outline renderer is ready for a given submesh.
  80798. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  80799. * @param subMesh Defines the submesh to check readyness for
  80800. * @param useInstances Defines wheter wee are trying to render instances or not
  80801. * @returns true if ready otherwise false
  80802. */
  80803. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80804. private _beforeRenderingMesh;
  80805. private _afterRenderingMesh;
  80806. }
  80807. }
  80808. declare module "babylonjs/Rendering/index" {
  80809. export * from "babylonjs/Rendering/boundingBoxRenderer";
  80810. export * from "babylonjs/Rendering/depthRenderer";
  80811. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  80812. export * from "babylonjs/Rendering/edgesRenderer";
  80813. export * from "babylonjs/Rendering/geometryBufferRenderer";
  80814. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80815. export * from "babylonjs/Rendering/prePassRenderer";
  80816. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  80817. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  80818. export * from "babylonjs/Rendering/outlineRenderer";
  80819. export * from "babylonjs/Rendering/renderingGroup";
  80820. export * from "babylonjs/Rendering/renderingManager";
  80821. export * from "babylonjs/Rendering/utilityLayerRenderer";
  80822. }
  80823. declare module "babylonjs/Sprites/ISprites" {
  80824. /**
  80825. * Defines the basic options interface of a Sprite Frame Source Size.
  80826. */
  80827. export interface ISpriteJSONSpriteSourceSize {
  80828. /**
  80829. * number of the original width of the Frame
  80830. */
  80831. w: number;
  80832. /**
  80833. * number of the original height of the Frame
  80834. */
  80835. h: number;
  80836. }
  80837. /**
  80838. * Defines the basic options interface of a Sprite Frame Data.
  80839. */
  80840. export interface ISpriteJSONSpriteFrameData {
  80841. /**
  80842. * number of the x offset of the Frame
  80843. */
  80844. x: number;
  80845. /**
  80846. * number of the y offset of the Frame
  80847. */
  80848. y: number;
  80849. /**
  80850. * number of the width of the Frame
  80851. */
  80852. w: number;
  80853. /**
  80854. * number of the height of the Frame
  80855. */
  80856. h: number;
  80857. }
  80858. /**
  80859. * Defines the basic options interface of a JSON Sprite.
  80860. */
  80861. export interface ISpriteJSONSprite {
  80862. /**
  80863. * string name of the Frame
  80864. */
  80865. filename: string;
  80866. /**
  80867. * ISpriteJSONSpriteFrame basic object of the frame data
  80868. */
  80869. frame: ISpriteJSONSpriteFrameData;
  80870. /**
  80871. * boolean to flag is the frame was rotated.
  80872. */
  80873. rotated: boolean;
  80874. /**
  80875. * boolean to flag is the frame was trimmed.
  80876. */
  80877. trimmed: boolean;
  80878. /**
  80879. * ISpriteJSONSpriteFrame basic object of the source data
  80880. */
  80881. spriteSourceSize: ISpriteJSONSpriteFrameData;
  80882. /**
  80883. * ISpriteJSONSpriteFrame basic object of the source data
  80884. */
  80885. sourceSize: ISpriteJSONSpriteSourceSize;
  80886. }
  80887. /**
  80888. * Defines the basic options interface of a JSON atlas.
  80889. */
  80890. export interface ISpriteJSONAtlas {
  80891. /**
  80892. * Array of objects that contain the frame data.
  80893. */
  80894. frames: Array<ISpriteJSONSprite>;
  80895. /**
  80896. * object basic object containing the sprite meta data.
  80897. */
  80898. meta?: object;
  80899. }
  80900. }
  80901. declare module "babylonjs/Shaders/spriteMap.fragment" {
  80902. /** @hidden */
  80903. export var spriteMapPixelShader: {
  80904. name: string;
  80905. shader: string;
  80906. };
  80907. }
  80908. declare module "babylonjs/Shaders/spriteMap.vertex" {
  80909. /** @hidden */
  80910. export var spriteMapVertexShader: {
  80911. name: string;
  80912. shader: string;
  80913. };
  80914. }
  80915. declare module "babylonjs/Sprites/spriteMap" {
  80916. import { IDisposable, Scene } from "babylonjs/scene";
  80917. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  80918. import { Texture } from "babylonjs/Materials/Textures/texture";
  80919. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  80920. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  80921. import "babylonjs/Meshes/Builders/planeBuilder";
  80922. import "babylonjs/Shaders/spriteMap.fragment";
  80923. import "babylonjs/Shaders/spriteMap.vertex";
  80924. /**
  80925. * Defines the basic options interface of a SpriteMap
  80926. */
  80927. export interface ISpriteMapOptions {
  80928. /**
  80929. * Vector2 of the number of cells in the grid.
  80930. */
  80931. stageSize?: Vector2;
  80932. /**
  80933. * Vector2 of the size of the output plane in World Units.
  80934. */
  80935. outputSize?: Vector2;
  80936. /**
  80937. * Vector3 of the position of the output plane in World Units.
  80938. */
  80939. outputPosition?: Vector3;
  80940. /**
  80941. * Vector3 of the rotation of the output plane.
  80942. */
  80943. outputRotation?: Vector3;
  80944. /**
  80945. * number of layers that the system will reserve in resources.
  80946. */
  80947. layerCount?: number;
  80948. /**
  80949. * number of max animation frames a single cell will reserve in resources.
  80950. */
  80951. maxAnimationFrames?: number;
  80952. /**
  80953. * number cell index of the base tile when the system compiles.
  80954. */
  80955. baseTile?: number;
  80956. /**
  80957. * boolean flip the sprite after its been repositioned by the framing data.
  80958. */
  80959. flipU?: boolean;
  80960. /**
  80961. * Vector3 scalar of the global RGB values of the SpriteMap.
  80962. */
  80963. colorMultiply?: Vector3;
  80964. }
  80965. /**
  80966. * Defines the IDisposable interface in order to be cleanable from resources.
  80967. */
  80968. export interface ISpriteMap extends IDisposable {
  80969. /**
  80970. * String name of the SpriteMap.
  80971. */
  80972. name: string;
  80973. /**
  80974. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  80975. */
  80976. atlasJSON: ISpriteJSONAtlas;
  80977. /**
  80978. * Texture of the SpriteMap.
  80979. */
  80980. spriteSheet: Texture;
  80981. /**
  80982. * The parameters to initialize the SpriteMap with.
  80983. */
  80984. options: ISpriteMapOptions;
  80985. }
  80986. /**
  80987. * Class used to manage a grid restricted sprite deployment on an Output plane.
  80988. */
  80989. export class SpriteMap implements ISpriteMap {
  80990. /** The Name of the spriteMap */
  80991. name: string;
  80992. /** The JSON file with the frame and meta data */
  80993. atlasJSON: ISpriteJSONAtlas;
  80994. /** The systems Sprite Sheet Texture */
  80995. spriteSheet: Texture;
  80996. /** Arguments passed with the Constructor */
  80997. options: ISpriteMapOptions;
  80998. /** Public Sprite Storage array, parsed from atlasJSON */
  80999. sprites: Array<ISpriteJSONSprite>;
  81000. /** Returns the Number of Sprites in the System */
  81001. get spriteCount(): number;
  81002. /** Returns the Position of Output Plane*/
  81003. get position(): Vector3;
  81004. /** Returns the Position of Output Plane*/
  81005. set position(v: Vector3);
  81006. /** Returns the Rotation of Output Plane*/
  81007. get rotation(): Vector3;
  81008. /** Returns the Rotation of Output Plane*/
  81009. set rotation(v: Vector3);
  81010. /** Sets the AnimationMap*/
  81011. get animationMap(): RawTexture;
  81012. /** Sets the AnimationMap*/
  81013. set animationMap(v: RawTexture);
  81014. /** Scene that the SpriteMap was created in */
  81015. private _scene;
  81016. /** Texture Buffer of Float32 that holds tile frame data*/
  81017. private _frameMap;
  81018. /** Texture Buffers of Float32 that holds tileMap data*/
  81019. private _tileMaps;
  81020. /** Texture Buffer of Float32 that holds Animation Data*/
  81021. private _animationMap;
  81022. /** Custom ShaderMaterial Central to the System*/
  81023. private _material;
  81024. /** Custom ShaderMaterial Central to the System*/
  81025. private _output;
  81026. /** Systems Time Ticker*/
  81027. private _time;
  81028. /**
  81029. * Creates a new SpriteMap
  81030. * @param name defines the SpriteMaps Name
  81031. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  81032. * @param spriteSheet is the Texture that the Sprites are on.
  81033. * @param options a basic deployment configuration
  81034. * @param scene The Scene that the map is deployed on
  81035. */
  81036. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  81037. /**
  81038. * Returns tileID location
  81039. * @returns Vector2 the cell position ID
  81040. */
  81041. getTileID(): Vector2;
  81042. /**
  81043. * Gets the UV location of the mouse over the SpriteMap.
  81044. * @returns Vector2 the UV position of the mouse interaction
  81045. */
  81046. getMousePosition(): Vector2;
  81047. /**
  81048. * Creates the "frame" texture Buffer
  81049. * -------------------------------------
  81050. * Structure of frames
  81051. * "filename": "Falling-Water-2.png",
  81052. * "frame": {"x":69,"y":103,"w":24,"h":32},
  81053. * "rotated": true,
  81054. * "trimmed": true,
  81055. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  81056. * "sourceSize": {"w":32,"h":32}
  81057. * @returns RawTexture of the frameMap
  81058. */
  81059. private _createFrameBuffer;
  81060. /**
  81061. * Creates the tileMap texture Buffer
  81062. * @param buffer normally and array of numbers, or a false to generate from scratch
  81063. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  81064. * @returns RawTexture of the tileMap
  81065. */
  81066. private _createTileBuffer;
  81067. /**
  81068. * Modifies the data of the tileMaps
  81069. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  81070. * @param pos is the iVector2 Coordinates of the Tile
  81071. * @param tile The SpriteIndex of the new Tile
  81072. */
  81073. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  81074. /**
  81075. * Creates the animationMap texture Buffer
  81076. * @param buffer normally and array of numbers, or a false to generate from scratch
  81077. * @returns RawTexture of the animationMap
  81078. */
  81079. private _createTileAnimationBuffer;
  81080. /**
  81081. * Modifies the data of the animationMap
  81082. * @param cellID is the Index of the Sprite
  81083. * @param _frame is the target Animation frame
  81084. * @param toCell is the Target Index of the next frame of the animation
  81085. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  81086. * @param speed is a global scalar of the time variable on the map.
  81087. */
  81088. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  81089. /**
  81090. * Exports the .tilemaps file
  81091. */
  81092. saveTileMaps(): void;
  81093. /**
  81094. * Imports the .tilemaps file
  81095. * @param url of the .tilemaps file
  81096. */
  81097. loadTileMaps(url: string): void;
  81098. /**
  81099. * Release associated resources
  81100. */
  81101. dispose(): void;
  81102. }
  81103. }
  81104. declare module "babylonjs/Sprites/spritePackedManager" {
  81105. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  81106. import { Scene } from "babylonjs/scene";
  81107. /**
  81108. * Class used to manage multiple sprites of different sizes on the same spritesheet
  81109. * @see https://doc.babylonjs.com/babylon101/sprites
  81110. */
  81111. export class SpritePackedManager extends SpriteManager {
  81112. /** defines the packed manager's name */
  81113. name: string;
  81114. /**
  81115. * Creates a new sprite manager from a packed sprite sheet
  81116. * @param name defines the manager's name
  81117. * @param imgUrl defines the sprite sheet url
  81118. * @param capacity defines the maximum allowed number of sprites
  81119. * @param scene defines the hosting scene
  81120. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  81121. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81122. * @param samplingMode defines the smapling mode to use with spritesheet
  81123. * @param fromPacked set to true; do not alter
  81124. */
  81125. constructor(
  81126. /** defines the packed manager's name */
  81127. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  81128. }
  81129. }
  81130. declare module "babylonjs/Sprites/index" {
  81131. export * from "babylonjs/Sprites/sprite";
  81132. export * from "babylonjs/Sprites/ISprites";
  81133. export * from "babylonjs/Sprites/spriteManager";
  81134. export * from "babylonjs/Sprites/spriteMap";
  81135. export * from "babylonjs/Sprites/spritePackedManager";
  81136. export * from "babylonjs/Sprites/spriteSceneComponent";
  81137. }
  81138. declare module "babylonjs/States/index" {
  81139. export * from "babylonjs/States/alphaCullingState";
  81140. export * from "babylonjs/States/depthCullingState";
  81141. export * from "babylonjs/States/stencilState";
  81142. }
  81143. declare module "babylonjs/Misc/assetsManager" {
  81144. import { Scene } from "babylonjs/scene";
  81145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  81147. import { Skeleton } from "babylonjs/Bones/skeleton";
  81148. import { Observable } from "babylonjs/Misc/observable";
  81149. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  81150. import { Texture } from "babylonjs/Materials/Textures/texture";
  81151. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  81152. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  81153. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  81154. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  81155. import { AssetContainer } from "babylonjs/assetContainer";
  81156. /**
  81157. * Defines the list of states available for a task inside a AssetsManager
  81158. */
  81159. export enum AssetTaskState {
  81160. /**
  81161. * Initialization
  81162. */
  81163. INIT = 0,
  81164. /**
  81165. * Running
  81166. */
  81167. RUNNING = 1,
  81168. /**
  81169. * Done
  81170. */
  81171. DONE = 2,
  81172. /**
  81173. * Error
  81174. */
  81175. ERROR = 3
  81176. }
  81177. /**
  81178. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  81179. */
  81180. export abstract class AbstractAssetTask {
  81181. /**
  81182. * Task name
  81183. */ name: string;
  81184. /**
  81185. * Callback called when the task is successful
  81186. */
  81187. onSuccess: (task: any) => void;
  81188. /**
  81189. * Callback called when the task is not successful
  81190. */
  81191. onError: (task: any, message?: string, exception?: any) => void;
  81192. /**
  81193. * Creates a new AssetsManager
  81194. * @param name defines the name of the task
  81195. */
  81196. constructor(
  81197. /**
  81198. * Task name
  81199. */ name: string);
  81200. private _isCompleted;
  81201. private _taskState;
  81202. private _errorObject;
  81203. /**
  81204. * Get if the task is completed
  81205. */
  81206. get isCompleted(): boolean;
  81207. /**
  81208. * Gets the current state of the task
  81209. */
  81210. get taskState(): AssetTaskState;
  81211. /**
  81212. * Gets the current error object (if task is in error)
  81213. */
  81214. get errorObject(): {
  81215. message?: string;
  81216. exception?: any;
  81217. };
  81218. /**
  81219. * Internal only
  81220. * @hidden
  81221. */
  81222. _setErrorObject(message?: string, exception?: any): void;
  81223. /**
  81224. * Execute the current task
  81225. * @param scene defines the scene where you want your assets to be loaded
  81226. * @param onSuccess is a callback called when the task is successfully executed
  81227. * @param onError is a callback called if an error occurs
  81228. */
  81229. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81230. /**
  81231. * Execute the current task
  81232. * @param scene defines the scene where you want your assets to be loaded
  81233. * @param onSuccess is a callback called when the task is successfully executed
  81234. * @param onError is a callback called if an error occurs
  81235. */
  81236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81237. /**
  81238. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  81239. * This can be used with failed tasks that have the reason for failure fixed.
  81240. */
  81241. reset(): void;
  81242. private onErrorCallback;
  81243. private onDoneCallback;
  81244. }
  81245. /**
  81246. * Define the interface used by progress events raised during assets loading
  81247. */
  81248. export interface IAssetsProgressEvent {
  81249. /**
  81250. * Defines the number of remaining tasks to process
  81251. */
  81252. remainingCount: number;
  81253. /**
  81254. * Defines the total number of tasks
  81255. */
  81256. totalCount: number;
  81257. /**
  81258. * Defines the task that was just processed
  81259. */
  81260. task: AbstractAssetTask;
  81261. }
  81262. /**
  81263. * Class used to share progress information about assets loading
  81264. */
  81265. export class AssetsProgressEvent implements IAssetsProgressEvent {
  81266. /**
  81267. * Defines the number of remaining tasks to process
  81268. */
  81269. remainingCount: number;
  81270. /**
  81271. * Defines the total number of tasks
  81272. */
  81273. totalCount: number;
  81274. /**
  81275. * Defines the task that was just processed
  81276. */
  81277. task: AbstractAssetTask;
  81278. /**
  81279. * Creates a AssetsProgressEvent
  81280. * @param remainingCount defines the number of remaining tasks to process
  81281. * @param totalCount defines the total number of tasks
  81282. * @param task defines the task that was just processed
  81283. */
  81284. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  81285. }
  81286. /**
  81287. * Define a task used by AssetsManager to load assets into a container
  81288. */
  81289. export class ContainerAssetTask extends AbstractAssetTask {
  81290. /**
  81291. * Defines the name of the task
  81292. */
  81293. name: string;
  81294. /**
  81295. * Defines the list of mesh's names you want to load
  81296. */
  81297. meshesNames: any;
  81298. /**
  81299. * Defines the root url to use as a base to load your meshes and associated resources
  81300. */
  81301. rootUrl: string;
  81302. /**
  81303. * Defines the filename or File of the scene to load from
  81304. */
  81305. sceneFilename: string | File;
  81306. /**
  81307. * Get the loaded asset container
  81308. */
  81309. loadedContainer: AssetContainer;
  81310. /**
  81311. * Gets the list of loaded meshes
  81312. */
  81313. loadedMeshes: Array<AbstractMesh>;
  81314. /**
  81315. * Gets the list of loaded particle systems
  81316. */
  81317. loadedParticleSystems: Array<IParticleSystem>;
  81318. /**
  81319. * Gets the list of loaded skeletons
  81320. */
  81321. loadedSkeletons: Array<Skeleton>;
  81322. /**
  81323. * Gets the list of loaded animation groups
  81324. */
  81325. loadedAnimationGroups: Array<AnimationGroup>;
  81326. /**
  81327. * Callback called when the task is successful
  81328. */
  81329. onSuccess: (task: ContainerAssetTask) => void;
  81330. /**
  81331. * Callback called when the task is successful
  81332. */
  81333. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  81334. /**
  81335. * Creates a new ContainerAssetTask
  81336. * @param name defines the name of the task
  81337. * @param meshesNames defines the list of mesh's names you want to load
  81338. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81339. * @param sceneFilename defines the filename or File of the scene to load from
  81340. */
  81341. constructor(
  81342. /**
  81343. * Defines the name of the task
  81344. */
  81345. name: string,
  81346. /**
  81347. * Defines the list of mesh's names you want to load
  81348. */
  81349. meshesNames: any,
  81350. /**
  81351. * Defines the root url to use as a base to load your meshes and associated resources
  81352. */
  81353. rootUrl: string,
  81354. /**
  81355. * Defines the filename or File of the scene to load from
  81356. */
  81357. sceneFilename: string | File);
  81358. /**
  81359. * Execute the current task
  81360. * @param scene defines the scene where you want your assets to be loaded
  81361. * @param onSuccess is a callback called when the task is successfully executed
  81362. * @param onError is a callback called if an error occurs
  81363. */
  81364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81365. }
  81366. /**
  81367. * Define a task used by AssetsManager to load meshes
  81368. */
  81369. export class MeshAssetTask extends AbstractAssetTask {
  81370. /**
  81371. * Defines the name of the task
  81372. */
  81373. name: string;
  81374. /**
  81375. * Defines the list of mesh's names you want to load
  81376. */
  81377. meshesNames: any;
  81378. /**
  81379. * Defines the root url to use as a base to load your meshes and associated resources
  81380. */
  81381. rootUrl: string;
  81382. /**
  81383. * Defines the filename or File of the scene to load from
  81384. */
  81385. sceneFilename: string | File;
  81386. /**
  81387. * Gets the list of loaded meshes
  81388. */
  81389. loadedMeshes: Array<AbstractMesh>;
  81390. /**
  81391. * Gets the list of loaded particle systems
  81392. */
  81393. loadedParticleSystems: Array<IParticleSystem>;
  81394. /**
  81395. * Gets the list of loaded skeletons
  81396. */
  81397. loadedSkeletons: Array<Skeleton>;
  81398. /**
  81399. * Gets the list of loaded animation groups
  81400. */
  81401. loadedAnimationGroups: Array<AnimationGroup>;
  81402. /**
  81403. * Callback called when the task is successful
  81404. */
  81405. onSuccess: (task: MeshAssetTask) => void;
  81406. /**
  81407. * Callback called when the task is successful
  81408. */
  81409. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  81410. /**
  81411. * Creates a new MeshAssetTask
  81412. * @param name defines the name of the task
  81413. * @param meshesNames defines the list of mesh's names you want to load
  81414. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81415. * @param sceneFilename defines the filename or File of the scene to load from
  81416. */
  81417. constructor(
  81418. /**
  81419. * Defines the name of the task
  81420. */
  81421. name: string,
  81422. /**
  81423. * Defines the list of mesh's names you want to load
  81424. */
  81425. meshesNames: any,
  81426. /**
  81427. * Defines the root url to use as a base to load your meshes and associated resources
  81428. */
  81429. rootUrl: string,
  81430. /**
  81431. * Defines the filename or File of the scene to load from
  81432. */
  81433. sceneFilename: string | File);
  81434. /**
  81435. * Execute the current task
  81436. * @param scene defines the scene where you want your assets to be loaded
  81437. * @param onSuccess is a callback called when the task is successfully executed
  81438. * @param onError is a callback called if an error occurs
  81439. */
  81440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81441. }
  81442. /**
  81443. * Define a task used by AssetsManager to load text content
  81444. */
  81445. export class TextFileAssetTask extends AbstractAssetTask {
  81446. /**
  81447. * Defines the name of the task
  81448. */
  81449. name: string;
  81450. /**
  81451. * Defines the location of the file to load
  81452. */
  81453. url: string;
  81454. /**
  81455. * Gets the loaded text string
  81456. */
  81457. text: string;
  81458. /**
  81459. * Callback called when the task is successful
  81460. */
  81461. onSuccess: (task: TextFileAssetTask) => void;
  81462. /**
  81463. * Callback called when the task is successful
  81464. */
  81465. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  81466. /**
  81467. * Creates a new TextFileAssetTask object
  81468. * @param name defines the name of the task
  81469. * @param url defines the location of the file to load
  81470. */
  81471. constructor(
  81472. /**
  81473. * Defines the name of the task
  81474. */
  81475. name: string,
  81476. /**
  81477. * Defines the location of the file to load
  81478. */
  81479. url: string);
  81480. /**
  81481. * Execute the current task
  81482. * @param scene defines the scene where you want your assets to be loaded
  81483. * @param onSuccess is a callback called when the task is successfully executed
  81484. * @param onError is a callback called if an error occurs
  81485. */
  81486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81487. }
  81488. /**
  81489. * Define a task used by AssetsManager to load binary data
  81490. */
  81491. export class BinaryFileAssetTask extends AbstractAssetTask {
  81492. /**
  81493. * Defines the name of the task
  81494. */
  81495. name: string;
  81496. /**
  81497. * Defines the location of the file to load
  81498. */
  81499. url: string;
  81500. /**
  81501. * Gets the lodaded data (as an array buffer)
  81502. */
  81503. data: ArrayBuffer;
  81504. /**
  81505. * Callback called when the task is successful
  81506. */
  81507. onSuccess: (task: BinaryFileAssetTask) => void;
  81508. /**
  81509. * Callback called when the task is successful
  81510. */
  81511. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  81512. /**
  81513. * Creates a new BinaryFileAssetTask object
  81514. * @param name defines the name of the new task
  81515. * @param url defines the location of the file to load
  81516. */
  81517. constructor(
  81518. /**
  81519. * Defines the name of the task
  81520. */
  81521. name: string,
  81522. /**
  81523. * Defines the location of the file to load
  81524. */
  81525. url: string);
  81526. /**
  81527. * Execute the current task
  81528. * @param scene defines the scene where you want your assets to be loaded
  81529. * @param onSuccess is a callback called when the task is successfully executed
  81530. * @param onError is a callback called if an error occurs
  81531. */
  81532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81533. }
  81534. /**
  81535. * Define a task used by AssetsManager to load images
  81536. */
  81537. export class ImageAssetTask extends AbstractAssetTask {
  81538. /**
  81539. * Defines the name of the task
  81540. */
  81541. name: string;
  81542. /**
  81543. * Defines the location of the image to load
  81544. */
  81545. url: string;
  81546. /**
  81547. * Gets the loaded images
  81548. */
  81549. image: HTMLImageElement;
  81550. /**
  81551. * Callback called when the task is successful
  81552. */
  81553. onSuccess: (task: ImageAssetTask) => void;
  81554. /**
  81555. * Callback called when the task is successful
  81556. */
  81557. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  81558. /**
  81559. * Creates a new ImageAssetTask
  81560. * @param name defines the name of the task
  81561. * @param url defines the location of the image to load
  81562. */
  81563. constructor(
  81564. /**
  81565. * Defines the name of the task
  81566. */
  81567. name: string,
  81568. /**
  81569. * Defines the location of the image to load
  81570. */
  81571. url: string);
  81572. /**
  81573. * Execute the current task
  81574. * @param scene defines the scene where you want your assets to be loaded
  81575. * @param onSuccess is a callback called when the task is successfully executed
  81576. * @param onError is a callback called if an error occurs
  81577. */
  81578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81579. }
  81580. /**
  81581. * Defines the interface used by texture loading tasks
  81582. */
  81583. export interface ITextureAssetTask<TEX extends BaseTexture> {
  81584. /**
  81585. * Gets the loaded texture
  81586. */
  81587. texture: TEX;
  81588. }
  81589. /**
  81590. * Define a task used by AssetsManager to load 2D textures
  81591. */
  81592. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  81593. /**
  81594. * Defines the name of the task
  81595. */
  81596. name: string;
  81597. /**
  81598. * Defines the location of the file to load
  81599. */
  81600. url: string;
  81601. /**
  81602. * Defines if mipmap should not be generated (default is false)
  81603. */
  81604. noMipmap?: boolean | undefined;
  81605. /**
  81606. * Defines if texture must be inverted on Y axis (default is true)
  81607. */
  81608. invertY: boolean;
  81609. /**
  81610. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81611. */
  81612. samplingMode: number;
  81613. /**
  81614. * Gets the loaded texture
  81615. */
  81616. texture: Texture;
  81617. /**
  81618. * Callback called when the task is successful
  81619. */
  81620. onSuccess: (task: TextureAssetTask) => void;
  81621. /**
  81622. * Callback called when the task is successful
  81623. */
  81624. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  81625. /**
  81626. * Creates a new TextureAssetTask object
  81627. * @param name defines the name of the task
  81628. * @param url defines the location of the file to load
  81629. * @param noMipmap defines if mipmap should not be generated (default is false)
  81630. * @param invertY defines if texture must be inverted on Y axis (default is true)
  81631. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81632. */
  81633. constructor(
  81634. /**
  81635. * Defines the name of the task
  81636. */
  81637. name: string,
  81638. /**
  81639. * Defines the location of the file to load
  81640. */
  81641. url: string,
  81642. /**
  81643. * Defines if mipmap should not be generated (default is false)
  81644. */
  81645. noMipmap?: boolean | undefined,
  81646. /**
  81647. * Defines if texture must be inverted on Y axis (default is true)
  81648. */
  81649. invertY?: boolean,
  81650. /**
  81651. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81652. */
  81653. samplingMode?: number);
  81654. /**
  81655. * Execute the current task
  81656. * @param scene defines the scene where you want your assets to be loaded
  81657. * @param onSuccess is a callback called when the task is successfully executed
  81658. * @param onError is a callback called if an error occurs
  81659. */
  81660. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81661. }
  81662. /**
  81663. * Define a task used by AssetsManager to load cube textures
  81664. */
  81665. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  81666. /**
  81667. * Defines the name of the task
  81668. */
  81669. name: string;
  81670. /**
  81671. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81672. */
  81673. url: string;
  81674. /**
  81675. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81676. */
  81677. extensions?: string[] | undefined;
  81678. /**
  81679. * Defines if mipmaps should not be generated (default is false)
  81680. */
  81681. noMipmap?: boolean | undefined;
  81682. /**
  81683. * Defines the explicit list of files (undefined by default)
  81684. */
  81685. files?: string[] | undefined;
  81686. /**
  81687. * Gets the loaded texture
  81688. */
  81689. texture: CubeTexture;
  81690. /**
  81691. * Callback called when the task is successful
  81692. */
  81693. onSuccess: (task: CubeTextureAssetTask) => void;
  81694. /**
  81695. * Callback called when the task is successful
  81696. */
  81697. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  81698. /**
  81699. * Creates a new CubeTextureAssetTask
  81700. * @param name defines the name of the task
  81701. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81702. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81703. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81704. * @param files defines the explicit list of files (undefined by default)
  81705. */
  81706. constructor(
  81707. /**
  81708. * Defines the name of the task
  81709. */
  81710. name: string,
  81711. /**
  81712. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81713. */
  81714. url: string,
  81715. /**
  81716. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81717. */
  81718. extensions?: string[] | undefined,
  81719. /**
  81720. * Defines if mipmaps should not be generated (default is false)
  81721. */
  81722. noMipmap?: boolean | undefined,
  81723. /**
  81724. * Defines the explicit list of files (undefined by default)
  81725. */
  81726. files?: string[] | undefined);
  81727. /**
  81728. * Execute the current task
  81729. * @param scene defines the scene where you want your assets to be loaded
  81730. * @param onSuccess is a callback called when the task is successfully executed
  81731. * @param onError is a callback called if an error occurs
  81732. */
  81733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81734. }
  81735. /**
  81736. * Define a task used by AssetsManager to load HDR cube textures
  81737. */
  81738. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  81739. /**
  81740. * Defines the name of the task
  81741. */
  81742. name: string;
  81743. /**
  81744. * Defines the location of the file to load
  81745. */
  81746. url: string;
  81747. /**
  81748. * Defines the desired size (the more it increases the longer the generation will be)
  81749. */
  81750. size: number;
  81751. /**
  81752. * Defines if mipmaps should not be generated (default is false)
  81753. */
  81754. noMipmap: boolean;
  81755. /**
  81756. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81757. */
  81758. generateHarmonics: boolean;
  81759. /**
  81760. * 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)
  81761. */
  81762. gammaSpace: boolean;
  81763. /**
  81764. * Internal Use Only
  81765. */
  81766. reserved: boolean;
  81767. /**
  81768. * Gets the loaded texture
  81769. */
  81770. texture: HDRCubeTexture;
  81771. /**
  81772. * Callback called when the task is successful
  81773. */
  81774. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  81775. /**
  81776. * Callback called when the task is successful
  81777. */
  81778. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  81779. /**
  81780. * Creates a new HDRCubeTextureAssetTask object
  81781. * @param name defines the name of the task
  81782. * @param url defines the location of the file to load
  81783. * @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.
  81784. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81785. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81786. * @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)
  81787. * @param reserved Internal use only
  81788. */
  81789. constructor(
  81790. /**
  81791. * Defines the name of the task
  81792. */
  81793. name: string,
  81794. /**
  81795. * Defines the location of the file to load
  81796. */
  81797. url: string,
  81798. /**
  81799. * Defines the desired size (the more it increases the longer the generation will be)
  81800. */
  81801. size: number,
  81802. /**
  81803. * Defines if mipmaps should not be generated (default is false)
  81804. */
  81805. noMipmap?: boolean,
  81806. /**
  81807. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81808. */
  81809. generateHarmonics?: boolean,
  81810. /**
  81811. * 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)
  81812. */
  81813. gammaSpace?: boolean,
  81814. /**
  81815. * Internal Use Only
  81816. */
  81817. reserved?: boolean);
  81818. /**
  81819. * Execute the current task
  81820. * @param scene defines the scene where you want your assets to be loaded
  81821. * @param onSuccess is a callback called when the task is successfully executed
  81822. * @param onError is a callback called if an error occurs
  81823. */
  81824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81825. }
  81826. /**
  81827. * Define a task used by AssetsManager to load Equirectangular cube textures
  81828. */
  81829. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  81830. /**
  81831. * Defines the name of the task
  81832. */
  81833. name: string;
  81834. /**
  81835. * Defines the location of the file to load
  81836. */
  81837. url: string;
  81838. /**
  81839. * Defines the desired size (the more it increases the longer the generation will be)
  81840. */
  81841. size: number;
  81842. /**
  81843. * Defines if mipmaps should not be generated (default is false)
  81844. */
  81845. noMipmap: boolean;
  81846. /**
  81847. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81848. * but the standard material would require them in Gamma space) (default is true)
  81849. */
  81850. gammaSpace: boolean;
  81851. /**
  81852. * Gets the loaded texture
  81853. */
  81854. texture: EquiRectangularCubeTexture;
  81855. /**
  81856. * Callback called when the task is successful
  81857. */
  81858. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  81859. /**
  81860. * Callback called when the task is successful
  81861. */
  81862. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  81863. /**
  81864. * Creates a new EquiRectangularCubeTextureAssetTask object
  81865. * @param name defines the name of the task
  81866. * @param url defines the location of the file to load
  81867. * @param size defines the desired size (the more it increases the longer the generation will be)
  81868. * If the size is omitted this implies you are using a preprocessed cubemap.
  81869. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81870. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  81871. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  81872. * (default is true)
  81873. */
  81874. constructor(
  81875. /**
  81876. * Defines the name of the task
  81877. */
  81878. name: string,
  81879. /**
  81880. * Defines the location of the file to load
  81881. */
  81882. url: string,
  81883. /**
  81884. * Defines the desired size (the more it increases the longer the generation will be)
  81885. */
  81886. size: number,
  81887. /**
  81888. * Defines if mipmaps should not be generated (default is false)
  81889. */
  81890. noMipmap?: boolean,
  81891. /**
  81892. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81893. * but the standard material would require them in Gamma space) (default is true)
  81894. */
  81895. gammaSpace?: boolean);
  81896. /**
  81897. * Execute the current task
  81898. * @param scene defines the scene where you want your assets to be loaded
  81899. * @param onSuccess is a callback called when the task is successfully executed
  81900. * @param onError is a callback called if an error occurs
  81901. */
  81902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81903. }
  81904. /**
  81905. * This class can be used to easily import assets into a scene
  81906. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  81907. */
  81908. export class AssetsManager {
  81909. private _scene;
  81910. private _isLoading;
  81911. protected _tasks: AbstractAssetTask[];
  81912. protected _waitingTasksCount: number;
  81913. protected _totalTasksCount: number;
  81914. /**
  81915. * Callback called when all tasks are processed
  81916. */
  81917. onFinish: (tasks: AbstractAssetTask[]) => void;
  81918. /**
  81919. * Callback called when a task is successful
  81920. */
  81921. onTaskSuccess: (task: AbstractAssetTask) => void;
  81922. /**
  81923. * Callback called when a task had an error
  81924. */
  81925. onTaskError: (task: AbstractAssetTask) => void;
  81926. /**
  81927. * Callback called when a task is done (whatever the result is)
  81928. */
  81929. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  81930. /**
  81931. * Observable called when all tasks are processed
  81932. */
  81933. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  81934. /**
  81935. * Observable called when a task had an error
  81936. */
  81937. onTaskErrorObservable: Observable<AbstractAssetTask>;
  81938. /**
  81939. * Observable called when all tasks were executed
  81940. */
  81941. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  81942. /**
  81943. * Observable called when a task is done (whatever the result is)
  81944. */
  81945. onProgressObservable: Observable<IAssetsProgressEvent>;
  81946. /**
  81947. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  81948. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  81949. */
  81950. useDefaultLoadingScreen: boolean;
  81951. /**
  81952. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  81953. * when all assets have been downloaded.
  81954. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  81955. */
  81956. autoHideLoadingUI: boolean;
  81957. /**
  81958. * Creates a new AssetsManager
  81959. * @param scene defines the scene to work on
  81960. */
  81961. constructor(scene: Scene);
  81962. /**
  81963. * Add a ContainerAssetTask to the list of active tasks
  81964. * @param taskName defines the name of the new task
  81965. * @param meshesNames defines the name of meshes to load
  81966. * @param rootUrl defines the root url to use to locate files
  81967. * @param sceneFilename defines the filename of the scene file
  81968. * @returns a new ContainerAssetTask object
  81969. */
  81970. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  81971. /**
  81972. * Add a MeshAssetTask to the list of active tasks
  81973. * @param taskName defines the name of the new task
  81974. * @param meshesNames defines the name of meshes to load
  81975. * @param rootUrl defines the root url to use to locate files
  81976. * @param sceneFilename defines the filename of the scene file
  81977. * @returns a new MeshAssetTask object
  81978. */
  81979. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  81980. /**
  81981. * Add a TextFileAssetTask to the list of active tasks
  81982. * @param taskName defines the name of the new task
  81983. * @param url defines the url of the file to load
  81984. * @returns a new TextFileAssetTask object
  81985. */
  81986. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  81987. /**
  81988. * Add a BinaryFileAssetTask to the list of active tasks
  81989. * @param taskName defines the name of the new task
  81990. * @param url defines the url of the file to load
  81991. * @returns a new BinaryFileAssetTask object
  81992. */
  81993. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  81994. /**
  81995. * Add a ImageAssetTask to the list of active tasks
  81996. * @param taskName defines the name of the new task
  81997. * @param url defines the url of the file to load
  81998. * @returns a new ImageAssetTask object
  81999. */
  82000. addImageTask(taskName: string, url: string): ImageAssetTask;
  82001. /**
  82002. * Add a TextureAssetTask to the list of active tasks
  82003. * @param taskName defines the name of the new task
  82004. * @param url defines the url of the file to load
  82005. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82006. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  82007. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  82008. * @returns a new TextureAssetTask object
  82009. */
  82010. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  82011. /**
  82012. * Add a CubeTextureAssetTask to the list of active tasks
  82013. * @param taskName defines the name of the new task
  82014. * @param url defines the url of the file to load
  82015. * @param extensions defines the extension to use to load the cube map (can be null)
  82016. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82017. * @param files defines the list of files to load (can be null)
  82018. * @returns a new CubeTextureAssetTask object
  82019. */
  82020. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  82021. /**
  82022. *
  82023. * Add a HDRCubeTextureAssetTask to the list of active tasks
  82024. * @param taskName defines the name of the new task
  82025. * @param url defines the url of the file to load
  82026. * @param size defines the size you want for the cubemap (can be null)
  82027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82028. * @param generateHarmonics defines if you want to automatically generate (true by default)
  82029. * @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)
  82030. * @param reserved Internal use only
  82031. * @returns a new HDRCubeTextureAssetTask object
  82032. */
  82033. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  82034. /**
  82035. *
  82036. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  82037. * @param taskName defines the name of the new task
  82038. * @param url defines the url of the file to load
  82039. * @param size defines the size you want for the cubemap (can be null)
  82040. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82041. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  82042. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  82043. * @returns a new EquiRectangularCubeTextureAssetTask object
  82044. */
  82045. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  82046. /**
  82047. * Remove a task from the assets manager.
  82048. * @param task the task to remove
  82049. */
  82050. removeTask(task: AbstractAssetTask): void;
  82051. private _decreaseWaitingTasksCount;
  82052. private _runTask;
  82053. /**
  82054. * Reset the AssetsManager and remove all tasks
  82055. * @return the current instance of the AssetsManager
  82056. */
  82057. reset(): AssetsManager;
  82058. /**
  82059. * Start the loading process
  82060. * @return the current instance of the AssetsManager
  82061. */
  82062. load(): AssetsManager;
  82063. /**
  82064. * Start the loading process as an async operation
  82065. * @return a promise returning the list of failed tasks
  82066. */
  82067. loadAsync(): Promise<void>;
  82068. }
  82069. }
  82070. declare module "babylonjs/Misc/deferred" {
  82071. /**
  82072. * Wrapper class for promise with external resolve and reject.
  82073. */
  82074. export class Deferred<T> {
  82075. /**
  82076. * The promise associated with this deferred object.
  82077. */
  82078. readonly promise: Promise<T>;
  82079. private _resolve;
  82080. private _reject;
  82081. /**
  82082. * The resolve method of the promise associated with this deferred object.
  82083. */
  82084. get resolve(): (value: T | PromiseLike<T>) => void;
  82085. /**
  82086. * The reject method of the promise associated with this deferred object.
  82087. */
  82088. get reject(): (reason?: any) => void;
  82089. /**
  82090. * Constructor for this deferred object.
  82091. */
  82092. constructor();
  82093. }
  82094. }
  82095. declare module "babylonjs/Misc/meshExploder" {
  82096. import { Mesh } from "babylonjs/Meshes/mesh";
  82097. /**
  82098. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  82099. */
  82100. export class MeshExploder {
  82101. private _centerMesh;
  82102. private _meshes;
  82103. private _meshesOrigins;
  82104. private _toCenterVectors;
  82105. private _scaledDirection;
  82106. private _newPosition;
  82107. private _centerPosition;
  82108. /**
  82109. * Explodes meshes from a center mesh.
  82110. * @param meshes The meshes to explode.
  82111. * @param centerMesh The mesh to be center of explosion.
  82112. */
  82113. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  82114. private _setCenterMesh;
  82115. /**
  82116. * Get class name
  82117. * @returns "MeshExploder"
  82118. */
  82119. getClassName(): string;
  82120. /**
  82121. * "Exploded meshes"
  82122. * @returns Array of meshes with the centerMesh at index 0.
  82123. */
  82124. getMeshes(): Array<Mesh>;
  82125. /**
  82126. * Explodes meshes giving a specific direction
  82127. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  82128. */
  82129. explode(direction?: number): void;
  82130. }
  82131. }
  82132. declare module "babylonjs/Misc/filesInput" {
  82133. import { Engine } from "babylonjs/Engines/engine";
  82134. import { Scene } from "babylonjs/scene";
  82135. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  82136. import { Nullable } from "babylonjs/types";
  82137. /**
  82138. * Class used to help managing file picking and drag'n'drop
  82139. */
  82140. export class FilesInput {
  82141. /**
  82142. * List of files ready to be loaded
  82143. */
  82144. static get FilesToLoad(): {
  82145. [key: string]: File;
  82146. };
  82147. /**
  82148. * Callback called when a file is processed
  82149. */
  82150. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  82151. /**
  82152. * Function used when loading the scene file
  82153. */
  82154. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  82155. private _engine;
  82156. private _currentScene;
  82157. private _sceneLoadedCallback;
  82158. private _progressCallback;
  82159. private _additionalRenderLoopLogicCallback;
  82160. private _textureLoadingCallback;
  82161. private _startingProcessingFilesCallback;
  82162. private _onReloadCallback;
  82163. private _errorCallback;
  82164. private _elementToMonitor;
  82165. private _sceneFileToLoad;
  82166. private _filesToLoad;
  82167. /**
  82168. * Creates a new FilesInput
  82169. * @param engine defines the rendering engine
  82170. * @param scene defines the hosting scene
  82171. * @param sceneLoadedCallback callback called when scene is loaded
  82172. * @param progressCallback callback called to track progress
  82173. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  82174. * @param textureLoadingCallback callback called when a texture is loading
  82175. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  82176. * @param onReloadCallback callback called when a reload is requested
  82177. * @param errorCallback callback call if an error occurs
  82178. */
  82179. 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>);
  82180. private _dragEnterHandler;
  82181. private _dragOverHandler;
  82182. private _dropHandler;
  82183. /**
  82184. * Calls this function to listen to drag'n'drop events on a specific DOM element
  82185. * @param elementToMonitor defines the DOM element to track
  82186. */
  82187. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  82188. /** Gets the current list of files to load */
  82189. get filesToLoad(): File[];
  82190. /**
  82191. * Release all associated resources
  82192. */
  82193. dispose(): void;
  82194. private renderFunction;
  82195. private drag;
  82196. private drop;
  82197. private _traverseFolder;
  82198. private _processFiles;
  82199. /**
  82200. * Load files from a drop event
  82201. * @param event defines the drop event to use as source
  82202. */
  82203. loadFiles(event: any): void;
  82204. private _processReload;
  82205. /**
  82206. * Reload the current scene from the loaded files
  82207. */
  82208. reload(): void;
  82209. }
  82210. }
  82211. declare module "babylonjs/Misc/HighDynamicRange/index" {
  82212. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  82213. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  82214. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  82215. }
  82216. declare module "babylonjs/Misc/sceneOptimizer" {
  82217. import { Scene, IDisposable } from "babylonjs/scene";
  82218. import { Observable } from "babylonjs/Misc/observable";
  82219. /**
  82220. * Defines the root class used to create scene optimization to use with SceneOptimizer
  82221. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82222. */
  82223. export class SceneOptimization {
  82224. /**
  82225. * Defines the priority of this optimization (0 by default which means first in the list)
  82226. */
  82227. priority: number;
  82228. /**
  82229. * Gets a string describing the action executed by the current optimization
  82230. * @returns description string
  82231. */
  82232. getDescription(): string;
  82233. /**
  82234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82235. * @param scene defines the current scene where to apply this optimization
  82236. * @param optimizer defines the current optimizer
  82237. * @returns true if everything that can be done was applied
  82238. */
  82239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82240. /**
  82241. * Creates the SceneOptimization object
  82242. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82243. * @param desc defines the description associated with the optimization
  82244. */
  82245. constructor(
  82246. /**
  82247. * Defines the priority of this optimization (0 by default which means first in the list)
  82248. */
  82249. priority?: number);
  82250. }
  82251. /**
  82252. * Defines an optimization used to reduce the size of render target textures
  82253. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82254. */
  82255. export class TextureOptimization extends SceneOptimization {
  82256. /**
  82257. * Defines the priority of this optimization (0 by default which means first in the list)
  82258. */
  82259. priority: number;
  82260. /**
  82261. * 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
  82262. */
  82263. maximumSize: number;
  82264. /**
  82265. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82266. */
  82267. step: number;
  82268. /**
  82269. * Gets a string describing the action executed by the current optimization
  82270. * @returns description string
  82271. */
  82272. getDescription(): string;
  82273. /**
  82274. * Creates the TextureOptimization object
  82275. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82276. * @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
  82277. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82278. */
  82279. constructor(
  82280. /**
  82281. * Defines the priority of this optimization (0 by default which means first in the list)
  82282. */
  82283. priority?: number,
  82284. /**
  82285. * 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
  82286. */
  82287. maximumSize?: number,
  82288. /**
  82289. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82290. */
  82291. step?: number);
  82292. /**
  82293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82294. * @param scene defines the current scene where to apply this optimization
  82295. * @param optimizer defines the current optimizer
  82296. * @returns true if everything that can be done was applied
  82297. */
  82298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82299. }
  82300. /**
  82301. * Defines an optimization used to increase or decrease the rendering resolution
  82302. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82303. */
  82304. export class HardwareScalingOptimization extends SceneOptimization {
  82305. /**
  82306. * Defines the priority of this optimization (0 by default which means first in the list)
  82307. */
  82308. priority: number;
  82309. /**
  82310. * Defines the maximum scale to use (2 by default)
  82311. */
  82312. maximumScale: number;
  82313. /**
  82314. * Defines the step to use between two passes (0.5 by default)
  82315. */
  82316. step: number;
  82317. private _currentScale;
  82318. private _directionOffset;
  82319. /**
  82320. * Gets a string describing the action executed by the current optimization
  82321. * @return description string
  82322. */
  82323. getDescription(): string;
  82324. /**
  82325. * Creates the HardwareScalingOptimization object
  82326. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82327. * @param maximumScale defines the maximum scale to use (2 by default)
  82328. * @param step defines the step to use between two passes (0.5 by default)
  82329. */
  82330. constructor(
  82331. /**
  82332. * Defines the priority of this optimization (0 by default which means first in the list)
  82333. */
  82334. priority?: number,
  82335. /**
  82336. * Defines the maximum scale to use (2 by default)
  82337. */
  82338. maximumScale?: number,
  82339. /**
  82340. * Defines the step to use between two passes (0.5 by default)
  82341. */
  82342. step?: number);
  82343. /**
  82344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82345. * @param scene defines the current scene where to apply this optimization
  82346. * @param optimizer defines the current optimizer
  82347. * @returns true if everything that can be done was applied
  82348. */
  82349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82350. }
  82351. /**
  82352. * Defines an optimization used to remove shadows
  82353. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82354. */
  82355. export class ShadowsOptimization extends SceneOptimization {
  82356. /**
  82357. * Gets a string describing the action executed by the current optimization
  82358. * @return description string
  82359. */
  82360. getDescription(): string;
  82361. /**
  82362. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82363. * @param scene defines the current scene where to apply this optimization
  82364. * @param optimizer defines the current optimizer
  82365. * @returns true if everything that can be done was applied
  82366. */
  82367. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82368. }
  82369. /**
  82370. * Defines an optimization used to turn post-processes off
  82371. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82372. */
  82373. export class PostProcessesOptimization extends SceneOptimization {
  82374. /**
  82375. * Gets a string describing the action executed by the current optimization
  82376. * @return description string
  82377. */
  82378. getDescription(): string;
  82379. /**
  82380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82381. * @param scene defines the current scene where to apply this optimization
  82382. * @param optimizer defines the current optimizer
  82383. * @returns true if everything that can be done was applied
  82384. */
  82385. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82386. }
  82387. /**
  82388. * Defines an optimization used to turn lens flares off
  82389. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82390. */
  82391. export class LensFlaresOptimization extends SceneOptimization {
  82392. /**
  82393. * Gets a string describing the action executed by the current optimization
  82394. * @return description string
  82395. */
  82396. getDescription(): string;
  82397. /**
  82398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82399. * @param scene defines the current scene where to apply this optimization
  82400. * @param optimizer defines the current optimizer
  82401. * @returns true if everything that can be done was applied
  82402. */
  82403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82404. }
  82405. /**
  82406. * Defines an optimization based on user defined callback.
  82407. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82408. */
  82409. export class CustomOptimization extends SceneOptimization {
  82410. /**
  82411. * Callback called to apply the custom optimization.
  82412. */
  82413. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  82414. /**
  82415. * Callback called to get custom description
  82416. */
  82417. onGetDescription: () => string;
  82418. /**
  82419. * Gets a string describing the action executed by the current optimization
  82420. * @returns description string
  82421. */
  82422. getDescription(): string;
  82423. /**
  82424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82425. * @param scene defines the current scene where to apply this optimization
  82426. * @param optimizer defines the current optimizer
  82427. * @returns true if everything that can be done was applied
  82428. */
  82429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82430. }
  82431. /**
  82432. * Defines an optimization used to turn particles off
  82433. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82434. */
  82435. export class ParticlesOptimization extends SceneOptimization {
  82436. /**
  82437. * Gets a string describing the action executed by the current optimization
  82438. * @return description string
  82439. */
  82440. getDescription(): string;
  82441. /**
  82442. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82443. * @param scene defines the current scene where to apply this optimization
  82444. * @param optimizer defines the current optimizer
  82445. * @returns true if everything that can be done was applied
  82446. */
  82447. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82448. }
  82449. /**
  82450. * Defines an optimization used to turn render targets off
  82451. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82452. */
  82453. export class RenderTargetsOptimization extends SceneOptimization {
  82454. /**
  82455. * Gets a string describing the action executed by the current optimization
  82456. * @return description string
  82457. */
  82458. getDescription(): string;
  82459. /**
  82460. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82461. * @param scene defines the current scene where to apply this optimization
  82462. * @param optimizer defines the current optimizer
  82463. * @returns true if everything that can be done was applied
  82464. */
  82465. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82466. }
  82467. /**
  82468. * Defines an optimization used to merge meshes with compatible materials
  82469. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82470. */
  82471. export class MergeMeshesOptimization extends SceneOptimization {
  82472. private static _UpdateSelectionTree;
  82473. /**
  82474. * Gets or sets a boolean which defines if optimization octree has to be updated
  82475. */
  82476. static get UpdateSelectionTree(): boolean;
  82477. /**
  82478. * Gets or sets a boolean which defines if optimization octree has to be updated
  82479. */
  82480. static set UpdateSelectionTree(value: boolean);
  82481. /**
  82482. * Gets a string describing the action executed by the current optimization
  82483. * @return description string
  82484. */
  82485. getDescription(): string;
  82486. private _canBeMerged;
  82487. /**
  82488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82489. * @param scene defines the current scene where to apply this optimization
  82490. * @param optimizer defines the current optimizer
  82491. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  82492. * @returns true if everything that can be done was applied
  82493. */
  82494. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  82495. }
  82496. /**
  82497. * Defines a list of options used by SceneOptimizer
  82498. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82499. */
  82500. export class SceneOptimizerOptions {
  82501. /**
  82502. * Defines the target frame rate to reach (60 by default)
  82503. */
  82504. targetFrameRate: number;
  82505. /**
  82506. * Defines the interval between two checkes (2000ms by default)
  82507. */
  82508. trackerDuration: number;
  82509. /**
  82510. * Gets the list of optimizations to apply
  82511. */
  82512. optimizations: SceneOptimization[];
  82513. /**
  82514. * Creates a new list of options used by SceneOptimizer
  82515. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  82516. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  82517. */
  82518. constructor(
  82519. /**
  82520. * Defines the target frame rate to reach (60 by default)
  82521. */
  82522. targetFrameRate?: number,
  82523. /**
  82524. * Defines the interval between two checkes (2000ms by default)
  82525. */
  82526. trackerDuration?: number);
  82527. /**
  82528. * Add a new optimization
  82529. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  82530. * @returns the current SceneOptimizerOptions
  82531. */
  82532. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  82533. /**
  82534. * Add a new custom optimization
  82535. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  82536. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  82537. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82538. * @returns the current SceneOptimizerOptions
  82539. */
  82540. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  82541. /**
  82542. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  82543. * @param targetFrameRate defines the target frame rate (60 by default)
  82544. * @returns a SceneOptimizerOptions object
  82545. */
  82546. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82547. /**
  82548. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  82549. * @param targetFrameRate defines the target frame rate (60 by default)
  82550. * @returns a SceneOptimizerOptions object
  82551. */
  82552. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82553. /**
  82554. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  82555. * @param targetFrameRate defines the target frame rate (60 by default)
  82556. * @returns a SceneOptimizerOptions object
  82557. */
  82558. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82559. }
  82560. /**
  82561. * Class used to run optimizations in order to reach a target frame rate
  82562. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82563. */
  82564. export class SceneOptimizer implements IDisposable {
  82565. private _isRunning;
  82566. private _options;
  82567. private _scene;
  82568. private _currentPriorityLevel;
  82569. private _targetFrameRate;
  82570. private _trackerDuration;
  82571. private _currentFrameRate;
  82572. private _sceneDisposeObserver;
  82573. private _improvementMode;
  82574. /**
  82575. * Defines an observable called when the optimizer reaches the target frame rate
  82576. */
  82577. onSuccessObservable: Observable<SceneOptimizer>;
  82578. /**
  82579. * Defines an observable called when the optimizer enables an optimization
  82580. */
  82581. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  82582. /**
  82583. * Defines an observable called when the optimizer is not able to reach the target frame rate
  82584. */
  82585. onFailureObservable: Observable<SceneOptimizer>;
  82586. /**
  82587. * Gets a boolean indicating if the optimizer is in improvement mode
  82588. */
  82589. get isInImprovementMode(): boolean;
  82590. /**
  82591. * Gets the current priority level (0 at start)
  82592. */
  82593. get currentPriorityLevel(): number;
  82594. /**
  82595. * Gets the current frame rate checked by the SceneOptimizer
  82596. */
  82597. get currentFrameRate(): number;
  82598. /**
  82599. * Gets or sets the current target frame rate (60 by default)
  82600. */
  82601. get targetFrameRate(): number;
  82602. /**
  82603. * Gets or sets the current target frame rate (60 by default)
  82604. */
  82605. set targetFrameRate(value: number);
  82606. /**
  82607. * Gets or sets the current interval between two checks (every 2000ms by default)
  82608. */
  82609. get trackerDuration(): number;
  82610. /**
  82611. * Gets or sets the current interval between two checks (every 2000ms by default)
  82612. */
  82613. set trackerDuration(value: number);
  82614. /**
  82615. * Gets the list of active optimizations
  82616. */
  82617. get optimizations(): SceneOptimization[];
  82618. /**
  82619. * Creates a new SceneOptimizer
  82620. * @param scene defines the scene to work on
  82621. * @param options defines the options to use with the SceneOptimizer
  82622. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  82623. * @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)
  82624. */
  82625. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  82626. /**
  82627. * Stops the current optimizer
  82628. */
  82629. stop(): void;
  82630. /**
  82631. * Reset the optimizer to initial step (current priority level = 0)
  82632. */
  82633. reset(): void;
  82634. /**
  82635. * Start the optimizer. By default it will try to reach a specific framerate
  82636. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  82637. */
  82638. start(): void;
  82639. private _checkCurrentState;
  82640. /**
  82641. * Release all resources
  82642. */
  82643. dispose(): void;
  82644. /**
  82645. * Helper function to create a SceneOptimizer with one single line of code
  82646. * @param scene defines the scene to work on
  82647. * @param options defines the options to use with the SceneOptimizer
  82648. * @param onSuccess defines a callback to call on success
  82649. * @param onFailure defines a callback to call on failure
  82650. * @returns the new SceneOptimizer object
  82651. */
  82652. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  82653. }
  82654. }
  82655. declare module "babylonjs/Misc/sceneSerializer" {
  82656. import { Scene } from "babylonjs/scene";
  82657. /**
  82658. * Class used to serialize a scene into a string
  82659. */
  82660. export class SceneSerializer {
  82661. /**
  82662. * Clear cache used by a previous serialization
  82663. */
  82664. static ClearCache(): void;
  82665. /**
  82666. * Serialize a scene into a JSON compatible object
  82667. * @param scene defines the scene to serialize
  82668. * @returns a JSON compatible object
  82669. */
  82670. static Serialize(scene: Scene): any;
  82671. /**
  82672. * Serialize a mesh into a JSON compatible object
  82673. * @param toSerialize defines the mesh to serialize
  82674. * @param withParents defines if parents must be serialized as well
  82675. * @param withChildren defines if children must be serialized as well
  82676. * @returns a JSON compatible object
  82677. */
  82678. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  82679. }
  82680. }
  82681. declare module "babylonjs/Misc/videoRecorder" {
  82682. import { Nullable } from "babylonjs/types";
  82683. import { Engine } from "babylonjs/Engines/engine";
  82684. /**
  82685. * This represents the different options available for the video capture.
  82686. */
  82687. export interface VideoRecorderOptions {
  82688. /** Defines the mime type of the video. */
  82689. mimeType: string;
  82690. /** Defines the FPS the video should be recorded at. */
  82691. fps: number;
  82692. /** Defines the chunk size for the recording data. */
  82693. recordChunckSize: number;
  82694. /** The audio tracks to attach to the recording. */
  82695. audioTracks?: MediaStreamTrack[];
  82696. }
  82697. /**
  82698. * This can help with recording videos from BabylonJS.
  82699. * This is based on the available WebRTC functionalities of the browser.
  82700. *
  82701. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  82702. */
  82703. export class VideoRecorder {
  82704. private static readonly _defaultOptions;
  82705. /**
  82706. * Returns whether or not the VideoRecorder is available in your browser.
  82707. * @param engine Defines the Babylon Engine.
  82708. * @returns true if supported otherwise false.
  82709. */
  82710. static IsSupported(engine: Engine): boolean;
  82711. private readonly _options;
  82712. private _canvas;
  82713. private _mediaRecorder;
  82714. private _recordedChunks;
  82715. private _fileName;
  82716. private _resolve;
  82717. private _reject;
  82718. /**
  82719. * True when a recording is already in progress.
  82720. */
  82721. get isRecording(): boolean;
  82722. /**
  82723. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  82724. * @param engine Defines the BabylonJS Engine you wish to record.
  82725. * @param options Defines options that can be used to customize the capture.
  82726. */
  82727. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  82728. /**
  82729. * Stops the current recording before the default capture timeout passed in the startRecording function.
  82730. */
  82731. stopRecording(): void;
  82732. /**
  82733. * Starts recording the canvas for a max duration specified in parameters.
  82734. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  82735. * If null no automatic download will start and you can rely on the promise to get the data back.
  82736. * @param maxDuration Defines the maximum recording time in seconds.
  82737. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  82738. * @return A promise callback at the end of the recording with the video data in Blob.
  82739. */
  82740. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  82741. /**
  82742. * Releases internal resources used during the recording.
  82743. */
  82744. dispose(): void;
  82745. private _handleDataAvailable;
  82746. private _handleError;
  82747. private _handleStop;
  82748. }
  82749. }
  82750. declare module "babylonjs/Misc/screenshotTools" {
  82751. import { Camera } from "babylonjs/Cameras/camera";
  82752. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  82753. import { Engine } from "babylonjs/Engines/engine";
  82754. /**
  82755. * Class containing a set of static utilities functions for screenshots
  82756. */
  82757. export class ScreenshotTools {
  82758. /**
  82759. * Captures a screenshot of the current rendering
  82760. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82761. * @param engine defines the rendering engine
  82762. * @param camera defines the source camera
  82763. * @param size This parameter can be set to a single number or to an object with the
  82764. * following (optional) properties: precision, width, height. If a single number is passed,
  82765. * it will be used for both width and height. If an object is passed, the screenshot size
  82766. * will be derived from the parameters. The precision property is a multiplier allowing
  82767. * rendering at a higher or lower resolution
  82768. * @param successCallback defines the callback receives a single parameter which contains the
  82769. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82770. * src parameter of an <img> to display it
  82771. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82772. * Check your browser for supported MIME types
  82773. * @param forceDownload force the system to download the image even if a successCallback is provided
  82774. */
  82775. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  82776. /**
  82777. * Captures a screenshot of the current rendering
  82778. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82779. * @param engine defines the rendering engine
  82780. * @param camera defines the source camera
  82781. * @param size This parameter can be set to a single number or to an object with the
  82782. * following (optional) properties: precision, width, height. If a single number is passed,
  82783. * it will be used for both width and height. If an object is passed, the screenshot size
  82784. * will be derived from the parameters. The precision property is a multiplier allowing
  82785. * rendering at a higher or lower resolution
  82786. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82787. * Check your browser for supported MIME types
  82788. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82789. * to the src parameter of an <img> to display it
  82790. */
  82791. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  82792. /**
  82793. * 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)
  82794. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82795. * @param engine defines the rendering engine
  82796. * @param camera defines the source camera
  82797. * @param width defines the expected width
  82798. * @param height defines the expected height
  82799. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82800. * Check your browser for supported MIME types
  82801. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82802. * to the src parameter of an <img> to display it
  82803. */
  82804. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  82805. /**
  82806. * Generates an image screenshot from the specified camera.
  82807. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82808. * @param engine The engine to use for rendering
  82809. * @param camera The camera to use for rendering
  82810. * @param size This parameter can be set to a single number or to an object with the
  82811. * following (optional) properties: precision, width, height. If a single number is passed,
  82812. * it will be used for both width and height. If an object is passed, the screenshot size
  82813. * will be derived from the parameters. The precision property is a multiplier allowing
  82814. * rendering at a higher or lower resolution
  82815. * @param successCallback The callback receives a single parameter which contains the
  82816. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82817. * src parameter of an <img> to display it
  82818. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82819. * Check your browser for supported MIME types
  82820. * @param samples Texture samples (default: 1)
  82821. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82822. * @param fileName A name for for the downloaded file.
  82823. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82824. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  82825. */
  82826. 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;
  82827. /**
  82828. * Generates an image screenshot from the specified camera.
  82829. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82830. * @param engine The engine to use for rendering
  82831. * @param camera The camera to use for rendering
  82832. * @param size This parameter can be set to a single number or to an object with the
  82833. * following (optional) properties: precision, width, height. If a single number is passed,
  82834. * it will be used for both width and height. If an object is passed, the screenshot size
  82835. * will be derived from the parameters. The precision property is a multiplier allowing
  82836. * rendering at a higher or lower resolution
  82837. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82838. * Check your browser for supported MIME types
  82839. * @param samples Texture samples (default: 1)
  82840. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82841. * @param fileName A name for for the downloaded file.
  82842. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82843. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82844. * to the src parameter of an <img> to display it
  82845. */
  82846. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  82847. /**
  82848. * Gets height and width for screenshot size
  82849. * @private
  82850. */
  82851. private static _getScreenshotSize;
  82852. }
  82853. }
  82854. declare module "babylonjs/Misc/dataReader" {
  82855. /**
  82856. * Interface for a data buffer
  82857. */
  82858. export interface IDataBuffer {
  82859. /**
  82860. * Reads bytes from the data buffer.
  82861. * @param byteOffset The byte offset to read
  82862. * @param byteLength The byte length to read
  82863. * @returns A promise that resolves when the bytes are read
  82864. */
  82865. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  82866. /**
  82867. * The byte length of the buffer.
  82868. */
  82869. readonly byteLength: number;
  82870. }
  82871. /**
  82872. * Utility class for reading from a data buffer
  82873. */
  82874. export class DataReader {
  82875. /**
  82876. * The data buffer associated with this data reader.
  82877. */
  82878. readonly buffer: IDataBuffer;
  82879. /**
  82880. * The current byte offset from the beginning of the data buffer.
  82881. */
  82882. byteOffset: number;
  82883. private _dataView;
  82884. private _dataByteOffset;
  82885. /**
  82886. * Constructor
  82887. * @param buffer The buffer to read
  82888. */
  82889. constructor(buffer: IDataBuffer);
  82890. /**
  82891. * Loads the given byte length.
  82892. * @param byteLength The byte length to load
  82893. * @returns A promise that resolves when the load is complete
  82894. */
  82895. loadAsync(byteLength: number): Promise<void>;
  82896. /**
  82897. * Read a unsigned 32-bit integer from the currently loaded data range.
  82898. * @returns The 32-bit integer read
  82899. */
  82900. readUint32(): number;
  82901. /**
  82902. * Read a byte array from the currently loaded data range.
  82903. * @param byteLength The byte length to read
  82904. * @returns The byte array read
  82905. */
  82906. readUint8Array(byteLength: number): Uint8Array;
  82907. /**
  82908. * Read a string from the currently loaded data range.
  82909. * @param byteLength The byte length to read
  82910. * @returns The string read
  82911. */
  82912. readString(byteLength: number): string;
  82913. /**
  82914. * Skips the given byte length the currently loaded data range.
  82915. * @param byteLength The byte length to skip
  82916. */
  82917. skipBytes(byteLength: number): void;
  82918. }
  82919. }
  82920. declare module "babylonjs/Misc/dataStorage" {
  82921. /**
  82922. * Class for storing data to local storage if available or in-memory storage otherwise
  82923. */
  82924. export class DataStorage {
  82925. private static _Storage;
  82926. private static _GetStorage;
  82927. /**
  82928. * Reads a string from the data storage
  82929. * @param key The key to read
  82930. * @param defaultValue The value if the key doesn't exist
  82931. * @returns The string value
  82932. */
  82933. static ReadString(key: string, defaultValue: string): string;
  82934. /**
  82935. * Writes a string to the data storage
  82936. * @param key The key to write
  82937. * @param value The value to write
  82938. */
  82939. static WriteString(key: string, value: string): void;
  82940. /**
  82941. * Reads a boolean from the data storage
  82942. * @param key The key to read
  82943. * @param defaultValue The value if the key doesn't exist
  82944. * @returns The boolean value
  82945. */
  82946. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  82947. /**
  82948. * Writes a boolean to the data storage
  82949. * @param key The key to write
  82950. * @param value The value to write
  82951. */
  82952. static WriteBoolean(key: string, value: boolean): void;
  82953. /**
  82954. * Reads a number from the data storage
  82955. * @param key The key to read
  82956. * @param defaultValue The value if the key doesn't exist
  82957. * @returns The number value
  82958. */
  82959. static ReadNumber(key: string, defaultValue: number): number;
  82960. /**
  82961. * Writes a number to the data storage
  82962. * @param key The key to write
  82963. * @param value The value to write
  82964. */
  82965. static WriteNumber(key: string, value: number): void;
  82966. }
  82967. }
  82968. declare module "babylonjs/Misc/sceneRecorder" {
  82969. import { Scene } from "babylonjs/scene";
  82970. /**
  82971. * Class used to record delta files between 2 scene states
  82972. */
  82973. export class SceneRecorder {
  82974. private _trackedScene;
  82975. private _savedJSON;
  82976. /**
  82977. * Track a given scene. This means the current scene state will be considered the original state
  82978. * @param scene defines the scene to track
  82979. */
  82980. track(scene: Scene): void;
  82981. /**
  82982. * Get the delta between current state and original state
  82983. * @returns a string containing the delta
  82984. */
  82985. getDelta(): any;
  82986. private _compareArray;
  82987. private _compareObjects;
  82988. private _compareCollections;
  82989. private static GetShadowGeneratorById;
  82990. /**
  82991. * Apply a given delta to a given scene
  82992. * @param deltaJSON defines the JSON containing the delta
  82993. * @param scene defines the scene to apply the delta to
  82994. */
  82995. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  82996. private static _ApplyPropertiesToEntity;
  82997. private static _ApplyDeltaForEntity;
  82998. }
  82999. }
  83000. declare module "babylonjs/Misc/trajectoryClassifier" {
  83001. import { DeepImmutable, Nullable } from "babylonjs/types";
  83002. import { Vector3 } from "babylonjs/Maths/math.vector";
  83003. /**
  83004. * A 3D trajectory consisting of an order list of vectors describing a
  83005. * path of motion through 3D space.
  83006. */
  83007. export class Trajectory {
  83008. private _points;
  83009. private readonly _segmentLength;
  83010. /**
  83011. * Serialize to JSON.
  83012. * @returns serialized JSON string
  83013. */
  83014. serialize(): string;
  83015. /**
  83016. * Deserialize from JSON.
  83017. * @param json serialized JSON string
  83018. * @returns deserialized Trajectory
  83019. */
  83020. static Deserialize(json: string): Trajectory;
  83021. /**
  83022. * Create a new empty Trajectory.
  83023. * @param segmentLength radius of discretization for Trajectory points
  83024. */
  83025. constructor(segmentLength?: number);
  83026. /**
  83027. * Get the length of the Trajectory.
  83028. * @returns length of the Trajectory
  83029. */
  83030. getLength(): number;
  83031. /**
  83032. * Append a new point to the Trajectory.
  83033. * NOTE: This implementation has many allocations.
  83034. * @param point point to append to the Trajectory
  83035. */
  83036. add(point: DeepImmutable<Vector3>): void;
  83037. /**
  83038. * Create a new Trajectory with a segment length chosen to make it
  83039. * probable that the new Trajectory will have a specified number of
  83040. * segments. This operation is imprecise.
  83041. * @param targetResolution number of segments desired
  83042. * @returns new Trajectory with approximately the requested number of segments
  83043. */
  83044. resampleAtTargetResolution(targetResolution: number): Trajectory;
  83045. /**
  83046. * Convert Trajectory segments into tokenized representation. This
  83047. * representation is an array of numbers where each nth number is the
  83048. * index of the token which is most similar to the nth segment of the
  83049. * Trajectory.
  83050. * @param tokens list of vectors which serve as discrete tokens
  83051. * @returns list of indices of most similar token per segment
  83052. */
  83053. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  83054. private static _forwardDir;
  83055. private static _inverseFromVec;
  83056. private static _upDir;
  83057. private static _fromToVec;
  83058. private static _lookMatrix;
  83059. /**
  83060. * Transform the rotation (i.e., direction) of a segment to isolate
  83061. * the relative transformation represented by the segment. This operation
  83062. * may or may not succeed due to singularities in the equations that define
  83063. * motion relativity in this context.
  83064. * @param priorVec the origin of the prior segment
  83065. * @param fromVec the origin of the current segment
  83066. * @param toVec the destination of the current segment
  83067. * @param result reference to output variable
  83068. * @returns whether or not transformation was successful
  83069. */
  83070. private static _transformSegmentDirToRef;
  83071. private static _bestMatch;
  83072. private static _score;
  83073. private static _bestScore;
  83074. /**
  83075. * Determine which token vector is most similar to the
  83076. * segment vector.
  83077. * @param segment segment vector
  83078. * @param tokens token vector list
  83079. * @returns index of the most similar token to the segment
  83080. */
  83081. private static _tokenizeSegment;
  83082. }
  83083. /**
  83084. * Class representing a set of known, named trajectories to which Trajectories can be
  83085. * added and using which Trajectories can be recognized.
  83086. */
  83087. export class TrajectoryClassifier {
  83088. private _maximumAllowableMatchCost;
  83089. private _vector3Alphabet;
  83090. private _levenshteinAlphabet;
  83091. private _nameToDescribedTrajectory;
  83092. /**
  83093. * Serialize to JSON.
  83094. * @returns JSON serialization
  83095. */
  83096. serialize(): string;
  83097. /**
  83098. * Deserialize from JSON.
  83099. * @param json JSON serialization
  83100. * @returns deserialized TrajectorySet
  83101. */
  83102. static Deserialize(json: string): TrajectoryClassifier;
  83103. /**
  83104. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  83105. * VERY naive, need to be generating these things from known
  83106. * sets. Better version later, probably eliminating this one.
  83107. * @returns auto-generated TrajectorySet
  83108. */
  83109. static Generate(): TrajectoryClassifier;
  83110. private constructor();
  83111. /**
  83112. * Add a new Trajectory to the set with a given name.
  83113. * @param trajectory new Trajectory to be added
  83114. * @param classification name to which to add the Trajectory
  83115. */
  83116. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  83117. /**
  83118. * Remove a known named trajectory and all Trajectories associated with it.
  83119. * @param classification name to remove
  83120. * @returns whether anything was removed
  83121. */
  83122. deleteClassification(classification: string): boolean;
  83123. /**
  83124. * Attempt to recognize a Trajectory from among all the classifications
  83125. * already known to the classifier.
  83126. * @param trajectory Trajectory to be recognized
  83127. * @returns classification of Trajectory if recognized, null otherwise
  83128. */
  83129. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  83130. }
  83131. }
  83132. declare module "babylonjs/Misc/index" {
  83133. export * from "babylonjs/Misc/andOrNotEvaluator";
  83134. export * from "babylonjs/Misc/assetsManager";
  83135. export * from "babylonjs/Misc/basis";
  83136. export * from "babylonjs/Misc/dds";
  83137. export * from "babylonjs/Misc/decorators";
  83138. export * from "babylonjs/Misc/deferred";
  83139. export * from "babylonjs/Misc/environmentTextureTools";
  83140. export * from "babylonjs/Misc/meshExploder";
  83141. export * from "babylonjs/Misc/filesInput";
  83142. export * from "babylonjs/Misc/HighDynamicRange/index";
  83143. export * from "babylonjs/Misc/khronosTextureContainer";
  83144. export * from "babylonjs/Misc/observable";
  83145. export * from "babylonjs/Misc/performanceMonitor";
  83146. export * from "babylonjs/Misc/promise";
  83147. export * from "babylonjs/Misc/sceneOptimizer";
  83148. export * from "babylonjs/Misc/sceneSerializer";
  83149. export * from "babylonjs/Misc/smartArray";
  83150. export * from "babylonjs/Misc/stringDictionary";
  83151. export * from "babylonjs/Misc/tags";
  83152. export * from "babylonjs/Misc/textureTools";
  83153. export * from "babylonjs/Misc/tga";
  83154. export * from "babylonjs/Misc/tools";
  83155. export * from "babylonjs/Misc/videoRecorder";
  83156. export * from "babylonjs/Misc/virtualJoystick";
  83157. export * from "babylonjs/Misc/workerPool";
  83158. export * from "babylonjs/Misc/logger";
  83159. export * from "babylonjs/Misc/typeStore";
  83160. export * from "babylonjs/Misc/filesInputStore";
  83161. export * from "babylonjs/Misc/deepCopier";
  83162. export * from "babylonjs/Misc/pivotTools";
  83163. export * from "babylonjs/Misc/precisionDate";
  83164. export * from "babylonjs/Misc/screenshotTools";
  83165. export * from "babylonjs/Misc/typeStore";
  83166. export * from "babylonjs/Misc/webRequest";
  83167. export * from "babylonjs/Misc/iInspectable";
  83168. export * from "babylonjs/Misc/brdfTextureTools";
  83169. export * from "babylonjs/Misc/rgbdTextureTools";
  83170. export * from "babylonjs/Misc/gradients";
  83171. export * from "babylonjs/Misc/perfCounter";
  83172. export * from "babylonjs/Misc/fileRequest";
  83173. export * from "babylonjs/Misc/customAnimationFrameRequester";
  83174. export * from "babylonjs/Misc/retryStrategy";
  83175. export * from "babylonjs/Misc/interfaces/screenshotSize";
  83176. export * from "babylonjs/Misc/canvasGenerator";
  83177. export * from "babylonjs/Misc/fileTools";
  83178. export * from "babylonjs/Misc/stringTools";
  83179. export * from "babylonjs/Misc/dataReader";
  83180. export * from "babylonjs/Misc/minMaxReducer";
  83181. export * from "babylonjs/Misc/depthReducer";
  83182. export * from "babylonjs/Misc/dataStorage";
  83183. export * from "babylonjs/Misc/sceneRecorder";
  83184. export * from "babylonjs/Misc/khronosTextureContainer2";
  83185. export * from "babylonjs/Misc/trajectoryClassifier";
  83186. export * from "babylonjs/Misc/timer";
  83187. export * from "babylonjs/Misc/copyTools";
  83188. }
  83189. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  83190. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  83191. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83192. import { Observable } from "babylonjs/Misc/observable";
  83193. import { Matrix } from "babylonjs/Maths/math.vector";
  83194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83195. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83196. /**
  83197. * An interface for all Hit test features
  83198. */
  83199. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  83200. /**
  83201. * Triggered when new babylon (transformed) hit test results are available
  83202. */
  83203. onHitTestResultObservable: Observable<T[]>;
  83204. }
  83205. /**
  83206. * Options used for hit testing
  83207. */
  83208. export interface IWebXRLegacyHitTestOptions {
  83209. /**
  83210. * Only test when user interacted with the scene. Default - hit test every frame
  83211. */
  83212. testOnPointerDownOnly?: boolean;
  83213. /**
  83214. * The node to use to transform the local results to world coordinates
  83215. */
  83216. worldParentNode?: TransformNode;
  83217. }
  83218. /**
  83219. * Interface defining the babylon result of raycasting/hit-test
  83220. */
  83221. export interface IWebXRLegacyHitResult {
  83222. /**
  83223. * Transformation matrix that can be applied to a node that will put it in the hit point location
  83224. */
  83225. transformationMatrix: Matrix;
  83226. /**
  83227. * The native hit test result
  83228. */
  83229. xrHitResult: XRHitResult | XRHitTestResult;
  83230. }
  83231. /**
  83232. * The currently-working hit-test module.
  83233. * Hit test (or Ray-casting) is used to interact with the real world.
  83234. * For further information read here - https://github.com/immersive-web/hit-test
  83235. */
  83236. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  83237. /**
  83238. * options to use when constructing this feature
  83239. */
  83240. readonly options: IWebXRLegacyHitTestOptions;
  83241. private _direction;
  83242. private _mat;
  83243. private _onSelectEnabled;
  83244. private _origin;
  83245. /**
  83246. * The module's name
  83247. */
  83248. static readonly Name: string;
  83249. /**
  83250. * The (Babylon) version of this module.
  83251. * This is an integer representing the implementation version.
  83252. * This number does not correspond to the WebXR specs version
  83253. */
  83254. static readonly Version: number;
  83255. /**
  83256. * Populated with the last native XR Hit Results
  83257. */
  83258. lastNativeXRHitResults: XRHitResult[];
  83259. /**
  83260. * Triggered when new babylon (transformed) hit test results are available
  83261. */
  83262. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  83263. /**
  83264. * Creates a new instance of the (legacy version) hit test feature
  83265. * @param _xrSessionManager an instance of WebXRSessionManager
  83266. * @param options options to use when constructing this feature
  83267. */
  83268. constructor(_xrSessionManager: WebXRSessionManager,
  83269. /**
  83270. * options to use when constructing this feature
  83271. */
  83272. options?: IWebXRLegacyHitTestOptions);
  83273. /**
  83274. * execute a hit test with an XR Ray
  83275. *
  83276. * @param xrSession a native xrSession that will execute this hit test
  83277. * @param xrRay the ray (position and direction) to use for ray-casting
  83278. * @param referenceSpace native XR reference space to use for the hit-test
  83279. * @param filter filter function that will filter the results
  83280. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83281. */
  83282. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  83283. /**
  83284. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  83285. * @param event the (select) event to use to select with
  83286. * @param referenceSpace the reference space to use for this hit test
  83287. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83288. */
  83289. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  83290. /**
  83291. * attach this feature
  83292. * Will usually be called by the features manager
  83293. *
  83294. * @returns true if successful.
  83295. */
  83296. attach(): boolean;
  83297. /**
  83298. * detach this feature.
  83299. * Will usually be called by the features manager
  83300. *
  83301. * @returns true if successful.
  83302. */
  83303. detach(): boolean;
  83304. /**
  83305. * Dispose this feature and all of the resources attached
  83306. */
  83307. dispose(): void;
  83308. protected _onXRFrame(frame: XRFrame): void;
  83309. private _onHitTestResults;
  83310. private _onSelect;
  83311. }
  83312. }
  83313. declare module "babylonjs/XR/features/WebXRHitTest" {
  83314. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83315. import { Observable } from "babylonjs/Misc/observable";
  83316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83317. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83318. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  83319. /**
  83320. * Options used for hit testing (version 2)
  83321. */
  83322. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  83323. /**
  83324. * Do not create a permanent hit test. Will usually be used when only
  83325. * transient inputs are needed.
  83326. */
  83327. disablePermanentHitTest?: boolean;
  83328. /**
  83329. * Enable transient (for example touch-based) hit test inspections
  83330. */
  83331. enableTransientHitTest?: boolean;
  83332. /**
  83333. * Offset ray for the permanent hit test
  83334. */
  83335. offsetRay?: Vector3;
  83336. /**
  83337. * Offset ray for the transient hit test
  83338. */
  83339. transientOffsetRay?: Vector3;
  83340. /**
  83341. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  83342. */
  83343. useReferenceSpace?: boolean;
  83344. /**
  83345. * Override the default entity type(s) of the hit-test result
  83346. */
  83347. entityTypes?: XRHitTestTrackableType[];
  83348. }
  83349. /**
  83350. * Interface defining the babylon result of hit-test
  83351. */
  83352. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  83353. /**
  83354. * The input source that generated this hit test (if transient)
  83355. */
  83356. inputSource?: XRInputSource;
  83357. /**
  83358. * Is this a transient hit test
  83359. */
  83360. isTransient?: boolean;
  83361. /**
  83362. * Position of the hit test result
  83363. */
  83364. position: Vector3;
  83365. /**
  83366. * Rotation of the hit test result
  83367. */
  83368. rotationQuaternion: Quaternion;
  83369. /**
  83370. * The native hit test result
  83371. */
  83372. xrHitResult: XRHitTestResult;
  83373. }
  83374. /**
  83375. * The currently-working hit-test module.
  83376. * Hit test (or Ray-casting) is used to interact with the real world.
  83377. * For further information read here - https://github.com/immersive-web/hit-test
  83378. *
  83379. * Tested on chrome (mobile) 80.
  83380. */
  83381. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  83382. /**
  83383. * options to use when constructing this feature
  83384. */
  83385. readonly options: IWebXRHitTestOptions;
  83386. private _tmpMat;
  83387. private _tmpPos;
  83388. private _tmpQuat;
  83389. private _transientXrHitTestSource;
  83390. private _xrHitTestSource;
  83391. private initHitTestSource;
  83392. /**
  83393. * The module's name
  83394. */
  83395. static readonly Name: string;
  83396. /**
  83397. * The (Babylon) version of this module.
  83398. * This is an integer representing the implementation version.
  83399. * This number does not correspond to the WebXR specs version
  83400. */
  83401. static readonly Version: number;
  83402. /**
  83403. * When set to true, each hit test will have its own position/rotation objects
  83404. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  83405. * the developers will clone them or copy them as they see fit.
  83406. */
  83407. autoCloneTransformation: boolean;
  83408. /**
  83409. * Triggered when new babylon (transformed) hit test results are available
  83410. * Note - this will be called when results come back from the device. It can be an empty array!!
  83411. */
  83412. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  83413. /**
  83414. * Use this to temporarily pause hit test checks.
  83415. */
  83416. paused: boolean;
  83417. /**
  83418. * Creates a new instance of the hit test feature
  83419. * @param _xrSessionManager an instance of WebXRSessionManager
  83420. * @param options options to use when constructing this feature
  83421. */
  83422. constructor(_xrSessionManager: WebXRSessionManager,
  83423. /**
  83424. * options to use when constructing this feature
  83425. */
  83426. options?: IWebXRHitTestOptions);
  83427. /**
  83428. * attach this feature
  83429. * Will usually be called by the features manager
  83430. *
  83431. * @returns true if successful.
  83432. */
  83433. attach(): boolean;
  83434. /**
  83435. * detach this feature.
  83436. * Will usually be called by the features manager
  83437. *
  83438. * @returns true if successful.
  83439. */
  83440. detach(): boolean;
  83441. /**
  83442. * Dispose this feature and all of the resources attached
  83443. */
  83444. dispose(): void;
  83445. protected _onXRFrame(frame: XRFrame): void;
  83446. private _processWebXRHitTestResult;
  83447. }
  83448. }
  83449. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  83450. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83451. import { Observable } from "babylonjs/Misc/observable";
  83452. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83453. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83454. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83455. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  83456. /**
  83457. * Configuration options of the anchor system
  83458. */
  83459. export interface IWebXRAnchorSystemOptions {
  83460. /**
  83461. * a node that will be used to convert local to world coordinates
  83462. */
  83463. worldParentNode?: TransformNode;
  83464. /**
  83465. * If set to true a reference of the created anchors will be kept until the next session starts
  83466. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  83467. */
  83468. doNotRemoveAnchorsOnSessionEnded?: boolean;
  83469. }
  83470. /**
  83471. * A babylon container for an XR Anchor
  83472. */
  83473. export interface IWebXRAnchor {
  83474. /**
  83475. * A babylon-assigned ID for this anchor
  83476. */
  83477. id: number;
  83478. /**
  83479. * Transformation matrix to apply to an object attached to this anchor
  83480. */
  83481. transformationMatrix: Matrix;
  83482. /**
  83483. * The native anchor object
  83484. */
  83485. xrAnchor: XRAnchor;
  83486. /**
  83487. * if defined, this object will be constantly updated by the anchor's position and rotation
  83488. */
  83489. attachedNode?: TransformNode;
  83490. /**
  83491. * Remove this anchor from the scene
  83492. */
  83493. remove(): void;
  83494. }
  83495. /**
  83496. * An implementation of the anchor system for WebXR.
  83497. * For further information see https://github.com/immersive-web/anchors/
  83498. */
  83499. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  83500. private _options;
  83501. private _lastFrameDetected;
  83502. private _trackedAnchors;
  83503. private _referenceSpaceForFrameAnchors;
  83504. private _futureAnchors;
  83505. /**
  83506. * The module's name
  83507. */
  83508. static readonly Name: string;
  83509. /**
  83510. * The (Babylon) version of this module.
  83511. * This is an integer representing the implementation version.
  83512. * This number does not correspond to the WebXR specs version
  83513. */
  83514. static readonly Version: number;
  83515. /**
  83516. * Observers registered here will be executed when a new anchor was added to the session
  83517. */
  83518. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  83519. /**
  83520. * Observers registered here will be executed when an anchor was removed from the session
  83521. */
  83522. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  83523. /**
  83524. * Observers registered here will be executed when an existing anchor updates
  83525. * This can execute N times every frame
  83526. */
  83527. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  83528. /**
  83529. * Set the reference space to use for anchor creation, when not using a hit test.
  83530. * Will default to the session's reference space if not defined
  83531. */
  83532. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  83533. /**
  83534. * constructs a new anchor system
  83535. * @param _xrSessionManager an instance of WebXRSessionManager
  83536. * @param _options configuration object for this feature
  83537. */
  83538. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  83539. private _tmpVector;
  83540. private _tmpQuaternion;
  83541. private _populateTmpTransformation;
  83542. /**
  83543. * Create a new anchor point using a hit test result at a specific point in the scene
  83544. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83545. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83546. *
  83547. * @param hitTestResult The hit test result to use for this anchor creation
  83548. * @param position an optional position offset for this anchor
  83549. * @param rotationQuaternion an optional rotation offset for this anchor
  83550. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83551. */
  83552. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  83553. /**
  83554. * Add a new anchor at a specific position and rotation
  83555. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  83556. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  83557. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83558. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83559. *
  83560. * @param position the position in which to add an anchor
  83561. * @param rotationQuaternion an optional rotation for the anchor transformation
  83562. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  83563. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83564. */
  83565. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  83566. /**
  83567. * Get the list of anchors currently being tracked by the system
  83568. */
  83569. get anchors(): IWebXRAnchor[];
  83570. /**
  83571. * detach this feature.
  83572. * Will usually be called by the features manager
  83573. *
  83574. * @returns true if successful.
  83575. */
  83576. detach(): boolean;
  83577. /**
  83578. * Dispose this feature and all of the resources attached
  83579. */
  83580. dispose(): void;
  83581. protected _onXRFrame(frame: XRFrame): void;
  83582. /**
  83583. * avoiding using Array.find for global support.
  83584. * @param xrAnchor the plane to find in the array
  83585. */
  83586. private _findIndexInAnchorArray;
  83587. private _updateAnchorWithXRFrame;
  83588. private _createAnchorAtTransformation;
  83589. }
  83590. }
  83591. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  83592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83593. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83594. import { Observable } from "babylonjs/Misc/observable";
  83595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  83596. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83597. /**
  83598. * Options used in the plane detector module
  83599. */
  83600. export interface IWebXRPlaneDetectorOptions {
  83601. /**
  83602. * The node to use to transform the local results to world coordinates
  83603. */
  83604. worldParentNode?: TransformNode;
  83605. /**
  83606. * If set to true a reference of the created planes will be kept until the next session starts
  83607. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  83608. */
  83609. doNotRemovePlanesOnSessionEnded?: boolean;
  83610. /**
  83611. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  83612. */
  83613. preferredDetectorOptions?: XRGeometryDetectorOptions;
  83614. }
  83615. /**
  83616. * A babylon interface for a WebXR plane.
  83617. * A Plane is actually a polygon, built from N points in space
  83618. *
  83619. * Supported in chrome 79, not supported in canary 81 ATM
  83620. */
  83621. export interface IWebXRPlane {
  83622. /**
  83623. * a babylon-assigned ID for this polygon
  83624. */
  83625. id: number;
  83626. /**
  83627. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  83628. */
  83629. polygonDefinition: Array<Vector3>;
  83630. /**
  83631. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  83632. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  83633. */
  83634. transformationMatrix: Matrix;
  83635. /**
  83636. * the native xr-plane object
  83637. */
  83638. xrPlane: XRPlane;
  83639. }
  83640. /**
  83641. * The plane detector is used to detect planes in the real world when in AR
  83642. * For more information see https://github.com/immersive-web/real-world-geometry/
  83643. */
  83644. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  83645. private _options;
  83646. private _detectedPlanes;
  83647. private _enabled;
  83648. private _lastFrameDetected;
  83649. /**
  83650. * The module's name
  83651. */
  83652. static readonly Name: string;
  83653. /**
  83654. * The (Babylon) version of this module.
  83655. * This is an integer representing the implementation version.
  83656. * This number does not correspond to the WebXR specs version
  83657. */
  83658. static readonly Version: number;
  83659. /**
  83660. * Observers registered here will be executed when a new plane was added to the session
  83661. */
  83662. onPlaneAddedObservable: Observable<IWebXRPlane>;
  83663. /**
  83664. * Observers registered here will be executed when a plane is no longer detected in the session
  83665. */
  83666. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  83667. /**
  83668. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  83669. * This can execute N times every frame
  83670. */
  83671. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  83672. /**
  83673. * construct a new Plane Detector
  83674. * @param _xrSessionManager an instance of xr Session manager
  83675. * @param _options configuration to use when constructing this feature
  83676. */
  83677. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  83678. /**
  83679. * detach this feature.
  83680. * Will usually be called by the features manager
  83681. *
  83682. * @returns true if successful.
  83683. */
  83684. detach(): boolean;
  83685. /**
  83686. * Dispose this feature and all of the resources attached
  83687. */
  83688. dispose(): void;
  83689. /**
  83690. * Check if the needed objects are defined.
  83691. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83692. */
  83693. isCompatible(): boolean;
  83694. protected _onXRFrame(frame: XRFrame): void;
  83695. private _init;
  83696. private _updatePlaneWithXRPlane;
  83697. /**
  83698. * avoiding using Array.find for global support.
  83699. * @param xrPlane the plane to find in the array
  83700. */
  83701. private _findIndexInPlaneArray;
  83702. }
  83703. }
  83704. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  83705. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83707. import { Observable } from "babylonjs/Misc/observable";
  83708. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83709. /**
  83710. * Options interface for the background remover plugin
  83711. */
  83712. export interface IWebXRBackgroundRemoverOptions {
  83713. /**
  83714. * Further background meshes to disable when entering AR
  83715. */
  83716. backgroundMeshes?: AbstractMesh[];
  83717. /**
  83718. * flags to configure the removal of the environment helper.
  83719. * If not set, the entire background will be removed. If set, flags should be set as well.
  83720. */
  83721. environmentHelperRemovalFlags?: {
  83722. /**
  83723. * Should the skybox be removed (default false)
  83724. */
  83725. skyBox?: boolean;
  83726. /**
  83727. * Should the ground be removed (default false)
  83728. */
  83729. ground?: boolean;
  83730. };
  83731. /**
  83732. * don't disable the environment helper
  83733. */
  83734. ignoreEnvironmentHelper?: boolean;
  83735. }
  83736. /**
  83737. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  83738. */
  83739. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  83740. /**
  83741. * read-only options to be used in this module
  83742. */
  83743. readonly options: IWebXRBackgroundRemoverOptions;
  83744. /**
  83745. * The module's name
  83746. */
  83747. static readonly Name: string;
  83748. /**
  83749. * The (Babylon) version of this module.
  83750. * This is an integer representing the implementation version.
  83751. * This number does not correspond to the WebXR specs version
  83752. */
  83753. static readonly Version: number;
  83754. /**
  83755. * registered observers will be triggered when the background state changes
  83756. */
  83757. onBackgroundStateChangedObservable: Observable<boolean>;
  83758. /**
  83759. * constructs a new background remover module
  83760. * @param _xrSessionManager the session manager for this module
  83761. * @param options read-only options to be used in this module
  83762. */
  83763. constructor(_xrSessionManager: WebXRSessionManager,
  83764. /**
  83765. * read-only options to be used in this module
  83766. */
  83767. options?: IWebXRBackgroundRemoverOptions);
  83768. /**
  83769. * attach this feature
  83770. * Will usually be called by the features manager
  83771. *
  83772. * @returns true if successful.
  83773. */
  83774. attach(): boolean;
  83775. /**
  83776. * detach this feature.
  83777. * Will usually be called by the features manager
  83778. *
  83779. * @returns true if successful.
  83780. */
  83781. detach(): boolean;
  83782. /**
  83783. * Dispose this feature and all of the resources attached
  83784. */
  83785. dispose(): void;
  83786. protected _onXRFrame(_xrFrame: XRFrame): void;
  83787. private _setBackgroundState;
  83788. }
  83789. }
  83790. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  83791. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83792. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83793. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  83794. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83795. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83796. import { Nullable } from "babylonjs/types";
  83797. /**
  83798. * Options for the controller physics feature
  83799. */
  83800. export class IWebXRControllerPhysicsOptions {
  83801. /**
  83802. * Should the headset get its own impostor
  83803. */
  83804. enableHeadsetImpostor?: boolean;
  83805. /**
  83806. * Optional parameters for the headset impostor
  83807. */
  83808. headsetImpostorParams?: {
  83809. /**
  83810. * The type of impostor to create. Default is sphere
  83811. */
  83812. impostorType: number;
  83813. /**
  83814. * the size of the impostor. Defaults to 10cm
  83815. */
  83816. impostorSize?: number | {
  83817. width: number;
  83818. height: number;
  83819. depth: number;
  83820. };
  83821. /**
  83822. * Friction definitions
  83823. */
  83824. friction?: number;
  83825. /**
  83826. * Restitution
  83827. */
  83828. restitution?: number;
  83829. };
  83830. /**
  83831. * The physics properties of the future impostors
  83832. */
  83833. physicsProperties?: {
  83834. /**
  83835. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  83836. * Note that this requires a physics engine that supports mesh impostors!
  83837. */
  83838. useControllerMesh?: boolean;
  83839. /**
  83840. * The type of impostor to create. Default is sphere
  83841. */
  83842. impostorType?: number;
  83843. /**
  83844. * the size of the impostor. Defaults to 10cm
  83845. */
  83846. impostorSize?: number | {
  83847. width: number;
  83848. height: number;
  83849. depth: number;
  83850. };
  83851. /**
  83852. * Friction definitions
  83853. */
  83854. friction?: number;
  83855. /**
  83856. * Restitution
  83857. */
  83858. restitution?: number;
  83859. };
  83860. /**
  83861. * the xr input to use with this pointer selection
  83862. */
  83863. xrInput: WebXRInput;
  83864. }
  83865. /**
  83866. * Add physics impostor to your webxr controllers,
  83867. * including naive calculation of their linear and angular velocity
  83868. */
  83869. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  83870. private readonly _options;
  83871. private _attachController;
  83872. private _controllers;
  83873. private _debugMode;
  83874. private _delta;
  83875. private _headsetImpostor?;
  83876. private _headsetMesh?;
  83877. private _lastTimestamp;
  83878. private _tmpQuaternion;
  83879. private _tmpVector;
  83880. /**
  83881. * The module's name
  83882. */
  83883. static readonly Name: string;
  83884. /**
  83885. * The (Babylon) version of this module.
  83886. * This is an integer representing the implementation version.
  83887. * This number does not correspond to the webxr specs version
  83888. */
  83889. static readonly Version: number;
  83890. /**
  83891. * Construct a new Controller Physics Feature
  83892. * @param _xrSessionManager the corresponding xr session manager
  83893. * @param _options options to create this feature with
  83894. */
  83895. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  83896. /**
  83897. * @hidden
  83898. * enable debugging - will show console outputs and the impostor mesh
  83899. */
  83900. _enablePhysicsDebug(): void;
  83901. /**
  83902. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  83903. * @param xrController the controller to add
  83904. */
  83905. addController(xrController: WebXRInputSource): void;
  83906. /**
  83907. * attach this feature
  83908. * Will usually be called by the features manager
  83909. *
  83910. * @returns true if successful.
  83911. */
  83912. attach(): boolean;
  83913. /**
  83914. * detach this feature.
  83915. * Will usually be called by the features manager
  83916. *
  83917. * @returns true if successful.
  83918. */
  83919. detach(): boolean;
  83920. /**
  83921. * Get the headset impostor, if enabled
  83922. * @returns the impostor
  83923. */
  83924. getHeadsetImpostor(): PhysicsImpostor | undefined;
  83925. /**
  83926. * Get the physics impostor of a specific controller.
  83927. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  83928. * @param controller the controller or the controller id of which to get the impostor
  83929. * @returns the impostor or null
  83930. */
  83931. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  83932. /**
  83933. * Update the physics properties provided in the constructor
  83934. * @param newProperties the new properties object
  83935. */
  83936. setPhysicsProperties(newProperties: {
  83937. impostorType?: number;
  83938. impostorSize?: number | {
  83939. width: number;
  83940. height: number;
  83941. depth: number;
  83942. };
  83943. friction?: number;
  83944. restitution?: number;
  83945. }): void;
  83946. protected _onXRFrame(_xrFrame: any): void;
  83947. private _detachController;
  83948. }
  83949. }
  83950. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  83951. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83952. import { Observable } from "babylonjs/Misc/observable";
  83953. import { Vector3 } from "babylonjs/Maths/math.vector";
  83954. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83955. /**
  83956. * A babylon interface for a "WebXR" feature point.
  83957. * Represents the position and confidence value of a given feature point.
  83958. */
  83959. export interface IWebXRFeaturePoint {
  83960. /**
  83961. * Represents the position of the feature point in world space.
  83962. */
  83963. position: Vector3;
  83964. /**
  83965. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  83966. */
  83967. confidenceValue: number;
  83968. }
  83969. /**
  83970. * The feature point system is used to detect feature points from real world geometry.
  83971. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  83972. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  83973. */
  83974. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  83975. private _enabled;
  83976. private _featurePointCloud;
  83977. /**
  83978. * The module's name
  83979. */
  83980. static readonly Name: string;
  83981. /**
  83982. * The (Babylon) version of this module.
  83983. * This is an integer representing the implementation version.
  83984. * This number does not correspond to the WebXR specs version
  83985. */
  83986. static readonly Version: number;
  83987. /**
  83988. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  83989. * Will notify the observers about which feature points have been added.
  83990. */
  83991. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  83992. /**
  83993. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  83994. * Will notify the observers about which feature points have been updated.
  83995. */
  83996. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  83997. /**
  83998. * The current feature point cloud maintained across frames.
  83999. */
  84000. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  84001. /**
  84002. * construct the feature point system
  84003. * @param _xrSessionManager an instance of xr Session manager
  84004. */
  84005. constructor(_xrSessionManager: WebXRSessionManager);
  84006. /**
  84007. * Detach this feature.
  84008. * Will usually be called by the features manager
  84009. *
  84010. * @returns true if successful.
  84011. */
  84012. detach(): boolean;
  84013. /**
  84014. * Dispose this feature and all of the resources attached
  84015. */
  84016. dispose(): void;
  84017. /**
  84018. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  84019. */
  84020. protected _onXRFrame(frame: XRFrame): void;
  84021. /**
  84022. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  84023. */
  84024. private _init;
  84025. }
  84026. }
  84027. declare module "babylonjs/XR/features/WebXRHandTracking" {
  84028. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84029. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84031. import { Mesh } from "babylonjs/Meshes/mesh";
  84032. import { WebXRInput } from "babylonjs/XR/webXRInput";
  84033. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  84034. import { Nullable } from "babylonjs/types";
  84035. import { IDisposable } from "babylonjs/scene";
  84036. import { Observable } from "babylonjs/Misc/observable";
  84037. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  84038. /**
  84039. * Configuration interface for the hand tracking feature
  84040. */
  84041. export interface IWebXRHandTrackingOptions {
  84042. /**
  84043. * The xrInput that will be used as source for new hands
  84044. */
  84045. xrInput: WebXRInput;
  84046. /**
  84047. * Configuration object for the joint meshes
  84048. */
  84049. jointMeshes?: {
  84050. /**
  84051. * Should the meshes created be invisible (defaults to false)
  84052. */
  84053. invisible?: boolean;
  84054. /**
  84055. * A source mesh to be used to create instances. Defaults to a sphere.
  84056. * This mesh will be the source for all other (25) meshes.
  84057. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  84058. */
  84059. sourceMesh?: Mesh;
  84060. /**
  84061. * This function will be called after a mesh was created for a specific joint.
  84062. * Using this function you can either manipulate the instance or return a new mesh.
  84063. * When returning a new mesh the instance created before will be disposed
  84064. */
  84065. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  84066. /**
  84067. * Should the source mesh stay visible. Defaults to false
  84068. */
  84069. keepOriginalVisible?: boolean;
  84070. /**
  84071. * Scale factor for all instances (defaults to 2)
  84072. */
  84073. scaleFactor?: number;
  84074. /**
  84075. * Should each instance have its own physics impostor
  84076. */
  84077. enablePhysics?: boolean;
  84078. /**
  84079. * If enabled, override default physics properties
  84080. */
  84081. physicsProps?: {
  84082. friction?: number;
  84083. restitution?: number;
  84084. impostorType?: number;
  84085. };
  84086. /**
  84087. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  84088. */
  84089. disableDefaultHandMesh?: boolean;
  84090. /**
  84091. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  84092. */
  84093. handMeshes?: {
  84094. right: AbstractMesh;
  84095. left: AbstractMesh;
  84096. };
  84097. /**
  84098. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  84099. */
  84100. rigMapping?: {
  84101. right: string[];
  84102. left: string[];
  84103. };
  84104. };
  84105. }
  84106. /**
  84107. * Parts of the hands divided to writs and finger names
  84108. */
  84109. export const enum HandPart {
  84110. /**
  84111. * HandPart - Wrist
  84112. */
  84113. WRIST = "wrist",
  84114. /**
  84115. * HandPart - The THumb
  84116. */
  84117. THUMB = "thumb",
  84118. /**
  84119. * HandPart - Index finger
  84120. */
  84121. INDEX = "index",
  84122. /**
  84123. * HandPart - Middle finger
  84124. */
  84125. MIDDLE = "middle",
  84126. /**
  84127. * HandPart - Ring finger
  84128. */
  84129. RING = "ring",
  84130. /**
  84131. * HandPart - Little finger
  84132. */
  84133. LITTLE = "little"
  84134. }
  84135. /**
  84136. * Representing a single hand (with its corresponding native XRHand object)
  84137. */
  84138. export class WebXRHand implements IDisposable {
  84139. /** the controller to which the hand correlates */
  84140. readonly xrController: WebXRInputSource;
  84141. /** the meshes to be used to track the hand joints */
  84142. readonly trackedMeshes: AbstractMesh[];
  84143. private _handMesh?;
  84144. private _rigMapping?;
  84145. private _scene;
  84146. private _defaultHandMesh;
  84147. private _transformNodeMapping;
  84148. /**
  84149. * Hand-parts definition (key is HandPart)
  84150. */
  84151. handPartsDefinition: {
  84152. [key: string]: number[];
  84153. };
  84154. /**
  84155. * Observers will be triggered when the mesh for this hand was initialized.
  84156. */
  84157. onHandMeshReadyObservable: Observable<WebXRHand>;
  84158. /**
  84159. * Populate the HandPartsDefinition object.
  84160. * This is called as a side effect since certain browsers don't have XRHand defined.
  84161. */
  84162. private generateHandPartsDefinition;
  84163. /**
  84164. * Construct a new hand object
  84165. * @param xrController the controller to which the hand correlates
  84166. * @param trackedMeshes the meshes to be used to track the hand joints
  84167. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  84168. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  84169. * @param disableDefaultHandMesh should the default mesh creation be disabled
  84170. */
  84171. constructor(
  84172. /** the controller to which the hand correlates */
  84173. xrController: WebXRInputSource,
  84174. /** the meshes to be used to track the hand joints */
  84175. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  84176. /**
  84177. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  84178. */
  84179. get handMesh(): AbstractMesh | undefined;
  84180. /**
  84181. * Update this hand from the latest xr frame
  84182. * @param xrFrame xrFrame to update from
  84183. * @param referenceSpace The current viewer reference space
  84184. * @param scaleFactor optional scale factor for the meshes
  84185. */
  84186. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  84187. /**
  84188. * Get meshes of part of the hand
  84189. * @param part the part of hand to get
  84190. * @returns An array of meshes that correlate to the hand part requested
  84191. */
  84192. getHandPartMeshes(part: HandPart): AbstractMesh[];
  84193. /**
  84194. * Dispose this Hand object
  84195. */
  84196. dispose(): void;
  84197. private _generateDefaultHandMesh;
  84198. }
  84199. /**
  84200. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  84201. */
  84202. export class WebXRHandTracking extends WebXRAbstractFeature {
  84203. /**
  84204. * options to use when constructing this feature
  84205. */
  84206. readonly options: IWebXRHandTrackingOptions;
  84207. private static _idCounter;
  84208. /**
  84209. * The module's name
  84210. */
  84211. static readonly Name: string;
  84212. /**
  84213. * The (Babylon) version of this module.
  84214. * This is an integer representing the implementation version.
  84215. * This number does not correspond to the WebXR specs version
  84216. */
  84217. static readonly Version: number;
  84218. /**
  84219. * This observable will notify registered observers when a new hand object was added and initialized
  84220. */
  84221. onHandAddedObservable: Observable<WebXRHand>;
  84222. /**
  84223. * This observable will notify its observers right before the hand object is disposed
  84224. */
  84225. onHandRemovedObservable: Observable<WebXRHand>;
  84226. private _hands;
  84227. /**
  84228. * Creates a new instance of the hit test feature
  84229. * @param _xrSessionManager an instance of WebXRSessionManager
  84230. * @param options options to use when constructing this feature
  84231. */
  84232. constructor(_xrSessionManager: WebXRSessionManager,
  84233. /**
  84234. * options to use when constructing this feature
  84235. */
  84236. options: IWebXRHandTrackingOptions);
  84237. /**
  84238. * Check if the needed objects are defined.
  84239. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84240. */
  84241. isCompatible(): boolean;
  84242. /**
  84243. * attach this feature
  84244. * Will usually be called by the features manager
  84245. *
  84246. * @returns true if successful.
  84247. */
  84248. attach(): boolean;
  84249. /**
  84250. * detach this feature.
  84251. * Will usually be called by the features manager
  84252. *
  84253. * @returns true if successful.
  84254. */
  84255. detach(): boolean;
  84256. /**
  84257. * Dispose this feature and all of the resources attached
  84258. */
  84259. dispose(): void;
  84260. /**
  84261. * Get the hand object according to the controller id
  84262. * @param controllerId the controller id to which we want to get the hand
  84263. * @returns null if not found or the WebXRHand object if found
  84264. */
  84265. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  84266. /**
  84267. * Get a hand object according to the requested handedness
  84268. * @param handedness the handedness to request
  84269. * @returns null if not found or the WebXRHand object if found
  84270. */
  84271. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  84272. protected _onXRFrame(_xrFrame: XRFrame): void;
  84273. private _attachHand;
  84274. private _detachHand;
  84275. }
  84276. }
  84277. declare module "babylonjs/XR/features/WebXRMeshDetector" {
  84278. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84279. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84281. import { Matrix } from "babylonjs/Maths/math";
  84282. import { Observable } from "babylonjs/Misc/observable";
  84283. /**
  84284. * Options used in the mesh detector module
  84285. */
  84286. export interface IWebXRMeshDetectorOptions {
  84287. /**
  84288. * The node to use to transform the local results to world coordinates
  84289. */
  84290. worldParentNode?: TransformNode;
  84291. /**
  84292. * If set to true a reference of the created meshes will be kept until the next session starts
  84293. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  84294. */
  84295. doNotRemoveMeshesOnSessionEnded?: boolean;
  84296. /**
  84297. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84298. */
  84299. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84300. /**
  84301. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  84302. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  84303. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  84304. */
  84305. convertCoordinateSystems?: boolean;
  84306. }
  84307. /**
  84308. * A babylon interface for a XR mesh's vertex data.
  84309. *
  84310. * Currently not supported by WebXR, available only with BabylonNative
  84311. */
  84312. export interface IWebXRVertexData {
  84313. /**
  84314. * A babylon-assigned ID for this mesh
  84315. */
  84316. id: number;
  84317. /**
  84318. * Data required for constructing a mesh in Babylon.js.
  84319. */
  84320. xrMesh: XRMesh;
  84321. /**
  84322. * The node to use to transform the local results to world coordinates.
  84323. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  84324. */
  84325. worldParentNode?: TransformNode;
  84326. /**
  84327. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  84328. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84329. */
  84330. positions?: Float32Array;
  84331. /**
  84332. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  84333. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84334. */
  84335. indices?: Uint32Array;
  84336. /**
  84337. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  84338. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  84339. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  84340. */
  84341. normals?: Float32Array;
  84342. /**
  84343. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  84344. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  84345. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84346. */
  84347. transformationMatrix?: Matrix;
  84348. }
  84349. /**
  84350. * The mesh detector is used to detect meshes in the real world when in AR
  84351. */
  84352. export class WebXRMeshDetector extends WebXRAbstractFeature {
  84353. private _options;
  84354. private _detectedMeshes;
  84355. /**
  84356. * The module's name
  84357. */
  84358. static readonly Name: string;
  84359. /**
  84360. * The (Babylon) version of this module.
  84361. * This is an integer representing the implementation version.
  84362. * This number does not correspond to the WebXR specs version
  84363. */
  84364. static readonly Version: number;
  84365. /**
  84366. * Observers registered here will be executed when a new mesh was added to the session
  84367. */
  84368. onMeshAddedObservable: Observable<IWebXRVertexData>;
  84369. /**
  84370. * Observers registered here will be executed when a mesh is no longer detected in the session
  84371. */
  84372. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  84373. /**
  84374. * Observers registered here will be executed when an existing mesh updates
  84375. */
  84376. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  84377. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  84378. detach(): boolean;
  84379. dispose(): void;
  84380. protected _onXRFrame(frame: XRFrame): void;
  84381. private _init;
  84382. private _updateVertexDataWithXRMesh;
  84383. }
  84384. }
  84385. declare module "babylonjs/XR/features/WebXRImageTracking" {
  84386. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84387. import { Observable } from "babylonjs/Misc/observable";
  84388. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84389. import { Matrix } from "babylonjs/Maths/math.vector";
  84390. import { Nullable } from "babylonjs/types";
  84391. /**
  84392. * Options interface for the background remover plugin
  84393. */
  84394. export interface IWebXRImageTrackingOptions {
  84395. /**
  84396. * A required array with images to track
  84397. */
  84398. images: {
  84399. /**
  84400. * The source of the image. can be a URL or an image bitmap
  84401. */
  84402. src: string | ImageBitmap;
  84403. /**
  84404. * The estimated width in the real world (in meters)
  84405. */
  84406. estimatedRealWorldWidth: number;
  84407. }[];
  84408. }
  84409. /**
  84410. * An object representing an image tracked by the system
  84411. */
  84412. export interface IWebXRTrackedImage {
  84413. /**
  84414. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  84415. */
  84416. id: number;
  84417. /**
  84418. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  84419. */
  84420. emulated?: boolean;
  84421. /**
  84422. * Just in case it is needed - the image bitmap that is being tracked
  84423. */
  84424. originalBitmap: ImageBitmap;
  84425. /**
  84426. * The native XR result image tracking result, untouched
  84427. */
  84428. xrTrackingResult?: XRImageTrackingResult;
  84429. /**
  84430. * Width in real world (meters)
  84431. */
  84432. realWorldWidth?: number;
  84433. /**
  84434. * A transformation matrix of this current image in the current reference space.
  84435. */
  84436. transformationMatrix: Matrix;
  84437. /**
  84438. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  84439. */
  84440. ratio?: number;
  84441. }
  84442. /**
  84443. * Image tracking for immersive AR sessions.
  84444. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  84445. */
  84446. export class WebXRImageTracking extends WebXRAbstractFeature {
  84447. /**
  84448. * read-only options to be used in this module
  84449. */
  84450. readonly options: IWebXRImageTrackingOptions;
  84451. /**
  84452. * The module's name
  84453. */
  84454. static readonly Name: string;
  84455. /**
  84456. * The (Babylon) version of this module.
  84457. * This is an integer representing the implementation version.
  84458. * This number does not correspond to the WebXR specs version
  84459. */
  84460. static readonly Version: number;
  84461. /**
  84462. * This will be triggered if the underlying system deems an image untrackable.
  84463. * The index is the index of the image from the array used to initialize the feature.
  84464. */
  84465. onUntrackableImageFoundObservable: Observable<number>;
  84466. /**
  84467. * An image was deemed trackable, and the system will start tracking it.
  84468. */
  84469. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  84470. /**
  84471. * The image was found and its state was updated.
  84472. */
  84473. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  84474. private _trackedImages;
  84475. private _originalTrackingRequest;
  84476. /**
  84477. * constructs the image tracking feature
  84478. * @param _xrSessionManager the session manager for this module
  84479. * @param options read-only options to be used in this module
  84480. */
  84481. constructor(_xrSessionManager: WebXRSessionManager,
  84482. /**
  84483. * read-only options to be used in this module
  84484. */
  84485. options: IWebXRImageTrackingOptions);
  84486. /**
  84487. * attach this feature
  84488. * Will usually be called by the features manager
  84489. *
  84490. * @returns true if successful.
  84491. */
  84492. attach(): boolean;
  84493. /**
  84494. * detach this feature.
  84495. * Will usually be called by the features manager
  84496. *
  84497. * @returns true if successful.
  84498. */
  84499. detach(): boolean;
  84500. /**
  84501. * Check if the needed objects are defined.
  84502. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84503. */
  84504. isCompatible(): boolean;
  84505. /**
  84506. * Get a tracked image by its ID.
  84507. *
  84508. * @param id the id of the image to load (position in the init array)
  84509. * @returns a trackable image, if exists in this location
  84510. */
  84511. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  84512. /**
  84513. * Dispose this feature and all of the resources attached
  84514. */
  84515. dispose(): void;
  84516. /**
  84517. * Extends the session init object if needed
  84518. * @returns augmentation object fo the xr session init object.
  84519. */
  84520. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  84521. protected _onXRFrame(_xrFrame: XRFrame): void;
  84522. private _init;
  84523. }
  84524. }
  84525. declare module "babylonjs/XR/features/index" {
  84526. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  84527. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  84528. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  84529. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  84530. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  84531. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  84532. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  84533. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  84534. export * from "babylonjs/XR/features/WebXRHitTest";
  84535. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  84536. export * from "babylonjs/XR/features/WebXRHandTracking";
  84537. export * from "babylonjs/XR/features/WebXRMeshDetector";
  84538. export * from "babylonjs/XR/features/WebXRImageTracking";
  84539. }
  84540. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  84541. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84543. import { Scene } from "babylonjs/scene";
  84544. /**
  84545. * The motion controller class for all microsoft mixed reality controllers
  84546. */
  84547. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  84548. protected readonly _mapping: {
  84549. defaultButton: {
  84550. valueNodeName: string;
  84551. unpressedNodeName: string;
  84552. pressedNodeName: string;
  84553. };
  84554. defaultAxis: {
  84555. valueNodeName: string;
  84556. minNodeName: string;
  84557. maxNodeName: string;
  84558. };
  84559. buttons: {
  84560. "xr-standard-trigger": {
  84561. rootNodeName: string;
  84562. componentProperty: string;
  84563. states: string[];
  84564. };
  84565. "xr-standard-squeeze": {
  84566. rootNodeName: string;
  84567. componentProperty: string;
  84568. states: string[];
  84569. };
  84570. "xr-standard-touchpad": {
  84571. rootNodeName: string;
  84572. labelAnchorNodeName: string;
  84573. touchPointNodeName: string;
  84574. };
  84575. "xr-standard-thumbstick": {
  84576. rootNodeName: string;
  84577. componentProperty: string;
  84578. states: string[];
  84579. };
  84580. };
  84581. axes: {
  84582. "xr-standard-touchpad": {
  84583. "x-axis": {
  84584. rootNodeName: string;
  84585. };
  84586. "y-axis": {
  84587. rootNodeName: string;
  84588. };
  84589. };
  84590. "xr-standard-thumbstick": {
  84591. "x-axis": {
  84592. rootNodeName: string;
  84593. };
  84594. "y-axis": {
  84595. rootNodeName: string;
  84596. };
  84597. };
  84598. };
  84599. };
  84600. /**
  84601. * The base url used to load the left and right controller models
  84602. */
  84603. static MODEL_BASE_URL: string;
  84604. /**
  84605. * The name of the left controller model file
  84606. */
  84607. static MODEL_LEFT_FILENAME: string;
  84608. /**
  84609. * The name of the right controller model file
  84610. */
  84611. static MODEL_RIGHT_FILENAME: string;
  84612. profileId: string;
  84613. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84614. protected _getFilenameAndPath(): {
  84615. filename: string;
  84616. path: string;
  84617. };
  84618. protected _getModelLoadingConstraints(): boolean;
  84619. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84620. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84621. protected _updateModel(): void;
  84622. }
  84623. }
  84624. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  84625. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84627. import { Scene } from "babylonjs/scene";
  84628. /**
  84629. * The motion controller class for oculus touch (quest, rift).
  84630. * This class supports legacy mapping as well the standard xr mapping
  84631. */
  84632. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  84633. private _forceLegacyControllers;
  84634. private _modelRootNode;
  84635. /**
  84636. * The base url used to load the left and right controller models
  84637. */
  84638. static MODEL_BASE_URL: string;
  84639. /**
  84640. * The name of the left controller model file
  84641. */
  84642. static MODEL_LEFT_FILENAME: string;
  84643. /**
  84644. * The name of the right controller model file
  84645. */
  84646. static MODEL_RIGHT_FILENAME: string;
  84647. /**
  84648. * Base Url for the Quest controller model.
  84649. */
  84650. static QUEST_MODEL_BASE_URL: string;
  84651. profileId: string;
  84652. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  84653. protected _getFilenameAndPath(): {
  84654. filename: string;
  84655. path: string;
  84656. };
  84657. protected _getModelLoadingConstraints(): boolean;
  84658. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84659. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84660. protected _updateModel(): void;
  84661. /**
  84662. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  84663. * between the touch and touch 2.
  84664. */
  84665. private _isQuest;
  84666. }
  84667. }
  84668. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  84669. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84670. import { Scene } from "babylonjs/scene";
  84671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84672. /**
  84673. * The motion controller class for the standard HTC-Vive controllers
  84674. */
  84675. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  84676. private _modelRootNode;
  84677. /**
  84678. * The base url used to load the left and right controller models
  84679. */
  84680. static MODEL_BASE_URL: string;
  84681. /**
  84682. * File name for the controller model.
  84683. */
  84684. static MODEL_FILENAME: string;
  84685. profileId: string;
  84686. /**
  84687. * Create a new Vive motion controller object
  84688. * @param scene the scene to use to create this controller
  84689. * @param gamepadObject the corresponding gamepad object
  84690. * @param handedness the handedness of the controller
  84691. */
  84692. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84693. protected _getFilenameAndPath(): {
  84694. filename: string;
  84695. path: string;
  84696. };
  84697. protected _getModelLoadingConstraints(): boolean;
  84698. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84699. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84700. protected _updateModel(): void;
  84701. }
  84702. }
  84703. declare module "babylonjs/XR/motionController/index" {
  84704. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84705. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  84706. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  84707. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  84708. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  84709. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  84710. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  84711. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  84712. }
  84713. declare module "babylonjs/XR/index" {
  84714. export * from "babylonjs/XR/webXRCamera";
  84715. export * from "babylonjs/XR/webXREnterExitUI";
  84716. export * from "babylonjs/XR/webXRExperienceHelper";
  84717. export * from "babylonjs/XR/webXRInput";
  84718. export * from "babylonjs/XR/webXRInputSource";
  84719. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  84720. export * from "babylonjs/XR/webXRTypes";
  84721. export * from "babylonjs/XR/webXRSessionManager";
  84722. export * from "babylonjs/XR/webXRDefaultExperience";
  84723. export * from "babylonjs/XR/webXRFeaturesManager";
  84724. export * from "babylonjs/XR/features/index";
  84725. export * from "babylonjs/XR/motionController/index";
  84726. }
  84727. declare module "babylonjs/index" {
  84728. export * from "babylonjs/abstractScene";
  84729. export * from "babylonjs/Actions/index";
  84730. export * from "babylonjs/Animations/index";
  84731. export * from "babylonjs/assetContainer";
  84732. export * from "babylonjs/Audio/index";
  84733. export * from "babylonjs/Behaviors/index";
  84734. export * from "babylonjs/Bones/index";
  84735. export * from "babylonjs/Cameras/index";
  84736. export * from "babylonjs/Collisions/index";
  84737. export * from "babylonjs/Culling/index";
  84738. export * from "babylonjs/Debug/index";
  84739. export * from "babylonjs/DeviceInput/index";
  84740. export * from "babylonjs/Engines/index";
  84741. export * from "babylonjs/Events/index";
  84742. export * from "babylonjs/Gamepads/index";
  84743. export * from "babylonjs/Gizmos/index";
  84744. export * from "babylonjs/Helpers/index";
  84745. export * from "babylonjs/Instrumentation/index";
  84746. export * from "babylonjs/Layers/index";
  84747. export * from "babylonjs/LensFlares/index";
  84748. export * from "babylonjs/Lights/index";
  84749. export * from "babylonjs/Loading/index";
  84750. export * from "babylonjs/Materials/index";
  84751. export * from "babylonjs/Maths/index";
  84752. export * from "babylonjs/Meshes/index";
  84753. export * from "babylonjs/Morph/index";
  84754. export * from "babylonjs/Navigation/index";
  84755. export * from "babylonjs/node";
  84756. export * from "babylonjs/Offline/index";
  84757. export * from "babylonjs/Particles/index";
  84758. export * from "babylonjs/Physics/index";
  84759. export * from "babylonjs/PostProcesses/index";
  84760. export * from "babylonjs/Probes/index";
  84761. export * from "babylonjs/Rendering/index";
  84762. export * from "babylonjs/scene";
  84763. export * from "babylonjs/sceneComponent";
  84764. export * from "babylonjs/Sprites/index";
  84765. export * from "babylonjs/States/index";
  84766. export * from "babylonjs/Misc/index";
  84767. export * from "babylonjs/XR/index";
  84768. export * from "babylonjs/types";
  84769. }
  84770. declare module "babylonjs/Animations/pathCursor" {
  84771. import { Vector3 } from "babylonjs/Maths/math.vector";
  84772. import { Path2 } from "babylonjs/Maths/math.path";
  84773. /**
  84774. * A cursor which tracks a point on a path
  84775. */
  84776. export class PathCursor {
  84777. private path;
  84778. /**
  84779. * Stores path cursor callbacks for when an onchange event is triggered
  84780. */
  84781. private _onchange;
  84782. /**
  84783. * The value of the path cursor
  84784. */
  84785. value: number;
  84786. /**
  84787. * The animation array of the path cursor
  84788. */
  84789. animations: Animation[];
  84790. /**
  84791. * Initializes the path cursor
  84792. * @param path The path to track
  84793. */
  84794. constructor(path: Path2);
  84795. /**
  84796. * Gets the cursor point on the path
  84797. * @returns A point on the path cursor at the cursor location
  84798. */
  84799. getPoint(): Vector3;
  84800. /**
  84801. * Moves the cursor ahead by the step amount
  84802. * @param step The amount to move the cursor forward
  84803. * @returns This path cursor
  84804. */
  84805. moveAhead(step?: number): PathCursor;
  84806. /**
  84807. * Moves the cursor behind by the step amount
  84808. * @param step The amount to move the cursor back
  84809. * @returns This path cursor
  84810. */
  84811. moveBack(step?: number): PathCursor;
  84812. /**
  84813. * Moves the cursor by the step amount
  84814. * If the step amount is greater than one, an exception is thrown
  84815. * @param step The amount to move the cursor
  84816. * @returns This path cursor
  84817. */
  84818. move(step: number): PathCursor;
  84819. /**
  84820. * Ensures that the value is limited between zero and one
  84821. * @returns This path cursor
  84822. */
  84823. private ensureLimits;
  84824. /**
  84825. * Runs onchange callbacks on change (used by the animation engine)
  84826. * @returns This path cursor
  84827. */
  84828. private raiseOnChange;
  84829. /**
  84830. * Executes a function on change
  84831. * @param f A path cursor onchange callback
  84832. * @returns This path cursor
  84833. */
  84834. onchange(f: (cursor: PathCursor) => void): PathCursor;
  84835. }
  84836. }
  84837. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  84838. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  84839. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  84840. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  84841. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  84842. }
  84843. declare module "babylonjs/Engines/Processors/Expressions/index" {
  84844. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  84845. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  84846. }
  84847. declare module "babylonjs/Engines/Processors/index" {
  84848. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  84849. export * from "babylonjs/Engines/Processors/Expressions/index";
  84850. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  84851. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  84852. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  84853. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  84854. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  84855. export * from "babylonjs/Engines/Processors/shaderProcessor";
  84856. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  84857. }
  84858. declare module "babylonjs/Legacy/legacy" {
  84859. import * as Babylon from "babylonjs/index";
  84860. export * from "babylonjs/index";
  84861. }
  84862. declare module "babylonjs/Shaders/blur.fragment" {
  84863. /** @hidden */
  84864. export var blurPixelShader: {
  84865. name: string;
  84866. shader: string;
  84867. };
  84868. }
  84869. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  84870. /** @hidden */
  84871. export var pointCloudVertexDeclaration: {
  84872. name: string;
  84873. shader: string;
  84874. };
  84875. }
  84876. declare module "babylonjs" {
  84877. export * from "babylonjs/Legacy/legacy";
  84878. }
  84879. declare module BABYLON {
  84880. /** Alias type for value that can be null */
  84881. export type Nullable<T> = T | null;
  84882. /**
  84883. * Alias type for number that are floats
  84884. * @ignorenaming
  84885. */
  84886. export type float = number;
  84887. /**
  84888. * Alias type for number that are doubles.
  84889. * @ignorenaming
  84890. */
  84891. export type double = number;
  84892. /**
  84893. * Alias type for number that are integer
  84894. * @ignorenaming
  84895. */
  84896. export type int = number;
  84897. /** Alias type for number array or Float32Array */
  84898. export type FloatArray = number[] | Float32Array;
  84899. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  84900. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  84901. /**
  84902. * Alias for types that can be used by a Buffer or VertexBuffer.
  84903. */
  84904. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  84905. /**
  84906. * Alias type for primitive types
  84907. * @ignorenaming
  84908. */
  84909. type Primitive = undefined | null | boolean | string | number | Function;
  84910. /**
  84911. * Type modifier to make all the properties of an object Readonly
  84912. */
  84913. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  84914. /**
  84915. * Type modifier to make all the properties of an object Readonly recursively
  84916. */
  84917. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  84918. /**
  84919. * Type modifier to make object properties readonly.
  84920. */
  84921. export type DeepImmutableObject<T> = {
  84922. readonly [K in keyof T]: DeepImmutable<T[K]>;
  84923. };
  84924. /** @hidden */
  84925. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  84926. }
  84927. }
  84928. declare module BABYLON {
  84929. /**
  84930. * A class serves as a medium between the observable and its observers
  84931. */
  84932. export class EventState {
  84933. /**
  84934. * Create a new EventState
  84935. * @param mask defines the mask associated with this state
  84936. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84937. * @param target defines the original target of the state
  84938. * @param currentTarget defines the current target of the state
  84939. */
  84940. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  84941. /**
  84942. * Initialize the current event state
  84943. * @param mask defines the mask associated with this state
  84944. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84945. * @param target defines the original target of the state
  84946. * @param currentTarget defines the current target of the state
  84947. * @returns the current event state
  84948. */
  84949. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  84950. /**
  84951. * An Observer can set this property to true to prevent subsequent observers of being notified
  84952. */
  84953. skipNextObservers: boolean;
  84954. /**
  84955. * Get the mask value that were used to trigger the event corresponding to this EventState object
  84956. */
  84957. mask: number;
  84958. /**
  84959. * The object that originally notified the event
  84960. */
  84961. target?: any;
  84962. /**
  84963. * The current object in the bubbling phase
  84964. */
  84965. currentTarget?: any;
  84966. /**
  84967. * This will be populated with the return value of the last function that was executed.
  84968. * If it is the first function in the callback chain it will be the event data.
  84969. */
  84970. lastReturnValue?: any;
  84971. /**
  84972. * User defined information that will be sent to observers
  84973. */
  84974. userInfo?: any;
  84975. }
  84976. /**
  84977. * Represent an Observer registered to a given Observable object.
  84978. */
  84979. export class Observer<T> {
  84980. /**
  84981. * Defines the callback to call when the observer is notified
  84982. */
  84983. callback: (eventData: T, eventState: EventState) => void;
  84984. /**
  84985. * Defines the mask of the observer (used to filter notifications)
  84986. */
  84987. mask: number;
  84988. /**
  84989. * Defines the current scope used to restore the JS context
  84990. */
  84991. scope: any;
  84992. /** @hidden */
  84993. _willBeUnregistered: boolean;
  84994. /**
  84995. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  84996. */
  84997. unregisterOnNextCall: boolean;
  84998. /**
  84999. * Creates a new observer
  85000. * @param callback defines the callback to call when the observer is notified
  85001. * @param mask defines the mask of the observer (used to filter notifications)
  85002. * @param scope defines the current scope used to restore the JS context
  85003. */
  85004. constructor(
  85005. /**
  85006. * Defines the callback to call when the observer is notified
  85007. */
  85008. callback: (eventData: T, eventState: EventState) => void,
  85009. /**
  85010. * Defines the mask of the observer (used to filter notifications)
  85011. */
  85012. mask: number,
  85013. /**
  85014. * Defines the current scope used to restore the JS context
  85015. */
  85016. scope?: any);
  85017. }
  85018. /**
  85019. * Represent a list of observers registered to multiple Observables object.
  85020. */
  85021. export class MultiObserver<T> {
  85022. private _observers;
  85023. private _observables;
  85024. /**
  85025. * Release associated resources
  85026. */
  85027. dispose(): void;
  85028. /**
  85029. * Raise a callback when one of the observable will notify
  85030. * @param observables defines a list of observables to watch
  85031. * @param callback defines the callback to call on notification
  85032. * @param mask defines the mask used to filter notifications
  85033. * @param scope defines the current scope used to restore the JS context
  85034. * @returns the new MultiObserver
  85035. */
  85036. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  85037. }
  85038. /**
  85039. * The Observable class is a simple implementation of the Observable pattern.
  85040. *
  85041. * 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.
  85042. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  85043. * 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).
  85044. * 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.
  85045. */
  85046. export class Observable<T> {
  85047. private _observers;
  85048. private _eventState;
  85049. private _onObserverAdded;
  85050. /**
  85051. * Gets the list of observers
  85052. */
  85053. get observers(): Array<Observer<T>>;
  85054. /**
  85055. * Creates a new observable
  85056. * @param onObserverAdded defines a callback to call when a new observer is added
  85057. */
  85058. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  85059. /**
  85060. * Create a new Observer with the specified callback
  85061. * @param callback the callback that will be executed for that Observer
  85062. * @param mask the mask used to filter observers
  85063. * @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.
  85064. * @param scope optional scope for the callback to be called from
  85065. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  85066. * @returns the new observer created for the callback
  85067. */
  85068. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  85069. /**
  85070. * Create a new Observer with the specified callback and unregisters after the next notification
  85071. * @param callback the callback that will be executed for that Observer
  85072. * @returns the new observer created for the callback
  85073. */
  85074. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  85075. /**
  85076. * Remove an Observer from the Observable object
  85077. * @param observer the instance of the Observer to remove
  85078. * @returns false if it doesn't belong to this Observable
  85079. */
  85080. remove(observer: Nullable<Observer<T>>): boolean;
  85081. /**
  85082. * Remove a callback from the Observable object
  85083. * @param callback the callback to remove
  85084. * @param scope optional scope. If used only the callbacks with this scope will be removed
  85085. * @returns false if it doesn't belong to this Observable
  85086. */
  85087. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  85088. private _deferUnregister;
  85089. private _remove;
  85090. /**
  85091. * Moves the observable to the top of the observer list making it get called first when notified
  85092. * @param observer the observer to move
  85093. */
  85094. makeObserverTopPriority(observer: Observer<T>): void;
  85095. /**
  85096. * Moves the observable to the bottom of the observer list making it get called last when notified
  85097. * @param observer the observer to move
  85098. */
  85099. makeObserverBottomPriority(observer: Observer<T>): void;
  85100. /**
  85101. * Notify all Observers by calling their respective callback with the given data
  85102. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  85103. * @param eventData defines the data to send to all observers
  85104. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  85105. * @param target defines the original target of the state
  85106. * @param currentTarget defines the current target of the state
  85107. * @param userInfo defines any user info to send to observers
  85108. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  85109. */
  85110. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  85111. /**
  85112. * Calling this will execute each callback, expecting it to be a promise or return a value.
  85113. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  85114. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  85115. * and it is crucial that all callbacks will be executed.
  85116. * The order of the callbacks is kept, callbacks are not executed parallel.
  85117. *
  85118. * @param eventData The data to be sent to each callback
  85119. * @param mask is used to filter observers defaults to -1
  85120. * @param target defines the callback target (see EventState)
  85121. * @param currentTarget defines he current object in the bubbling phase
  85122. * @param userInfo defines any user info to send to observers
  85123. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  85124. */
  85125. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  85126. /**
  85127. * Notify a specific observer
  85128. * @param observer defines the observer to notify
  85129. * @param eventData defines the data to be sent to each callback
  85130. * @param mask is used to filter observers defaults to -1
  85131. */
  85132. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  85133. /**
  85134. * Gets a boolean indicating if the observable has at least one observer
  85135. * @returns true is the Observable has at least one Observer registered
  85136. */
  85137. hasObservers(): boolean;
  85138. /**
  85139. * Clear the list of observers
  85140. */
  85141. clear(): void;
  85142. /**
  85143. * Clone the current observable
  85144. * @returns a new observable
  85145. */
  85146. clone(): Observable<T>;
  85147. /**
  85148. * Does this observable handles observer registered with a given mask
  85149. * @param mask defines the mask to be tested
  85150. * @return whether or not one observer registered with the given mask is handeled
  85151. **/
  85152. hasSpecificMask(mask?: number): boolean;
  85153. }
  85154. }
  85155. declare module BABYLON {
  85156. /**
  85157. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  85158. * Babylon.js
  85159. */
  85160. export class DomManagement {
  85161. /**
  85162. * Checks if the window object exists
  85163. * @returns true if the window object exists
  85164. */
  85165. static IsWindowObjectExist(): boolean;
  85166. /**
  85167. * Checks if the navigator object exists
  85168. * @returns true if the navigator object exists
  85169. */
  85170. static IsNavigatorAvailable(): boolean;
  85171. /**
  85172. * Check if the document object exists
  85173. * @returns true if the document object exists
  85174. */
  85175. static IsDocumentAvailable(): boolean;
  85176. /**
  85177. * Extracts text content from a DOM element hierarchy
  85178. * @param element defines the root element
  85179. * @returns a string
  85180. */
  85181. static GetDOMTextContent(element: HTMLElement): string;
  85182. }
  85183. }
  85184. declare module BABYLON {
  85185. /**
  85186. * Logger used througouht the application to allow configuration of
  85187. * the log level required for the messages.
  85188. */
  85189. export class Logger {
  85190. /**
  85191. * No log
  85192. */
  85193. static readonly NoneLogLevel: number;
  85194. /**
  85195. * Only message logs
  85196. */
  85197. static readonly MessageLogLevel: number;
  85198. /**
  85199. * Only warning logs
  85200. */
  85201. static readonly WarningLogLevel: number;
  85202. /**
  85203. * Only error logs
  85204. */
  85205. static readonly ErrorLogLevel: number;
  85206. /**
  85207. * All logs
  85208. */
  85209. static readonly AllLogLevel: number;
  85210. /**
  85211. * Message to display when a message has been logged too many times
  85212. */
  85213. static MessageLimitReached: string;
  85214. private static _LogCache;
  85215. private static _LogLimitOutputs;
  85216. /**
  85217. * Gets a value indicating the number of loading errors
  85218. * @ignorenaming
  85219. */
  85220. static errorsCount: number;
  85221. /**
  85222. * Callback called when a new log is added
  85223. */
  85224. static OnNewCacheEntry: (entry: string) => void;
  85225. private static _CheckLimit;
  85226. private static _GenerateLimitMessage;
  85227. private static _AddLogEntry;
  85228. private static _FormatMessage;
  85229. private static _LogDisabled;
  85230. private static _LogEnabled;
  85231. private static _WarnDisabled;
  85232. private static _WarnEnabled;
  85233. private static _ErrorDisabled;
  85234. private static _ErrorEnabled;
  85235. /**
  85236. * Log a message to the console
  85237. */
  85238. static Log: (message: string, limit?: number) => void;
  85239. /**
  85240. * Write a warning message to the console
  85241. */
  85242. static Warn: (message: string, limit?: number) => void;
  85243. /**
  85244. * Write an error message to the console
  85245. */
  85246. static Error: (message: string, limit?: number) => void;
  85247. /**
  85248. * Gets current log cache (list of logs)
  85249. */
  85250. static get LogCache(): string;
  85251. /**
  85252. * Clears the log cache
  85253. */
  85254. static ClearLogCache(): void;
  85255. /**
  85256. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  85257. */
  85258. static set LogLevels(level: number);
  85259. }
  85260. }
  85261. declare module BABYLON {
  85262. /** @hidden */
  85263. export class _TypeStore {
  85264. /** @hidden */
  85265. static RegisteredTypes: {
  85266. [key: string]: Object;
  85267. };
  85268. /** @hidden */
  85269. static GetClass(fqdn: string): any;
  85270. }
  85271. }
  85272. declare module BABYLON {
  85273. /**
  85274. * Helper to manipulate strings
  85275. */
  85276. export class StringTools {
  85277. /**
  85278. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  85279. * @param str Source string
  85280. * @param suffix Suffix to search for in the source string
  85281. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85282. */
  85283. static EndsWith(str: string, suffix: string): boolean;
  85284. /**
  85285. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  85286. * @param str Source string
  85287. * @param suffix Suffix to search for in the source string
  85288. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85289. */
  85290. static StartsWith(str: string, suffix: string): boolean;
  85291. /**
  85292. * Decodes a buffer into a string
  85293. * @param buffer The buffer to decode
  85294. * @returns The decoded string
  85295. */
  85296. static Decode(buffer: Uint8Array | Uint16Array): string;
  85297. /**
  85298. * Encode a buffer to a base64 string
  85299. * @param buffer defines the buffer to encode
  85300. * @returns the encoded string
  85301. */
  85302. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  85303. /**
  85304. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  85305. * @param num the number to convert and pad
  85306. * @param length the expected length of the string
  85307. * @returns the padded string
  85308. */
  85309. static PadNumber(num: number, length: number): string;
  85310. }
  85311. }
  85312. declare module BABYLON {
  85313. /**
  85314. * Class containing a set of static utilities functions for deep copy.
  85315. */
  85316. export class DeepCopier {
  85317. /**
  85318. * Tries to copy an object by duplicating every property
  85319. * @param source defines the source object
  85320. * @param destination defines the target object
  85321. * @param doNotCopyList defines a list of properties to avoid
  85322. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  85323. */
  85324. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  85325. }
  85326. }
  85327. declare module BABYLON {
  85328. /**
  85329. * Class containing a set of static utilities functions for precision date
  85330. */
  85331. export class PrecisionDate {
  85332. /**
  85333. * Gets either window.performance.now() if supported or Date.now() else
  85334. */
  85335. static get Now(): number;
  85336. }
  85337. }
  85338. declare module BABYLON {
  85339. /** @hidden */
  85340. export class _DevTools {
  85341. static WarnImport(name: string): string;
  85342. }
  85343. }
  85344. declare module BABYLON {
  85345. /**
  85346. * Interface used to define the mechanism to get data from the network
  85347. */
  85348. export interface IWebRequest {
  85349. /**
  85350. * Returns client's response url
  85351. */
  85352. responseURL: string;
  85353. /**
  85354. * Returns client's status
  85355. */
  85356. status: number;
  85357. /**
  85358. * Returns client's status as a text
  85359. */
  85360. statusText: string;
  85361. }
  85362. }
  85363. declare module BABYLON {
  85364. /**
  85365. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  85366. */
  85367. export class WebRequest implements IWebRequest {
  85368. private readonly _xhr;
  85369. /**
  85370. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  85371. * i.e. when loading files, where the server/service expects an Authorization header
  85372. */
  85373. static CustomRequestHeaders: {
  85374. [key: string]: string;
  85375. };
  85376. /**
  85377. * Add callback functions in this array to update all the requests before they get sent to the network
  85378. */
  85379. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  85380. private _injectCustomRequestHeaders;
  85381. /**
  85382. * Gets or sets a function to be called when loading progress changes
  85383. */
  85384. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  85385. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  85386. /**
  85387. * Returns client's state
  85388. */
  85389. get readyState(): number;
  85390. /**
  85391. * Returns client's status
  85392. */
  85393. get status(): number;
  85394. /**
  85395. * Returns client's status as a text
  85396. */
  85397. get statusText(): string;
  85398. /**
  85399. * Returns client's response
  85400. */
  85401. get response(): any;
  85402. /**
  85403. * Returns client's response url
  85404. */
  85405. get responseURL(): string;
  85406. /**
  85407. * Returns client's response as text
  85408. */
  85409. get responseText(): string;
  85410. /**
  85411. * Gets or sets the expected response type
  85412. */
  85413. get responseType(): XMLHttpRequestResponseType;
  85414. set responseType(value: XMLHttpRequestResponseType);
  85415. /** @hidden */
  85416. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  85417. /** @hidden */
  85418. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  85419. /**
  85420. * Cancels any network activity
  85421. */
  85422. abort(): void;
  85423. /**
  85424. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  85425. * @param body defines an optional request body
  85426. */
  85427. send(body?: Document | BodyInit | null): void;
  85428. /**
  85429. * Sets the request method, request URL
  85430. * @param method defines the method to use (GET, POST, etc..)
  85431. * @param url defines the url to connect with
  85432. */
  85433. open(method: string, url: string): void;
  85434. /**
  85435. * Sets the value of a request header.
  85436. * @param name The name of the header whose value is to be set
  85437. * @param value The value to set as the body of the header
  85438. */
  85439. setRequestHeader(name: string, value: string): void;
  85440. /**
  85441. * Get the string containing the text of a particular header's value.
  85442. * @param name The name of the header
  85443. * @returns The string containing the text of the given header name
  85444. */
  85445. getResponseHeader(name: string): Nullable<string>;
  85446. }
  85447. }
  85448. declare module BABYLON {
  85449. /**
  85450. * File request interface
  85451. */
  85452. export interface IFileRequest {
  85453. /**
  85454. * Raised when the request is complete (success or error).
  85455. */
  85456. onCompleteObservable: Observable<IFileRequest>;
  85457. /**
  85458. * Aborts the request for a file.
  85459. */
  85460. abort: () => void;
  85461. }
  85462. }
  85463. declare module BABYLON {
  85464. /**
  85465. * Define options used to create a render target texture
  85466. */
  85467. export class RenderTargetCreationOptions {
  85468. /**
  85469. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  85470. */
  85471. createMipMaps?: boolean;
  85472. /**
  85473. * Specifies if mipmaps must be generated
  85474. */
  85475. generateMipMaps?: boolean;
  85476. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  85477. generateDepthBuffer?: boolean;
  85478. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  85479. generateStencilBuffer?: boolean;
  85480. /** Defines texture type (int by default) */
  85481. type?: number;
  85482. /** Defines sampling mode (trilinear by default) */
  85483. samplingMode?: number;
  85484. /** Defines format (RGBA by default) */
  85485. format?: number;
  85486. /** Defines sample count (1 by default) */
  85487. samples?: number;
  85488. }
  85489. }
  85490. declare module BABYLON {
  85491. /** Defines the cross module used constants to avoid circular dependncies */
  85492. export class Constants {
  85493. /** Defines that alpha blending is disabled */
  85494. static readonly ALPHA_DISABLE: number;
  85495. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  85496. static readonly ALPHA_ADD: number;
  85497. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85498. static readonly ALPHA_COMBINE: number;
  85499. /** Defines that alpha blending is DEST - SRC * DEST */
  85500. static readonly ALPHA_SUBTRACT: number;
  85501. /** Defines that alpha blending is SRC * DEST */
  85502. static readonly ALPHA_MULTIPLY: number;
  85503. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  85504. static readonly ALPHA_MAXIMIZED: number;
  85505. /** Defines that alpha blending is SRC + DEST */
  85506. static readonly ALPHA_ONEONE: number;
  85507. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  85508. static readonly ALPHA_PREMULTIPLIED: number;
  85509. /**
  85510. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  85511. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85512. */
  85513. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85514. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  85515. static readonly ALPHA_INTERPOLATE: number;
  85516. /**
  85517. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  85518. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85519. */
  85520. static readonly ALPHA_SCREENMODE: number;
  85521. /**
  85522. * Defines that alpha blending is SRC + DST
  85523. * Alpha will be set to SRC ALPHA + DST ALPHA
  85524. */
  85525. static readonly ALPHA_ONEONE_ONEONE: number;
  85526. /**
  85527. * Defines that alpha blending is SRC * DST ALPHA + DST
  85528. * Alpha will be set to 0
  85529. */
  85530. static readonly ALPHA_ALPHATOCOLOR: number;
  85531. /**
  85532. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85533. */
  85534. static readonly ALPHA_REVERSEONEMINUS: number;
  85535. /**
  85536. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  85537. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  85538. */
  85539. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  85540. /**
  85541. * Defines that alpha blending is SRC + DST
  85542. * Alpha will be set to SRC ALPHA
  85543. */
  85544. static readonly ALPHA_ONEONE_ONEZERO: number;
  85545. /**
  85546. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85547. * Alpha will be set to DST ALPHA
  85548. */
  85549. static readonly ALPHA_EXCLUSION: number;
  85550. /** Defines that alpha blending equation a SUM */
  85551. static readonly ALPHA_EQUATION_ADD: number;
  85552. /** Defines that alpha blending equation a SUBSTRACTION */
  85553. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  85554. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  85555. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  85556. /** Defines that alpha blending equation a MAX operation */
  85557. static readonly ALPHA_EQUATION_MAX: number;
  85558. /** Defines that alpha blending equation a MIN operation */
  85559. static readonly ALPHA_EQUATION_MIN: number;
  85560. /**
  85561. * Defines that alpha blending equation a DARKEN operation:
  85562. * It takes the min of the src and sums the alpha channels.
  85563. */
  85564. static readonly ALPHA_EQUATION_DARKEN: number;
  85565. /** Defines that the ressource is not delayed*/
  85566. static readonly DELAYLOADSTATE_NONE: number;
  85567. /** Defines that the ressource was successfully delay loaded */
  85568. static readonly DELAYLOADSTATE_LOADED: number;
  85569. /** Defines that the ressource is currently delay loading */
  85570. static readonly DELAYLOADSTATE_LOADING: number;
  85571. /** Defines that the ressource is delayed and has not started loading */
  85572. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85574. static readonly NEVER: number;
  85575. /** 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 */
  85576. static readonly ALWAYS: number;
  85577. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85578. static readonly LESS: number;
  85579. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85580. static readonly EQUAL: number;
  85581. /** 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 */
  85582. static readonly LEQUAL: number;
  85583. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85584. static readonly GREATER: number;
  85585. /** 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 */
  85586. static readonly GEQUAL: number;
  85587. /** 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 */
  85588. static readonly NOTEQUAL: number;
  85589. /** Passed to stencilOperation to specify that stencil value must be kept */
  85590. static readonly KEEP: number;
  85591. /** Passed to stencilOperation to specify that stencil value must be zero */
  85592. static readonly ZERO: number;
  85593. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85594. static readonly REPLACE: number;
  85595. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85596. static readonly INCR: number;
  85597. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85598. static readonly DECR: number;
  85599. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85600. static readonly INVERT: number;
  85601. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85602. static readonly INCR_WRAP: number;
  85603. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85604. static readonly DECR_WRAP: number;
  85605. /** Texture is not repeating outside of 0..1 UVs */
  85606. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85607. /** Texture is repeating outside of 0..1 UVs */
  85608. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85609. /** Texture is repeating and mirrored */
  85610. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85611. /** ALPHA */
  85612. static readonly TEXTUREFORMAT_ALPHA: number;
  85613. /** LUMINANCE */
  85614. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85615. /** LUMINANCE_ALPHA */
  85616. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85617. /** RGB */
  85618. static readonly TEXTUREFORMAT_RGB: number;
  85619. /** RGBA */
  85620. static readonly TEXTUREFORMAT_RGBA: number;
  85621. /** RED */
  85622. static readonly TEXTUREFORMAT_RED: number;
  85623. /** RED (2nd reference) */
  85624. static readonly TEXTUREFORMAT_R: number;
  85625. /** RG */
  85626. static readonly TEXTUREFORMAT_RG: number;
  85627. /** RED_INTEGER */
  85628. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85629. /** RED_INTEGER (2nd reference) */
  85630. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85631. /** RG_INTEGER */
  85632. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85633. /** RGB_INTEGER */
  85634. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85635. /** RGBA_INTEGER */
  85636. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85637. /** BGRA */
  85638. static readonly TEXTUREFORMAT_BGRA: number;
  85639. /** Depth 24 bits + Stencil 8 bits */
  85640. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  85641. /** Depth 32 bits float */
  85642. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  85643. /** Compressed BC7 */
  85644. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  85645. /** Compressed BC6 unsigned float */
  85646. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  85647. /** Compressed BC6 signed float */
  85648. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  85649. /** Compressed BC3 */
  85650. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  85651. /** Compressed BC2 */
  85652. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  85653. /** Compressed BC1 */
  85654. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  85655. /** UNSIGNED_BYTE */
  85656. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85657. /** UNSIGNED_BYTE (2nd reference) */
  85658. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85659. /** FLOAT */
  85660. static readonly TEXTURETYPE_FLOAT: number;
  85661. /** HALF_FLOAT */
  85662. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85663. /** BYTE */
  85664. static readonly TEXTURETYPE_BYTE: number;
  85665. /** SHORT */
  85666. static readonly TEXTURETYPE_SHORT: number;
  85667. /** UNSIGNED_SHORT */
  85668. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85669. /** INT */
  85670. static readonly TEXTURETYPE_INT: number;
  85671. /** UNSIGNED_INT */
  85672. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85673. /** UNSIGNED_SHORT_4_4_4_4 */
  85674. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85675. /** UNSIGNED_SHORT_5_5_5_1 */
  85676. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85677. /** UNSIGNED_SHORT_5_6_5 */
  85678. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85679. /** UNSIGNED_INT_2_10_10_10_REV */
  85680. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85681. /** UNSIGNED_INT_24_8 */
  85682. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85683. /** UNSIGNED_INT_10F_11F_11F_REV */
  85684. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85685. /** UNSIGNED_INT_5_9_9_9_REV */
  85686. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85687. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85688. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85689. /** nearest is mag = nearest and min = nearest and no mip */
  85690. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85691. /** mag = nearest and min = nearest and mip = none */
  85692. static readonly TEXTURE_NEAREST_NEAREST: number;
  85693. /** Bilinear is mag = linear and min = linear and no mip */
  85694. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85695. /** mag = linear and min = linear and mip = none */
  85696. static readonly TEXTURE_LINEAR_LINEAR: number;
  85697. /** Trilinear is mag = linear and min = linear and mip = linear */
  85698. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85699. /** Trilinear is mag = linear and min = linear and mip = linear */
  85700. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85701. /** mag = nearest and min = nearest and mip = nearest */
  85702. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85703. /** mag = nearest and min = linear and mip = nearest */
  85704. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85705. /** mag = nearest and min = linear and mip = linear */
  85706. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85707. /** mag = nearest and min = linear and mip = none */
  85708. static readonly TEXTURE_NEAREST_LINEAR: number;
  85709. /** nearest is mag = nearest and min = nearest and mip = linear */
  85710. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85711. /** mag = linear and min = nearest and mip = nearest */
  85712. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85713. /** mag = linear and min = nearest and mip = linear */
  85714. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85715. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85716. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85717. /** mag = linear and min = nearest and mip = none */
  85718. static readonly TEXTURE_LINEAR_NEAREST: number;
  85719. /** Explicit coordinates mode */
  85720. static readonly TEXTURE_EXPLICIT_MODE: number;
  85721. /** Spherical coordinates mode */
  85722. static readonly TEXTURE_SPHERICAL_MODE: number;
  85723. /** Planar coordinates mode */
  85724. static readonly TEXTURE_PLANAR_MODE: number;
  85725. /** Cubic coordinates mode */
  85726. static readonly TEXTURE_CUBIC_MODE: number;
  85727. /** Projection coordinates mode */
  85728. static readonly TEXTURE_PROJECTION_MODE: number;
  85729. /** Skybox coordinates mode */
  85730. static readonly TEXTURE_SKYBOX_MODE: number;
  85731. /** Inverse Cubic coordinates mode */
  85732. static readonly TEXTURE_INVCUBIC_MODE: number;
  85733. /** Equirectangular coordinates mode */
  85734. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85735. /** Equirectangular Fixed coordinates mode */
  85736. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85737. /** Equirectangular Fixed Mirrored coordinates mode */
  85738. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85739. /** Offline (baking) quality for texture filtering */
  85740. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  85741. /** High quality for texture filtering */
  85742. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  85743. /** Medium quality for texture filtering */
  85744. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  85745. /** Low quality for texture filtering */
  85746. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  85747. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85748. static readonly SCALEMODE_FLOOR: number;
  85749. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85750. static readonly SCALEMODE_NEAREST: number;
  85751. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85752. static readonly SCALEMODE_CEILING: number;
  85753. /**
  85754. * The dirty texture flag value
  85755. */
  85756. static readonly MATERIAL_TextureDirtyFlag: number;
  85757. /**
  85758. * The dirty light flag value
  85759. */
  85760. static readonly MATERIAL_LightDirtyFlag: number;
  85761. /**
  85762. * The dirty fresnel flag value
  85763. */
  85764. static readonly MATERIAL_FresnelDirtyFlag: number;
  85765. /**
  85766. * The dirty attribute flag value
  85767. */
  85768. static readonly MATERIAL_AttributesDirtyFlag: number;
  85769. /**
  85770. * The dirty misc flag value
  85771. */
  85772. static readonly MATERIAL_MiscDirtyFlag: number;
  85773. /**
  85774. * The dirty prepass flag value
  85775. */
  85776. static readonly MATERIAL_PrePassDirtyFlag: number;
  85777. /**
  85778. * The all dirty flag value
  85779. */
  85780. static readonly MATERIAL_AllDirtyFlag: number;
  85781. /**
  85782. * Returns the triangle fill mode
  85783. */
  85784. static readonly MATERIAL_TriangleFillMode: number;
  85785. /**
  85786. * Returns the wireframe mode
  85787. */
  85788. static readonly MATERIAL_WireFrameFillMode: number;
  85789. /**
  85790. * Returns the point fill mode
  85791. */
  85792. static readonly MATERIAL_PointFillMode: number;
  85793. /**
  85794. * Returns the point list draw mode
  85795. */
  85796. static readonly MATERIAL_PointListDrawMode: number;
  85797. /**
  85798. * Returns the line list draw mode
  85799. */
  85800. static readonly MATERIAL_LineListDrawMode: number;
  85801. /**
  85802. * Returns the line loop draw mode
  85803. */
  85804. static readonly MATERIAL_LineLoopDrawMode: number;
  85805. /**
  85806. * Returns the line strip draw mode
  85807. */
  85808. static readonly MATERIAL_LineStripDrawMode: number;
  85809. /**
  85810. * Returns the triangle strip draw mode
  85811. */
  85812. static readonly MATERIAL_TriangleStripDrawMode: number;
  85813. /**
  85814. * Returns the triangle fan draw mode
  85815. */
  85816. static readonly MATERIAL_TriangleFanDrawMode: number;
  85817. /**
  85818. * Stores the clock-wise side orientation
  85819. */
  85820. static readonly MATERIAL_ClockWiseSideOrientation: number;
  85821. /**
  85822. * Stores the counter clock-wise side orientation
  85823. */
  85824. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  85825. /**
  85826. * Nothing
  85827. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85828. */
  85829. static readonly ACTION_NothingTrigger: number;
  85830. /**
  85831. * On pick
  85832. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85833. */
  85834. static readonly ACTION_OnPickTrigger: number;
  85835. /**
  85836. * On left pick
  85837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85838. */
  85839. static readonly ACTION_OnLeftPickTrigger: number;
  85840. /**
  85841. * On right pick
  85842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85843. */
  85844. static readonly ACTION_OnRightPickTrigger: number;
  85845. /**
  85846. * On center pick
  85847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85848. */
  85849. static readonly ACTION_OnCenterPickTrigger: number;
  85850. /**
  85851. * On pick down
  85852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85853. */
  85854. static readonly ACTION_OnPickDownTrigger: number;
  85855. /**
  85856. * On double pick
  85857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85858. */
  85859. static readonly ACTION_OnDoublePickTrigger: number;
  85860. /**
  85861. * On pick up
  85862. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85863. */
  85864. static readonly ACTION_OnPickUpTrigger: number;
  85865. /**
  85866. * On pick out.
  85867. * This trigger will only be raised if you also declared a OnPickDown
  85868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85869. */
  85870. static readonly ACTION_OnPickOutTrigger: number;
  85871. /**
  85872. * On long press
  85873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85874. */
  85875. static readonly ACTION_OnLongPressTrigger: number;
  85876. /**
  85877. * On pointer over
  85878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85879. */
  85880. static readonly ACTION_OnPointerOverTrigger: number;
  85881. /**
  85882. * On pointer out
  85883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85884. */
  85885. static readonly ACTION_OnPointerOutTrigger: number;
  85886. /**
  85887. * On every frame
  85888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85889. */
  85890. static readonly ACTION_OnEveryFrameTrigger: number;
  85891. /**
  85892. * On intersection enter
  85893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85894. */
  85895. static readonly ACTION_OnIntersectionEnterTrigger: number;
  85896. /**
  85897. * On intersection exit
  85898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85899. */
  85900. static readonly ACTION_OnIntersectionExitTrigger: number;
  85901. /**
  85902. * On key down
  85903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85904. */
  85905. static readonly ACTION_OnKeyDownTrigger: number;
  85906. /**
  85907. * On key up
  85908. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85909. */
  85910. static readonly ACTION_OnKeyUpTrigger: number;
  85911. /**
  85912. * Billboard mode will only apply to Y axis
  85913. */
  85914. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  85915. /**
  85916. * Billboard mode will apply to all axes
  85917. */
  85918. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  85919. /**
  85920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85921. */
  85922. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  85923. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  85924. * Test order :
  85925. * Is the bounding sphere outside the frustum ?
  85926. * If not, are the bounding box vertices outside the frustum ?
  85927. * It not, then the cullable object is in the frustum.
  85928. */
  85929. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  85930. /** Culling strategy : Bounding Sphere Only.
  85931. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  85932. * It's also less accurate than the standard because some not visible objects can still be selected.
  85933. * Test : is the bounding sphere outside the frustum ?
  85934. * If not, then the cullable object is in the frustum.
  85935. */
  85936. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  85937. /** Culling strategy : Optimistic Inclusion.
  85938. * This in an inclusion test first, then the standard exclusion test.
  85939. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  85940. * 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.
  85941. * Anyway, it's as accurate as the standard strategy.
  85942. * Test :
  85943. * Is the cullable object bounding sphere center in the frustum ?
  85944. * If not, apply the default culling strategy.
  85945. */
  85946. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  85947. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  85948. * This in an inclusion test first, then the bounding sphere only exclusion test.
  85949. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  85950. * 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.
  85951. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  85952. * Test :
  85953. * Is the cullable object bounding sphere center in the frustum ?
  85954. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  85955. */
  85956. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  85957. /**
  85958. * No logging while loading
  85959. */
  85960. static readonly SCENELOADER_NO_LOGGING: number;
  85961. /**
  85962. * Minimal logging while loading
  85963. */
  85964. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  85965. /**
  85966. * Summary logging while loading
  85967. */
  85968. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  85969. /**
  85970. * Detailled logging while loading
  85971. */
  85972. static readonly SCENELOADER_DETAILED_LOGGING: number;
  85973. /**
  85974. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  85975. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  85976. */
  85977. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  85978. /**
  85979. * Constant used to retrieve the position texture index in the textures array in the prepass
  85980. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  85981. */
  85982. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  85983. /**
  85984. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  85985. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  85986. */
  85987. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  85988. /**
  85989. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  85990. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  85991. */
  85992. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  85993. /**
  85994. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  85995. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  85996. */
  85997. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  85998. /**
  85999. * Constant used to retrieve depth + normal index in the textures array in the prepass
  86000. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  86001. */
  86002. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  86003. /**
  86004. * Constant used to retrieve albedo index in the textures array in the prepass
  86005. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  86006. */
  86007. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  86008. /**
  86009. * Prefixes used by the engine for custom effects
  86010. */
  86011. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  86012. }
  86013. }
  86014. declare module BABYLON {
  86015. /** @hidden */
  86016. export interface HardwareTextureWrapper {
  86017. underlyingResource: any;
  86018. set(hardwareTexture: any): void;
  86019. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  86020. reset(): void;
  86021. release(): void;
  86022. }
  86023. }
  86024. declare module BABYLON {
  86025. /**
  86026. * This represents the required contract to create a new type of texture loader.
  86027. */
  86028. export interface IInternalTextureLoader {
  86029. /**
  86030. * Defines wether the loader supports cascade loading the different faces.
  86031. */
  86032. supportCascades: boolean;
  86033. /**
  86034. * This returns if the loader support the current file information.
  86035. * @param extension defines the file extension of the file being loaded
  86036. * @param mimeType defines the optional mime type of the file being loaded
  86037. * @returns true if the loader can load the specified file
  86038. */
  86039. canLoad(extension: string, mimeType?: string): boolean;
  86040. /**
  86041. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  86042. * @param data contains the texture data
  86043. * @param texture defines the BabylonJS internal texture
  86044. * @param createPolynomials will be true if polynomials have been requested
  86045. * @param onLoad defines the callback to trigger once the texture is ready
  86046. * @param onError defines the callback to trigger in case of error
  86047. * @param options options to be passed to the loader
  86048. */
  86049. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  86050. /**
  86051. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  86052. * @param data contains the texture data
  86053. * @param texture defines the BabylonJS internal texture
  86054. * @param callback defines the method to call once ready to upload
  86055. * @param options options to be passed to the loader
  86056. */
  86057. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  86058. }
  86059. }
  86060. declare module BABYLON {
  86061. /**
  86062. * @hidden
  86063. */
  86064. export interface IColor4Like {
  86065. r: float;
  86066. g: float;
  86067. b: float;
  86068. a: float;
  86069. }
  86070. /**
  86071. * @hidden
  86072. */
  86073. export interface IColor3Like {
  86074. r: float;
  86075. g: float;
  86076. b: float;
  86077. }
  86078. /**
  86079. * @hidden
  86080. */
  86081. export interface IVector4Like {
  86082. x: float;
  86083. y: float;
  86084. z: float;
  86085. w: float;
  86086. }
  86087. /**
  86088. * @hidden
  86089. */
  86090. export interface IVector3Like {
  86091. x: float;
  86092. y: float;
  86093. z: float;
  86094. }
  86095. /**
  86096. * @hidden
  86097. */
  86098. export interface IVector2Like {
  86099. x: float;
  86100. y: float;
  86101. }
  86102. /**
  86103. * @hidden
  86104. */
  86105. export interface IMatrixLike {
  86106. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86107. updateFlag: int;
  86108. }
  86109. /**
  86110. * @hidden
  86111. */
  86112. export interface IViewportLike {
  86113. x: float;
  86114. y: float;
  86115. width: float;
  86116. height: float;
  86117. }
  86118. /**
  86119. * @hidden
  86120. */
  86121. export interface IPlaneLike {
  86122. normal: IVector3Like;
  86123. d: float;
  86124. normalize(): void;
  86125. }
  86126. }
  86127. declare module BABYLON {
  86128. /**
  86129. * Class used to store and describe the pipeline context associated with an effect
  86130. */
  86131. export interface IPipelineContext {
  86132. /**
  86133. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  86134. */
  86135. isAsync: boolean;
  86136. /**
  86137. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  86138. */
  86139. isReady: boolean;
  86140. /** @hidden */
  86141. _name?: string;
  86142. /** @hidden */
  86143. _getVertexShaderCode(): string | null;
  86144. /** @hidden */
  86145. _getFragmentShaderCode(): string | null;
  86146. /** @hidden */
  86147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  86148. /** @hidden */
  86149. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  86150. [key: string]: number;
  86151. }, uniformsNames: string[], uniforms: {
  86152. [key: string]: Nullable<WebGLUniformLocation>;
  86153. }, samplerList: string[], samplers: {
  86154. [key: string]: number;
  86155. }, attributesNames: string[], attributes: number[]): void;
  86156. /** Releases the resources associated with the pipeline. */
  86157. dispose(): void;
  86158. /**
  86159. * Sets an integer value on a uniform variable.
  86160. * @param uniformName Name of the variable.
  86161. * @param value Value to be set.
  86162. */
  86163. setInt(uniformName: string, value: number): void;
  86164. /**
  86165. * Sets an int2 value on a uniform variable.
  86166. * @param uniformName Name of the variable.
  86167. * @param x First int in int2.
  86168. * @param y Second int in int2.
  86169. */
  86170. setInt2(uniformName: string, x: number, y: number): void;
  86171. /**
  86172. * Sets an int3 value on a uniform variable.
  86173. * @param uniformName Name of the variable.
  86174. * @param x First int in int3.
  86175. * @param y Second int in int3.
  86176. * @param z Third int in int3.
  86177. */
  86178. setInt3(uniformName: string, x: number, y: number, z: number): void;
  86179. /**
  86180. * Sets an int4 value on a uniform variable.
  86181. * @param uniformName Name of the variable.
  86182. * @param x First int in int4.
  86183. * @param y Second int in int4.
  86184. * @param z Third int in int4.
  86185. * @param w Fourth int in int4.
  86186. */
  86187. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86188. /**
  86189. * Sets an int array on a uniform variable.
  86190. * @param uniformName Name of the variable.
  86191. * @param array array to be set.
  86192. */
  86193. setIntArray(uniformName: string, array: Int32Array): void;
  86194. /**
  86195. * 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)
  86196. * @param uniformName Name of the variable.
  86197. * @param array array to be set.
  86198. */
  86199. setIntArray2(uniformName: string, array: Int32Array): void;
  86200. /**
  86201. * 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)
  86202. * @param uniformName Name of the variable.
  86203. * @param array array to be set.
  86204. */
  86205. setIntArray3(uniformName: string, array: Int32Array): void;
  86206. /**
  86207. * 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)
  86208. * @param uniformName Name of the variable.
  86209. * @param array array to be set.
  86210. */
  86211. setIntArray4(uniformName: string, array: Int32Array): void;
  86212. /**
  86213. * Sets an array on a uniform variable.
  86214. * @param uniformName Name of the variable.
  86215. * @param array array to be set.
  86216. */
  86217. setArray(uniformName: string, array: number[] | Float32Array): void;
  86218. /**
  86219. * 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)
  86220. * @param uniformName Name of the variable.
  86221. * @param array array to be set.
  86222. */
  86223. setArray2(uniformName: string, array: number[] | Float32Array): void;
  86224. /**
  86225. * 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)
  86226. * @param uniformName Name of the variable.
  86227. * @param array array to be set.
  86228. */
  86229. setArray3(uniformName: string, array: number[] | Float32Array): void;
  86230. /**
  86231. * 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)
  86232. * @param uniformName Name of the variable.
  86233. * @param array array to be set.
  86234. */
  86235. setArray4(uniformName: string, array: number[] | Float32Array): void;
  86236. /**
  86237. * Sets matrices on a uniform variable.
  86238. * @param uniformName Name of the variable.
  86239. * @param matrices matrices to be set.
  86240. */
  86241. setMatrices(uniformName: string, matrices: Float32Array): void;
  86242. /**
  86243. * Sets matrix on a uniform variable.
  86244. * @param uniformName Name of the variable.
  86245. * @param matrix matrix to be set.
  86246. */
  86247. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  86248. /**
  86249. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  86250. * @param uniformName Name of the variable.
  86251. * @param matrix matrix to be set.
  86252. */
  86253. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  86254. /**
  86255. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86256. * @param uniformName Name of the variable.
  86257. * @param matrix matrix to be set.
  86258. */
  86259. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  86260. /**
  86261. * Sets a float on a uniform variable.
  86262. * @param uniformName Name of the variable.
  86263. * @param value value to be set.
  86264. */
  86265. setFloat(uniformName: string, value: number): void;
  86266. /**
  86267. * Sets a Vector2 on a uniform variable.
  86268. * @param uniformName Name of the variable.
  86269. * @param vector2 vector2 to be set.
  86270. */
  86271. setVector2(uniformName: string, vector2: IVector2Like): void;
  86272. /**
  86273. * Sets a float2 on a uniform variable.
  86274. * @param uniformName Name of the variable.
  86275. * @param x First float in float2.
  86276. * @param y Second float in float2.
  86277. */
  86278. setFloat2(uniformName: string, x: number, y: number): void;
  86279. /**
  86280. * Sets a Vector3 on a uniform variable.
  86281. * @param uniformName Name of the variable.
  86282. * @param vector3 Value to be set.
  86283. */
  86284. setVector3(uniformName: string, vector3: IVector3Like): void;
  86285. /**
  86286. * Sets a float3 on a uniform variable.
  86287. * @param uniformName Name of the variable.
  86288. * @param x First float in float3.
  86289. * @param y Second float in float3.
  86290. * @param z Third float in float3.
  86291. */
  86292. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  86293. /**
  86294. * Sets a Vector4 on a uniform variable.
  86295. * @param uniformName Name of the variable.
  86296. * @param vector4 Value to be set.
  86297. */
  86298. setVector4(uniformName: string, vector4: IVector4Like): void;
  86299. /**
  86300. * Sets a float4 on a uniform variable.
  86301. * @param uniformName Name of the variable.
  86302. * @param x First float in float4.
  86303. * @param y Second float in float4.
  86304. * @param z Third float in float4.
  86305. * @param w Fourth float in float4.
  86306. */
  86307. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86308. /**
  86309. * Sets a Color3 on a uniform variable.
  86310. * @param uniformName Name of the variable.
  86311. * @param color3 Value to be set.
  86312. */
  86313. setColor3(uniformName: string, color3: IColor3Like): void;
  86314. /**
  86315. * Sets a Color4 on a uniform variable.
  86316. * @param uniformName Name of the variable.
  86317. * @param color3 Value to be set.
  86318. * @param alpha Alpha value to be set.
  86319. */
  86320. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  86321. /**
  86322. * Sets a Color4 on a uniform variable
  86323. * @param uniformName defines the name of the variable
  86324. * @param color4 defines the value to be set
  86325. */
  86326. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  86327. }
  86328. }
  86329. declare module BABYLON {
  86330. /**
  86331. * Class used to store gfx data (like WebGLBuffer)
  86332. */
  86333. export class DataBuffer {
  86334. private static _Counter;
  86335. /**
  86336. * Gets or sets the number of objects referencing this buffer
  86337. */
  86338. references: number;
  86339. /** Gets or sets the size of the underlying buffer */
  86340. capacity: number;
  86341. /**
  86342. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  86343. */
  86344. is32Bits: boolean;
  86345. /**
  86346. * Gets the underlying buffer
  86347. */
  86348. get underlyingResource(): any;
  86349. /**
  86350. * Gets the unique id of this buffer
  86351. */
  86352. readonly uniqueId: number;
  86353. /**
  86354. * Constructs the buffer
  86355. */
  86356. constructor();
  86357. }
  86358. }
  86359. declare module BABYLON {
  86360. /** @hidden */
  86361. export interface IShaderProcessor {
  86362. attributeProcessor?: (attribute: string, preProcessors: {
  86363. [key: string]: string;
  86364. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86365. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  86366. [key: string]: string;
  86367. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86368. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  86369. [key: string]: string;
  86370. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86371. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86372. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86373. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86374. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86375. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  86376. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  86377. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  86378. vertexCode: string;
  86379. fragmentCode: string;
  86380. };
  86381. }
  86382. }
  86383. declare module BABYLON {
  86384. /** @hidden */
  86385. export interface ShaderProcessingContext {
  86386. }
  86387. /** @hidden */
  86388. export interface ProcessingOptions {
  86389. defines: string[];
  86390. indexParameters: any;
  86391. isFragment: boolean;
  86392. shouldUseHighPrecisionShader: boolean;
  86393. supportsUniformBuffers: boolean;
  86394. shadersRepository: string;
  86395. includesShadersStore: {
  86396. [key: string]: string;
  86397. };
  86398. processor: Nullable<IShaderProcessor>;
  86399. version: string;
  86400. platformName: string;
  86401. lookForClosingBracketForUniformBuffer?: boolean;
  86402. processingContext: Nullable<ShaderProcessingContext>;
  86403. }
  86404. }
  86405. declare module BABYLON {
  86406. /** @hidden */
  86407. export class ShaderCodeNode {
  86408. line: string;
  86409. children: ShaderCodeNode[];
  86410. additionalDefineKey?: string;
  86411. additionalDefineValue?: string;
  86412. isValid(preprocessors: {
  86413. [key: string]: string;
  86414. }): boolean;
  86415. process(preprocessors: {
  86416. [key: string]: string;
  86417. }, options: ProcessingOptions): string;
  86418. }
  86419. }
  86420. declare module BABYLON {
  86421. /** @hidden */
  86422. export class ShaderCodeCursor {
  86423. private _lines;
  86424. lineIndex: number;
  86425. get currentLine(): string;
  86426. get canRead(): boolean;
  86427. set lines(value: string[]);
  86428. }
  86429. }
  86430. declare module BABYLON {
  86431. /** @hidden */
  86432. export class ShaderCodeConditionNode extends ShaderCodeNode {
  86433. process(preprocessors: {
  86434. [key: string]: string;
  86435. }, options: ProcessingOptions): string;
  86436. }
  86437. }
  86438. declare module BABYLON {
  86439. /** @hidden */
  86440. export class ShaderDefineExpression {
  86441. isTrue(preprocessors: {
  86442. [key: string]: string;
  86443. }): boolean;
  86444. private static _OperatorPriority;
  86445. private static _Stack;
  86446. static postfixToInfix(postfix: string[]): string;
  86447. static infixToPostfix(infix: string): string[];
  86448. }
  86449. }
  86450. declare module BABYLON {
  86451. /** @hidden */
  86452. export class ShaderCodeTestNode extends ShaderCodeNode {
  86453. testExpression: ShaderDefineExpression;
  86454. isValid(preprocessors: {
  86455. [key: string]: string;
  86456. }): boolean;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /** @hidden */
  86461. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  86462. define: string;
  86463. not: boolean;
  86464. constructor(define: string, not?: boolean);
  86465. isTrue(preprocessors: {
  86466. [key: string]: string;
  86467. }): boolean;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /** @hidden */
  86472. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  86473. leftOperand: ShaderDefineExpression;
  86474. rightOperand: ShaderDefineExpression;
  86475. isTrue(preprocessors: {
  86476. [key: string]: string;
  86477. }): boolean;
  86478. }
  86479. }
  86480. declare module BABYLON {
  86481. /** @hidden */
  86482. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  86483. leftOperand: ShaderDefineExpression;
  86484. rightOperand: ShaderDefineExpression;
  86485. isTrue(preprocessors: {
  86486. [key: string]: string;
  86487. }): boolean;
  86488. }
  86489. }
  86490. declare module BABYLON {
  86491. /** @hidden */
  86492. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  86493. define: string;
  86494. operand: string;
  86495. testValue: string;
  86496. constructor(define: string, operand: string, testValue: string);
  86497. isTrue(preprocessors: {
  86498. [key: string]: string;
  86499. }): boolean;
  86500. }
  86501. }
  86502. declare module BABYLON {
  86503. /**
  86504. * Class used to enable access to offline support
  86505. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  86506. */
  86507. export interface IOfflineProvider {
  86508. /**
  86509. * Gets a boolean indicating if scene must be saved in the database
  86510. */
  86511. enableSceneOffline: boolean;
  86512. /**
  86513. * Gets a boolean indicating if textures must be saved in the database
  86514. */
  86515. enableTexturesOffline: boolean;
  86516. /**
  86517. * Open the offline support and make it available
  86518. * @param successCallback defines the callback to call on success
  86519. * @param errorCallback defines the callback to call on error
  86520. */
  86521. open(successCallback: () => void, errorCallback: () => void): void;
  86522. /**
  86523. * Loads an image from the offline support
  86524. * @param url defines the url to load from
  86525. * @param image defines the target DOM image
  86526. */
  86527. loadImage(url: string, image: HTMLImageElement): void;
  86528. /**
  86529. * Loads a file from offline support
  86530. * @param url defines the URL to load from
  86531. * @param sceneLoaded defines a callback to call on success
  86532. * @param progressCallBack defines a callback to call when progress changed
  86533. * @param errorCallback defines a callback to call on error
  86534. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  86535. */
  86536. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  86537. }
  86538. }
  86539. declare module BABYLON {
  86540. /**
  86541. * Class used to help managing file picking and drag'n'drop
  86542. * File Storage
  86543. */
  86544. export class FilesInputStore {
  86545. /**
  86546. * List of files ready to be loaded
  86547. */
  86548. static FilesToLoad: {
  86549. [key: string]: File;
  86550. };
  86551. }
  86552. }
  86553. declare module BABYLON {
  86554. /**
  86555. * Class used to define a retry strategy when error happens while loading assets
  86556. */
  86557. export class RetryStrategy {
  86558. /**
  86559. * Function used to defines an exponential back off strategy
  86560. * @param maxRetries defines the maximum number of retries (3 by default)
  86561. * @param baseInterval defines the interval between retries
  86562. * @returns the strategy function to use
  86563. */
  86564. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  86565. }
  86566. }
  86567. declare module BABYLON {
  86568. /**
  86569. * @ignore
  86570. * Application error to support additional information when loading a file
  86571. */
  86572. export abstract class BaseError extends Error {
  86573. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  86574. }
  86575. }
  86576. declare module BABYLON {
  86577. /** @ignore */
  86578. export class LoadFileError extends BaseError {
  86579. request?: WebRequest;
  86580. file?: File;
  86581. /**
  86582. * Creates a new LoadFileError
  86583. * @param message defines the message of the error
  86584. * @param request defines the optional web request
  86585. * @param file defines the optional file
  86586. */
  86587. constructor(message: string, object?: WebRequest | File);
  86588. }
  86589. /** @ignore */
  86590. export class RequestFileError extends BaseError {
  86591. request: WebRequest;
  86592. /**
  86593. * Creates a new LoadFileError
  86594. * @param message defines the message of the error
  86595. * @param request defines the optional web request
  86596. */
  86597. constructor(message: string, request: WebRequest);
  86598. }
  86599. /** @ignore */
  86600. export class ReadFileError extends BaseError {
  86601. file: File;
  86602. /**
  86603. * Creates a new ReadFileError
  86604. * @param message defines the message of the error
  86605. * @param file defines the optional file
  86606. */
  86607. constructor(message: string, file: File);
  86608. }
  86609. /**
  86610. * @hidden
  86611. */
  86612. export class FileTools {
  86613. /**
  86614. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86615. */
  86616. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  86617. /**
  86618. * Gets or sets the base URL to use to load assets
  86619. */
  86620. static BaseUrl: string;
  86621. /**
  86622. * Default behaviour for cors in the application.
  86623. * It can be a string if the expected behavior is identical in the entire app.
  86624. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86625. */
  86626. static CorsBehavior: string | ((url: string | string[]) => string);
  86627. /**
  86628. * Gets or sets a function used to pre-process url before using them to load assets
  86629. */
  86630. static PreprocessUrl: (url: string) => string;
  86631. /**
  86632. * Removes unwanted characters from an url
  86633. * @param url defines the url to clean
  86634. * @returns the cleaned url
  86635. */
  86636. private static _CleanUrl;
  86637. /**
  86638. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86639. * @param url define the url we are trying
  86640. * @param element define the dom element where to configure the cors policy
  86641. */
  86642. static SetCorsBehavior(url: string | string[], element: {
  86643. crossOrigin: string | null;
  86644. }): void;
  86645. /**
  86646. * Loads an image as an HTMLImageElement.
  86647. * @param input url string, ArrayBuffer, or Blob to load
  86648. * @param onLoad callback called when the image successfully loads
  86649. * @param onError callback called when the image fails to load
  86650. * @param offlineProvider offline provider for caching
  86651. * @param mimeType optional mime type
  86652. * @returns the HTMLImageElement of the loaded image
  86653. */
  86654. 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>;
  86655. /**
  86656. * Reads a file from a File object
  86657. * @param file defines the file to load
  86658. * @param onSuccess defines the callback to call when data is loaded
  86659. * @param onProgress defines the callback to call during loading process
  86660. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86661. * @param onError defines the callback to call when an error occurs
  86662. * @returns a file request object
  86663. */
  86664. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  86665. /**
  86666. * Loads a file from a url
  86667. * @param url url to load
  86668. * @param onSuccess callback called when the file successfully loads
  86669. * @param onProgress callback called while file is loading (if the server supports this mode)
  86670. * @param offlineProvider defines the offline provider for caching
  86671. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86672. * @param onError callback called when the file fails to load
  86673. * @returns a file request object
  86674. */
  86675. 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;
  86676. /**
  86677. * Loads a file
  86678. * @param url url to load
  86679. * @param onSuccess callback called when the file successfully loads
  86680. * @param onProgress callback called while file is loading (if the server supports this mode)
  86681. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86682. * @param onError callback called when the file fails to load
  86683. * @param onOpened callback called when the web request is opened
  86684. * @returns a file request object
  86685. */
  86686. 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;
  86687. /**
  86688. * Checks if the loaded document was accessed via `file:`-Protocol.
  86689. * @returns boolean
  86690. */
  86691. static IsFileURL(): boolean;
  86692. }
  86693. }
  86694. declare module BABYLON {
  86695. /** @hidden */
  86696. export class ShaderProcessor {
  86697. static Initialize(options: ProcessingOptions): void;
  86698. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  86699. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  86700. vertexCode: string;
  86701. fragmentCode: string;
  86702. };
  86703. private static _ProcessPrecision;
  86704. private static _ExtractOperation;
  86705. private static _BuildSubExpression;
  86706. private static _BuildExpression;
  86707. private static _MoveCursorWithinIf;
  86708. private static _MoveCursor;
  86709. private static _EvaluatePreProcessors;
  86710. private static _PreparePreProcessors;
  86711. private static _ProcessShaderConversion;
  86712. private static _ProcessIncludes;
  86713. /**
  86714. * Loads a file from a url
  86715. * @param url url to load
  86716. * @param onSuccess callback called when the file successfully loads
  86717. * @param onProgress callback called while file is loading (if the server supports this mode)
  86718. * @param offlineProvider defines the offline provider for caching
  86719. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86720. * @param onError callback called when the file fails to load
  86721. * @returns a file request object
  86722. * @hidden
  86723. */
  86724. 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;
  86725. }
  86726. }
  86727. declare module BABYLON {
  86728. /**
  86729. * Interface used to define common properties for effect fallbacks
  86730. */
  86731. export interface IEffectFallbacks {
  86732. /**
  86733. * Removes the defines that should be removed when falling back.
  86734. * @param currentDefines defines the current define statements for the shader.
  86735. * @param effect defines the current effect we try to compile
  86736. * @returns The resulting defines with defines of the current rank removed.
  86737. */
  86738. reduce(currentDefines: string, effect: Effect): string;
  86739. /**
  86740. * Removes the fallback from the bound mesh.
  86741. */
  86742. unBindMesh(): void;
  86743. /**
  86744. * Checks to see if more fallbacks are still availible.
  86745. */
  86746. hasMoreFallbacks: boolean;
  86747. }
  86748. }
  86749. declare module BABYLON {
  86750. /**
  86751. * Interface for the size containing width and height
  86752. */
  86753. export interface ISize {
  86754. /**
  86755. * Width
  86756. */
  86757. width: number;
  86758. /**
  86759. * Heighht
  86760. */
  86761. height: number;
  86762. }
  86763. /**
  86764. * Size containing widht and height
  86765. */
  86766. export class Size implements ISize {
  86767. /**
  86768. * Width
  86769. */
  86770. width: number;
  86771. /**
  86772. * Height
  86773. */
  86774. height: number;
  86775. /**
  86776. * Creates a Size object from the given width and height (floats).
  86777. * @param width width of the new size
  86778. * @param height height of the new size
  86779. */
  86780. constructor(width: number, height: number);
  86781. /**
  86782. * Returns a string with the Size width and height
  86783. * @returns a string with the Size width and height
  86784. */
  86785. toString(): string;
  86786. /**
  86787. * "Size"
  86788. * @returns the string "Size"
  86789. */
  86790. getClassName(): string;
  86791. /**
  86792. * Returns the Size hash code.
  86793. * @returns a hash code for a unique width and height
  86794. */
  86795. getHashCode(): number;
  86796. /**
  86797. * Updates the current size from the given one.
  86798. * @param src the given size
  86799. */
  86800. copyFrom(src: Size): void;
  86801. /**
  86802. * Updates in place the current Size from the given floats.
  86803. * @param width width of the new size
  86804. * @param height height of the new size
  86805. * @returns the updated Size.
  86806. */
  86807. copyFromFloats(width: number, height: number): Size;
  86808. /**
  86809. * Updates in place the current Size from the given floats.
  86810. * @param width width to set
  86811. * @param height height to set
  86812. * @returns the updated Size.
  86813. */
  86814. set(width: number, height: number): Size;
  86815. /**
  86816. * Multiplies the width and height by numbers
  86817. * @param w factor to multiple the width by
  86818. * @param h factor to multiple the height by
  86819. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86820. */
  86821. multiplyByFloats(w: number, h: number): Size;
  86822. /**
  86823. * Clones the size
  86824. * @returns a new Size copied from the given one.
  86825. */
  86826. clone(): Size;
  86827. /**
  86828. * True if the current Size and the given one width and height are strictly equal.
  86829. * @param other the other size to compare against
  86830. * @returns True if the current Size and the given one width and height are strictly equal.
  86831. */
  86832. equals(other: Size): boolean;
  86833. /**
  86834. * The surface of the Size : width * height (float).
  86835. */
  86836. get surface(): number;
  86837. /**
  86838. * Create a new size of zero
  86839. * @returns a new Size set to (0.0, 0.0)
  86840. */
  86841. static Zero(): Size;
  86842. /**
  86843. * Sums the width and height of two sizes
  86844. * @param otherSize size to add to this size
  86845. * @returns a new Size set as the addition result of the current Size and the given one.
  86846. */
  86847. add(otherSize: Size): Size;
  86848. /**
  86849. * Subtracts the width and height of two
  86850. * @param otherSize size to subtract to this size
  86851. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86852. */
  86853. subtract(otherSize: Size): Size;
  86854. /**
  86855. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86856. * @param start starting size to lerp between
  86857. * @param end end size to lerp between
  86858. * @param amount amount to lerp between the start and end values
  86859. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86860. */
  86861. static Lerp(start: Size, end: Size, amount: number): Size;
  86862. }
  86863. }
  86864. declare module BABYLON {
  86865. /**
  86866. * Base class of all the textures in babylon.
  86867. * It groups all the common properties required to work with Thin Engine.
  86868. */
  86869. export class ThinTexture {
  86870. protected _wrapU: number;
  86871. /**
  86872. * | Value | Type | Description |
  86873. * | ----- | ------------------ | ----------- |
  86874. * | 0 | CLAMP_ADDRESSMODE | |
  86875. * | 1 | WRAP_ADDRESSMODE | |
  86876. * | 2 | MIRROR_ADDRESSMODE | |
  86877. */
  86878. get wrapU(): number;
  86879. set wrapU(value: number);
  86880. protected _wrapV: number;
  86881. /**
  86882. * | Value | Type | Description |
  86883. * | ----- | ------------------ | ----------- |
  86884. * | 0 | CLAMP_ADDRESSMODE | |
  86885. * | 1 | WRAP_ADDRESSMODE | |
  86886. * | 2 | MIRROR_ADDRESSMODE | |
  86887. */
  86888. get wrapV(): number;
  86889. set wrapV(value: number);
  86890. /**
  86891. * | Value | Type | Description |
  86892. * | ----- | ------------------ | ----------- |
  86893. * | 0 | CLAMP_ADDRESSMODE | |
  86894. * | 1 | WRAP_ADDRESSMODE | |
  86895. * | 2 | MIRROR_ADDRESSMODE | |
  86896. */
  86897. wrapR: number;
  86898. /**
  86899. * With compliant hardware and browser (supporting anisotropic filtering)
  86900. * this defines the level of anisotropic filtering in the texture.
  86901. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86902. */
  86903. anisotropicFilteringLevel: number;
  86904. /**
  86905. * Define the current state of the loading sequence when in delayed load mode.
  86906. */
  86907. delayLoadState: number;
  86908. /**
  86909. * How a texture is mapped.
  86910. * Unused in thin texture mode.
  86911. */
  86912. get coordinatesMode(): number;
  86913. /**
  86914. * Define if the texture is a cube texture or if false a 2d texture.
  86915. */
  86916. get isCube(): boolean;
  86917. set isCube(value: boolean);
  86918. /**
  86919. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86920. */
  86921. get is3D(): boolean;
  86922. set is3D(value: boolean);
  86923. /**
  86924. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  86925. */
  86926. get is2DArray(): boolean;
  86927. set is2DArray(value: boolean);
  86928. /**
  86929. * Get the class name of the texture.
  86930. * @returns "ThinTexture"
  86931. */
  86932. getClassName(): string;
  86933. /** @hidden */
  86934. _texture: Nullable<InternalTexture>;
  86935. protected _engine: Nullable<ThinEngine>;
  86936. private _cachedSize;
  86937. private _cachedBaseSize;
  86938. /**
  86939. * Instantiates a new ThinTexture.
  86940. * Base class of all the textures in babylon.
  86941. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  86942. * @param internalTexture Define the internalTexture to wrap
  86943. */
  86944. constructor(internalTexture: Nullable<InternalTexture>);
  86945. /**
  86946. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86947. * @returns true if fully ready
  86948. */
  86949. isReady(): boolean;
  86950. /**
  86951. * Triggers the load sequence in delayed load mode.
  86952. */
  86953. delayLoad(): void;
  86954. /**
  86955. * Get the underlying lower level texture from Babylon.
  86956. * @returns the insternal texture
  86957. */
  86958. getInternalTexture(): Nullable<InternalTexture>;
  86959. /**
  86960. * Get the size of the texture.
  86961. * @returns the texture size.
  86962. */
  86963. getSize(): ISize;
  86964. /**
  86965. * Get the base size of the texture.
  86966. * It can be different from the size if the texture has been resized for POT for instance
  86967. * @returns the base size
  86968. */
  86969. getBaseSize(): ISize;
  86970. /**
  86971. * Update the sampling mode of the texture.
  86972. * Default is Trilinear mode.
  86973. *
  86974. * | Value | Type | Description |
  86975. * | ----- | ------------------ | ----------- |
  86976. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86977. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86978. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86979. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86980. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86981. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86982. * | 7 | NEAREST_LINEAR | |
  86983. * | 8 | NEAREST_NEAREST | |
  86984. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86985. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86986. * | 11 | LINEAR_LINEAR | |
  86987. * | 12 | LINEAR_NEAREST | |
  86988. *
  86989. * > _mag_: magnification filter (close to the viewer)
  86990. * > _min_: minification filter (far from the viewer)
  86991. * > _mip_: filter used between mip map levels
  86992. *@param samplingMode Define the new sampling mode of the texture
  86993. */
  86994. updateSamplingMode(samplingMode: number): void;
  86995. /**
  86996. * Release and destroy the underlying lower level texture aka internalTexture.
  86997. */
  86998. releaseInternalTexture(): void;
  86999. /**
  87000. * Dispose the texture and release its associated resources.
  87001. */
  87002. dispose(): void;
  87003. }
  87004. }
  87005. declare module BABYLON {
  87006. /**
  87007. * Defines an array and its length.
  87008. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87009. */
  87010. export interface ISmartArrayLike<T> {
  87011. /**
  87012. * The data of the array.
  87013. */
  87014. data: Array<T>;
  87015. /**
  87016. * The active length of the array.
  87017. */
  87018. length: number;
  87019. }
  87020. /**
  87021. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87022. */
  87023. export class SmartArray<T> implements ISmartArrayLike<T> {
  87024. /**
  87025. * The full set of data from the array.
  87026. */
  87027. data: Array<T>;
  87028. /**
  87029. * The active length of the array.
  87030. */
  87031. length: number;
  87032. protected _id: number;
  87033. /**
  87034. * Instantiates a Smart Array.
  87035. * @param capacity defines the default capacity of the array.
  87036. */
  87037. constructor(capacity: number);
  87038. /**
  87039. * Pushes a value at the end of the active data.
  87040. * @param value defines the object to push in the array.
  87041. */
  87042. push(value: T): void;
  87043. /**
  87044. * Iterates over the active data and apply the lambda to them.
  87045. * @param func defines the action to apply on each value.
  87046. */
  87047. forEach(func: (content: T) => void): void;
  87048. /**
  87049. * Sorts the full sets of data.
  87050. * @param compareFn defines the comparison function to apply.
  87051. */
  87052. sort(compareFn: (a: T, b: T) => number): void;
  87053. /**
  87054. * Resets the active data to an empty array.
  87055. */
  87056. reset(): void;
  87057. /**
  87058. * Releases all the data from the array as well as the array.
  87059. */
  87060. dispose(): void;
  87061. /**
  87062. * Concats the active data with a given array.
  87063. * @param array defines the data to concatenate with.
  87064. */
  87065. concat(array: any): void;
  87066. /**
  87067. * Returns the position of a value in the active data.
  87068. * @param value defines the value to find the index for
  87069. * @returns the index if found in the active data otherwise -1
  87070. */
  87071. indexOf(value: T): number;
  87072. /**
  87073. * Returns whether an element is part of the active data.
  87074. * @param value defines the value to look for
  87075. * @returns true if found in the active data otherwise false
  87076. */
  87077. contains(value: T): boolean;
  87078. private static _GlobalId;
  87079. }
  87080. /**
  87081. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87082. * The data in this array can only be present once
  87083. */
  87084. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87085. private _duplicateId;
  87086. /**
  87087. * Pushes a value at the end of the active data.
  87088. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87089. * @param value defines the object to push in the array.
  87090. */
  87091. push(value: T): void;
  87092. /**
  87093. * Pushes a value at the end of the active data.
  87094. * If the data is already present, it won t be added again
  87095. * @param value defines the object to push in the array.
  87096. * @returns true if added false if it was already present
  87097. */
  87098. pushNoDuplicate(value: T): boolean;
  87099. /**
  87100. * Resets the active data to an empty array.
  87101. */
  87102. reset(): void;
  87103. /**
  87104. * Concats the active data with a given array.
  87105. * This ensures no dupplicate will be present in the result.
  87106. * @param array defines the data to concatenate with.
  87107. */
  87108. concatWithNoDuplicate(array: any): void;
  87109. }
  87110. }
  87111. declare module BABYLON {
  87112. /**
  87113. * Class used to evalaute queries containing `and` and `or` operators
  87114. */
  87115. export class AndOrNotEvaluator {
  87116. /**
  87117. * Evaluate a query
  87118. * @param query defines the query to evaluate
  87119. * @param evaluateCallback defines the callback used to filter result
  87120. * @returns true if the query matches
  87121. */
  87122. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  87123. private static _HandleParenthesisContent;
  87124. private static _SimplifyNegation;
  87125. }
  87126. }
  87127. declare module BABYLON {
  87128. /**
  87129. * Class used to store custom tags
  87130. */
  87131. export class Tags {
  87132. /**
  87133. * Adds support for tags on the given object
  87134. * @param obj defines the object to use
  87135. */
  87136. static EnableFor(obj: any): void;
  87137. /**
  87138. * Removes tags support
  87139. * @param obj defines the object to use
  87140. */
  87141. static DisableFor(obj: any): void;
  87142. /**
  87143. * Gets a boolean indicating if the given object has tags
  87144. * @param obj defines the object to use
  87145. * @returns a boolean
  87146. */
  87147. static HasTags(obj: any): boolean;
  87148. /**
  87149. * Gets the tags available on a given object
  87150. * @param obj defines the object to use
  87151. * @param asString defines if the tags must be returned as a string instead of an array of strings
  87152. * @returns the tags
  87153. */
  87154. static GetTags(obj: any, asString?: boolean): any;
  87155. /**
  87156. * Adds tags to an object
  87157. * @param obj defines the object to use
  87158. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  87159. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  87160. */
  87161. static AddTagsTo(obj: any, tagsString: string): void;
  87162. /**
  87163. * @hidden
  87164. */
  87165. static _AddTagTo(obj: any, tag: string): void;
  87166. /**
  87167. * Removes specific tags from a specific object
  87168. * @param obj defines the object to use
  87169. * @param tagsString defines the tags to remove
  87170. */
  87171. static RemoveTagsFrom(obj: any, tagsString: string): void;
  87172. /**
  87173. * @hidden
  87174. */
  87175. static _RemoveTagFrom(obj: any, tag: string): void;
  87176. /**
  87177. * Defines if tags hosted on an object match a given query
  87178. * @param obj defines the object to use
  87179. * @param tagsQuery defines the tag query
  87180. * @returns a boolean
  87181. */
  87182. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  87183. }
  87184. }
  87185. declare module BABYLON {
  87186. /**
  87187. * Scalar computation library
  87188. */
  87189. export class Scalar {
  87190. /**
  87191. * Two pi constants convenient for computation.
  87192. */
  87193. static TwoPi: number;
  87194. /**
  87195. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87196. * @param a number
  87197. * @param b number
  87198. * @param epsilon (default = 1.401298E-45)
  87199. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87200. */
  87201. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  87202. /**
  87203. * Returns a string : the upper case translation of the number i to hexadecimal.
  87204. * @param i number
  87205. * @returns the upper case translation of the number i to hexadecimal.
  87206. */
  87207. static ToHex(i: number): string;
  87208. /**
  87209. * Returns -1 if value is negative and +1 is value is positive.
  87210. * @param value the value
  87211. * @returns the value itself if it's equal to zero.
  87212. */
  87213. static Sign(value: number): number;
  87214. /**
  87215. * Returns the value itself if it's between min and max.
  87216. * Returns min if the value is lower than min.
  87217. * Returns max if the value is greater than max.
  87218. * @param value the value to clmap
  87219. * @param min the min value to clamp to (default: 0)
  87220. * @param max the max value to clamp to (default: 1)
  87221. * @returns the clamped value
  87222. */
  87223. static Clamp(value: number, min?: number, max?: number): number;
  87224. /**
  87225. * the log2 of value.
  87226. * @param value the value to compute log2 of
  87227. * @returns the log2 of value.
  87228. */
  87229. static Log2(value: number): number;
  87230. /**
  87231. * the floor part of a log2 value.
  87232. * @param value the value to compute log2 of
  87233. * @returns the log2 of value.
  87234. */
  87235. static ILog2(value: number): number;
  87236. /**
  87237. * Loops the value, so that it is never larger than length and never smaller than 0.
  87238. *
  87239. * This is similar to the modulo operator but it works with floating point numbers.
  87240. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  87241. * With t = 5 and length = 2.5, the result would be 0.0.
  87242. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  87243. * @param value the value
  87244. * @param length the length
  87245. * @returns the looped value
  87246. */
  87247. static Repeat(value: number, length: number): number;
  87248. /**
  87249. * Normalize the value between 0.0 and 1.0 using min and max values
  87250. * @param value value to normalize
  87251. * @param min max to normalize between
  87252. * @param max min to normalize between
  87253. * @returns the normalized value
  87254. */
  87255. static Normalize(value: number, min: number, max: number): number;
  87256. /**
  87257. * Denormalize the value from 0.0 and 1.0 using min and max values
  87258. * @param normalized value to denormalize
  87259. * @param min max to denormalize between
  87260. * @param max min to denormalize between
  87261. * @returns the denormalized value
  87262. */
  87263. static Denormalize(normalized: number, min: number, max: number): number;
  87264. /**
  87265. * Calculates the shortest difference between two given angles given in degrees.
  87266. * @param current current angle in degrees
  87267. * @param target target angle in degrees
  87268. * @returns the delta
  87269. */
  87270. static DeltaAngle(current: number, target: number): number;
  87271. /**
  87272. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  87273. * @param tx value
  87274. * @param length length
  87275. * @returns The returned value will move back and forth between 0 and length
  87276. */
  87277. static PingPong(tx: number, length: number): number;
  87278. /**
  87279. * Interpolates between min and max with smoothing at the limits.
  87280. *
  87281. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  87282. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  87283. * @param from from
  87284. * @param to to
  87285. * @param tx value
  87286. * @returns the smooth stepped value
  87287. */
  87288. static SmoothStep(from: number, to: number, tx: number): number;
  87289. /**
  87290. * Moves a value current towards target.
  87291. *
  87292. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  87293. * Negative values of maxDelta pushes the value away from target.
  87294. * @param current current value
  87295. * @param target target value
  87296. * @param maxDelta max distance to move
  87297. * @returns resulting value
  87298. */
  87299. static MoveTowards(current: number, target: number, maxDelta: number): number;
  87300. /**
  87301. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87302. *
  87303. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  87304. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  87305. * @param current current value
  87306. * @param target target value
  87307. * @param maxDelta max distance to move
  87308. * @returns resulting angle
  87309. */
  87310. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  87311. /**
  87312. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  87313. * @param start start value
  87314. * @param end target value
  87315. * @param amount amount to lerp between
  87316. * @returns the lerped value
  87317. */
  87318. static Lerp(start: number, end: number, amount: number): number;
  87319. /**
  87320. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87321. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  87322. * @param start start value
  87323. * @param end target value
  87324. * @param amount amount to lerp between
  87325. * @returns the lerped value
  87326. */
  87327. static LerpAngle(start: number, end: number, amount: number): number;
  87328. /**
  87329. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  87330. * @param a start value
  87331. * @param b target value
  87332. * @param value value between a and b
  87333. * @returns the inverseLerp value
  87334. */
  87335. static InverseLerp(a: number, b: number, value: number): number;
  87336. /**
  87337. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  87338. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  87339. * @param value1 spline value
  87340. * @param tangent1 spline value
  87341. * @param value2 spline value
  87342. * @param tangent2 spline value
  87343. * @param amount input value
  87344. * @returns hermite result
  87345. */
  87346. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  87347. /**
  87348. * Returns a random float number between and min and max values
  87349. * @param min min value of random
  87350. * @param max max value of random
  87351. * @returns random value
  87352. */
  87353. static RandomRange(min: number, max: number): number;
  87354. /**
  87355. * This function returns percentage of a number in a given range.
  87356. *
  87357. * RangeToPercent(40,20,60) will return 0.5 (50%)
  87358. * RangeToPercent(34,0,100) will return 0.34 (34%)
  87359. * @param number to convert to percentage
  87360. * @param min min range
  87361. * @param max max range
  87362. * @returns the percentage
  87363. */
  87364. static RangeToPercent(number: number, min: number, max: number): number;
  87365. /**
  87366. * This function returns number that corresponds to the percentage in a given range.
  87367. *
  87368. * PercentToRange(0.34,0,100) will return 34.
  87369. * @param percent to convert to number
  87370. * @param min min range
  87371. * @param max max range
  87372. * @returns the number
  87373. */
  87374. static PercentToRange(percent: number, min: number, max: number): number;
  87375. /**
  87376. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  87377. * @param angle The angle to normalize in radian.
  87378. * @return The converted angle.
  87379. */
  87380. static NormalizeRadians(angle: number): number;
  87381. }
  87382. }
  87383. declare module BABYLON {
  87384. /**
  87385. * Constant used to convert a value to gamma space
  87386. * @ignorenaming
  87387. */
  87388. export const ToGammaSpace: number;
  87389. /**
  87390. * Constant used to convert a value to linear space
  87391. * @ignorenaming
  87392. */
  87393. export const ToLinearSpace = 2.2;
  87394. /**
  87395. * Constant used to define the minimal number value in Babylon.js
  87396. * @ignorenaming
  87397. */
  87398. let Epsilon: number;
  87399. }
  87400. declare module BABYLON {
  87401. /**
  87402. * Class used to represent a viewport on screen
  87403. */
  87404. export class Viewport {
  87405. /** viewport left coordinate */
  87406. x: number;
  87407. /** viewport top coordinate */
  87408. y: number;
  87409. /**viewport width */
  87410. width: number;
  87411. /** viewport height */
  87412. height: number;
  87413. /**
  87414. * Creates a Viewport object located at (x, y) and sized (width, height)
  87415. * @param x defines viewport left coordinate
  87416. * @param y defines viewport top coordinate
  87417. * @param width defines the viewport width
  87418. * @param height defines the viewport height
  87419. */
  87420. constructor(
  87421. /** viewport left coordinate */
  87422. x: number,
  87423. /** viewport top coordinate */
  87424. y: number,
  87425. /**viewport width */
  87426. width: number,
  87427. /** viewport height */
  87428. height: number);
  87429. /**
  87430. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87431. * @param renderWidth defines the rendering width
  87432. * @param renderHeight defines the rendering height
  87433. * @returns a new Viewport
  87434. */
  87435. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  87436. /**
  87437. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87438. * @param renderWidth defines the rendering width
  87439. * @param renderHeight defines the rendering height
  87440. * @param ref defines the target viewport
  87441. * @returns the current viewport
  87442. */
  87443. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  87444. /**
  87445. * Returns a new Viewport copied from the current one
  87446. * @returns a new Viewport
  87447. */
  87448. clone(): Viewport;
  87449. }
  87450. }
  87451. declare module BABYLON {
  87452. /**
  87453. * Class containing a set of static utilities functions for arrays.
  87454. */
  87455. export class ArrayTools {
  87456. /**
  87457. * Returns an array of the given size filled with element built from the given constructor and the paramters
  87458. * @param size the number of element to construct and put in the array
  87459. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  87460. * @returns a new array filled with new objects
  87461. */
  87462. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  87463. }
  87464. }
  87465. declare module BABYLON {
  87466. /**
  87467. * Represents a plane by the equation ax + by + cz + d = 0
  87468. */
  87469. export class Plane {
  87470. private static _TmpMatrix;
  87471. /**
  87472. * Normal of the plane (a,b,c)
  87473. */
  87474. normal: Vector3;
  87475. /**
  87476. * d component of the plane
  87477. */
  87478. d: number;
  87479. /**
  87480. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  87481. * @param a a component of the plane
  87482. * @param b b component of the plane
  87483. * @param c c component of the plane
  87484. * @param d d component of the plane
  87485. */
  87486. constructor(a: number, b: number, c: number, d: number);
  87487. /**
  87488. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  87489. */
  87490. asArray(): number[];
  87491. /**
  87492. * @returns a new plane copied from the current Plane.
  87493. */
  87494. clone(): Plane;
  87495. /**
  87496. * @returns the string "Plane".
  87497. */
  87498. getClassName(): string;
  87499. /**
  87500. * @returns the Plane hash code.
  87501. */
  87502. getHashCode(): number;
  87503. /**
  87504. * Normalize the current Plane in place.
  87505. * @returns the updated Plane.
  87506. */
  87507. normalize(): Plane;
  87508. /**
  87509. * Applies a transformation the plane and returns the result
  87510. * @param transformation the transformation matrix to be applied to the plane
  87511. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  87512. */
  87513. transform(transformation: DeepImmutable<Matrix>): Plane;
  87514. /**
  87515. * Compute the dot product between the point and the plane normal
  87516. * @param point point to calculate the dot product with
  87517. * @returns the dot product (float) of the point coordinates and the plane normal.
  87518. */
  87519. dotCoordinate(point: DeepImmutable<Vector3>): number;
  87520. /**
  87521. * Updates the current Plane from the plane defined by the three given points.
  87522. * @param point1 one of the points used to contruct the plane
  87523. * @param point2 one of the points used to contruct the plane
  87524. * @param point3 one of the points used to contruct the plane
  87525. * @returns the updated Plane.
  87526. */
  87527. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87528. /**
  87529. * 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).
  87530. * Note that for this function to work as expected you should make sure that:
  87531. * - direction and the plane normal are normalized
  87532. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  87533. * @param direction the direction to check if the plane is facing
  87534. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  87535. * @returns True if the plane is facing the given direction
  87536. */
  87537. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  87538. /**
  87539. * Calculates the distance to a point
  87540. * @param point point to calculate distance to
  87541. * @returns the signed distance (float) from the given point to the Plane.
  87542. */
  87543. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  87544. /**
  87545. * Creates a plane from an array
  87546. * @param array the array to create a plane from
  87547. * @returns a new Plane from the given array.
  87548. */
  87549. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  87550. /**
  87551. * Creates a plane from three points
  87552. * @param point1 point used to create the plane
  87553. * @param point2 point used to create the plane
  87554. * @param point3 point used to create the plane
  87555. * @returns a new Plane defined by the three given points.
  87556. */
  87557. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87558. /**
  87559. * Creates a plane from an origin point and a normal
  87560. * @param origin origin of the plane to be constructed
  87561. * @param normal normal of the plane to be constructed
  87562. * @returns a new Plane the normal vector to this plane at the given origin point.
  87563. * Note : the vector "normal" is updated because normalized.
  87564. */
  87565. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  87566. /**
  87567. * Calculates the distance from a plane and a point
  87568. * @param origin origin of the plane to be constructed
  87569. * @param normal normal of the plane to be constructed
  87570. * @param point point to calculate distance to
  87571. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  87572. */
  87573. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  87574. }
  87575. }
  87576. declare module BABYLON {
  87577. /** @hidden */
  87578. export class PerformanceConfigurator {
  87579. /** @hidden */
  87580. static MatrixUse64Bits: boolean;
  87581. /** @hidden */
  87582. static MatrixTrackPrecisionChange: boolean;
  87583. /** @hidden */
  87584. static MatrixCurrentType: any;
  87585. /** @hidden */
  87586. static MatrixTrackedMatrices: Array<any> | null;
  87587. /** @hidden */
  87588. static SetMatrixPrecision(use64bits: boolean): void;
  87589. }
  87590. }
  87591. declare module BABYLON {
  87592. /**
  87593. * Class representing a vector containing 2 coordinates
  87594. */
  87595. export class Vector2 {
  87596. /** defines the first coordinate */
  87597. x: number;
  87598. /** defines the second coordinate */
  87599. y: number;
  87600. /**
  87601. * Creates a new Vector2 from the given x and y coordinates
  87602. * @param x defines the first coordinate
  87603. * @param y defines the second coordinate
  87604. */
  87605. constructor(
  87606. /** defines the first coordinate */
  87607. x?: number,
  87608. /** defines the second coordinate */
  87609. y?: number);
  87610. /**
  87611. * Gets a string with the Vector2 coordinates
  87612. * @returns a string with the Vector2 coordinates
  87613. */
  87614. toString(): string;
  87615. /**
  87616. * Gets class name
  87617. * @returns the string "Vector2"
  87618. */
  87619. getClassName(): string;
  87620. /**
  87621. * Gets current vector hash code
  87622. * @returns the Vector2 hash code as a number
  87623. */
  87624. getHashCode(): number;
  87625. /**
  87626. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  87627. * @param array defines the source array
  87628. * @param index defines the offset in source array
  87629. * @returns the current Vector2
  87630. */
  87631. toArray(array: FloatArray, index?: number): Vector2;
  87632. /**
  87633. * Update the current vector from an array
  87634. * @param array defines the destination array
  87635. * @param index defines the offset in the destination array
  87636. * @returns the current Vector3
  87637. */
  87638. fromArray(array: FloatArray, index?: number): Vector2;
  87639. /**
  87640. * Copy the current vector to an array
  87641. * @returns a new array with 2 elements: the Vector2 coordinates.
  87642. */
  87643. asArray(): number[];
  87644. /**
  87645. * Sets the Vector2 coordinates with the given Vector2 coordinates
  87646. * @param source defines the source Vector2
  87647. * @returns the current updated Vector2
  87648. */
  87649. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  87650. /**
  87651. * Sets the Vector2 coordinates with the given floats
  87652. * @param x defines the first coordinate
  87653. * @param y defines the second coordinate
  87654. * @returns the current updated Vector2
  87655. */
  87656. copyFromFloats(x: number, y: number): Vector2;
  87657. /**
  87658. * Sets the Vector2 coordinates with the given floats
  87659. * @param x defines the first coordinate
  87660. * @param y defines the second coordinate
  87661. * @returns the current updated Vector2
  87662. */
  87663. set(x: number, y: number): Vector2;
  87664. /**
  87665. * Add another vector with the current one
  87666. * @param otherVector defines the other vector
  87667. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  87668. */
  87669. add(otherVector: DeepImmutable<Vector2>): Vector2;
  87670. /**
  87671. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  87672. * @param otherVector defines the other vector
  87673. * @param result defines the target vector
  87674. * @returns the unmodified current Vector2
  87675. */
  87676. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87677. /**
  87678. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  87679. * @param otherVector defines the other vector
  87680. * @returns the current updated Vector2
  87681. */
  87682. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87683. /**
  87684. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  87685. * @param otherVector defines the other vector
  87686. * @returns a new Vector2
  87687. */
  87688. addVector3(otherVector: Vector3): Vector2;
  87689. /**
  87690. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  87691. * @param otherVector defines the other vector
  87692. * @returns a new Vector2
  87693. */
  87694. subtract(otherVector: Vector2): Vector2;
  87695. /**
  87696. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  87697. * @param otherVector defines the other vector
  87698. * @param result defines the target vector
  87699. * @returns the unmodified current Vector2
  87700. */
  87701. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87702. /**
  87703. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  87704. * @param otherVector defines the other vector
  87705. * @returns the current updated Vector2
  87706. */
  87707. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87708. /**
  87709. * Multiplies in place the current Vector2 coordinates by the given ones
  87710. * @param otherVector defines the other vector
  87711. * @returns the current updated Vector2
  87712. */
  87713. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87714. /**
  87715. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  87716. * @param otherVector defines the other vector
  87717. * @returns a new Vector2
  87718. */
  87719. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  87720. /**
  87721. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  87722. * @param otherVector defines the other vector
  87723. * @param result defines the target vector
  87724. * @returns the unmodified current Vector2
  87725. */
  87726. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87727. /**
  87728. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  87729. * @param x defines the first coordinate
  87730. * @param y defines the second coordinate
  87731. * @returns a new Vector2
  87732. */
  87733. multiplyByFloats(x: number, y: number): Vector2;
  87734. /**
  87735. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  87736. * @param otherVector defines the other vector
  87737. * @returns a new Vector2
  87738. */
  87739. divide(otherVector: Vector2): Vector2;
  87740. /**
  87741. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  87742. * @param otherVector defines the other vector
  87743. * @param result defines the target vector
  87744. * @returns the unmodified current Vector2
  87745. */
  87746. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87747. /**
  87748. * Divides the current Vector2 coordinates by the given ones
  87749. * @param otherVector defines the other vector
  87750. * @returns the current updated Vector2
  87751. */
  87752. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87753. /**
  87754. * Gets a new Vector2 with current Vector2 negated coordinates
  87755. * @returns a new Vector2
  87756. */
  87757. negate(): Vector2;
  87758. /**
  87759. * Negate this vector in place
  87760. * @returns this
  87761. */
  87762. negateInPlace(): Vector2;
  87763. /**
  87764. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  87765. * @param result defines the Vector3 object where to store the result
  87766. * @returns the current Vector2
  87767. */
  87768. negateToRef(result: Vector2): Vector2;
  87769. /**
  87770. * Multiply the Vector2 coordinates by scale
  87771. * @param scale defines the scaling factor
  87772. * @returns the current updated Vector2
  87773. */
  87774. scaleInPlace(scale: number): Vector2;
  87775. /**
  87776. * Returns a new Vector2 scaled by "scale" from the current Vector2
  87777. * @param scale defines the scaling factor
  87778. * @returns a new Vector2
  87779. */
  87780. scale(scale: number): Vector2;
  87781. /**
  87782. * Scale the current Vector2 values by a factor to a given Vector2
  87783. * @param scale defines the scale factor
  87784. * @param result defines the Vector2 object where to store the result
  87785. * @returns the unmodified current Vector2
  87786. */
  87787. scaleToRef(scale: number, result: Vector2): Vector2;
  87788. /**
  87789. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  87790. * @param scale defines the scale factor
  87791. * @param result defines the Vector2 object where to store the result
  87792. * @returns the unmodified current Vector2
  87793. */
  87794. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  87795. /**
  87796. * Gets a boolean if two vectors are equals
  87797. * @param otherVector defines the other vector
  87798. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  87799. */
  87800. equals(otherVector: DeepImmutable<Vector2>): boolean;
  87801. /**
  87802. * Gets a boolean if two vectors are equals (using an epsilon value)
  87803. * @param otherVector defines the other vector
  87804. * @param epsilon defines the minimal distance to consider equality
  87805. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  87806. */
  87807. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  87808. /**
  87809. * Gets a new Vector2 from current Vector2 floored values
  87810. * @returns a new Vector2
  87811. */
  87812. floor(): Vector2;
  87813. /**
  87814. * Gets a new Vector2 from current Vector2 floored values
  87815. * @returns a new Vector2
  87816. */
  87817. fract(): Vector2;
  87818. /**
  87819. * Gets the length of the vector
  87820. * @returns the vector length (float)
  87821. */
  87822. length(): number;
  87823. /**
  87824. * Gets the vector squared length
  87825. * @returns the vector squared length (float)
  87826. */
  87827. lengthSquared(): number;
  87828. /**
  87829. * Normalize the vector
  87830. * @returns the current updated Vector2
  87831. */
  87832. normalize(): Vector2;
  87833. /**
  87834. * Gets a new Vector2 copied from the Vector2
  87835. * @returns a new Vector2
  87836. */
  87837. clone(): Vector2;
  87838. /**
  87839. * Gets a new Vector2(0, 0)
  87840. * @returns a new Vector2
  87841. */
  87842. static Zero(): Vector2;
  87843. /**
  87844. * Gets a new Vector2(1, 1)
  87845. * @returns a new Vector2
  87846. */
  87847. static One(): Vector2;
  87848. /**
  87849. * Gets a new Vector2 set from the given index element of the given array
  87850. * @param array defines the data source
  87851. * @param offset defines the offset in the data source
  87852. * @returns a new Vector2
  87853. */
  87854. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  87855. /**
  87856. * Sets "result" from the given index element of the given array
  87857. * @param array defines the data source
  87858. * @param offset defines the offset in the data source
  87859. * @param result defines the target vector
  87860. */
  87861. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  87862. /**
  87863. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  87864. * @param value1 defines 1st point of control
  87865. * @param value2 defines 2nd point of control
  87866. * @param value3 defines 3rd point of control
  87867. * @param value4 defines 4th point of control
  87868. * @param amount defines the interpolation factor
  87869. * @returns a new Vector2
  87870. */
  87871. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  87872. /**
  87873. * 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".
  87874. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  87875. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  87876. * @param value defines the value to clamp
  87877. * @param min defines the lower limit
  87878. * @param max defines the upper limit
  87879. * @returns a new Vector2
  87880. */
  87881. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  87882. /**
  87883. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  87884. * @param value1 defines the 1st control point
  87885. * @param tangent1 defines the outgoing tangent
  87886. * @param value2 defines the 2nd control point
  87887. * @param tangent2 defines the incoming tangent
  87888. * @param amount defines the interpolation factor
  87889. * @returns a new Vector2
  87890. */
  87891. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  87892. /**
  87893. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  87894. * @param start defines the start vector
  87895. * @param end defines the end vector
  87896. * @param amount defines the interpolation factor
  87897. * @returns a new Vector2
  87898. */
  87899. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  87900. /**
  87901. * Gets the dot product of the vector "left" and the vector "right"
  87902. * @param left defines first vector
  87903. * @param right defines second vector
  87904. * @returns the dot product (float)
  87905. */
  87906. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  87907. /**
  87908. * Returns a new Vector2 equal to the normalized given vector
  87909. * @param vector defines the vector to normalize
  87910. * @returns a new Vector2
  87911. */
  87912. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  87913. /**
  87914. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  87915. * @param left defines 1st vector
  87916. * @param right defines 2nd vector
  87917. * @returns a new Vector2
  87918. */
  87919. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87920. /**
  87921. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  87922. * @param left defines 1st vector
  87923. * @param right defines 2nd vector
  87924. * @returns a new Vector2
  87925. */
  87926. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87927. /**
  87928. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  87929. * @param vector defines the vector to transform
  87930. * @param transformation defines the matrix to apply
  87931. * @returns a new Vector2
  87932. */
  87933. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  87934. /**
  87935. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  87936. * @param vector defines the vector to transform
  87937. * @param transformation defines the matrix to apply
  87938. * @param result defines the target vector
  87939. */
  87940. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  87941. /**
  87942. * Determines if a given vector is included in a triangle
  87943. * @param p defines the vector to test
  87944. * @param p0 defines 1st triangle point
  87945. * @param p1 defines 2nd triangle point
  87946. * @param p2 defines 3rd triangle point
  87947. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  87948. */
  87949. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  87950. /**
  87951. * Gets the distance between the vectors "value1" and "value2"
  87952. * @param value1 defines first vector
  87953. * @param value2 defines second vector
  87954. * @returns the distance between vectors
  87955. */
  87956. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87957. /**
  87958. * Returns the squared distance between the vectors "value1" and "value2"
  87959. * @param value1 defines first vector
  87960. * @param value2 defines second vector
  87961. * @returns the squared distance between vectors
  87962. */
  87963. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87964. /**
  87965. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  87966. * @param value1 defines first vector
  87967. * @param value2 defines second vector
  87968. * @returns a new Vector2
  87969. */
  87970. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  87971. /**
  87972. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  87973. * @param value1 defines first vector
  87974. * @param value2 defines second vector
  87975. * @param ref defines third vector
  87976. * @returns ref
  87977. */
  87978. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  87979. /**
  87980. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  87981. * @param p defines the middle point
  87982. * @param segA defines one point of the segment
  87983. * @param segB defines the other point of the segment
  87984. * @returns the shortest distance
  87985. */
  87986. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  87987. }
  87988. /**
  87989. * Class used to store (x,y,z) vector representation
  87990. * A Vector3 is the main object used in 3D geometry
  87991. * It can represent etiher the coordinates of a point the space, either a direction
  87992. * Reminder: js uses a left handed forward facing system
  87993. */
  87994. export class Vector3 {
  87995. private static _UpReadOnly;
  87996. private static _ZeroReadOnly;
  87997. /** @hidden */
  87998. _x: number;
  87999. /** @hidden */
  88000. _y: number;
  88001. /** @hidden */
  88002. _z: number;
  88003. /** @hidden */
  88004. _isDirty: boolean;
  88005. /** Gets or sets the x coordinate */
  88006. get x(): number;
  88007. set x(value: number);
  88008. /** Gets or sets the y coordinate */
  88009. get y(): number;
  88010. set y(value: number);
  88011. /** Gets or sets the z coordinate */
  88012. get z(): number;
  88013. set z(value: number);
  88014. /**
  88015. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  88016. * @param x defines the first coordinates (on X axis)
  88017. * @param y defines the second coordinates (on Y axis)
  88018. * @param z defines the third coordinates (on Z axis)
  88019. */
  88020. constructor(x?: number, y?: number, z?: number);
  88021. /**
  88022. * Creates a string representation of the Vector3
  88023. * @returns a string with the Vector3 coordinates.
  88024. */
  88025. toString(): string;
  88026. /**
  88027. * Gets the class name
  88028. * @returns the string "Vector3"
  88029. */
  88030. getClassName(): string;
  88031. /**
  88032. * Creates the Vector3 hash code
  88033. * @returns a number which tends to be unique between Vector3 instances
  88034. */
  88035. getHashCode(): number;
  88036. /**
  88037. * Creates an array containing three elements : the coordinates of the Vector3
  88038. * @returns a new array of numbers
  88039. */
  88040. asArray(): number[];
  88041. /**
  88042. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  88043. * @param array defines the destination array
  88044. * @param index defines the offset in the destination array
  88045. * @returns the current Vector3
  88046. */
  88047. toArray(array: FloatArray, index?: number): Vector3;
  88048. /**
  88049. * Update the current vector from an array
  88050. * @param array defines the destination array
  88051. * @param index defines the offset in the destination array
  88052. * @returns the current Vector3
  88053. */
  88054. fromArray(array: FloatArray, index?: number): Vector3;
  88055. /**
  88056. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  88057. * @returns a new Quaternion object, computed from the Vector3 coordinates
  88058. */
  88059. toQuaternion(): Quaternion;
  88060. /**
  88061. * Adds the given vector to the current Vector3
  88062. * @param otherVector defines the second operand
  88063. * @returns the current updated Vector3
  88064. */
  88065. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88066. /**
  88067. * Adds the given coordinates to the current Vector3
  88068. * @param x defines the x coordinate of the operand
  88069. * @param y defines the y coordinate of the operand
  88070. * @param z defines the z coordinate of the operand
  88071. * @returns the current updated Vector3
  88072. */
  88073. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88074. /**
  88075. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  88076. * @param otherVector defines the second operand
  88077. * @returns the resulting Vector3
  88078. */
  88079. add(otherVector: DeepImmutable<Vector3>): Vector3;
  88080. /**
  88081. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  88082. * @param otherVector defines the second operand
  88083. * @param result defines the Vector3 object where to store the result
  88084. * @returns the current Vector3
  88085. */
  88086. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88087. /**
  88088. * Subtract the given vector from the current Vector3
  88089. * @param otherVector defines the second operand
  88090. * @returns the current updated Vector3
  88091. */
  88092. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88093. /**
  88094. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  88095. * @param otherVector defines the second operand
  88096. * @returns the resulting Vector3
  88097. */
  88098. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  88099. /**
  88100. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  88101. * @param otherVector defines the second operand
  88102. * @param result defines the Vector3 object where to store the result
  88103. * @returns the current Vector3
  88104. */
  88105. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88106. /**
  88107. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  88108. * @param x defines the x coordinate of the operand
  88109. * @param y defines the y coordinate of the operand
  88110. * @param z defines the z coordinate of the operand
  88111. * @returns the resulting Vector3
  88112. */
  88113. subtractFromFloats(x: number, y: number, z: number): Vector3;
  88114. /**
  88115. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  88116. * @param x defines the x coordinate of the operand
  88117. * @param y defines the y coordinate of the operand
  88118. * @param z defines the z coordinate of the operand
  88119. * @param result defines the Vector3 object where to store the result
  88120. * @returns the current Vector3
  88121. */
  88122. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  88123. /**
  88124. * Gets a new Vector3 set with the current Vector3 negated coordinates
  88125. * @returns a new Vector3
  88126. */
  88127. negate(): Vector3;
  88128. /**
  88129. * Negate this vector in place
  88130. * @returns this
  88131. */
  88132. negateInPlace(): Vector3;
  88133. /**
  88134. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  88135. * @param result defines the Vector3 object where to store the result
  88136. * @returns the current Vector3
  88137. */
  88138. negateToRef(result: Vector3): Vector3;
  88139. /**
  88140. * Multiplies the Vector3 coordinates by the float "scale"
  88141. * @param scale defines the multiplier factor
  88142. * @returns the current updated Vector3
  88143. */
  88144. scaleInPlace(scale: number): Vector3;
  88145. /**
  88146. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  88147. * @param scale defines the multiplier factor
  88148. * @returns a new Vector3
  88149. */
  88150. scale(scale: number): Vector3;
  88151. /**
  88152. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  88153. * @param scale defines the multiplier factor
  88154. * @param result defines the Vector3 object where to store the result
  88155. * @returns the current Vector3
  88156. */
  88157. scaleToRef(scale: number, result: Vector3): Vector3;
  88158. /**
  88159. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  88160. * @param scale defines the scale factor
  88161. * @param result defines the Vector3 object where to store the result
  88162. * @returns the unmodified current Vector3
  88163. */
  88164. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  88165. /**
  88166. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88167. * @param origin defines the origin of the projection ray
  88168. * @param plane defines the plane to project to
  88169. * @returns the projected vector3
  88170. */
  88171. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  88172. /**
  88173. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88174. * @param origin defines the origin of the projection ray
  88175. * @param plane defines the plane to project to
  88176. * @param result defines the Vector3 where to store the result
  88177. */
  88178. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  88179. /**
  88180. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  88181. * @param otherVector defines the second operand
  88182. * @returns true if both vectors are equals
  88183. */
  88184. equals(otherVector: DeepImmutable<Vector3>): boolean;
  88185. /**
  88186. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  88187. * @param otherVector defines the second operand
  88188. * @param epsilon defines the minimal distance to define values as equals
  88189. * @returns true if both vectors are distant less than epsilon
  88190. */
  88191. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  88192. /**
  88193. * Returns true if the current Vector3 coordinates equals the given floats
  88194. * @param x defines the x coordinate of the operand
  88195. * @param y defines the y coordinate of the operand
  88196. * @param z defines the z coordinate of the operand
  88197. * @returns true if both vectors are equals
  88198. */
  88199. equalsToFloats(x: number, y: number, z: number): boolean;
  88200. /**
  88201. * Multiplies the current Vector3 coordinates by the given ones
  88202. * @param otherVector defines the second operand
  88203. * @returns the current updated Vector3
  88204. */
  88205. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88206. /**
  88207. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  88208. * @param otherVector defines the second operand
  88209. * @returns the new Vector3
  88210. */
  88211. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  88212. /**
  88213. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  88214. * @param otherVector defines the second operand
  88215. * @param result defines the Vector3 object where to store the result
  88216. * @returns the current Vector3
  88217. */
  88218. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88219. /**
  88220. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  88221. * @param x defines the x coordinate of the operand
  88222. * @param y defines the y coordinate of the operand
  88223. * @param z defines the z coordinate of the operand
  88224. * @returns the new Vector3
  88225. */
  88226. multiplyByFloats(x: number, y: number, z: number): Vector3;
  88227. /**
  88228. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  88229. * @param otherVector defines the second operand
  88230. * @returns the new Vector3
  88231. */
  88232. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  88233. /**
  88234. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  88235. * @param otherVector defines the second operand
  88236. * @param result defines the Vector3 object where to store the result
  88237. * @returns the current Vector3
  88238. */
  88239. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88240. /**
  88241. * Divides the current Vector3 coordinates by the given ones.
  88242. * @param otherVector defines the second operand
  88243. * @returns the current updated Vector3
  88244. */
  88245. divideInPlace(otherVector: Vector3): Vector3;
  88246. /**
  88247. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  88248. * @param other defines the second operand
  88249. * @returns the current updated Vector3
  88250. */
  88251. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88252. /**
  88253. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  88254. * @param other defines the second operand
  88255. * @returns the current updated Vector3
  88256. */
  88257. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88258. /**
  88259. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  88260. * @param x defines the x coordinate of the operand
  88261. * @param y defines the y coordinate of the operand
  88262. * @param z defines the z coordinate of the operand
  88263. * @returns the current updated Vector3
  88264. */
  88265. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88266. /**
  88267. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  88268. * @param x defines the x coordinate of the operand
  88269. * @param y defines the y coordinate of the operand
  88270. * @param z defines the z coordinate of the operand
  88271. * @returns the current updated Vector3
  88272. */
  88273. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88274. /**
  88275. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  88276. * Check if is non uniform within a certain amount of decimal places to account for this
  88277. * @param epsilon the amount the values can differ
  88278. * @returns if the the vector is non uniform to a certain number of decimal places
  88279. */
  88280. isNonUniformWithinEpsilon(epsilon: number): boolean;
  88281. /**
  88282. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  88283. */
  88284. get isNonUniform(): boolean;
  88285. /**
  88286. * Gets a new Vector3 from current Vector3 floored values
  88287. * @returns a new Vector3
  88288. */
  88289. floor(): Vector3;
  88290. /**
  88291. * Gets a new Vector3 from current Vector3 floored values
  88292. * @returns a new Vector3
  88293. */
  88294. fract(): Vector3;
  88295. /**
  88296. * Gets the length of the Vector3
  88297. * @returns the length of the Vector3
  88298. */
  88299. length(): number;
  88300. /**
  88301. * Gets the squared length of the Vector3
  88302. * @returns squared length of the Vector3
  88303. */
  88304. lengthSquared(): number;
  88305. /**
  88306. * Normalize the current Vector3.
  88307. * Please note that this is an in place operation.
  88308. * @returns the current updated Vector3
  88309. */
  88310. normalize(): Vector3;
  88311. /**
  88312. * Reorders the x y z properties of the vector in place
  88313. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  88314. * @returns the current updated vector
  88315. */
  88316. reorderInPlace(order: string): this;
  88317. /**
  88318. * Rotates the vector around 0,0,0 by a quaternion
  88319. * @param quaternion the rotation quaternion
  88320. * @param result vector to store the result
  88321. * @returns the resulting vector
  88322. */
  88323. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  88324. /**
  88325. * Rotates a vector around a given point
  88326. * @param quaternion the rotation quaternion
  88327. * @param point the point to rotate around
  88328. * @param result vector to store the result
  88329. * @returns the resulting vector
  88330. */
  88331. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  88332. /**
  88333. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  88334. * The cross product is then orthogonal to both current and "other"
  88335. * @param other defines the right operand
  88336. * @returns the cross product
  88337. */
  88338. cross(other: Vector3): Vector3;
  88339. /**
  88340. * Normalize the current Vector3 with the given input length.
  88341. * Please note that this is an in place operation.
  88342. * @param len the length of the vector
  88343. * @returns the current updated Vector3
  88344. */
  88345. normalizeFromLength(len: number): Vector3;
  88346. /**
  88347. * Normalize the current Vector3 to a new vector
  88348. * @returns the new Vector3
  88349. */
  88350. normalizeToNew(): Vector3;
  88351. /**
  88352. * Normalize the current Vector3 to the reference
  88353. * @param reference define the Vector3 to update
  88354. * @returns the updated Vector3
  88355. */
  88356. normalizeToRef(reference: Vector3): Vector3;
  88357. /**
  88358. * Creates a new Vector3 copied from the current Vector3
  88359. * @returns the new Vector3
  88360. */
  88361. clone(): Vector3;
  88362. /**
  88363. * Copies the given vector coordinates to the current Vector3 ones
  88364. * @param source defines the source Vector3
  88365. * @returns the current updated Vector3
  88366. */
  88367. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  88368. /**
  88369. * Copies the given floats to the current Vector3 coordinates
  88370. * @param x defines the x coordinate of the operand
  88371. * @param y defines the y coordinate of the operand
  88372. * @param z defines the z coordinate of the operand
  88373. * @returns the current updated Vector3
  88374. */
  88375. copyFromFloats(x: number, y: number, z: number): Vector3;
  88376. /**
  88377. * Copies the given floats to the current Vector3 coordinates
  88378. * @param x defines the x coordinate of the operand
  88379. * @param y defines the y coordinate of the operand
  88380. * @param z defines the z coordinate of the operand
  88381. * @returns the current updated Vector3
  88382. */
  88383. set(x: number, y: number, z: number): Vector3;
  88384. /**
  88385. * Copies the given float to the current Vector3 coordinates
  88386. * @param v defines the x, y and z coordinates of the operand
  88387. * @returns the current updated Vector3
  88388. */
  88389. setAll(v: number): Vector3;
  88390. /**
  88391. * Get the clip factor between two vectors
  88392. * @param vector0 defines the first operand
  88393. * @param vector1 defines the second operand
  88394. * @param axis defines the axis to use
  88395. * @param size defines the size along the axis
  88396. * @returns the clip factor
  88397. */
  88398. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  88399. /**
  88400. * Get angle between two vectors
  88401. * @param vector0 angle between vector0 and vector1
  88402. * @param vector1 angle between vector0 and vector1
  88403. * @param normal direction of the normal
  88404. * @return the angle between vector0 and vector1
  88405. */
  88406. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  88407. /**
  88408. * Returns a new Vector3 set from the index "offset" of the given array
  88409. * @param array defines the source array
  88410. * @param offset defines the offset in the source array
  88411. * @returns the new Vector3
  88412. */
  88413. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  88414. /**
  88415. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  88416. * @param array defines the source array
  88417. * @param offset defines the offset in the source array
  88418. * @returns the new Vector3
  88419. * @deprecated Please use FromArray instead.
  88420. */
  88421. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  88422. /**
  88423. * Sets the given vector "result" with the element values from the index "offset" of the given array
  88424. * @param array defines the source array
  88425. * @param offset defines the offset in the source array
  88426. * @param result defines the Vector3 where to store the result
  88427. */
  88428. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  88429. /**
  88430. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  88431. * @param array defines the source array
  88432. * @param offset defines the offset in the source array
  88433. * @param result defines the Vector3 where to store the result
  88434. * @deprecated Please use FromArrayToRef instead.
  88435. */
  88436. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  88437. /**
  88438. * Sets the given vector "result" with the given floats.
  88439. * @param x defines the x coordinate of the source
  88440. * @param y defines the y coordinate of the source
  88441. * @param z defines the z coordinate of the source
  88442. * @param result defines the Vector3 where to store the result
  88443. */
  88444. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  88445. /**
  88446. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  88447. * @returns a new empty Vector3
  88448. */
  88449. static Zero(): Vector3;
  88450. /**
  88451. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  88452. * @returns a new unit Vector3
  88453. */
  88454. static One(): Vector3;
  88455. /**
  88456. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  88457. * @returns a new up Vector3
  88458. */
  88459. static Up(): Vector3;
  88460. /**
  88461. * Gets a up Vector3 that must not be updated
  88462. */
  88463. static get UpReadOnly(): DeepImmutable<Vector3>;
  88464. /**
  88465. * Gets a zero Vector3 that must not be updated
  88466. */
  88467. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  88468. /**
  88469. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  88470. * @returns a new down Vector3
  88471. */
  88472. static Down(): Vector3;
  88473. /**
  88474. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  88475. * @param rightHandedSystem is the scene right-handed (negative z)
  88476. * @returns a new forward Vector3
  88477. */
  88478. static Forward(rightHandedSystem?: boolean): Vector3;
  88479. /**
  88480. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  88481. * @param rightHandedSystem is the scene right-handed (negative-z)
  88482. * @returns a new forward Vector3
  88483. */
  88484. static Backward(rightHandedSystem?: boolean): Vector3;
  88485. /**
  88486. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  88487. * @returns a new right Vector3
  88488. */
  88489. static Right(): Vector3;
  88490. /**
  88491. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  88492. * @returns a new left Vector3
  88493. */
  88494. static Left(): Vector3;
  88495. /**
  88496. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  88497. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88498. * @param vector defines the Vector3 to transform
  88499. * @param transformation defines the transformation matrix
  88500. * @returns the transformed Vector3
  88501. */
  88502. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88503. /**
  88504. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  88505. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88506. * @param vector defines the Vector3 to transform
  88507. * @param transformation defines the transformation matrix
  88508. * @param result defines the Vector3 where to store the result
  88509. */
  88510. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88511. /**
  88512. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  88513. * This method computes tranformed coordinates only, not transformed direction vectors
  88514. * @param x define the x coordinate of the source vector
  88515. * @param y define the y coordinate of the source vector
  88516. * @param z define the z coordinate of the source vector
  88517. * @param transformation defines the transformation matrix
  88518. * @param result defines the Vector3 where to store the result
  88519. */
  88520. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88521. /**
  88522. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  88523. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88524. * @param vector defines the Vector3 to transform
  88525. * @param transformation defines the transformation matrix
  88526. * @returns the new Vector3
  88527. */
  88528. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88529. /**
  88530. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  88531. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88532. * @param vector defines the Vector3 to transform
  88533. * @param transformation defines the transformation matrix
  88534. * @param result defines the Vector3 where to store the result
  88535. */
  88536. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88537. /**
  88538. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  88539. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88540. * @param x define the x coordinate of the source vector
  88541. * @param y define the y coordinate of the source vector
  88542. * @param z define the z coordinate of the source vector
  88543. * @param transformation defines the transformation matrix
  88544. * @param result defines the Vector3 where to store the result
  88545. */
  88546. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88547. /**
  88548. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  88549. * @param value1 defines the first control point
  88550. * @param value2 defines the second control point
  88551. * @param value3 defines the third control point
  88552. * @param value4 defines the fourth control point
  88553. * @param amount defines the amount on the spline to use
  88554. * @returns the new Vector3
  88555. */
  88556. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  88557. /**
  88558. * 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"
  88559. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88560. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88561. * @param value defines the current value
  88562. * @param min defines the lower range value
  88563. * @param max defines the upper range value
  88564. * @returns the new Vector3
  88565. */
  88566. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  88567. /**
  88568. * 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"
  88569. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88570. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88571. * @param value defines the current value
  88572. * @param min defines the lower range value
  88573. * @param max defines the upper range value
  88574. * @param result defines the Vector3 where to store the result
  88575. */
  88576. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  88577. /**
  88578. * Checks if a given vector is inside a specific range
  88579. * @param v defines the vector to test
  88580. * @param min defines the minimum range
  88581. * @param max defines the maximum range
  88582. */
  88583. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88584. /**
  88585. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  88586. * @param value1 defines the first control point
  88587. * @param tangent1 defines the first tangent vector
  88588. * @param value2 defines the second control point
  88589. * @param tangent2 defines the second tangent vector
  88590. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  88591. * @returns the new Vector3
  88592. */
  88593. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  88594. /**
  88595. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  88596. * @param start defines the start value
  88597. * @param end defines the end value
  88598. * @param amount max defines amount between both (between 0 and 1)
  88599. * @returns the new Vector3
  88600. */
  88601. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  88602. /**
  88603. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  88604. * @param start defines the start value
  88605. * @param end defines the end value
  88606. * @param amount max defines amount between both (between 0 and 1)
  88607. * @param result defines the Vector3 where to store the result
  88608. */
  88609. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  88610. /**
  88611. * Returns the dot product (float) between the vectors "left" and "right"
  88612. * @param left defines the left operand
  88613. * @param right defines the right operand
  88614. * @returns the dot product
  88615. */
  88616. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  88617. /**
  88618. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  88619. * The cross product is then orthogonal to both "left" and "right"
  88620. * @param left defines the left operand
  88621. * @param right defines the right operand
  88622. * @returns the cross product
  88623. */
  88624. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88625. /**
  88626. * Sets the given vector "result" with the cross product of "left" and "right"
  88627. * The cross product is then orthogonal to both "left" and "right"
  88628. * @param left defines the left operand
  88629. * @param right defines the right operand
  88630. * @param result defines the Vector3 where to store the result
  88631. */
  88632. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  88633. /**
  88634. * Returns a new Vector3 as the normalization of the given vector
  88635. * @param vector defines the Vector3 to normalize
  88636. * @returns the new Vector3
  88637. */
  88638. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  88639. /**
  88640. * Sets the given vector "result" with the normalization of the given first vector
  88641. * @param vector defines the Vector3 to normalize
  88642. * @param result defines the Vector3 where to store the result
  88643. */
  88644. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  88645. /**
  88646. * Project a Vector3 onto screen space
  88647. * @param vector defines the Vector3 to project
  88648. * @param world defines the world matrix to use
  88649. * @param transform defines the transform (view x projection) matrix to use
  88650. * @param viewport defines the screen viewport to use
  88651. * @returns the new Vector3
  88652. */
  88653. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  88654. /**
  88655. * Project a Vector3 onto screen space to reference
  88656. * @param vector defines the Vector3 to project
  88657. * @param world defines the world matrix to use
  88658. * @param transform defines the transform (view x projection) matrix to use
  88659. * @param viewport defines the screen viewport to use
  88660. * @param result the vector in which the screen space will be stored
  88661. * @returns the new Vector3
  88662. */
  88663. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  88664. /** @hidden */
  88665. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  88666. /**
  88667. * Unproject from screen space to object space
  88668. * @param source defines the screen space Vector3 to use
  88669. * @param viewportWidth defines the current width of the viewport
  88670. * @param viewportHeight defines the current height of the viewport
  88671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88672. * @param transform defines the transform (view x projection) matrix to use
  88673. * @returns the new Vector3
  88674. */
  88675. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  88676. /**
  88677. * Unproject from screen space to object space
  88678. * @param source defines the screen space Vector3 to use
  88679. * @param viewportWidth defines the current width of the viewport
  88680. * @param viewportHeight defines the current height of the viewport
  88681. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88682. * @param view defines the view matrix to use
  88683. * @param projection defines the projection matrix to use
  88684. * @returns the new Vector3
  88685. */
  88686. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  88687. /**
  88688. * Unproject from screen space to object space
  88689. * @param source defines the screen space Vector3 to use
  88690. * @param viewportWidth defines the current width of the viewport
  88691. * @param viewportHeight defines the current height of the viewport
  88692. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88693. * @param view defines the view matrix to use
  88694. * @param projection defines the projection matrix to use
  88695. * @param result defines the Vector3 where to store the result
  88696. */
  88697. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88698. /**
  88699. * Unproject from screen space to object space
  88700. * @param sourceX defines the screen space x coordinate to use
  88701. * @param sourceY defines the screen space y coordinate to use
  88702. * @param sourceZ defines the screen space z coordinate to use
  88703. * @param viewportWidth defines the current width of the viewport
  88704. * @param viewportHeight defines the current height of the viewport
  88705. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88706. * @param view defines the view matrix to use
  88707. * @param projection defines the projection matrix to use
  88708. * @param result defines the Vector3 where to store the result
  88709. */
  88710. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88711. /**
  88712. * Gets the minimal coordinate values between two Vector3
  88713. * @param left defines the first operand
  88714. * @param right defines the second operand
  88715. * @returns the new Vector3
  88716. */
  88717. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88718. /**
  88719. * Gets the maximal coordinate values between two Vector3
  88720. * @param left defines the first operand
  88721. * @param right defines the second operand
  88722. * @returns the new Vector3
  88723. */
  88724. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88725. /**
  88726. * Returns the distance between the vectors "value1" and "value2"
  88727. * @param value1 defines the first operand
  88728. * @param value2 defines the second operand
  88729. * @returns the distance
  88730. */
  88731. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88732. /**
  88733. * Returns the squared distance between the vectors "value1" and "value2"
  88734. * @param value1 defines the first operand
  88735. * @param value2 defines the second operand
  88736. * @returns the squared distance
  88737. */
  88738. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88739. /**
  88740. * Returns a new Vector3 located at the center between "value1" and "value2"
  88741. * @param value1 defines the first operand
  88742. * @param value2 defines the second operand
  88743. * @returns the new Vector3
  88744. */
  88745. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  88746. /**
  88747. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88748. * @param value1 defines first vector
  88749. * @param value2 defines second vector
  88750. * @param ref defines third vector
  88751. * @returns ref
  88752. */
  88753. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  88754. /**
  88755. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  88756. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  88757. * to something in order to rotate it from its local system to the given target system
  88758. * Note: axis1, axis2 and axis3 are normalized during this operation
  88759. * @param axis1 defines the first axis
  88760. * @param axis2 defines the second axis
  88761. * @param axis3 defines the third axis
  88762. * @returns a new Vector3
  88763. */
  88764. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  88765. /**
  88766. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  88767. * @param axis1 defines the first axis
  88768. * @param axis2 defines the second axis
  88769. * @param axis3 defines the third axis
  88770. * @param ref defines the Vector3 where to store the result
  88771. */
  88772. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  88773. }
  88774. /**
  88775. * Vector4 class created for EulerAngle class conversion to Quaternion
  88776. */
  88777. export class Vector4 {
  88778. /** x value of the vector */
  88779. x: number;
  88780. /** y value of the vector */
  88781. y: number;
  88782. /** z value of the vector */
  88783. z: number;
  88784. /** w value of the vector */
  88785. w: number;
  88786. /**
  88787. * Creates a Vector4 object from the given floats.
  88788. * @param x x value of the vector
  88789. * @param y y value of the vector
  88790. * @param z z value of the vector
  88791. * @param w w value of the vector
  88792. */
  88793. constructor(
  88794. /** x value of the vector */
  88795. x: number,
  88796. /** y value of the vector */
  88797. y: number,
  88798. /** z value of the vector */
  88799. z: number,
  88800. /** w value of the vector */
  88801. w: number);
  88802. /**
  88803. * Returns the string with the Vector4 coordinates.
  88804. * @returns a string containing all the vector values
  88805. */
  88806. toString(): string;
  88807. /**
  88808. * Returns the string "Vector4".
  88809. * @returns "Vector4"
  88810. */
  88811. getClassName(): string;
  88812. /**
  88813. * Returns the Vector4 hash code.
  88814. * @returns a unique hash code
  88815. */
  88816. getHashCode(): number;
  88817. /**
  88818. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  88819. * @returns the resulting array
  88820. */
  88821. asArray(): number[];
  88822. /**
  88823. * Populates the given array from the given index with the Vector4 coordinates.
  88824. * @param array array to populate
  88825. * @param index index of the array to start at (default: 0)
  88826. * @returns the Vector4.
  88827. */
  88828. toArray(array: FloatArray, index?: number): Vector4;
  88829. /**
  88830. * Update the current vector from an array
  88831. * @param array defines the destination array
  88832. * @param index defines the offset in the destination array
  88833. * @returns the current Vector3
  88834. */
  88835. fromArray(array: FloatArray, index?: number): Vector4;
  88836. /**
  88837. * Adds the given vector to the current Vector4.
  88838. * @param otherVector the vector to add
  88839. * @returns the updated Vector4.
  88840. */
  88841. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88842. /**
  88843. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  88844. * @param otherVector the vector to add
  88845. * @returns the resulting vector
  88846. */
  88847. add(otherVector: DeepImmutable<Vector4>): Vector4;
  88848. /**
  88849. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  88850. * @param otherVector the vector to add
  88851. * @param result the vector to store the result
  88852. * @returns the current Vector4.
  88853. */
  88854. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88855. /**
  88856. * Subtract in place the given vector from the current Vector4.
  88857. * @param otherVector the vector to subtract
  88858. * @returns the updated Vector4.
  88859. */
  88860. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88861. /**
  88862. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  88863. * @param otherVector the vector to add
  88864. * @returns the new vector with the result
  88865. */
  88866. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  88867. /**
  88868. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  88869. * @param otherVector the vector to subtract
  88870. * @param result the vector to store the result
  88871. * @returns the current Vector4.
  88872. */
  88873. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88874. /**
  88875. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88876. */
  88877. /**
  88878. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88879. * @param x value to subtract
  88880. * @param y value to subtract
  88881. * @param z value to subtract
  88882. * @param w value to subtract
  88883. * @returns new vector containing the result
  88884. */
  88885. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  88886. /**
  88887. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88888. * @param x value to subtract
  88889. * @param y value to subtract
  88890. * @param z value to subtract
  88891. * @param w value to subtract
  88892. * @param result the vector to store the result in
  88893. * @returns the current Vector4.
  88894. */
  88895. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  88896. /**
  88897. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  88898. * @returns a new vector with the negated values
  88899. */
  88900. negate(): Vector4;
  88901. /**
  88902. * Negate this vector in place
  88903. * @returns this
  88904. */
  88905. negateInPlace(): Vector4;
  88906. /**
  88907. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  88908. * @param result defines the Vector3 object where to store the result
  88909. * @returns the current Vector4
  88910. */
  88911. negateToRef(result: Vector4): Vector4;
  88912. /**
  88913. * Multiplies the current Vector4 coordinates by scale (float).
  88914. * @param scale the number to scale with
  88915. * @returns the updated Vector4.
  88916. */
  88917. scaleInPlace(scale: number): Vector4;
  88918. /**
  88919. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  88920. * @param scale the number to scale with
  88921. * @returns a new vector with the result
  88922. */
  88923. scale(scale: number): Vector4;
  88924. /**
  88925. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  88926. * @param scale the number to scale with
  88927. * @param result a vector to store the result in
  88928. * @returns the current Vector4.
  88929. */
  88930. scaleToRef(scale: number, result: Vector4): Vector4;
  88931. /**
  88932. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  88933. * @param scale defines the scale factor
  88934. * @param result defines the Vector4 object where to store the result
  88935. * @returns the unmodified current Vector4
  88936. */
  88937. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  88938. /**
  88939. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  88940. * @param otherVector the vector to compare against
  88941. * @returns true if they are equal
  88942. */
  88943. equals(otherVector: DeepImmutable<Vector4>): boolean;
  88944. /**
  88945. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  88946. * @param otherVector vector to compare against
  88947. * @param epsilon (Default: very small number)
  88948. * @returns true if they are equal
  88949. */
  88950. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  88951. /**
  88952. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  88953. * @param x x value to compare against
  88954. * @param y y value to compare against
  88955. * @param z z value to compare against
  88956. * @param w w value to compare against
  88957. * @returns true if equal
  88958. */
  88959. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  88960. /**
  88961. * Multiplies in place the current Vector4 by the given one.
  88962. * @param otherVector vector to multiple with
  88963. * @returns the updated Vector4.
  88964. */
  88965. multiplyInPlace(otherVector: Vector4): Vector4;
  88966. /**
  88967. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  88968. * @param otherVector vector to multiple with
  88969. * @returns resulting new vector
  88970. */
  88971. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  88972. /**
  88973. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  88974. * @param otherVector vector to multiple with
  88975. * @param result vector to store the result
  88976. * @returns the current Vector4.
  88977. */
  88978. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88979. /**
  88980. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  88981. * @param x x value multiply with
  88982. * @param y y value multiply with
  88983. * @param z z value multiply with
  88984. * @param w w value multiply with
  88985. * @returns resulting new vector
  88986. */
  88987. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  88988. /**
  88989. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  88990. * @param otherVector vector to devide with
  88991. * @returns resulting new vector
  88992. */
  88993. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  88994. /**
  88995. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  88996. * @param otherVector vector to devide with
  88997. * @param result vector to store the result
  88998. * @returns the current Vector4.
  88999. */
  89000. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89001. /**
  89002. * Divides the current Vector3 coordinates by the given ones.
  89003. * @param otherVector vector to devide with
  89004. * @returns the updated Vector3.
  89005. */
  89006. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  89007. /**
  89008. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  89009. * @param other defines the second operand
  89010. * @returns the current updated Vector4
  89011. */
  89012. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89013. /**
  89014. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  89015. * @param other defines the second operand
  89016. * @returns the current updated Vector4
  89017. */
  89018. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89019. /**
  89020. * Gets a new Vector4 from current Vector4 floored values
  89021. * @returns a new Vector4
  89022. */
  89023. floor(): Vector4;
  89024. /**
  89025. * Gets a new Vector4 from current Vector3 floored values
  89026. * @returns a new Vector4
  89027. */
  89028. fract(): Vector4;
  89029. /**
  89030. * Returns the Vector4 length (float).
  89031. * @returns the length
  89032. */
  89033. length(): number;
  89034. /**
  89035. * Returns the Vector4 squared length (float).
  89036. * @returns the length squared
  89037. */
  89038. lengthSquared(): number;
  89039. /**
  89040. * Normalizes in place the Vector4.
  89041. * @returns the updated Vector4.
  89042. */
  89043. normalize(): Vector4;
  89044. /**
  89045. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  89046. * @returns this converted to a new vector3
  89047. */
  89048. toVector3(): Vector3;
  89049. /**
  89050. * Returns a new Vector4 copied from the current one.
  89051. * @returns the new cloned vector
  89052. */
  89053. clone(): Vector4;
  89054. /**
  89055. * Updates the current Vector4 with the given one coordinates.
  89056. * @param source the source vector to copy from
  89057. * @returns the updated Vector4.
  89058. */
  89059. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  89060. /**
  89061. * Updates the current Vector4 coordinates with the given floats.
  89062. * @param x float to copy from
  89063. * @param y float to copy from
  89064. * @param z float to copy from
  89065. * @param w float to copy from
  89066. * @returns the updated Vector4.
  89067. */
  89068. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  89069. /**
  89070. * Updates the current Vector4 coordinates with the given floats.
  89071. * @param x float to set from
  89072. * @param y float to set from
  89073. * @param z float to set from
  89074. * @param w float to set from
  89075. * @returns the updated Vector4.
  89076. */
  89077. set(x: number, y: number, z: number, w: number): Vector4;
  89078. /**
  89079. * Copies the given float to the current Vector3 coordinates
  89080. * @param v defines the x, y, z and w coordinates of the operand
  89081. * @returns the current updated Vector3
  89082. */
  89083. setAll(v: number): Vector4;
  89084. /**
  89085. * Returns a new Vector4 set from the starting index of the given array.
  89086. * @param array the array to pull values from
  89087. * @param offset the offset into the array to start at
  89088. * @returns the new vector
  89089. */
  89090. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  89091. /**
  89092. * Updates the given vector "result" from the starting index of the given array.
  89093. * @param array the array to pull values from
  89094. * @param offset the offset into the array to start at
  89095. * @param result the vector to store the result in
  89096. */
  89097. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  89098. /**
  89099. * Updates the given vector "result" from the starting index of the given Float32Array.
  89100. * @param array the array to pull values from
  89101. * @param offset the offset into the array to start at
  89102. * @param result the vector to store the result in
  89103. */
  89104. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  89105. /**
  89106. * Updates the given vector "result" coordinates from the given floats.
  89107. * @param x float to set from
  89108. * @param y float to set from
  89109. * @param z float to set from
  89110. * @param w float to set from
  89111. * @param result the vector to the floats in
  89112. */
  89113. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  89114. /**
  89115. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  89116. * @returns the new vector
  89117. */
  89118. static Zero(): Vector4;
  89119. /**
  89120. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  89121. * @returns the new vector
  89122. */
  89123. static One(): Vector4;
  89124. /**
  89125. * Returns a new normalized Vector4 from the given one.
  89126. * @param vector the vector to normalize
  89127. * @returns the vector
  89128. */
  89129. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  89130. /**
  89131. * Updates the given vector "result" from the normalization of the given one.
  89132. * @param vector the vector to normalize
  89133. * @param result the vector to store the result in
  89134. */
  89135. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  89136. /**
  89137. * Returns a vector with the minimum values from the left and right vectors
  89138. * @param left left vector to minimize
  89139. * @param right right vector to minimize
  89140. * @returns a new vector with the minimum of the left and right vector values
  89141. */
  89142. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89143. /**
  89144. * Returns a vector with the maximum values from the left and right vectors
  89145. * @param left left vector to maximize
  89146. * @param right right vector to maximize
  89147. * @returns a new vector with the maximum of the left and right vector values
  89148. */
  89149. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89150. /**
  89151. * Returns the distance (float) between the vectors "value1" and "value2".
  89152. * @param value1 value to calulate the distance between
  89153. * @param value2 value to calulate the distance between
  89154. * @return the distance between the two vectors
  89155. */
  89156. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89157. /**
  89158. * Returns the squared distance (float) between the vectors "value1" and "value2".
  89159. * @param value1 value to calulate the distance between
  89160. * @param value2 value to calulate the distance between
  89161. * @return the distance between the two vectors squared
  89162. */
  89163. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89164. /**
  89165. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  89166. * @param value1 value to calulate the center between
  89167. * @param value2 value to calulate the center between
  89168. * @return the center between the two vectors
  89169. */
  89170. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  89171. /**
  89172. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  89173. * @param value1 defines first vector
  89174. * @param value2 defines second vector
  89175. * @param ref defines third vector
  89176. * @returns ref
  89177. */
  89178. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  89179. /**
  89180. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  89181. * This methods computes transformed normalized direction vectors only.
  89182. * @param vector the vector to transform
  89183. * @param transformation the transformation matrix to apply
  89184. * @returns the new vector
  89185. */
  89186. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  89187. /**
  89188. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  89189. * This methods computes transformed normalized direction vectors only.
  89190. * @param vector the vector to transform
  89191. * @param transformation the transformation matrix to apply
  89192. * @param result the vector to store the result in
  89193. */
  89194. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89195. /**
  89196. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  89197. * This methods computes transformed normalized direction vectors only.
  89198. * @param x value to transform
  89199. * @param y value to transform
  89200. * @param z value to transform
  89201. * @param w value to transform
  89202. * @param transformation the transformation matrix to apply
  89203. * @param result the vector to store the results in
  89204. */
  89205. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89206. /**
  89207. * Creates a new Vector4 from a Vector3
  89208. * @param source defines the source data
  89209. * @param w defines the 4th component (default is 0)
  89210. * @returns a new Vector4
  89211. */
  89212. static FromVector3(source: Vector3, w?: number): Vector4;
  89213. }
  89214. /**
  89215. * Class used to store quaternion data
  89216. * @see https://en.wikipedia.org/wiki/Quaternion
  89217. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  89218. */
  89219. export class Quaternion {
  89220. /** @hidden */
  89221. _x: number;
  89222. /** @hidden */
  89223. _y: number;
  89224. /** @hidden */
  89225. _z: number;
  89226. /** @hidden */
  89227. _w: number;
  89228. /** @hidden */
  89229. _isDirty: boolean;
  89230. /** Gets or sets the x coordinate */
  89231. get x(): number;
  89232. set x(value: number);
  89233. /** Gets or sets the y coordinate */
  89234. get y(): number;
  89235. set y(value: number);
  89236. /** Gets or sets the z coordinate */
  89237. get z(): number;
  89238. set z(value: number);
  89239. /** Gets or sets the w coordinate */
  89240. get w(): number;
  89241. set w(value: number);
  89242. /**
  89243. * Creates a new Quaternion from the given floats
  89244. * @param x defines the first component (0 by default)
  89245. * @param y defines the second component (0 by default)
  89246. * @param z defines the third component (0 by default)
  89247. * @param w defines the fourth component (1.0 by default)
  89248. */
  89249. constructor(x?: number, y?: number, z?: number, w?: number);
  89250. /**
  89251. * Gets a string representation for the current quaternion
  89252. * @returns a string with the Quaternion coordinates
  89253. */
  89254. toString(): string;
  89255. /**
  89256. * Gets the class name of the quaternion
  89257. * @returns the string "Quaternion"
  89258. */
  89259. getClassName(): string;
  89260. /**
  89261. * Gets a hash code for this quaternion
  89262. * @returns the quaternion hash code
  89263. */
  89264. getHashCode(): number;
  89265. /**
  89266. * Copy the quaternion to an array
  89267. * @returns a new array populated with 4 elements from the quaternion coordinates
  89268. */
  89269. asArray(): number[];
  89270. /**
  89271. * Check if two quaternions are equals
  89272. * @param otherQuaternion defines the second operand
  89273. * @return true if the current quaternion and the given one coordinates are strictly equals
  89274. */
  89275. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  89276. /**
  89277. * Gets a boolean if two quaternions are equals (using an epsilon value)
  89278. * @param otherQuaternion defines the other quaternion
  89279. * @param epsilon defines the minimal distance to consider equality
  89280. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  89281. */
  89282. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  89283. /**
  89284. * Clone the current quaternion
  89285. * @returns a new quaternion copied from the current one
  89286. */
  89287. clone(): Quaternion;
  89288. /**
  89289. * Copy a quaternion to the current one
  89290. * @param other defines the other quaternion
  89291. * @returns the updated current quaternion
  89292. */
  89293. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  89294. /**
  89295. * Updates the current quaternion with the given float coordinates
  89296. * @param x defines the x coordinate
  89297. * @param y defines the y coordinate
  89298. * @param z defines the z coordinate
  89299. * @param w defines the w coordinate
  89300. * @returns the updated current quaternion
  89301. */
  89302. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  89303. /**
  89304. * Updates the current quaternion from the given float coordinates
  89305. * @param x defines the x coordinate
  89306. * @param y defines the y coordinate
  89307. * @param z defines the z coordinate
  89308. * @param w defines the w coordinate
  89309. * @returns the updated current quaternion
  89310. */
  89311. set(x: number, y: number, z: number, w: number): Quaternion;
  89312. /**
  89313. * Adds two quaternions
  89314. * @param other defines the second operand
  89315. * @returns a new quaternion as the addition result of the given one and the current quaternion
  89316. */
  89317. add(other: DeepImmutable<Quaternion>): Quaternion;
  89318. /**
  89319. * Add a quaternion to the current one
  89320. * @param other defines the quaternion to add
  89321. * @returns the current quaternion
  89322. */
  89323. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  89324. /**
  89325. * Subtract two quaternions
  89326. * @param other defines the second operand
  89327. * @returns a new quaternion as the subtraction result of the given one from the current one
  89328. */
  89329. subtract(other: Quaternion): Quaternion;
  89330. /**
  89331. * Multiplies the current quaternion by a scale factor
  89332. * @param value defines the scale factor
  89333. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  89334. */
  89335. scale(value: number): Quaternion;
  89336. /**
  89337. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  89338. * @param scale defines the scale factor
  89339. * @param result defines the Quaternion object where to store the result
  89340. * @returns the unmodified current quaternion
  89341. */
  89342. scaleToRef(scale: number, result: Quaternion): Quaternion;
  89343. /**
  89344. * Multiplies in place the current quaternion by a scale factor
  89345. * @param value defines the scale factor
  89346. * @returns the current modified quaternion
  89347. */
  89348. scaleInPlace(value: number): Quaternion;
  89349. /**
  89350. * Scale the current quaternion values by a factor and add the result to a given quaternion
  89351. * @param scale defines the scale factor
  89352. * @param result defines the Quaternion object where to store the result
  89353. * @returns the unmodified current quaternion
  89354. */
  89355. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  89356. /**
  89357. * Multiplies two quaternions
  89358. * @param q1 defines the second operand
  89359. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  89360. */
  89361. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  89362. /**
  89363. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  89364. * @param q1 defines the second operand
  89365. * @param result defines the target quaternion
  89366. * @returns the current quaternion
  89367. */
  89368. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  89369. /**
  89370. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  89371. * @param q1 defines the second operand
  89372. * @returns the currentupdated quaternion
  89373. */
  89374. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  89375. /**
  89376. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  89377. * @param ref defines the target quaternion
  89378. * @returns the current quaternion
  89379. */
  89380. conjugateToRef(ref: Quaternion): Quaternion;
  89381. /**
  89382. * Conjugates in place (1-q) the current quaternion
  89383. * @returns the current updated quaternion
  89384. */
  89385. conjugateInPlace(): Quaternion;
  89386. /**
  89387. * Conjugates in place (1-q) the current quaternion
  89388. * @returns a new quaternion
  89389. */
  89390. conjugate(): Quaternion;
  89391. /**
  89392. * Gets length of current quaternion
  89393. * @returns the quaternion length (float)
  89394. */
  89395. length(): number;
  89396. /**
  89397. * Normalize in place the current quaternion
  89398. * @returns the current updated quaternion
  89399. */
  89400. normalize(): Quaternion;
  89401. /**
  89402. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  89403. * @param order is a reserved parameter and is ignored for now
  89404. * @returns a new Vector3 containing the Euler angles
  89405. */
  89406. toEulerAngles(order?: string): Vector3;
  89407. /**
  89408. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  89409. * @param result defines the vector which will be filled with the Euler angles
  89410. * @returns the current unchanged quaternion
  89411. */
  89412. toEulerAnglesToRef(result: Vector3): Quaternion;
  89413. /**
  89414. * Updates the given rotation matrix with the current quaternion values
  89415. * @param result defines the target matrix
  89416. * @returns the current unchanged quaternion
  89417. */
  89418. toRotationMatrix(result: Matrix): Quaternion;
  89419. /**
  89420. * Updates the current quaternion from the given rotation matrix values
  89421. * @param matrix defines the source matrix
  89422. * @returns the current updated quaternion
  89423. */
  89424. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89425. /**
  89426. * Creates a new quaternion from a rotation matrix
  89427. * @param matrix defines the source matrix
  89428. * @returns a new quaternion created from the given rotation matrix values
  89429. */
  89430. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89431. /**
  89432. * Updates the given quaternion with the given rotation matrix values
  89433. * @param matrix defines the source matrix
  89434. * @param result defines the target quaternion
  89435. */
  89436. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  89437. /**
  89438. * Returns the dot product (float) between the quaternions "left" and "right"
  89439. * @param left defines the left operand
  89440. * @param right defines the right operand
  89441. * @returns the dot product
  89442. */
  89443. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  89444. /**
  89445. * Checks if the two quaternions are close to each other
  89446. * @param quat0 defines the first quaternion to check
  89447. * @param quat1 defines the second quaternion to check
  89448. * @returns true if the two quaternions are close to each other
  89449. */
  89450. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  89451. /**
  89452. * Creates an empty quaternion
  89453. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  89454. */
  89455. static Zero(): Quaternion;
  89456. /**
  89457. * Inverse a given quaternion
  89458. * @param q defines the source quaternion
  89459. * @returns a new quaternion as the inverted current quaternion
  89460. */
  89461. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  89462. /**
  89463. * Inverse a given quaternion
  89464. * @param q defines the source quaternion
  89465. * @param result the quaternion the result will be stored in
  89466. * @returns the result quaternion
  89467. */
  89468. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  89469. /**
  89470. * Creates an identity quaternion
  89471. * @returns the identity quaternion
  89472. */
  89473. static Identity(): Quaternion;
  89474. /**
  89475. * Gets a boolean indicating if the given quaternion is identity
  89476. * @param quaternion defines the quaternion to check
  89477. * @returns true if the quaternion is identity
  89478. */
  89479. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  89480. /**
  89481. * Creates a quaternion from a rotation around an axis
  89482. * @param axis defines the axis to use
  89483. * @param angle defines the angle to use
  89484. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  89485. */
  89486. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  89487. /**
  89488. * Creates a rotation around an axis and stores it into the given quaternion
  89489. * @param axis defines the axis to use
  89490. * @param angle defines the angle to use
  89491. * @param result defines the target quaternion
  89492. * @returns the target quaternion
  89493. */
  89494. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  89495. /**
  89496. * Creates a new quaternion from data stored into an array
  89497. * @param array defines the data source
  89498. * @param offset defines the offset in the source array where the data starts
  89499. * @returns a new quaternion
  89500. */
  89501. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  89502. /**
  89503. * Updates the given quaternion "result" from the starting index of the given array.
  89504. * @param array the array to pull values from
  89505. * @param offset the offset into the array to start at
  89506. * @param result the quaternion to store the result in
  89507. */
  89508. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  89509. /**
  89510. * Create a quaternion from Euler rotation angles
  89511. * @param x Pitch
  89512. * @param y Yaw
  89513. * @param z Roll
  89514. * @returns the new Quaternion
  89515. */
  89516. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  89517. /**
  89518. * Updates a quaternion from Euler rotation angles
  89519. * @param x Pitch
  89520. * @param y Yaw
  89521. * @param z Roll
  89522. * @param result the quaternion to store the result
  89523. * @returns the updated quaternion
  89524. */
  89525. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  89526. /**
  89527. * Create a quaternion from Euler rotation vector
  89528. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89529. * @returns the new Quaternion
  89530. */
  89531. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  89532. /**
  89533. * Updates a quaternion from Euler rotation vector
  89534. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89535. * @param result the quaternion to store the result
  89536. * @returns the updated quaternion
  89537. */
  89538. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  89539. /**
  89540. * Creates a new quaternion from the given Euler float angles (y, x, z)
  89541. * @param yaw defines the rotation around Y axis
  89542. * @param pitch defines the rotation around X axis
  89543. * @param roll defines the rotation around Z axis
  89544. * @returns the new quaternion
  89545. */
  89546. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  89547. /**
  89548. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  89549. * @param yaw defines the rotation around Y axis
  89550. * @param pitch defines the rotation around X axis
  89551. * @param roll defines the rotation around Z axis
  89552. * @param result defines the target quaternion
  89553. */
  89554. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  89555. /**
  89556. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  89557. * @param alpha defines the rotation around first axis
  89558. * @param beta defines the rotation around second axis
  89559. * @param gamma defines the rotation around third axis
  89560. * @returns the new quaternion
  89561. */
  89562. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  89563. /**
  89564. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  89565. * @param alpha defines the rotation around first axis
  89566. * @param beta defines the rotation around second axis
  89567. * @param gamma defines the rotation around third axis
  89568. * @param result defines the target quaternion
  89569. */
  89570. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  89571. /**
  89572. * 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)
  89573. * @param axis1 defines the first axis
  89574. * @param axis2 defines the second axis
  89575. * @param axis3 defines the third axis
  89576. * @returns the new quaternion
  89577. */
  89578. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  89579. /**
  89580. * 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
  89581. * @param axis1 defines the first axis
  89582. * @param axis2 defines the second axis
  89583. * @param axis3 defines the third axis
  89584. * @param ref defines the target quaternion
  89585. */
  89586. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  89587. /**
  89588. * Interpolates between two quaternions
  89589. * @param left defines first quaternion
  89590. * @param right defines second quaternion
  89591. * @param amount defines the gradient to use
  89592. * @returns the new interpolated quaternion
  89593. */
  89594. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89595. /**
  89596. * Interpolates between two quaternions and stores it into a target quaternion
  89597. * @param left defines first quaternion
  89598. * @param right defines second quaternion
  89599. * @param amount defines the gradient to use
  89600. * @param result defines the target quaternion
  89601. */
  89602. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  89603. /**
  89604. * Interpolate between two quaternions using Hermite interpolation
  89605. * @param value1 defines first quaternion
  89606. * @param tangent1 defines the incoming tangent
  89607. * @param value2 defines second quaternion
  89608. * @param tangent2 defines the outgoing tangent
  89609. * @param amount defines the target quaternion
  89610. * @returns the new interpolated quaternion
  89611. */
  89612. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89613. }
  89614. /**
  89615. * Class used to store matrix data (4x4)
  89616. */
  89617. export class Matrix {
  89618. /**
  89619. * Gets the precision of matrix computations
  89620. */
  89621. static get Use64Bits(): boolean;
  89622. private static _updateFlagSeed;
  89623. private static _identityReadOnly;
  89624. private _isIdentity;
  89625. private _isIdentityDirty;
  89626. private _isIdentity3x2;
  89627. private _isIdentity3x2Dirty;
  89628. /**
  89629. * Gets the update flag of the matrix which is an unique number for the matrix.
  89630. * It will be incremented every time the matrix data change.
  89631. * You can use it to speed the comparison between two versions of the same matrix.
  89632. */
  89633. updateFlag: number;
  89634. private readonly _m;
  89635. /**
  89636. * Gets the internal data of the matrix
  89637. */
  89638. get m(): DeepImmutable<Float32Array | Array<number>>;
  89639. /** @hidden */
  89640. _markAsUpdated(): void;
  89641. /** @hidden */
  89642. private _updateIdentityStatus;
  89643. /**
  89644. * Creates an empty matrix (filled with zeros)
  89645. */
  89646. constructor();
  89647. /**
  89648. * Check if the current matrix is identity
  89649. * @returns true is the matrix is the identity matrix
  89650. */
  89651. isIdentity(): boolean;
  89652. /**
  89653. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  89654. * @returns true is the matrix is the identity matrix
  89655. */
  89656. isIdentityAs3x2(): boolean;
  89657. /**
  89658. * Gets the determinant of the matrix
  89659. * @returns the matrix determinant
  89660. */
  89661. determinant(): number;
  89662. /**
  89663. * Returns the matrix as a Float32Array or Array<number>
  89664. * @returns the matrix underlying array
  89665. */
  89666. toArray(): DeepImmutable<Float32Array | Array<number>>;
  89667. /**
  89668. * Returns the matrix as a Float32Array or Array<number>
  89669. * @returns the matrix underlying array.
  89670. */
  89671. asArray(): DeepImmutable<Float32Array | Array<number>>;
  89672. /**
  89673. * Inverts the current matrix in place
  89674. * @returns the current inverted matrix
  89675. */
  89676. invert(): Matrix;
  89677. /**
  89678. * Sets all the matrix elements to zero
  89679. * @returns the current matrix
  89680. */
  89681. reset(): Matrix;
  89682. /**
  89683. * Adds the current matrix with a second one
  89684. * @param other defines the matrix to add
  89685. * @returns a new matrix as the addition of the current matrix and the given one
  89686. */
  89687. add(other: DeepImmutable<Matrix>): Matrix;
  89688. /**
  89689. * Sets the given matrix "result" to the addition of the current matrix and the given one
  89690. * @param other defines the matrix to add
  89691. * @param result defines the target matrix
  89692. * @returns the current matrix
  89693. */
  89694. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89695. /**
  89696. * Adds in place the given matrix to the current matrix
  89697. * @param other defines the second operand
  89698. * @returns the current updated matrix
  89699. */
  89700. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  89701. /**
  89702. * Sets the given matrix to the current inverted Matrix
  89703. * @param other defines the target matrix
  89704. * @returns the unmodified current matrix
  89705. */
  89706. invertToRef(other: Matrix): Matrix;
  89707. /**
  89708. * add a value at the specified position in the current Matrix
  89709. * @param index the index of the value within the matrix. between 0 and 15.
  89710. * @param value the value to be added
  89711. * @returns the current updated matrix
  89712. */
  89713. addAtIndex(index: number, value: number): Matrix;
  89714. /**
  89715. * mutiply the specified position in the current Matrix by a value
  89716. * @param index the index of the value within the matrix. between 0 and 15.
  89717. * @param value the value to be added
  89718. * @returns the current updated matrix
  89719. */
  89720. multiplyAtIndex(index: number, value: number): Matrix;
  89721. /**
  89722. * Inserts the translation vector (using 3 floats) in the current matrix
  89723. * @param x defines the 1st component of the translation
  89724. * @param y defines the 2nd component of the translation
  89725. * @param z defines the 3rd component of the translation
  89726. * @returns the current updated matrix
  89727. */
  89728. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89729. /**
  89730. * Adds the translation vector (using 3 floats) in the current matrix
  89731. * @param x defines the 1st component of the translation
  89732. * @param y defines the 2nd component of the translation
  89733. * @param z defines the 3rd component of the translation
  89734. * @returns the current updated matrix
  89735. */
  89736. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89737. /**
  89738. * Inserts the translation vector in the current matrix
  89739. * @param vector3 defines the translation to insert
  89740. * @returns the current updated matrix
  89741. */
  89742. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  89743. /**
  89744. * Gets the translation value of the current matrix
  89745. * @returns a new Vector3 as the extracted translation from the matrix
  89746. */
  89747. getTranslation(): Vector3;
  89748. /**
  89749. * Fill a Vector3 with the extracted translation from the matrix
  89750. * @param result defines the Vector3 where to store the translation
  89751. * @returns the current matrix
  89752. */
  89753. getTranslationToRef(result: Vector3): Matrix;
  89754. /**
  89755. * Remove rotation and scaling part from the matrix
  89756. * @returns the updated matrix
  89757. */
  89758. removeRotationAndScaling(): Matrix;
  89759. /**
  89760. * Multiply two matrices
  89761. * @param other defines the second operand
  89762. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  89763. */
  89764. multiply(other: DeepImmutable<Matrix>): Matrix;
  89765. /**
  89766. * Copy the current matrix from the given one
  89767. * @param other defines the source matrix
  89768. * @returns the current updated matrix
  89769. */
  89770. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  89771. /**
  89772. * Populates the given array from the starting index with the current matrix values
  89773. * @param array defines the target array
  89774. * @param offset defines the offset in the target array where to start storing values
  89775. * @returns the current matrix
  89776. */
  89777. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  89778. /**
  89779. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  89780. * @param other defines the second operand
  89781. * @param result defines the matrix where to store the multiplication
  89782. * @returns the current matrix
  89783. */
  89784. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89785. /**
  89786. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  89787. * @param other defines the second operand
  89788. * @param result defines the array where to store the multiplication
  89789. * @param offset defines the offset in the target array where to start storing values
  89790. * @returns the current matrix
  89791. */
  89792. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  89793. /**
  89794. * Check equality between this matrix and a second one
  89795. * @param value defines the second matrix to compare
  89796. * @returns true is the current matrix and the given one values are strictly equal
  89797. */
  89798. equals(value: DeepImmutable<Matrix>): boolean;
  89799. /**
  89800. * Clone the current matrix
  89801. * @returns a new matrix from the current matrix
  89802. */
  89803. clone(): Matrix;
  89804. /**
  89805. * Returns the name of the current matrix class
  89806. * @returns the string "Matrix"
  89807. */
  89808. getClassName(): string;
  89809. /**
  89810. * Gets the hash code of the current matrix
  89811. * @returns the hash code
  89812. */
  89813. getHashCode(): number;
  89814. /**
  89815. * Decomposes the current Matrix into a translation, rotation and scaling components
  89816. * @param scale defines the scale vector3 given as a reference to update
  89817. * @param rotation defines the rotation quaternion given as a reference to update
  89818. * @param translation defines the translation vector3 given as a reference to update
  89819. * @returns true if operation was successful
  89820. */
  89821. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  89822. /**
  89823. * Gets specific row of the matrix
  89824. * @param index defines the number of the row to get
  89825. * @returns the index-th row of the current matrix as a new Vector4
  89826. */
  89827. getRow(index: number): Nullable<Vector4>;
  89828. /**
  89829. * Sets the index-th row of the current matrix to the vector4 values
  89830. * @param index defines the number of the row to set
  89831. * @param row defines the target vector4
  89832. * @returns the updated current matrix
  89833. */
  89834. setRow(index: number, row: Vector4): Matrix;
  89835. /**
  89836. * Compute the transpose of the matrix
  89837. * @returns the new transposed matrix
  89838. */
  89839. transpose(): Matrix;
  89840. /**
  89841. * Compute the transpose of the matrix and store it in a given matrix
  89842. * @param result defines the target matrix
  89843. * @returns the current matrix
  89844. */
  89845. transposeToRef(result: Matrix): Matrix;
  89846. /**
  89847. * Sets the index-th row of the current matrix with the given 4 x float values
  89848. * @param index defines the row index
  89849. * @param x defines the x component to set
  89850. * @param y defines the y component to set
  89851. * @param z defines the z component to set
  89852. * @param w defines the w component to set
  89853. * @returns the updated current matrix
  89854. */
  89855. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  89856. /**
  89857. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  89858. * @param scale defines the scale factor
  89859. * @returns a new matrix
  89860. */
  89861. scale(scale: number): Matrix;
  89862. /**
  89863. * Scale the current matrix values by a factor to a given result matrix
  89864. * @param scale defines the scale factor
  89865. * @param result defines the matrix to store the result
  89866. * @returns the current matrix
  89867. */
  89868. scaleToRef(scale: number, result: Matrix): Matrix;
  89869. /**
  89870. * Scale the current matrix values by a factor and add the result to a given matrix
  89871. * @param scale defines the scale factor
  89872. * @param result defines the Matrix to store the result
  89873. * @returns the current matrix
  89874. */
  89875. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  89876. /**
  89877. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  89878. * @param ref matrix to store the result
  89879. */
  89880. toNormalMatrix(ref: Matrix): void;
  89881. /**
  89882. * Gets only rotation part of the current matrix
  89883. * @returns a new matrix sets to the extracted rotation matrix from the current one
  89884. */
  89885. getRotationMatrix(): Matrix;
  89886. /**
  89887. * Extracts the rotation matrix from the current one and sets it as the given "result"
  89888. * @param result defines the target matrix to store data to
  89889. * @returns the current matrix
  89890. */
  89891. getRotationMatrixToRef(result: Matrix): Matrix;
  89892. /**
  89893. * Toggles model matrix from being right handed to left handed in place and vice versa
  89894. */
  89895. toggleModelMatrixHandInPlace(): void;
  89896. /**
  89897. * Toggles projection matrix from being right handed to left handed in place and vice versa
  89898. */
  89899. toggleProjectionMatrixHandInPlace(): void;
  89900. /**
  89901. * Creates a matrix from an array
  89902. * @param array defines the source array
  89903. * @param offset defines an offset in the source array
  89904. * @returns a new Matrix set from the starting index of the given array
  89905. */
  89906. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  89907. /**
  89908. * Copy the content of an array into a given matrix
  89909. * @param array defines the source array
  89910. * @param offset defines an offset in the source array
  89911. * @param result defines the target matrix
  89912. */
  89913. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  89914. /**
  89915. * Stores an array into a matrix after having multiplied each component by a given factor
  89916. * @param array defines the source array
  89917. * @param offset defines the offset in the source array
  89918. * @param scale defines the scaling factor
  89919. * @param result defines the target matrix
  89920. */
  89921. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  89922. /**
  89923. * Gets an identity matrix that must not be updated
  89924. */
  89925. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  89926. /**
  89927. * Stores a list of values (16) inside a given matrix
  89928. * @param initialM11 defines 1st value of 1st row
  89929. * @param initialM12 defines 2nd value of 1st row
  89930. * @param initialM13 defines 3rd value of 1st row
  89931. * @param initialM14 defines 4th value of 1st row
  89932. * @param initialM21 defines 1st value of 2nd row
  89933. * @param initialM22 defines 2nd value of 2nd row
  89934. * @param initialM23 defines 3rd value of 2nd row
  89935. * @param initialM24 defines 4th value of 2nd row
  89936. * @param initialM31 defines 1st value of 3rd row
  89937. * @param initialM32 defines 2nd value of 3rd row
  89938. * @param initialM33 defines 3rd value of 3rd row
  89939. * @param initialM34 defines 4th value of 3rd row
  89940. * @param initialM41 defines 1st value of 4th row
  89941. * @param initialM42 defines 2nd value of 4th row
  89942. * @param initialM43 defines 3rd value of 4th row
  89943. * @param initialM44 defines 4th value of 4th row
  89944. * @param result defines the target matrix
  89945. */
  89946. 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;
  89947. /**
  89948. * Creates new matrix from a list of values (16)
  89949. * @param initialM11 defines 1st value of 1st row
  89950. * @param initialM12 defines 2nd value of 1st row
  89951. * @param initialM13 defines 3rd value of 1st row
  89952. * @param initialM14 defines 4th value of 1st row
  89953. * @param initialM21 defines 1st value of 2nd row
  89954. * @param initialM22 defines 2nd value of 2nd row
  89955. * @param initialM23 defines 3rd value of 2nd row
  89956. * @param initialM24 defines 4th value of 2nd row
  89957. * @param initialM31 defines 1st value of 3rd row
  89958. * @param initialM32 defines 2nd value of 3rd row
  89959. * @param initialM33 defines 3rd value of 3rd row
  89960. * @param initialM34 defines 4th value of 3rd row
  89961. * @param initialM41 defines 1st value of 4th row
  89962. * @param initialM42 defines 2nd value of 4th row
  89963. * @param initialM43 defines 3rd value of 4th row
  89964. * @param initialM44 defines 4th value of 4th row
  89965. * @returns the new matrix
  89966. */
  89967. 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;
  89968. /**
  89969. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89970. * @param scale defines the scale vector3
  89971. * @param rotation defines the rotation quaternion
  89972. * @param translation defines the translation vector3
  89973. * @returns a new matrix
  89974. */
  89975. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  89976. /**
  89977. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89978. * @param scale defines the scale vector3
  89979. * @param rotation defines the rotation quaternion
  89980. * @param translation defines the translation vector3
  89981. * @param result defines the target matrix
  89982. */
  89983. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  89984. /**
  89985. * Creates a new identity matrix
  89986. * @returns a new identity matrix
  89987. */
  89988. static Identity(): Matrix;
  89989. /**
  89990. * Creates a new identity matrix and stores the result in a given matrix
  89991. * @param result defines the target matrix
  89992. */
  89993. static IdentityToRef(result: Matrix): void;
  89994. /**
  89995. * Creates a new zero matrix
  89996. * @returns a new zero matrix
  89997. */
  89998. static Zero(): Matrix;
  89999. /**
  90000. * Creates a new rotation matrix for "angle" radians around the X axis
  90001. * @param angle defines the angle (in radians) to use
  90002. * @return the new matrix
  90003. */
  90004. static RotationX(angle: number): Matrix;
  90005. /**
  90006. * Creates a new matrix as the invert of a given matrix
  90007. * @param source defines the source matrix
  90008. * @returns the new matrix
  90009. */
  90010. static Invert(source: DeepImmutable<Matrix>): Matrix;
  90011. /**
  90012. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  90013. * @param angle defines the angle (in radians) to use
  90014. * @param result defines the target matrix
  90015. */
  90016. static RotationXToRef(angle: number, result: Matrix): void;
  90017. /**
  90018. * Creates a new rotation matrix for "angle" radians around the Y axis
  90019. * @param angle defines the angle (in radians) to use
  90020. * @return the new matrix
  90021. */
  90022. static RotationY(angle: number): Matrix;
  90023. /**
  90024. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  90025. * @param angle defines the angle (in radians) to use
  90026. * @param result defines the target matrix
  90027. */
  90028. static RotationYToRef(angle: number, result: Matrix): void;
  90029. /**
  90030. * Creates a new rotation matrix for "angle" radians around the Z axis
  90031. * @param angle defines the angle (in radians) to use
  90032. * @return the new matrix
  90033. */
  90034. static RotationZ(angle: number): Matrix;
  90035. /**
  90036. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  90037. * @param angle defines the angle (in radians) to use
  90038. * @param result defines the target matrix
  90039. */
  90040. static RotationZToRef(angle: number, result: Matrix): void;
  90041. /**
  90042. * Creates a new rotation matrix for "angle" radians around the given axis
  90043. * @param axis defines the axis to use
  90044. * @param angle defines the angle (in radians) to use
  90045. * @return the new matrix
  90046. */
  90047. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  90048. /**
  90049. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  90050. * @param axis defines the axis to use
  90051. * @param angle defines the angle (in radians) to use
  90052. * @param result defines the target matrix
  90053. */
  90054. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  90055. /**
  90056. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  90057. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  90058. * @param from defines the vector to align
  90059. * @param to defines the vector to align to
  90060. * @param result defines the target matrix
  90061. */
  90062. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  90063. /**
  90064. * Creates a rotation matrix
  90065. * @param yaw defines the yaw angle in radians (Y axis)
  90066. * @param pitch defines the pitch angle in radians (X axis)
  90067. * @param roll defines the roll angle in radians (Z axis)
  90068. * @returns the new rotation matrix
  90069. */
  90070. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  90071. /**
  90072. * Creates a rotation matrix and stores it in a given matrix
  90073. * @param yaw defines the yaw angle in radians (Y axis)
  90074. * @param pitch defines the pitch angle in radians (X axis)
  90075. * @param roll defines the roll angle in radians (Z axis)
  90076. * @param result defines the target matrix
  90077. */
  90078. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  90079. /**
  90080. * Creates a scaling matrix
  90081. * @param x defines the scale factor on X axis
  90082. * @param y defines the scale factor on Y axis
  90083. * @param z defines the scale factor on Z axis
  90084. * @returns the new matrix
  90085. */
  90086. static Scaling(x: number, y: number, z: number): Matrix;
  90087. /**
  90088. * Creates a scaling matrix and stores it in a given matrix
  90089. * @param x defines the scale factor on X axis
  90090. * @param y defines the scale factor on Y axis
  90091. * @param z defines the scale factor on Z axis
  90092. * @param result defines the target matrix
  90093. */
  90094. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  90095. /**
  90096. * Creates a translation matrix
  90097. * @param x defines the translation on X axis
  90098. * @param y defines the translation on Y axis
  90099. * @param z defines the translationon Z axis
  90100. * @returns the new matrix
  90101. */
  90102. static Translation(x: number, y: number, z: number): Matrix;
  90103. /**
  90104. * Creates a translation matrix and stores it in a given matrix
  90105. * @param x defines the translation on X axis
  90106. * @param y defines the translation on Y axis
  90107. * @param z defines the translationon Z axis
  90108. * @param result defines the target matrix
  90109. */
  90110. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  90111. /**
  90112. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90113. * @param startValue defines the start value
  90114. * @param endValue defines the end value
  90115. * @param gradient defines the gradient factor
  90116. * @returns the new matrix
  90117. */
  90118. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90119. /**
  90120. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90121. * @param startValue defines the start value
  90122. * @param endValue defines the end value
  90123. * @param gradient defines the gradient factor
  90124. * @param result defines the Matrix object where to store data
  90125. */
  90126. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90127. /**
  90128. * Builds a new matrix whose values are computed by:
  90129. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90130. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90131. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90132. * @param startValue defines the first matrix
  90133. * @param endValue defines the second matrix
  90134. * @param gradient defines the gradient between the two matrices
  90135. * @returns the new matrix
  90136. */
  90137. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90138. /**
  90139. * Update a matrix to values which are computed by:
  90140. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90141. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90142. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90143. * @param startValue defines the first matrix
  90144. * @param endValue defines the second matrix
  90145. * @param gradient defines the gradient between the two matrices
  90146. * @param result defines the target matrix
  90147. */
  90148. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90149. /**
  90150. * 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"
  90151. * This function works in left handed mode
  90152. * @param eye defines the final position of the entity
  90153. * @param target defines where the entity should look at
  90154. * @param up defines the up vector for the entity
  90155. * @returns the new matrix
  90156. */
  90157. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90158. /**
  90159. * 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".
  90160. * This function works in left handed mode
  90161. * @param eye defines the final position of the entity
  90162. * @param target defines where the entity should look at
  90163. * @param up defines the up vector for the entity
  90164. * @param result defines the target matrix
  90165. */
  90166. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90167. /**
  90168. * 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"
  90169. * This function works in right handed mode
  90170. * @param eye defines the final position of the entity
  90171. * @param target defines where the entity should look at
  90172. * @param up defines the up vector for the entity
  90173. * @returns the new matrix
  90174. */
  90175. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90176. /**
  90177. * 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".
  90178. * This function works in right handed mode
  90179. * @param eye defines the final position of the entity
  90180. * @param target defines where the entity should look at
  90181. * @param up defines the up vector for the entity
  90182. * @param result defines the target matrix
  90183. */
  90184. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90185. /**
  90186. * Create a left-handed orthographic projection matrix
  90187. * @param width defines the viewport width
  90188. * @param height defines the viewport height
  90189. * @param znear defines the near clip plane
  90190. * @param zfar defines the far clip plane
  90191. * @returns a new matrix as a left-handed orthographic projection matrix
  90192. */
  90193. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90194. /**
  90195. * Store a left-handed orthographic projection to a given matrix
  90196. * @param width defines the viewport width
  90197. * @param height defines the viewport height
  90198. * @param znear defines the near clip plane
  90199. * @param zfar defines the far clip plane
  90200. * @param result defines the target matrix
  90201. */
  90202. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  90203. /**
  90204. * Create a left-handed orthographic projection matrix
  90205. * @param left defines the viewport left coordinate
  90206. * @param right defines the viewport right coordinate
  90207. * @param bottom defines the viewport bottom coordinate
  90208. * @param top defines the viewport top coordinate
  90209. * @param znear defines the near clip plane
  90210. * @param zfar defines the far clip plane
  90211. * @returns a new matrix as a left-handed orthographic projection matrix
  90212. */
  90213. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90214. /**
  90215. * Stores a left-handed orthographic projection into a given matrix
  90216. * @param left defines the viewport left coordinate
  90217. * @param right defines the viewport right coordinate
  90218. * @param bottom defines the viewport bottom coordinate
  90219. * @param top defines the viewport top coordinate
  90220. * @param znear defines the near clip plane
  90221. * @param zfar defines the far clip plane
  90222. * @param result defines the target matrix
  90223. */
  90224. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90225. /**
  90226. * Creates a right-handed orthographic projection matrix
  90227. * @param left defines the viewport left coordinate
  90228. * @param right defines the viewport right coordinate
  90229. * @param bottom defines the viewport bottom coordinate
  90230. * @param top defines the viewport top coordinate
  90231. * @param znear defines the near clip plane
  90232. * @param zfar defines the far clip plane
  90233. * @returns a new matrix as a right-handed orthographic projection matrix
  90234. */
  90235. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90236. /**
  90237. * Stores a right-handed orthographic projection into a given matrix
  90238. * @param left defines the viewport left coordinate
  90239. * @param right defines the viewport right coordinate
  90240. * @param bottom defines the viewport bottom coordinate
  90241. * @param top defines the viewport top coordinate
  90242. * @param znear defines the near clip plane
  90243. * @param zfar defines the far clip plane
  90244. * @param result defines the target matrix
  90245. */
  90246. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90247. /**
  90248. * Creates a left-handed perspective projection matrix
  90249. * @param width defines the viewport width
  90250. * @param height defines the viewport height
  90251. * @param znear defines the near clip plane
  90252. * @param zfar defines the far clip plane
  90253. * @returns a new matrix as a left-handed perspective projection matrix
  90254. */
  90255. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90256. /**
  90257. * Creates a left-handed perspective projection matrix
  90258. * @param fov defines the horizontal field of view
  90259. * @param aspect defines the aspect ratio
  90260. * @param znear defines the near clip plane
  90261. * @param zfar defines the far clip plane
  90262. * @returns a new matrix as a left-handed perspective projection matrix
  90263. */
  90264. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90265. /**
  90266. * Stores a left-handed perspective projection into a given matrix
  90267. * @param fov defines the horizontal field of view
  90268. * @param aspect defines the aspect ratio
  90269. * @param znear defines the near clip plane
  90270. * @param zfar defines the far clip plane
  90271. * @param result defines the target matrix
  90272. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90273. */
  90274. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90275. /**
  90276. * Stores a left-handed perspective projection into a given matrix with depth reversed
  90277. * @param fov defines the horizontal field of view
  90278. * @param aspect defines the aspect ratio
  90279. * @param znear defines the near clip plane
  90280. * @param zfar not used as infinity is used as far clip
  90281. * @param result defines the target matrix
  90282. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90283. */
  90284. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90285. /**
  90286. * Creates a right-handed perspective projection matrix
  90287. * @param fov defines the horizontal field of view
  90288. * @param aspect defines the aspect ratio
  90289. * @param znear defines the near clip plane
  90290. * @param zfar defines the far clip plane
  90291. * @returns a new matrix as a right-handed perspective projection matrix
  90292. */
  90293. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90294. /**
  90295. * Stores a right-handed perspective projection into a given matrix
  90296. * @param fov defines the horizontal field of view
  90297. * @param aspect defines the aspect ratio
  90298. * @param znear defines the near clip plane
  90299. * @param zfar defines the far clip plane
  90300. * @param result defines the target matrix
  90301. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90302. */
  90303. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90304. /**
  90305. * Stores a right-handed perspective projection into a given matrix
  90306. * @param fov defines the horizontal field of view
  90307. * @param aspect defines the aspect ratio
  90308. * @param znear defines the near clip plane
  90309. * @param zfar not used as infinity is used as far clip
  90310. * @param result defines the target matrix
  90311. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90312. */
  90313. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90314. /**
  90315. * Stores a perspective projection for WebVR info a given matrix
  90316. * @param fov defines the field of view
  90317. * @param znear defines the near clip plane
  90318. * @param zfar defines the far clip plane
  90319. * @param result defines the target matrix
  90320. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  90321. */
  90322. static PerspectiveFovWebVRToRef(fov: {
  90323. upDegrees: number;
  90324. downDegrees: number;
  90325. leftDegrees: number;
  90326. rightDegrees: number;
  90327. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  90328. /**
  90329. * Computes a complete transformation matrix
  90330. * @param viewport defines the viewport to use
  90331. * @param world defines the world matrix
  90332. * @param view defines the view matrix
  90333. * @param projection defines the projection matrix
  90334. * @param zmin defines the near clip plane
  90335. * @param zmax defines the far clip plane
  90336. * @returns the transformation matrix
  90337. */
  90338. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  90339. /**
  90340. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  90341. * @param matrix defines the matrix to use
  90342. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  90343. */
  90344. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90345. /**
  90346. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  90347. * @param matrix defines the matrix to use
  90348. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  90349. */
  90350. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90351. /**
  90352. * Compute the transpose of a given matrix
  90353. * @param matrix defines the matrix to transpose
  90354. * @returns the new matrix
  90355. */
  90356. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  90357. /**
  90358. * Compute the transpose of a matrix and store it in a target matrix
  90359. * @param matrix defines the matrix to transpose
  90360. * @param result defines the target matrix
  90361. */
  90362. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  90363. /**
  90364. * Computes a reflection matrix from a plane
  90365. * @param plane defines the reflection plane
  90366. * @returns a new matrix
  90367. */
  90368. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  90369. /**
  90370. * Computes a reflection matrix from a plane
  90371. * @param plane defines the reflection plane
  90372. * @param result defines the target matrix
  90373. */
  90374. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  90375. /**
  90376. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  90377. * @param xaxis defines the value of the 1st axis
  90378. * @param yaxis defines the value of the 2nd axis
  90379. * @param zaxis defines the value of the 3rd axis
  90380. * @param result defines the target matrix
  90381. */
  90382. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  90383. /**
  90384. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  90385. * @param quat defines the quaternion to use
  90386. * @param result defines the target matrix
  90387. */
  90388. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  90389. }
  90390. /**
  90391. * @hidden
  90392. */
  90393. export class TmpVectors {
  90394. static Vector2: Vector2[];
  90395. static Vector3: Vector3[];
  90396. static Vector4: Vector4[];
  90397. static Quaternion: Quaternion[];
  90398. static Matrix: Matrix[];
  90399. }
  90400. }
  90401. declare module BABYLON {
  90402. /**
  90403. * Defines potential orientation for back face culling
  90404. */
  90405. export enum Orientation {
  90406. /**
  90407. * Clockwise
  90408. */
  90409. CW = 0,
  90410. /** Counter clockwise */
  90411. CCW = 1
  90412. }
  90413. /** Class used to represent a Bezier curve */
  90414. export class BezierCurve {
  90415. /**
  90416. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  90417. * @param t defines the time
  90418. * @param x1 defines the left coordinate on X axis
  90419. * @param y1 defines the left coordinate on Y axis
  90420. * @param x2 defines the right coordinate on X axis
  90421. * @param y2 defines the right coordinate on Y axis
  90422. * @returns the interpolated value
  90423. */
  90424. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  90425. }
  90426. /**
  90427. * Defines angle representation
  90428. */
  90429. export class Angle {
  90430. private _radians;
  90431. /**
  90432. * Creates an Angle object of "radians" radians (float).
  90433. * @param radians the angle in radians
  90434. */
  90435. constructor(radians: number);
  90436. /**
  90437. * Get value in degrees
  90438. * @returns the Angle value in degrees (float)
  90439. */
  90440. degrees(): number;
  90441. /**
  90442. * Get value in radians
  90443. * @returns the Angle value in radians (float)
  90444. */
  90445. radians(): number;
  90446. /**
  90447. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  90448. * @param a defines first point as the origin
  90449. * @param b defines point
  90450. * @returns a new Angle
  90451. */
  90452. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  90453. /**
  90454. * Gets a new Angle object from the given float in radians
  90455. * @param radians defines the angle value in radians
  90456. * @returns a new Angle
  90457. */
  90458. static FromRadians(radians: number): Angle;
  90459. /**
  90460. * Gets a new Angle object from the given float in degrees
  90461. * @param degrees defines the angle value in degrees
  90462. * @returns a new Angle
  90463. */
  90464. static FromDegrees(degrees: number): Angle;
  90465. }
  90466. /**
  90467. * This represents an arc in a 2d space.
  90468. */
  90469. export class Arc2 {
  90470. /** Defines the start point of the arc */
  90471. startPoint: Vector2;
  90472. /** Defines the mid point of the arc */
  90473. midPoint: Vector2;
  90474. /** Defines the end point of the arc */
  90475. endPoint: Vector2;
  90476. /**
  90477. * Defines the center point of the arc.
  90478. */
  90479. centerPoint: Vector2;
  90480. /**
  90481. * Defines the radius of the arc.
  90482. */
  90483. radius: number;
  90484. /**
  90485. * Defines the angle of the arc (from mid point to end point).
  90486. */
  90487. angle: Angle;
  90488. /**
  90489. * Defines the start angle of the arc (from start point to middle point).
  90490. */
  90491. startAngle: Angle;
  90492. /**
  90493. * Defines the orientation of the arc (clock wise/counter clock wise).
  90494. */
  90495. orientation: Orientation;
  90496. /**
  90497. * Creates an Arc object from the three given points : start, middle and end.
  90498. * @param startPoint Defines the start point of the arc
  90499. * @param midPoint Defines the midlle point of the arc
  90500. * @param endPoint Defines the end point of the arc
  90501. */
  90502. constructor(
  90503. /** Defines the start point of the arc */
  90504. startPoint: Vector2,
  90505. /** Defines the mid point of the arc */
  90506. midPoint: Vector2,
  90507. /** Defines the end point of the arc */
  90508. endPoint: Vector2);
  90509. }
  90510. /**
  90511. * Represents a 2D path made up of multiple 2D points
  90512. */
  90513. export class Path2 {
  90514. private _points;
  90515. private _length;
  90516. /**
  90517. * If the path start and end point are the same
  90518. */
  90519. closed: boolean;
  90520. /**
  90521. * Creates a Path2 object from the starting 2D coordinates x and y.
  90522. * @param x the starting points x value
  90523. * @param y the starting points y value
  90524. */
  90525. constructor(x: number, y: number);
  90526. /**
  90527. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  90528. * @param x the added points x value
  90529. * @param y the added points y value
  90530. * @returns the updated Path2.
  90531. */
  90532. addLineTo(x: number, y: number): Path2;
  90533. /**
  90534. * 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.
  90535. * @param midX middle point x value
  90536. * @param midY middle point y value
  90537. * @param endX end point x value
  90538. * @param endY end point y value
  90539. * @param numberOfSegments (default: 36)
  90540. * @returns the updated Path2.
  90541. */
  90542. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  90543. /**
  90544. * Closes the Path2.
  90545. * @returns the Path2.
  90546. */
  90547. close(): Path2;
  90548. /**
  90549. * Gets the sum of the distance between each sequential point in the path
  90550. * @returns the Path2 total length (float).
  90551. */
  90552. length(): number;
  90553. /**
  90554. * Gets the points which construct the path
  90555. * @returns the Path2 internal array of points.
  90556. */
  90557. getPoints(): Vector2[];
  90558. /**
  90559. * Retreives the point at the distance aways from the starting point
  90560. * @param normalizedLengthPosition the length along the path to retreive the point from
  90561. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  90562. */
  90563. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  90564. /**
  90565. * Creates a new path starting from an x and y position
  90566. * @param x starting x value
  90567. * @param y starting y value
  90568. * @returns a new Path2 starting at the coordinates (x, y).
  90569. */
  90570. static StartingAt(x: number, y: number): Path2;
  90571. }
  90572. /**
  90573. * Represents a 3D path made up of multiple 3D points
  90574. */
  90575. export class Path3D {
  90576. /**
  90577. * an array of Vector3, the curve axis of the Path3D
  90578. */
  90579. path: Vector3[];
  90580. private _curve;
  90581. private _distances;
  90582. private _tangents;
  90583. private _normals;
  90584. private _binormals;
  90585. private _raw;
  90586. private _alignTangentsWithPath;
  90587. private readonly _pointAtData;
  90588. /**
  90589. * new Path3D(path, normal, raw)
  90590. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  90591. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  90592. * @param path an array of Vector3, the curve axis of the Path3D
  90593. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  90594. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  90595. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  90596. */
  90597. constructor(
  90598. /**
  90599. * an array of Vector3, the curve axis of the Path3D
  90600. */
  90601. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  90602. /**
  90603. * Returns the Path3D array of successive Vector3 designing its curve.
  90604. * @returns the Path3D array of successive Vector3 designing its curve.
  90605. */
  90606. getCurve(): Vector3[];
  90607. /**
  90608. * Returns the Path3D array of successive Vector3 designing its curve.
  90609. * @returns the Path3D array of successive Vector3 designing its curve.
  90610. */
  90611. getPoints(): Vector3[];
  90612. /**
  90613. * @returns the computed length (float) of the path.
  90614. */
  90615. length(): number;
  90616. /**
  90617. * Returns an array populated with tangent vectors on each Path3D curve point.
  90618. * @returns an array populated with tangent vectors on each Path3D curve point.
  90619. */
  90620. getTangents(): Vector3[];
  90621. /**
  90622. * Returns an array populated with normal vectors on each Path3D curve point.
  90623. * @returns an array populated with normal vectors on each Path3D curve point.
  90624. */
  90625. getNormals(): Vector3[];
  90626. /**
  90627. * Returns an array populated with binormal vectors on each Path3D curve point.
  90628. * @returns an array populated with binormal vectors on each Path3D curve point.
  90629. */
  90630. getBinormals(): Vector3[];
  90631. /**
  90632. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  90633. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  90634. */
  90635. getDistances(): number[];
  90636. /**
  90637. * Returns an interpolated point along this path
  90638. * @param position the position of the point along this path, from 0.0 to 1.0
  90639. * @returns a new Vector3 as the point
  90640. */
  90641. getPointAt(position: number): Vector3;
  90642. /**
  90643. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90644. * @param position the position of the point along this path, from 0.0 to 1.0
  90645. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  90646. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  90647. */
  90648. getTangentAt(position: number, interpolated?: boolean): Vector3;
  90649. /**
  90650. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90651. * @param position the position of the point along this path, from 0.0 to 1.0
  90652. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  90653. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  90654. */
  90655. getNormalAt(position: number, interpolated?: boolean): Vector3;
  90656. /**
  90657. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  90658. * @param position the position of the point along this path, from 0.0 to 1.0
  90659. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  90660. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  90661. */
  90662. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  90663. /**
  90664. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  90665. * @param position the position of the point along this path, from 0.0 to 1.0
  90666. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  90667. */
  90668. getDistanceAt(position: number): number;
  90669. /**
  90670. * Returns the array index of the previous point of an interpolated point along this path
  90671. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90672. * @returns the array index
  90673. */
  90674. getPreviousPointIndexAt(position: number): number;
  90675. /**
  90676. * 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)
  90677. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90678. * @returns the sub position
  90679. */
  90680. getSubPositionAt(position: number): number;
  90681. /**
  90682. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  90683. * @param target the vector of which to get the closest position to
  90684. * @returns the position of the closest virtual point on this path to the target vector
  90685. */
  90686. getClosestPositionTo(target: Vector3): number;
  90687. /**
  90688. * Returns a sub path (slice) of this path
  90689. * @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
  90690. * @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
  90691. * @returns a sub path (slice) of this path
  90692. */
  90693. slice(start?: number, end?: number): Path3D;
  90694. /**
  90695. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  90696. * @param path path which all values are copied into the curves points
  90697. * @param firstNormal which should be projected onto the curve
  90698. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  90699. * @returns the same object updated.
  90700. */
  90701. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  90702. private _compute;
  90703. private _getFirstNonNullVector;
  90704. private _getLastNonNullVector;
  90705. private _normalVector;
  90706. /**
  90707. * Updates the point at data for an interpolated point along this curve
  90708. * @param position the position of the point along this curve, from 0.0 to 1.0
  90709. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  90710. * @returns the (updated) point at data
  90711. */
  90712. private _updatePointAtData;
  90713. /**
  90714. * Updates the point at data from the specified parameters
  90715. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  90716. * @param point the interpolated point
  90717. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  90718. */
  90719. private _setPointAtData;
  90720. /**
  90721. * Updates the point at interpolation matrix for the tangents, normals and binormals
  90722. */
  90723. private _updateInterpolationMatrix;
  90724. }
  90725. /**
  90726. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90727. * A Curve3 is designed from a series of successive Vector3.
  90728. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  90729. */
  90730. export class Curve3 {
  90731. private _points;
  90732. private _length;
  90733. /**
  90734. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  90735. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  90736. * @param v1 (Vector3) the control point
  90737. * @param v2 (Vector3) the end point of the Quadratic Bezier
  90738. * @param nbPoints (integer) the wanted number of points in the curve
  90739. * @returns the created Curve3
  90740. */
  90741. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90742. /**
  90743. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  90744. * @param v0 (Vector3) the origin point of the Cubic Bezier
  90745. * @param v1 (Vector3) the first control point
  90746. * @param v2 (Vector3) the second control point
  90747. * @param v3 (Vector3) the end point of the Cubic Bezier
  90748. * @param nbPoints (integer) the wanted number of points in the curve
  90749. * @returns the created Curve3
  90750. */
  90751. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90752. /**
  90753. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  90754. * @param p1 (Vector3) the origin point of the Hermite Spline
  90755. * @param t1 (Vector3) the tangent vector at the origin point
  90756. * @param p2 (Vector3) the end point of the Hermite Spline
  90757. * @param t2 (Vector3) the tangent vector at the end point
  90758. * @param nbPoints (integer) the wanted number of points in the curve
  90759. * @returns the created Curve3
  90760. */
  90761. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90762. /**
  90763. * Returns a Curve3 object along a CatmullRom Spline curve :
  90764. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  90765. * @param nbPoints (integer) the wanted number of points between each curve control points
  90766. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  90767. * @returns the created Curve3
  90768. */
  90769. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  90770. /**
  90771. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90772. * A Curve3 is designed from a series of successive Vector3.
  90773. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  90774. * @param points points which make up the curve
  90775. */
  90776. constructor(points: Vector3[]);
  90777. /**
  90778. * @returns the Curve3 stored array of successive Vector3
  90779. */
  90780. getPoints(): Vector3[];
  90781. /**
  90782. * @returns the computed length (float) of the curve.
  90783. */
  90784. length(): number;
  90785. /**
  90786. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  90787. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  90788. * curveA and curveB keep unchanged.
  90789. * @param curve the curve to continue from this curve
  90790. * @returns the newly constructed curve
  90791. */
  90792. continue(curve: DeepImmutable<Curve3>): Curve3;
  90793. private _computeLength;
  90794. }
  90795. }
  90796. declare module BABYLON {
  90797. /**
  90798. * This represents the main contract an easing function should follow.
  90799. * Easing functions are used throughout the animation system.
  90800. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90801. */
  90802. export interface IEasingFunction {
  90803. /**
  90804. * Given an input gradient between 0 and 1, this returns the corrseponding value
  90805. * of the easing function.
  90806. * The link below provides some of the most common examples of easing functions.
  90807. * @see https://easings.net/
  90808. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90809. * @returns the corresponding value on the curve defined by the easing function
  90810. */
  90811. ease(gradient: number): number;
  90812. }
  90813. /**
  90814. * Base class used for every default easing function.
  90815. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90816. */
  90817. export class EasingFunction implements IEasingFunction {
  90818. /**
  90819. * Interpolation follows the mathematical formula associated with the easing function.
  90820. */
  90821. static readonly EASINGMODE_EASEIN: number;
  90822. /**
  90823. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  90824. */
  90825. static readonly EASINGMODE_EASEOUT: number;
  90826. /**
  90827. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  90828. */
  90829. static readonly EASINGMODE_EASEINOUT: number;
  90830. private _easingMode;
  90831. /**
  90832. * Sets the easing mode of the current function.
  90833. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  90834. */
  90835. setEasingMode(easingMode: number): void;
  90836. /**
  90837. * Gets the current easing mode.
  90838. * @returns the easing mode
  90839. */
  90840. getEasingMode(): number;
  90841. /**
  90842. * @hidden
  90843. */
  90844. easeInCore(gradient: number): number;
  90845. /**
  90846. * Given an input gradient between 0 and 1, this returns the corresponding value
  90847. * of the easing function.
  90848. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90849. * @returns the corresponding value on the curve defined by the easing function
  90850. */
  90851. ease(gradient: number): number;
  90852. }
  90853. /**
  90854. * Easing function with a circle shape (see link below).
  90855. * @see https://easings.net/#easeInCirc
  90856. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90857. */
  90858. export class CircleEase extends EasingFunction implements IEasingFunction {
  90859. /** @hidden */
  90860. easeInCore(gradient: number): number;
  90861. }
  90862. /**
  90863. * Easing function with a ease back shape (see link below).
  90864. * @see https://easings.net/#easeInBack
  90865. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90866. */
  90867. export class BackEase extends EasingFunction implements IEasingFunction {
  90868. /** Defines the amplitude of the function */
  90869. amplitude: number;
  90870. /**
  90871. * Instantiates a back ease easing
  90872. * @see https://easings.net/#easeInBack
  90873. * @param amplitude Defines the amplitude of the function
  90874. */
  90875. constructor(
  90876. /** Defines the amplitude of the function */
  90877. amplitude?: number);
  90878. /** @hidden */
  90879. easeInCore(gradient: number): number;
  90880. }
  90881. /**
  90882. * Easing function with a bouncing shape (see link below).
  90883. * @see https://easings.net/#easeInBounce
  90884. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90885. */
  90886. export class BounceEase extends EasingFunction implements IEasingFunction {
  90887. /** Defines the number of bounces */
  90888. bounces: number;
  90889. /** Defines the amplitude of the bounce */
  90890. bounciness: number;
  90891. /**
  90892. * Instantiates a bounce easing
  90893. * @see https://easings.net/#easeInBounce
  90894. * @param bounces Defines the number of bounces
  90895. * @param bounciness Defines the amplitude of the bounce
  90896. */
  90897. constructor(
  90898. /** Defines the number of bounces */
  90899. bounces?: number,
  90900. /** Defines the amplitude of the bounce */
  90901. bounciness?: number);
  90902. /** @hidden */
  90903. easeInCore(gradient: number): number;
  90904. }
  90905. /**
  90906. * Easing function with a power of 3 shape (see link below).
  90907. * @see https://easings.net/#easeInCubic
  90908. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90909. */
  90910. export class CubicEase extends EasingFunction implements IEasingFunction {
  90911. /** @hidden */
  90912. easeInCore(gradient: number): number;
  90913. }
  90914. /**
  90915. * Easing function with an elastic shape (see link below).
  90916. * @see https://easings.net/#easeInElastic
  90917. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90918. */
  90919. export class ElasticEase extends EasingFunction implements IEasingFunction {
  90920. /** Defines the number of oscillations*/
  90921. oscillations: number;
  90922. /** Defines the amplitude of the oscillations*/
  90923. springiness: number;
  90924. /**
  90925. * Instantiates an elastic easing function
  90926. * @see https://easings.net/#easeInElastic
  90927. * @param oscillations Defines the number of oscillations
  90928. * @param springiness Defines the amplitude of the oscillations
  90929. */
  90930. constructor(
  90931. /** Defines the number of oscillations*/
  90932. oscillations?: number,
  90933. /** Defines the amplitude of the oscillations*/
  90934. springiness?: number);
  90935. /** @hidden */
  90936. easeInCore(gradient: number): number;
  90937. }
  90938. /**
  90939. * Easing function with an exponential shape (see link below).
  90940. * @see https://easings.net/#easeInExpo
  90941. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90942. */
  90943. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  90944. /** Defines the exponent of the function */
  90945. exponent: number;
  90946. /**
  90947. * Instantiates an exponential easing function
  90948. * @see https://easings.net/#easeInExpo
  90949. * @param exponent Defines the exponent of the function
  90950. */
  90951. constructor(
  90952. /** Defines the exponent of the function */
  90953. exponent?: number);
  90954. /** @hidden */
  90955. easeInCore(gradient: number): number;
  90956. }
  90957. /**
  90958. * Easing function with a power shape (see link below).
  90959. * @see https://easings.net/#easeInQuad
  90960. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90961. */
  90962. export class PowerEase extends EasingFunction implements IEasingFunction {
  90963. /** Defines the power of the function */
  90964. power: number;
  90965. /**
  90966. * Instantiates an power base easing function
  90967. * @see https://easings.net/#easeInQuad
  90968. * @param power Defines the power of the function
  90969. */
  90970. constructor(
  90971. /** Defines the power of the function */
  90972. power?: number);
  90973. /** @hidden */
  90974. easeInCore(gradient: number): number;
  90975. }
  90976. /**
  90977. * Easing function with a power of 2 shape (see link below).
  90978. * @see https://easings.net/#easeInQuad
  90979. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90980. */
  90981. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  90982. /** @hidden */
  90983. easeInCore(gradient: number): number;
  90984. }
  90985. /**
  90986. * Easing function with a power of 4 shape (see link below).
  90987. * @see https://easings.net/#easeInQuart
  90988. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90989. */
  90990. export class QuarticEase extends EasingFunction implements IEasingFunction {
  90991. /** @hidden */
  90992. easeInCore(gradient: number): number;
  90993. }
  90994. /**
  90995. * Easing function with a power of 5 shape (see link below).
  90996. * @see https://easings.net/#easeInQuint
  90997. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90998. */
  90999. export class QuinticEase extends EasingFunction implements IEasingFunction {
  91000. /** @hidden */
  91001. easeInCore(gradient: number): number;
  91002. }
  91003. /**
  91004. * Easing function with a sin shape (see link below).
  91005. * @see https://easings.net/#easeInSine
  91006. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91007. */
  91008. export class SineEase extends EasingFunction implements IEasingFunction {
  91009. /** @hidden */
  91010. easeInCore(gradient: number): number;
  91011. }
  91012. /**
  91013. * Easing function with a bezier shape (see link below).
  91014. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91015. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91016. */
  91017. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  91018. /** Defines the x component of the start tangent in the bezier curve */
  91019. x1: number;
  91020. /** Defines the y component of the start tangent in the bezier curve */
  91021. y1: number;
  91022. /** Defines the x component of the end tangent in the bezier curve */
  91023. x2: number;
  91024. /** Defines the y component of the end tangent in the bezier curve */
  91025. y2: number;
  91026. /**
  91027. * Instantiates a bezier function
  91028. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91029. * @param x1 Defines the x component of the start tangent in the bezier curve
  91030. * @param y1 Defines the y component of the start tangent in the bezier curve
  91031. * @param x2 Defines the x component of the end tangent in the bezier curve
  91032. * @param y2 Defines the y component of the end tangent in the bezier curve
  91033. */
  91034. constructor(
  91035. /** Defines the x component of the start tangent in the bezier curve */
  91036. x1?: number,
  91037. /** Defines the y component of the start tangent in the bezier curve */
  91038. y1?: number,
  91039. /** Defines the x component of the end tangent in the bezier curve */
  91040. x2?: number,
  91041. /** Defines the y component of the end tangent in the bezier curve */
  91042. y2?: number);
  91043. /** @hidden */
  91044. easeInCore(gradient: number): number;
  91045. }
  91046. }
  91047. declare module BABYLON {
  91048. /**
  91049. * Class used to hold a RGB color
  91050. */
  91051. export class Color3 {
  91052. /**
  91053. * Defines the red component (between 0 and 1, default is 0)
  91054. */
  91055. r: number;
  91056. /**
  91057. * Defines the green component (between 0 and 1, default is 0)
  91058. */
  91059. g: number;
  91060. /**
  91061. * Defines the blue component (between 0 and 1, default is 0)
  91062. */
  91063. b: number;
  91064. /**
  91065. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  91066. * @param r defines the red component (between 0 and 1, default is 0)
  91067. * @param g defines the green component (between 0 and 1, default is 0)
  91068. * @param b defines the blue component (between 0 and 1, default is 0)
  91069. */
  91070. constructor(
  91071. /**
  91072. * Defines the red component (between 0 and 1, default is 0)
  91073. */
  91074. r?: number,
  91075. /**
  91076. * Defines the green component (between 0 and 1, default is 0)
  91077. */
  91078. g?: number,
  91079. /**
  91080. * Defines the blue component (between 0 and 1, default is 0)
  91081. */
  91082. b?: number);
  91083. /**
  91084. * Creates a string with the Color3 current values
  91085. * @returns the string representation of the Color3 object
  91086. */
  91087. toString(): string;
  91088. /**
  91089. * Returns the string "Color3"
  91090. * @returns "Color3"
  91091. */
  91092. getClassName(): string;
  91093. /**
  91094. * Compute the Color3 hash code
  91095. * @returns an unique number that can be used to hash Color3 objects
  91096. */
  91097. getHashCode(): number;
  91098. /**
  91099. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  91100. * @param array defines the array where to store the r,g,b components
  91101. * @param index defines an optional index in the target array to define where to start storing values
  91102. * @returns the current Color3 object
  91103. */
  91104. toArray(array: FloatArray, index?: number): Color3;
  91105. /**
  91106. * Update the current color with values stored in an array from the starting index of the given array
  91107. * @param array defines the source array
  91108. * @param offset defines an offset in the source array
  91109. * @returns the current Color3 object
  91110. */
  91111. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91112. /**
  91113. * Returns a new Color4 object from the current Color3 and the given alpha
  91114. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  91115. * @returns a new Color4 object
  91116. */
  91117. toColor4(alpha?: number): Color4;
  91118. /**
  91119. * Returns a new array populated with 3 numeric elements : red, green and blue values
  91120. * @returns the new array
  91121. */
  91122. asArray(): number[];
  91123. /**
  91124. * Returns the luminance value
  91125. * @returns a float value
  91126. */
  91127. toLuminance(): number;
  91128. /**
  91129. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  91130. * @param otherColor defines the second operand
  91131. * @returns the new Color3 object
  91132. */
  91133. multiply(otherColor: DeepImmutable<Color3>): Color3;
  91134. /**
  91135. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  91136. * @param otherColor defines the second operand
  91137. * @param result defines the Color3 object where to store the result
  91138. * @returns the current Color3
  91139. */
  91140. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91141. /**
  91142. * Determines equality between Color3 objects
  91143. * @param otherColor defines the second operand
  91144. * @returns true if the rgb values are equal to the given ones
  91145. */
  91146. equals(otherColor: DeepImmutable<Color3>): boolean;
  91147. /**
  91148. * Determines equality between the current Color3 object and a set of r,b,g values
  91149. * @param r defines the red component to check
  91150. * @param g defines the green component to check
  91151. * @param b defines the blue component to check
  91152. * @returns true if the rgb values are equal to the given ones
  91153. */
  91154. equalsFloats(r: number, g: number, b: number): boolean;
  91155. /**
  91156. * Multiplies in place each rgb value by scale
  91157. * @param scale defines the scaling factor
  91158. * @returns the updated Color3
  91159. */
  91160. scale(scale: number): Color3;
  91161. /**
  91162. * Multiplies the rgb values by scale and stores the result into "result"
  91163. * @param scale defines the scaling factor
  91164. * @param result defines the Color3 object where to store the result
  91165. * @returns the unmodified current Color3
  91166. */
  91167. scaleToRef(scale: number, result: Color3): Color3;
  91168. /**
  91169. * Scale the current Color3 values by a factor and add the result to a given Color3
  91170. * @param scale defines the scale factor
  91171. * @param result defines color to store the result into
  91172. * @returns the unmodified current Color3
  91173. */
  91174. scaleAndAddToRef(scale: number, result: Color3): Color3;
  91175. /**
  91176. * Clamps the rgb values by the min and max values and stores the result into "result"
  91177. * @param min defines minimum clamping value (default is 0)
  91178. * @param max defines maximum clamping value (default is 1)
  91179. * @param result defines color to store the result into
  91180. * @returns the original Color3
  91181. */
  91182. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  91183. /**
  91184. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  91185. * @param otherColor defines the second operand
  91186. * @returns the new Color3
  91187. */
  91188. add(otherColor: DeepImmutable<Color3>): Color3;
  91189. /**
  91190. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  91191. * @param otherColor defines the second operand
  91192. * @param result defines Color3 object to store the result into
  91193. * @returns the unmodified current Color3
  91194. */
  91195. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91196. /**
  91197. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  91198. * @param otherColor defines the second operand
  91199. * @returns the new Color3
  91200. */
  91201. subtract(otherColor: DeepImmutable<Color3>): Color3;
  91202. /**
  91203. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  91204. * @param otherColor defines the second operand
  91205. * @param result defines Color3 object to store the result into
  91206. * @returns the unmodified current Color3
  91207. */
  91208. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91209. /**
  91210. * Copy the current object
  91211. * @returns a new Color3 copied the current one
  91212. */
  91213. clone(): Color3;
  91214. /**
  91215. * Copies the rgb values from the source in the current Color3
  91216. * @param source defines the source Color3 object
  91217. * @returns the updated Color3 object
  91218. */
  91219. copyFrom(source: DeepImmutable<Color3>): Color3;
  91220. /**
  91221. * Updates the Color3 rgb values from the given floats
  91222. * @param r defines the red component to read from
  91223. * @param g defines the green component to read from
  91224. * @param b defines the blue component to read from
  91225. * @returns the current Color3 object
  91226. */
  91227. copyFromFloats(r: number, g: number, b: number): Color3;
  91228. /**
  91229. * Updates the Color3 rgb values from the given floats
  91230. * @param r defines the red component to read from
  91231. * @param g defines the green component to read from
  91232. * @param b defines the blue component to read from
  91233. * @returns the current Color3 object
  91234. */
  91235. set(r: number, g: number, b: number): Color3;
  91236. /**
  91237. * Compute the Color3 hexadecimal code as a string
  91238. * @returns a string containing the hexadecimal representation of the Color3 object
  91239. */
  91240. toHexString(): string;
  91241. /**
  91242. * Computes a new Color3 converted from the current one to linear space
  91243. * @returns a new Color3 object
  91244. */
  91245. toLinearSpace(): Color3;
  91246. /**
  91247. * Converts current color in rgb space to HSV values
  91248. * @returns a new color3 representing the HSV values
  91249. */
  91250. toHSV(): Color3;
  91251. /**
  91252. * Converts current color in rgb space to HSV values
  91253. * @param result defines the Color3 where to store the HSV values
  91254. */
  91255. toHSVToRef(result: Color3): void;
  91256. /**
  91257. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  91258. * @param convertedColor defines the Color3 object where to store the linear space version
  91259. * @returns the unmodified Color3
  91260. */
  91261. toLinearSpaceToRef(convertedColor: Color3): Color3;
  91262. /**
  91263. * Computes a new Color3 converted from the current one to gamma space
  91264. * @returns a new Color3 object
  91265. */
  91266. toGammaSpace(): Color3;
  91267. /**
  91268. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  91269. * @param convertedColor defines the Color3 object where to store the gamma space version
  91270. * @returns the unmodified Color3
  91271. */
  91272. toGammaSpaceToRef(convertedColor: Color3): Color3;
  91273. private static _BlackReadOnly;
  91274. /**
  91275. * Convert Hue, saturation and value to a Color3 (RGB)
  91276. * @param hue defines the hue
  91277. * @param saturation defines the saturation
  91278. * @param value defines the value
  91279. * @param result defines the Color3 where to store the RGB values
  91280. */
  91281. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  91282. /**
  91283. * Creates a new Color3 from the string containing valid hexadecimal values
  91284. * @param hex defines a string containing valid hexadecimal values
  91285. * @returns a new Color3 object
  91286. */
  91287. static FromHexString(hex: string): Color3;
  91288. /**
  91289. * Creates a new Color3 from the starting index of the given array
  91290. * @param array defines the source array
  91291. * @param offset defines an offset in the source array
  91292. * @returns a new Color3 object
  91293. */
  91294. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91295. /**
  91296. * Creates a new Color3 from the starting index element of the given array
  91297. * @param array defines the source array to read from
  91298. * @param offset defines the offset in the source array
  91299. * @param result defines the target Color3 object
  91300. */
  91301. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  91302. /**
  91303. * Creates a new Color3 from integer values (< 256)
  91304. * @param r defines the red component to read from (value between 0 and 255)
  91305. * @param g defines the green component to read from (value between 0 and 255)
  91306. * @param b defines the blue component to read from (value between 0 and 255)
  91307. * @returns a new Color3 object
  91308. */
  91309. static FromInts(r: number, g: number, b: number): Color3;
  91310. /**
  91311. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91312. * @param start defines the start Color3 value
  91313. * @param end defines the end Color3 value
  91314. * @param amount defines the gradient value between start and end
  91315. * @returns a new Color3 object
  91316. */
  91317. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  91318. /**
  91319. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91320. * @param left defines the start value
  91321. * @param right defines the end value
  91322. * @param amount defines the gradient factor
  91323. * @param result defines the Color3 object where to store the result
  91324. */
  91325. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  91326. /**
  91327. * Returns a Color3 value containing a red color
  91328. * @returns a new Color3 object
  91329. */
  91330. static Red(): Color3;
  91331. /**
  91332. * Returns a Color3 value containing a green color
  91333. * @returns a new Color3 object
  91334. */
  91335. static Green(): Color3;
  91336. /**
  91337. * Returns a Color3 value containing a blue color
  91338. * @returns a new Color3 object
  91339. */
  91340. static Blue(): Color3;
  91341. /**
  91342. * Returns a Color3 value containing a black color
  91343. * @returns a new Color3 object
  91344. */
  91345. static Black(): Color3;
  91346. /**
  91347. * Gets a Color3 value containing a black color that must not be updated
  91348. */
  91349. static get BlackReadOnly(): DeepImmutable<Color3>;
  91350. /**
  91351. * Returns a Color3 value containing a white color
  91352. * @returns a new Color3 object
  91353. */
  91354. static White(): Color3;
  91355. /**
  91356. * Returns a Color3 value containing a purple color
  91357. * @returns a new Color3 object
  91358. */
  91359. static Purple(): Color3;
  91360. /**
  91361. * Returns a Color3 value containing a magenta color
  91362. * @returns a new Color3 object
  91363. */
  91364. static Magenta(): Color3;
  91365. /**
  91366. * Returns a Color3 value containing a yellow color
  91367. * @returns a new Color3 object
  91368. */
  91369. static Yellow(): Color3;
  91370. /**
  91371. * Returns a Color3 value containing a gray color
  91372. * @returns a new Color3 object
  91373. */
  91374. static Gray(): Color3;
  91375. /**
  91376. * Returns a Color3 value containing a teal color
  91377. * @returns a new Color3 object
  91378. */
  91379. static Teal(): Color3;
  91380. /**
  91381. * Returns a Color3 value containing a random color
  91382. * @returns a new Color3 object
  91383. */
  91384. static Random(): Color3;
  91385. }
  91386. /**
  91387. * Class used to hold a RBGA color
  91388. */
  91389. export class Color4 {
  91390. /**
  91391. * Defines the red component (between 0 and 1, default is 0)
  91392. */
  91393. r: number;
  91394. /**
  91395. * Defines the green component (between 0 and 1, default is 0)
  91396. */
  91397. g: number;
  91398. /**
  91399. * Defines the blue component (between 0 and 1, default is 0)
  91400. */
  91401. b: number;
  91402. /**
  91403. * Defines the alpha component (between 0 and 1, default is 1)
  91404. */
  91405. a: number;
  91406. /**
  91407. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  91408. * @param r defines the red component (between 0 and 1, default is 0)
  91409. * @param g defines the green component (between 0 and 1, default is 0)
  91410. * @param b defines the blue component (between 0 and 1, default is 0)
  91411. * @param a defines the alpha component (between 0 and 1, default is 1)
  91412. */
  91413. constructor(
  91414. /**
  91415. * Defines the red component (between 0 and 1, default is 0)
  91416. */
  91417. r?: number,
  91418. /**
  91419. * Defines the green component (between 0 and 1, default is 0)
  91420. */
  91421. g?: number,
  91422. /**
  91423. * Defines the blue component (between 0 and 1, default is 0)
  91424. */
  91425. b?: number,
  91426. /**
  91427. * Defines the alpha component (between 0 and 1, default is 1)
  91428. */
  91429. a?: number);
  91430. /**
  91431. * Adds in place the given Color4 values to the current Color4 object
  91432. * @param right defines the second operand
  91433. * @returns the current updated Color4 object
  91434. */
  91435. addInPlace(right: DeepImmutable<Color4>): Color4;
  91436. /**
  91437. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  91438. * @returns the new array
  91439. */
  91440. asArray(): number[];
  91441. /**
  91442. * Stores from the starting index in the given array the Color4 successive values
  91443. * @param array defines the array where to store the r,g,b components
  91444. * @param index defines an optional index in the target array to define where to start storing values
  91445. * @returns the current Color4 object
  91446. */
  91447. toArray(array: number[], index?: number): Color4;
  91448. /**
  91449. * Update the current color with values stored in an array from the starting index of the given array
  91450. * @param array defines the source array
  91451. * @param offset defines an offset in the source array
  91452. * @returns the current Color4 object
  91453. */
  91454. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91455. /**
  91456. * Determines equality between Color4 objects
  91457. * @param otherColor defines the second operand
  91458. * @returns true if the rgba values are equal to the given ones
  91459. */
  91460. equals(otherColor: DeepImmutable<Color4>): boolean;
  91461. /**
  91462. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  91463. * @param right defines the second operand
  91464. * @returns a new Color4 object
  91465. */
  91466. add(right: DeepImmutable<Color4>): Color4;
  91467. /**
  91468. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  91469. * @param right defines the second operand
  91470. * @returns a new Color4 object
  91471. */
  91472. subtract(right: DeepImmutable<Color4>): Color4;
  91473. /**
  91474. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  91475. * @param right defines the second operand
  91476. * @param result defines the Color4 object where to store the result
  91477. * @returns the current Color4 object
  91478. */
  91479. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  91480. /**
  91481. * Creates a new Color4 with the current Color4 values multiplied by scale
  91482. * @param scale defines the scaling factor to apply
  91483. * @returns a new Color4 object
  91484. */
  91485. scale(scale: number): Color4;
  91486. /**
  91487. * Multiplies the current Color4 values by scale and stores the result in "result"
  91488. * @param scale defines the scaling factor to apply
  91489. * @param result defines the Color4 object where to store the result
  91490. * @returns the current unmodified Color4
  91491. */
  91492. scaleToRef(scale: number, result: Color4): Color4;
  91493. /**
  91494. * Scale the current Color4 values by a factor and add the result to a given Color4
  91495. * @param scale defines the scale factor
  91496. * @param result defines the Color4 object where to store the result
  91497. * @returns the unmodified current Color4
  91498. */
  91499. scaleAndAddToRef(scale: number, result: Color4): Color4;
  91500. /**
  91501. * Clamps the rgb values by the min and max values and stores the result into "result"
  91502. * @param min defines minimum clamping value (default is 0)
  91503. * @param max defines maximum clamping value (default is 1)
  91504. * @param result defines color to store the result into.
  91505. * @returns the cuurent Color4
  91506. */
  91507. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  91508. /**
  91509. * Multipy an Color4 value by another and return a new Color4 object
  91510. * @param color defines the Color4 value to multiply by
  91511. * @returns a new Color4 object
  91512. */
  91513. multiply(color: Color4): Color4;
  91514. /**
  91515. * Multipy a Color4 value by another and push the result in a reference value
  91516. * @param color defines the Color4 value to multiply by
  91517. * @param result defines the Color4 to fill the result in
  91518. * @returns the result Color4
  91519. */
  91520. multiplyToRef(color: Color4, result: Color4): Color4;
  91521. /**
  91522. * Creates a string with the Color4 current values
  91523. * @returns the string representation of the Color4 object
  91524. */
  91525. toString(): string;
  91526. /**
  91527. * Returns the string "Color4"
  91528. * @returns "Color4"
  91529. */
  91530. getClassName(): string;
  91531. /**
  91532. * Compute the Color4 hash code
  91533. * @returns an unique number that can be used to hash Color4 objects
  91534. */
  91535. getHashCode(): number;
  91536. /**
  91537. * Creates a new Color4 copied from the current one
  91538. * @returns a new Color4 object
  91539. */
  91540. clone(): Color4;
  91541. /**
  91542. * Copies the given Color4 values into the current one
  91543. * @param source defines the source Color4 object
  91544. * @returns the current updated Color4 object
  91545. */
  91546. copyFrom(source: Color4): Color4;
  91547. /**
  91548. * Copies the given float values into the current one
  91549. * @param r defines the red component to read from
  91550. * @param g defines the green component to read from
  91551. * @param b defines the blue component to read from
  91552. * @param a defines the alpha component to read from
  91553. * @returns the current updated Color4 object
  91554. */
  91555. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  91556. /**
  91557. * Copies the given float values into the current one
  91558. * @param r defines the red component to read from
  91559. * @param g defines the green component to read from
  91560. * @param b defines the blue component to read from
  91561. * @param a defines the alpha component to read from
  91562. * @returns the current updated Color4 object
  91563. */
  91564. set(r: number, g: number, b: number, a: number): Color4;
  91565. /**
  91566. * Compute the Color4 hexadecimal code as a string
  91567. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  91568. * @returns a string containing the hexadecimal representation of the Color4 object
  91569. */
  91570. toHexString(returnAsColor3?: boolean): string;
  91571. /**
  91572. * Computes a new Color4 converted from the current one to linear space
  91573. * @returns a new Color4 object
  91574. */
  91575. toLinearSpace(): Color4;
  91576. /**
  91577. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  91578. * @param convertedColor defines the Color4 object where to store the linear space version
  91579. * @returns the unmodified Color4
  91580. */
  91581. toLinearSpaceToRef(convertedColor: Color4): Color4;
  91582. /**
  91583. * Computes a new Color4 converted from the current one to gamma space
  91584. * @returns a new Color4 object
  91585. */
  91586. toGammaSpace(): Color4;
  91587. /**
  91588. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  91589. * @param convertedColor defines the Color4 object where to store the gamma space version
  91590. * @returns the unmodified Color4
  91591. */
  91592. toGammaSpaceToRef(convertedColor: Color4): Color4;
  91593. /**
  91594. * Creates a new Color4 from the string containing valid hexadecimal values
  91595. * @param hex defines a string containing valid hexadecimal values
  91596. * @returns a new Color4 object
  91597. */
  91598. static FromHexString(hex: string): Color4;
  91599. /**
  91600. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91601. * @param left defines the start value
  91602. * @param right defines the end value
  91603. * @param amount defines the gradient factor
  91604. * @returns a new Color4 object
  91605. */
  91606. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  91607. /**
  91608. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91609. * @param left defines the start value
  91610. * @param right defines the end value
  91611. * @param amount defines the gradient factor
  91612. * @param result defines the Color4 object where to store data
  91613. */
  91614. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  91615. /**
  91616. * Creates a new Color4 from a Color3 and an alpha value
  91617. * @param color3 defines the source Color3 to read from
  91618. * @param alpha defines the alpha component (1.0 by default)
  91619. * @returns a new Color4 object
  91620. */
  91621. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  91622. /**
  91623. * Creates a new Color4 from the starting index element of the given array
  91624. * @param array defines the source array to read from
  91625. * @param offset defines the offset in the source array
  91626. * @returns a new Color4 object
  91627. */
  91628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91629. /**
  91630. * Creates a new Color4 from the starting index element of the given array
  91631. * @param array defines the source array to read from
  91632. * @param offset defines the offset in the source array
  91633. * @param result defines the target Color4 object
  91634. */
  91635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  91636. /**
  91637. * Creates a new Color3 from integer values (< 256)
  91638. * @param r defines the red component to read from (value between 0 and 255)
  91639. * @param g defines the green component to read from (value between 0 and 255)
  91640. * @param b defines the blue component to read from (value between 0 and 255)
  91641. * @param a defines the alpha component to read from (value between 0 and 255)
  91642. * @returns a new Color3 object
  91643. */
  91644. static FromInts(r: number, g: number, b: number, a: number): Color4;
  91645. /**
  91646. * Check the content of a given array and convert it to an array containing RGBA data
  91647. * If the original array was already containing count * 4 values then it is returned directly
  91648. * @param colors defines the array to check
  91649. * @param count defines the number of RGBA data to expect
  91650. * @returns an array containing count * 4 values (RGBA)
  91651. */
  91652. static CheckColors4(colors: number[], count: number): number[];
  91653. }
  91654. /**
  91655. * @hidden
  91656. */
  91657. export class TmpColors {
  91658. static Color3: Color3[];
  91659. static Color4: Color4[];
  91660. }
  91661. }
  91662. declare module BABYLON {
  91663. /**
  91664. * Defines an interface which represents an animation key frame
  91665. */
  91666. export interface IAnimationKey {
  91667. /**
  91668. * Frame of the key frame
  91669. */
  91670. frame: number;
  91671. /**
  91672. * Value at the specifies key frame
  91673. */
  91674. value: any;
  91675. /**
  91676. * The input tangent for the cubic hermite spline
  91677. */
  91678. inTangent?: any;
  91679. /**
  91680. * The output tangent for the cubic hermite spline
  91681. */
  91682. outTangent?: any;
  91683. /**
  91684. * The animation interpolation type
  91685. */
  91686. interpolation?: AnimationKeyInterpolation;
  91687. }
  91688. /**
  91689. * Enum for the animation key frame interpolation type
  91690. */
  91691. export enum AnimationKeyInterpolation {
  91692. /**
  91693. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  91694. */
  91695. STEP = 1
  91696. }
  91697. }
  91698. declare module BABYLON {
  91699. /**
  91700. * Represents the range of an animation
  91701. */
  91702. export class AnimationRange {
  91703. /**The name of the animation range**/
  91704. name: string;
  91705. /**The starting frame of the animation */
  91706. from: number;
  91707. /**The ending frame of the animation*/
  91708. to: number;
  91709. /**
  91710. * Initializes the range of an animation
  91711. * @param name The name of the animation range
  91712. * @param from The starting frame of the animation
  91713. * @param to The ending frame of the animation
  91714. */
  91715. constructor(
  91716. /**The name of the animation range**/
  91717. name: string,
  91718. /**The starting frame of the animation */
  91719. from: number,
  91720. /**The ending frame of the animation*/
  91721. to: number);
  91722. /**
  91723. * Makes a copy of the animation range
  91724. * @returns A copy of the animation range
  91725. */
  91726. clone(): AnimationRange;
  91727. }
  91728. }
  91729. declare module BABYLON {
  91730. /**
  91731. * Composed of a frame, and an action function
  91732. */
  91733. export class AnimationEvent {
  91734. /** The frame for which the event is triggered **/
  91735. frame: number;
  91736. /** The event to perform when triggered **/
  91737. action: (currentFrame: number) => void;
  91738. /** Specifies if the event should be triggered only once**/
  91739. onlyOnce?: boolean | undefined;
  91740. /**
  91741. * Specifies if the animation event is done
  91742. */
  91743. isDone: boolean;
  91744. /**
  91745. * Initializes the animation event
  91746. * @param frame The frame for which the event is triggered
  91747. * @param action The event to perform when triggered
  91748. * @param onlyOnce Specifies if the event should be triggered only once
  91749. */
  91750. constructor(
  91751. /** The frame for which the event is triggered **/
  91752. frame: number,
  91753. /** The event to perform when triggered **/
  91754. action: (currentFrame: number) => void,
  91755. /** Specifies if the event should be triggered only once**/
  91756. onlyOnce?: boolean | undefined);
  91757. /** @hidden */
  91758. _clone(): AnimationEvent;
  91759. }
  91760. }
  91761. declare module BABYLON {
  91762. /**
  91763. * Interface used to define a behavior
  91764. */
  91765. export interface Behavior<T> {
  91766. /** gets or sets behavior's name */
  91767. name: string;
  91768. /**
  91769. * Function called when the behavior needs to be initialized (after attaching it to a target)
  91770. */
  91771. init(): void;
  91772. /**
  91773. * Called when the behavior is attached to a target
  91774. * @param target defines the target where the behavior is attached to
  91775. */
  91776. attach(target: T): void;
  91777. /**
  91778. * Called when the behavior is detached from its target
  91779. */
  91780. detach(): void;
  91781. }
  91782. /**
  91783. * Interface implemented by classes supporting behaviors
  91784. */
  91785. export interface IBehaviorAware<T> {
  91786. /**
  91787. * Attach a behavior
  91788. * @param behavior defines the behavior to attach
  91789. * @returns the current host
  91790. */
  91791. addBehavior(behavior: Behavior<T>): T;
  91792. /**
  91793. * Remove a behavior from the current object
  91794. * @param behavior defines the behavior to detach
  91795. * @returns the current host
  91796. */
  91797. removeBehavior(behavior: Behavior<T>): T;
  91798. /**
  91799. * Gets a behavior using its name to search
  91800. * @param name defines the name to search
  91801. * @returns the behavior or null if not found
  91802. */
  91803. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  91804. }
  91805. }
  91806. declare module BABYLON {
  91807. /**
  91808. * Class used to store data that will be store in GPU memory
  91809. */
  91810. export class Buffer {
  91811. private _engine;
  91812. private _buffer;
  91813. /** @hidden */
  91814. _data: Nullable<DataArray>;
  91815. private _updatable;
  91816. private _instanced;
  91817. private _divisor;
  91818. private _isAlreadyOwned;
  91819. /**
  91820. * Gets the byte stride.
  91821. */
  91822. readonly byteStride: number;
  91823. /**
  91824. * Constructor
  91825. * @param engine the engine
  91826. * @param data the data to use for this buffer
  91827. * @param updatable whether the data is updatable
  91828. * @param stride the stride (optional)
  91829. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91830. * @param instanced whether the buffer is instanced (optional)
  91831. * @param useBytes set to true if the stride in in bytes (optional)
  91832. * @param divisor sets an optional divisor for instances (1 by default)
  91833. */
  91834. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  91835. /**
  91836. * Create a new VertexBuffer based on the current buffer
  91837. * @param kind defines the vertex buffer kind (position, normal, etc.)
  91838. * @param offset defines offset in the buffer (0 by default)
  91839. * @param size defines the size in floats of attributes (position is 3 for instance)
  91840. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  91841. * @param instanced defines if the vertex buffer contains indexed data
  91842. * @param useBytes defines if the offset and stride are in bytes *
  91843. * @param divisor sets an optional divisor for instances (1 by default)
  91844. * @returns the new vertex buffer
  91845. */
  91846. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  91847. /**
  91848. * Gets a boolean indicating if the Buffer is updatable?
  91849. * @returns true if the buffer is updatable
  91850. */
  91851. isUpdatable(): boolean;
  91852. /**
  91853. * Gets current buffer's data
  91854. * @returns a DataArray or null
  91855. */
  91856. getData(): Nullable<DataArray>;
  91857. /**
  91858. * Gets underlying native buffer
  91859. * @returns underlying native buffer
  91860. */
  91861. getBuffer(): Nullable<DataBuffer>;
  91862. /**
  91863. * Gets the stride in float32 units (i.e. byte stride / 4).
  91864. * May not be an integer if the byte stride is not divisible by 4.
  91865. * @returns the stride in float32 units
  91866. * @deprecated Please use byteStride instead.
  91867. */
  91868. getStrideSize(): number;
  91869. /**
  91870. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  91871. * @param data defines the data to store
  91872. */
  91873. create(data?: Nullable<DataArray>): void;
  91874. /** @hidden */
  91875. _rebuild(): void;
  91876. /**
  91877. * Update current buffer data
  91878. * @param data defines the data to store
  91879. */
  91880. update(data: DataArray): void;
  91881. /**
  91882. * Updates the data directly.
  91883. * @param data the new data
  91884. * @param offset the new offset
  91885. * @param vertexCount the vertex count (optional)
  91886. * @param useBytes set to true if the offset is in bytes
  91887. */
  91888. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  91889. /** @hidden */
  91890. _increaseReferences(): void;
  91891. /**
  91892. * Release all resources
  91893. */
  91894. dispose(): void;
  91895. }
  91896. /**
  91897. * Specialized buffer used to store vertex data
  91898. */
  91899. export class VertexBuffer {
  91900. private static _Counter;
  91901. /** @hidden */
  91902. _buffer: Buffer;
  91903. private _kind;
  91904. private _size;
  91905. private _ownsBuffer;
  91906. private _instanced;
  91907. private _instanceDivisor;
  91908. /**
  91909. * The byte type.
  91910. */
  91911. static readonly BYTE: number;
  91912. /**
  91913. * The unsigned byte type.
  91914. */
  91915. static readonly UNSIGNED_BYTE: number;
  91916. /**
  91917. * The short type.
  91918. */
  91919. static readonly SHORT: number;
  91920. /**
  91921. * The unsigned short type.
  91922. */
  91923. static readonly UNSIGNED_SHORT: number;
  91924. /**
  91925. * The integer type.
  91926. */
  91927. static readonly INT: number;
  91928. /**
  91929. * The unsigned integer type.
  91930. */
  91931. static readonly UNSIGNED_INT: number;
  91932. /**
  91933. * The float type.
  91934. */
  91935. static readonly FLOAT: number;
  91936. /**
  91937. * Gets or sets the instance divisor when in instanced mode
  91938. */
  91939. get instanceDivisor(): number;
  91940. set instanceDivisor(value: number);
  91941. /**
  91942. * Gets the byte stride.
  91943. */
  91944. readonly byteStride: number;
  91945. /**
  91946. * Gets the byte offset.
  91947. */
  91948. readonly byteOffset: number;
  91949. /**
  91950. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  91951. */
  91952. readonly normalized: boolean;
  91953. /**
  91954. * Gets the data type of each component in the array.
  91955. */
  91956. readonly type: number;
  91957. /**
  91958. * Gets the unique id of this vertex buffer
  91959. */
  91960. readonly uniqueId: number;
  91961. /**
  91962. * Constructor
  91963. * @param engine the engine
  91964. * @param data the data to use for this vertex buffer
  91965. * @param kind the vertex buffer kind
  91966. * @param updatable whether the data is updatable
  91967. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91968. * @param stride the stride (optional)
  91969. * @param instanced whether the buffer is instanced (optional)
  91970. * @param offset the offset of the data (optional)
  91971. * @param size the number of components (optional)
  91972. * @param type the type of the component (optional)
  91973. * @param normalized whether the data contains normalized data (optional)
  91974. * @param useBytes set to true if stride and offset are in bytes (optional)
  91975. * @param divisor defines the instance divisor to use (1 by default)
  91976. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  91977. */
  91978. 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);
  91979. /** @hidden */
  91980. _rebuild(): void;
  91981. /**
  91982. * Returns the kind of the VertexBuffer (string)
  91983. * @returns a string
  91984. */
  91985. getKind(): string;
  91986. /**
  91987. * Gets a boolean indicating if the VertexBuffer is updatable?
  91988. * @returns true if the buffer is updatable
  91989. */
  91990. isUpdatable(): boolean;
  91991. /**
  91992. * Gets current buffer's data
  91993. * @returns a DataArray or null
  91994. */
  91995. getData(): Nullable<DataArray>;
  91996. /**
  91997. * Gets underlying native buffer
  91998. * @returns underlying native buffer
  91999. */
  92000. getBuffer(): Nullable<DataBuffer>;
  92001. /**
  92002. * Gets the stride in float32 units (i.e. byte stride / 4).
  92003. * May not be an integer if the byte stride is not divisible by 4.
  92004. * @returns the stride in float32 units
  92005. * @deprecated Please use byteStride instead.
  92006. */
  92007. getStrideSize(): number;
  92008. /**
  92009. * Returns the offset as a multiple of the type byte length.
  92010. * @returns the offset in bytes
  92011. * @deprecated Please use byteOffset instead.
  92012. */
  92013. getOffset(): number;
  92014. /**
  92015. * Returns the number of components per vertex attribute (integer)
  92016. * @returns the size in float
  92017. */
  92018. getSize(): number;
  92019. /**
  92020. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  92021. * @returns true if this buffer is instanced
  92022. */
  92023. getIsInstanced(): boolean;
  92024. /**
  92025. * Returns the instancing divisor, zero for non-instanced (integer).
  92026. * @returns a number
  92027. */
  92028. getInstanceDivisor(): number;
  92029. /**
  92030. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  92031. * @param data defines the data to store
  92032. */
  92033. create(data?: DataArray): void;
  92034. /**
  92035. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  92036. * This function will create a new buffer if the current one is not updatable
  92037. * @param data defines the data to store
  92038. */
  92039. update(data: DataArray): void;
  92040. /**
  92041. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  92042. * Returns the directly updated WebGLBuffer.
  92043. * @param data the new data
  92044. * @param offset the new offset
  92045. * @param useBytes set to true if the offset is in bytes
  92046. */
  92047. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  92048. /**
  92049. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  92050. */
  92051. dispose(): void;
  92052. /**
  92053. * Enumerates each value of this vertex buffer as numbers.
  92054. * @param count the number of values to enumerate
  92055. * @param callback the callback function called for each value
  92056. */
  92057. forEach(count: number, callback: (value: number, index: number) => void): void;
  92058. /**
  92059. * Positions
  92060. */
  92061. static readonly PositionKind: string;
  92062. /**
  92063. * Normals
  92064. */
  92065. static readonly NormalKind: string;
  92066. /**
  92067. * Tangents
  92068. */
  92069. static readonly TangentKind: string;
  92070. /**
  92071. * Texture coordinates
  92072. */
  92073. static readonly UVKind: string;
  92074. /**
  92075. * Texture coordinates 2
  92076. */
  92077. static readonly UV2Kind: string;
  92078. /**
  92079. * Texture coordinates 3
  92080. */
  92081. static readonly UV3Kind: string;
  92082. /**
  92083. * Texture coordinates 4
  92084. */
  92085. static readonly UV4Kind: string;
  92086. /**
  92087. * Texture coordinates 5
  92088. */
  92089. static readonly UV5Kind: string;
  92090. /**
  92091. * Texture coordinates 6
  92092. */
  92093. static readonly UV6Kind: string;
  92094. /**
  92095. * Colors
  92096. */
  92097. static readonly ColorKind: string;
  92098. /**
  92099. * Matrix indices (for bones)
  92100. */
  92101. static readonly MatricesIndicesKind: string;
  92102. /**
  92103. * Matrix weights (for bones)
  92104. */
  92105. static readonly MatricesWeightsKind: string;
  92106. /**
  92107. * Additional matrix indices (for bones)
  92108. */
  92109. static readonly MatricesIndicesExtraKind: string;
  92110. /**
  92111. * Additional matrix weights (for bones)
  92112. */
  92113. static readonly MatricesWeightsExtraKind: string;
  92114. /**
  92115. * Deduces the stride given a kind.
  92116. * @param kind The kind string to deduce
  92117. * @returns The deduced stride
  92118. */
  92119. static DeduceStride(kind: string): number;
  92120. /**
  92121. * Gets the byte length of the given type.
  92122. * @param type the type
  92123. * @returns the number of bytes
  92124. */
  92125. static GetTypeByteLength(type: number): number;
  92126. /**
  92127. * Enumerates each value of the given parameters as numbers.
  92128. * @param data the data to enumerate
  92129. * @param byteOffset the byte offset of the data
  92130. * @param byteStride the byte stride of the data
  92131. * @param componentCount the number of components per element
  92132. * @param componentType the type of the component
  92133. * @param count the number of values to enumerate
  92134. * @param normalized whether the data is normalized
  92135. * @param callback the callback function called for each value
  92136. */
  92137. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  92138. private static _GetFloatValue;
  92139. }
  92140. }
  92141. declare module BABYLON {
  92142. /**
  92143. * @hidden
  92144. */
  92145. export class IntersectionInfo {
  92146. bu: Nullable<number>;
  92147. bv: Nullable<number>;
  92148. distance: number;
  92149. faceId: number;
  92150. subMeshId: number;
  92151. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  92152. }
  92153. }
  92154. declare module BABYLON {
  92155. /**
  92156. * Class used to store bounding sphere information
  92157. */
  92158. export class BoundingSphere {
  92159. /**
  92160. * Gets the center of the bounding sphere in local space
  92161. */
  92162. readonly center: Vector3;
  92163. /**
  92164. * Radius of the bounding sphere in local space
  92165. */
  92166. radius: number;
  92167. /**
  92168. * Gets the center of the bounding sphere in world space
  92169. */
  92170. readonly centerWorld: Vector3;
  92171. /**
  92172. * Radius of the bounding sphere in world space
  92173. */
  92174. radiusWorld: number;
  92175. /**
  92176. * Gets the minimum vector in local space
  92177. */
  92178. readonly minimum: Vector3;
  92179. /**
  92180. * Gets the maximum vector in local space
  92181. */
  92182. readonly maximum: Vector3;
  92183. private _worldMatrix;
  92184. private static readonly TmpVector3;
  92185. /**
  92186. * Creates a new bounding sphere
  92187. * @param min defines the minimum vector (in local space)
  92188. * @param max defines the maximum vector (in local space)
  92189. * @param worldMatrix defines the new world matrix
  92190. */
  92191. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92192. /**
  92193. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  92194. * @param min defines the new minimum vector (in local space)
  92195. * @param max defines the new maximum vector (in local space)
  92196. * @param worldMatrix defines the new world matrix
  92197. */
  92198. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92199. /**
  92200. * Scale the current bounding sphere by applying a scale factor
  92201. * @param factor defines the scale factor to apply
  92202. * @returns the current bounding box
  92203. */
  92204. scale(factor: number): BoundingSphere;
  92205. /**
  92206. * Gets the world matrix of the bounding box
  92207. * @returns a matrix
  92208. */
  92209. getWorldMatrix(): DeepImmutable<Matrix>;
  92210. /** @hidden */
  92211. _update(worldMatrix: DeepImmutable<Matrix>): void;
  92212. /**
  92213. * Tests if the bounding sphere is intersecting the frustum planes
  92214. * @param frustumPlanes defines the frustum planes to test
  92215. * @returns true if there is an intersection
  92216. */
  92217. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92218. /**
  92219. * Tests if the bounding sphere center is in between the frustum planes.
  92220. * Used for optimistic fast inclusion.
  92221. * @param frustumPlanes defines the frustum planes to test
  92222. * @returns true if the sphere center is in between the frustum planes
  92223. */
  92224. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92225. /**
  92226. * Tests if a point is inside the bounding sphere
  92227. * @param point defines the point to test
  92228. * @returns true if the point is inside the bounding sphere
  92229. */
  92230. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92231. /**
  92232. * Checks if two sphere intersct
  92233. * @param sphere0 sphere 0
  92234. * @param sphere1 sphere 1
  92235. * @returns true if the speres intersect
  92236. */
  92237. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * Class used to store bounding box information
  92243. */
  92244. export class BoundingBox implements ICullable {
  92245. /**
  92246. * Gets the 8 vectors representing the bounding box in local space
  92247. */
  92248. readonly vectors: Vector3[];
  92249. /**
  92250. * Gets the center of the bounding box in local space
  92251. */
  92252. readonly center: Vector3;
  92253. /**
  92254. * Gets the center of the bounding box in world space
  92255. */
  92256. readonly centerWorld: Vector3;
  92257. /**
  92258. * Gets the extend size in local space
  92259. */
  92260. readonly extendSize: Vector3;
  92261. /**
  92262. * Gets the extend size in world space
  92263. */
  92264. readonly extendSizeWorld: Vector3;
  92265. /**
  92266. * Gets the OBB (object bounding box) directions
  92267. */
  92268. readonly directions: Vector3[];
  92269. /**
  92270. * Gets the 8 vectors representing the bounding box in world space
  92271. */
  92272. readonly vectorsWorld: Vector3[];
  92273. /**
  92274. * Gets the minimum vector in world space
  92275. */
  92276. readonly minimumWorld: Vector3;
  92277. /**
  92278. * Gets the maximum vector in world space
  92279. */
  92280. readonly maximumWorld: Vector3;
  92281. /**
  92282. * Gets the minimum vector in local space
  92283. */
  92284. readonly minimum: Vector3;
  92285. /**
  92286. * Gets the maximum vector in local space
  92287. */
  92288. readonly maximum: Vector3;
  92289. private _worldMatrix;
  92290. private static readonly TmpVector3;
  92291. /**
  92292. * @hidden
  92293. */
  92294. _tag: number;
  92295. /**
  92296. * Creates a new bounding box
  92297. * @param min defines the minimum vector (in local space)
  92298. * @param max defines the maximum vector (in local space)
  92299. * @param worldMatrix defines the new world matrix
  92300. */
  92301. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92302. /**
  92303. * Recreates the entire bounding box from scratch as if we call the constructor in place
  92304. * @param min defines the new minimum vector (in local space)
  92305. * @param max defines the new maximum vector (in local space)
  92306. * @param worldMatrix defines the new world matrix
  92307. */
  92308. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92309. /**
  92310. * Scale the current bounding box by applying a scale factor
  92311. * @param factor defines the scale factor to apply
  92312. * @returns the current bounding box
  92313. */
  92314. scale(factor: number): BoundingBox;
  92315. /**
  92316. * Gets the world matrix of the bounding box
  92317. * @returns a matrix
  92318. */
  92319. getWorldMatrix(): DeepImmutable<Matrix>;
  92320. /** @hidden */
  92321. _update(world: DeepImmutable<Matrix>): void;
  92322. /**
  92323. * Tests if the bounding box is intersecting the frustum planes
  92324. * @param frustumPlanes defines the frustum planes to test
  92325. * @returns true if there is an intersection
  92326. */
  92327. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92328. /**
  92329. * Tests if the bounding box is entirely inside the frustum planes
  92330. * @param frustumPlanes defines the frustum planes to test
  92331. * @returns true if there is an inclusion
  92332. */
  92333. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92334. /**
  92335. * Tests if a point is inside the bounding box
  92336. * @param point defines the point to test
  92337. * @returns true if the point is inside the bounding box
  92338. */
  92339. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92340. /**
  92341. * Tests if the bounding box intersects with a bounding sphere
  92342. * @param sphere defines the sphere to test
  92343. * @returns true if there is an intersection
  92344. */
  92345. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  92346. /**
  92347. * Tests if the bounding box intersects with a box defined by a min and max vectors
  92348. * @param min defines the min vector to use
  92349. * @param max defines the max vector to use
  92350. * @returns true if there is an intersection
  92351. */
  92352. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  92353. /**
  92354. * Tests if two bounding boxes are intersections
  92355. * @param box0 defines the first box to test
  92356. * @param box1 defines the second box to test
  92357. * @returns true if there is an intersection
  92358. */
  92359. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  92360. /**
  92361. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  92362. * @param minPoint defines the minimum vector of the bounding box
  92363. * @param maxPoint defines the maximum vector of the bounding box
  92364. * @param sphereCenter defines the sphere center
  92365. * @param sphereRadius defines the sphere radius
  92366. * @returns true if there is an intersection
  92367. */
  92368. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  92369. /**
  92370. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  92371. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92372. * @param frustumPlanes defines the frustum planes to test
  92373. * @return true if there is an inclusion
  92374. */
  92375. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92376. /**
  92377. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  92378. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92379. * @param frustumPlanes defines the frustum planes to test
  92380. * @return true if there is an intersection
  92381. */
  92382. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /** @hidden */
  92387. export class Collider {
  92388. /** Define if a collision was found */
  92389. collisionFound: boolean;
  92390. /**
  92391. * Define last intersection point in local space
  92392. */
  92393. intersectionPoint: Vector3;
  92394. /**
  92395. * Define last collided mesh
  92396. */
  92397. collidedMesh: Nullable<AbstractMesh>;
  92398. private _collisionPoint;
  92399. private _planeIntersectionPoint;
  92400. private _tempVector;
  92401. private _tempVector2;
  92402. private _tempVector3;
  92403. private _tempVector4;
  92404. private _edge;
  92405. private _baseToVertex;
  92406. private _destinationPoint;
  92407. private _slidePlaneNormal;
  92408. private _displacementVector;
  92409. /** @hidden */
  92410. _radius: Vector3;
  92411. /** @hidden */
  92412. _retry: number;
  92413. private _velocity;
  92414. private _basePoint;
  92415. private _epsilon;
  92416. /** @hidden */
  92417. _velocityWorldLength: number;
  92418. /** @hidden */
  92419. _basePointWorld: Vector3;
  92420. private _velocityWorld;
  92421. private _normalizedVelocity;
  92422. /** @hidden */
  92423. _initialVelocity: Vector3;
  92424. /** @hidden */
  92425. _initialPosition: Vector3;
  92426. private _nearestDistance;
  92427. private _collisionMask;
  92428. get collisionMask(): number;
  92429. set collisionMask(mask: number);
  92430. /**
  92431. * Gets the plane normal used to compute the sliding response (in local space)
  92432. */
  92433. get slidePlaneNormal(): Vector3;
  92434. /** @hidden */
  92435. _initialize(source: Vector3, dir: Vector3, e: number): void;
  92436. /** @hidden */
  92437. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  92438. /** @hidden */
  92439. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  92440. /** @hidden */
  92441. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92442. /** @hidden */
  92443. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92444. /** @hidden */
  92445. _getResponse(pos: Vector3, vel: Vector3): void;
  92446. }
  92447. }
  92448. declare module BABYLON {
  92449. /**
  92450. * Interface for cullable objects
  92451. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  92452. */
  92453. export interface ICullable {
  92454. /**
  92455. * Checks if the object or part of the object is in the frustum
  92456. * @param frustumPlanes Camera near/planes
  92457. * @returns true if the object is in frustum otherwise false
  92458. */
  92459. isInFrustum(frustumPlanes: Plane[]): boolean;
  92460. /**
  92461. * Checks if a cullable object (mesh...) is in the camera frustum
  92462. * Unlike isInFrustum this cheks the full bounding box
  92463. * @param frustumPlanes Camera near/planes
  92464. * @returns true if the object is in frustum otherwise false
  92465. */
  92466. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92467. }
  92468. /**
  92469. * Info for a bounding data of a mesh
  92470. */
  92471. export class BoundingInfo implements ICullable {
  92472. /**
  92473. * Bounding box for the mesh
  92474. */
  92475. readonly boundingBox: BoundingBox;
  92476. /**
  92477. * Bounding sphere for the mesh
  92478. */
  92479. readonly boundingSphere: BoundingSphere;
  92480. private _isLocked;
  92481. private static readonly TmpVector3;
  92482. /**
  92483. * Constructs bounding info
  92484. * @param minimum min vector of the bounding box/sphere
  92485. * @param maximum max vector of the bounding box/sphere
  92486. * @param worldMatrix defines the new world matrix
  92487. */
  92488. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92489. /**
  92490. * Recreates the entire bounding info from scratch as if we call the constructor in place
  92491. * @param min defines the new minimum vector (in local space)
  92492. * @param max defines the new maximum vector (in local space)
  92493. * @param worldMatrix defines the new world matrix
  92494. */
  92495. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92496. /**
  92497. * min vector of the bounding box/sphere
  92498. */
  92499. get minimum(): Vector3;
  92500. /**
  92501. * max vector of the bounding box/sphere
  92502. */
  92503. get maximum(): Vector3;
  92504. /**
  92505. * If the info is locked and won't be updated to avoid perf overhead
  92506. */
  92507. get isLocked(): boolean;
  92508. set isLocked(value: boolean);
  92509. /**
  92510. * Updates the bounding sphere and box
  92511. * @param world world matrix to be used to update
  92512. */
  92513. update(world: DeepImmutable<Matrix>): void;
  92514. /**
  92515. * Recreate the bounding info to be centered around a specific point given a specific extend.
  92516. * @param center New center of the bounding info
  92517. * @param extend New extend of the bounding info
  92518. * @returns the current bounding info
  92519. */
  92520. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  92521. /**
  92522. * Scale the current bounding info by applying a scale factor
  92523. * @param factor defines the scale factor to apply
  92524. * @returns the current bounding info
  92525. */
  92526. scale(factor: number): BoundingInfo;
  92527. /**
  92528. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  92529. * @param frustumPlanes defines the frustum to test
  92530. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  92531. * @returns true if the bounding info is in the frustum planes
  92532. */
  92533. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  92534. /**
  92535. * Gets the world distance between the min and max points of the bounding box
  92536. */
  92537. get diagonalLength(): number;
  92538. /**
  92539. * Checks if a cullable object (mesh...) is in the camera frustum
  92540. * Unlike isInFrustum this cheks the full bounding box
  92541. * @param frustumPlanes Camera near/planes
  92542. * @returns true if the object is in frustum otherwise false
  92543. */
  92544. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92545. /** @hidden */
  92546. _checkCollision(collider: Collider): boolean;
  92547. /**
  92548. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  92549. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92550. * @param point the point to check intersection with
  92551. * @returns if the point intersects
  92552. */
  92553. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92554. /**
  92555. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  92556. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92557. * @param boundingInfo the bounding info to check intersection with
  92558. * @param precise if the intersection should be done using OBB
  92559. * @returns if the bounding info intersects
  92560. */
  92561. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  92562. }
  92563. }
  92564. declare module BABYLON {
  92565. /**
  92566. * Extracts minimum and maximum values from a list of indexed positions
  92567. * @param positions defines the positions to use
  92568. * @param indices defines the indices to the positions
  92569. * @param indexStart defines the start index
  92570. * @param indexCount defines the end index
  92571. * @param bias defines bias value to add to the result
  92572. * @return minimum and maximum values
  92573. */
  92574. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  92575. minimum: Vector3;
  92576. maximum: Vector3;
  92577. };
  92578. /**
  92579. * Extracts minimum and maximum values from a list of positions
  92580. * @param positions defines the positions to use
  92581. * @param start defines the start index in the positions array
  92582. * @param count defines the number of positions to handle
  92583. * @param bias defines bias value to add to the result
  92584. * @param stride defines the stride size to use (distance between two positions in the positions array)
  92585. * @return minimum and maximum values
  92586. */
  92587. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  92588. minimum: Vector3;
  92589. maximum: Vector3;
  92590. };
  92591. }
  92592. declare module BABYLON {
  92593. /**
  92594. * Class used to manipulate GUIDs
  92595. */
  92596. export class GUID {
  92597. /**
  92598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92599. * Be aware Math.random() could cause collisions, but:
  92600. * "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"
  92601. * @returns a pseudo random id
  92602. */
  92603. static RandomId(): string;
  92604. }
  92605. }
  92606. declare module BABYLON {
  92607. /**
  92608. * Base class of all the textures in babylon.
  92609. * It groups all the common properties the materials, post process, lights... might need
  92610. * in order to make a correct use of the texture.
  92611. */
  92612. export class BaseTexture extends ThinTexture implements IAnimatable {
  92613. /**
  92614. * Default anisotropic filtering level for the application.
  92615. * It is set to 4 as a good tradeoff between perf and quality.
  92616. */
  92617. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92618. /**
  92619. * Gets or sets the unique id of the texture
  92620. */
  92621. uniqueId: number;
  92622. /**
  92623. * Define the name of the texture.
  92624. */
  92625. name: string;
  92626. /**
  92627. * Gets or sets an object used to store user defined information.
  92628. */
  92629. metadata: any;
  92630. /**
  92631. * For internal use only. Please do not use.
  92632. */
  92633. reservedDataStore: any;
  92634. private _hasAlpha;
  92635. /**
  92636. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92637. */
  92638. set hasAlpha(value: boolean);
  92639. get hasAlpha(): boolean;
  92640. /**
  92641. * Defines if the alpha value should be determined via the rgb values.
  92642. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92643. */
  92644. getAlphaFromRGB: boolean;
  92645. /**
  92646. * Intensity or strength of the texture.
  92647. * It is commonly used by materials to fine tune the intensity of the texture
  92648. */
  92649. level: number;
  92650. /**
  92651. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92652. * This is part of the texture as textures usually maps to one uv set.
  92653. */
  92654. coordinatesIndex: number;
  92655. protected _coordinatesMode: number;
  92656. /**
  92657. * How a texture is mapped.
  92658. *
  92659. * | Value | Type | Description |
  92660. * | ----- | ----------------------------------- | ----------- |
  92661. * | 0 | EXPLICIT_MODE | |
  92662. * | 1 | SPHERICAL_MODE | |
  92663. * | 2 | PLANAR_MODE | |
  92664. * | 3 | CUBIC_MODE | |
  92665. * | 4 | PROJECTION_MODE | |
  92666. * | 5 | SKYBOX_MODE | |
  92667. * | 6 | INVCUBIC_MODE | |
  92668. * | 7 | EQUIRECTANGULAR_MODE | |
  92669. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92670. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92671. */
  92672. set coordinatesMode(value: number);
  92673. get coordinatesMode(): number;
  92674. /**
  92675. * | Value | Type | Description |
  92676. * | ----- | ------------------ | ----------- |
  92677. * | 0 | CLAMP_ADDRESSMODE | |
  92678. * | 1 | WRAP_ADDRESSMODE | |
  92679. * | 2 | MIRROR_ADDRESSMODE | |
  92680. */
  92681. get wrapU(): number;
  92682. set wrapU(value: number);
  92683. /**
  92684. * | Value | Type | Description |
  92685. * | ----- | ------------------ | ----------- |
  92686. * | 0 | CLAMP_ADDRESSMODE | |
  92687. * | 1 | WRAP_ADDRESSMODE | |
  92688. * | 2 | MIRROR_ADDRESSMODE | |
  92689. */
  92690. get wrapV(): number;
  92691. set wrapV(value: number);
  92692. /**
  92693. * | Value | Type | Description |
  92694. * | ----- | ------------------ | ----------- |
  92695. * | 0 | CLAMP_ADDRESSMODE | |
  92696. * | 1 | WRAP_ADDRESSMODE | |
  92697. * | 2 | MIRROR_ADDRESSMODE | |
  92698. */
  92699. wrapR: number;
  92700. /**
  92701. * With compliant hardware and browser (supporting anisotropic filtering)
  92702. * this defines the level of anisotropic filtering in the texture.
  92703. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92704. */
  92705. anisotropicFilteringLevel: number;
  92706. private _isCube;
  92707. /**
  92708. * Define if the texture is a cube texture or if false a 2d texture.
  92709. */
  92710. get isCube(): boolean;
  92711. set isCube(value: boolean);
  92712. /**
  92713. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92714. */
  92715. get is3D(): boolean;
  92716. set is3D(value: boolean);
  92717. /**
  92718. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  92719. */
  92720. get is2DArray(): boolean;
  92721. set is2DArray(value: boolean);
  92722. private _gammaSpace;
  92723. /**
  92724. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92725. * HDR texture are usually stored in linear space.
  92726. * This only impacts the PBR and Background materials
  92727. */
  92728. get gammaSpace(): boolean;
  92729. set gammaSpace(gamma: boolean);
  92730. /**
  92731. * Gets or sets whether or not the texture contains RGBD data.
  92732. */
  92733. get isRGBD(): boolean;
  92734. set isRGBD(value: boolean);
  92735. /**
  92736. * Is Z inverted in the texture (useful in a cube texture).
  92737. */
  92738. invertZ: boolean;
  92739. /**
  92740. * Are mip maps generated for this texture or not.
  92741. */
  92742. get noMipmap(): boolean;
  92743. /**
  92744. * @hidden
  92745. */
  92746. lodLevelInAlpha: boolean;
  92747. /**
  92748. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92749. */
  92750. get lodGenerationOffset(): number;
  92751. set lodGenerationOffset(value: number);
  92752. /**
  92753. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92754. */
  92755. get lodGenerationScale(): number;
  92756. set lodGenerationScale(value: number);
  92757. /**
  92758. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92759. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92760. * average roughness values.
  92761. */
  92762. get linearSpecularLOD(): boolean;
  92763. set linearSpecularLOD(value: boolean);
  92764. /**
  92765. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92766. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92767. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92768. */
  92769. get irradianceTexture(): Nullable<BaseTexture>;
  92770. set irradianceTexture(value: Nullable<BaseTexture>);
  92771. /**
  92772. * Define if the texture is a render target.
  92773. */
  92774. isRenderTarget: boolean;
  92775. /**
  92776. * Define the unique id of the texture in the scene.
  92777. */
  92778. get uid(): string;
  92779. /** @hidden */
  92780. _prefiltered: boolean;
  92781. /**
  92782. * Return a string representation of the texture.
  92783. * @returns the texture as a string
  92784. */
  92785. toString(): string;
  92786. /**
  92787. * Get the class name of the texture.
  92788. * @returns "BaseTexture"
  92789. */
  92790. getClassName(): string;
  92791. /**
  92792. * Define the list of animation attached to the texture.
  92793. */
  92794. animations: Animation[];
  92795. /**
  92796. * An event triggered when the texture is disposed.
  92797. */
  92798. onDisposeObservable: Observable<BaseTexture>;
  92799. private _onDisposeObserver;
  92800. /**
  92801. * Callback triggered when the texture has been disposed.
  92802. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92803. */
  92804. set onDispose(callback: () => void);
  92805. protected _scene: Nullable<Scene>;
  92806. /** @hidden */
  92807. _texture: Nullable<InternalTexture>;
  92808. private _uid;
  92809. /**
  92810. * Define if the texture is preventinga material to render or not.
  92811. * If not and the texture is not ready, the engine will use a default black texture instead.
  92812. */
  92813. get isBlocking(): boolean;
  92814. /**
  92815. * Instantiates a new BaseTexture.
  92816. * Base class of all the textures in babylon.
  92817. * It groups all the common properties the materials, post process, lights... might need
  92818. * in order to make a correct use of the texture.
  92819. * @param sceneOrEngine Define the scene or engine the texture blongs to
  92820. */
  92821. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  92822. /**
  92823. * Get the scene the texture belongs to.
  92824. * @returns the scene or null if undefined
  92825. */
  92826. getScene(): Nullable<Scene>;
  92827. /** @hidden */
  92828. protected _getEngine(): Nullable<ThinEngine>;
  92829. /**
  92830. * Checks if the texture has the same transform matrix than another texture
  92831. * @param texture texture to check against
  92832. * @returns true if the transforms are the same, else false
  92833. */
  92834. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  92835. /**
  92836. * Get the texture transform matrix used to offset tile the texture for istance.
  92837. * @returns the transformation matrix
  92838. */
  92839. getTextureMatrix(): Matrix;
  92840. /**
  92841. * Get the texture reflection matrix used to rotate/transform the reflection.
  92842. * @returns the reflection matrix
  92843. */
  92844. getReflectionTextureMatrix(): Matrix;
  92845. /**
  92846. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92847. * @returns true if ready or not blocking
  92848. */
  92849. isReadyOrNotBlocking(): boolean;
  92850. /**
  92851. * Scales the texture if is `canRescale()`
  92852. * @param ratio the resize factor we want to use to rescale
  92853. */
  92854. scale(ratio: number): void;
  92855. /**
  92856. * Get if the texture can rescale.
  92857. */
  92858. get canRescale(): boolean;
  92859. /** @hidden */
  92860. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92861. /** @hidden */
  92862. _rebuild(): void;
  92863. /**
  92864. * Clones the texture.
  92865. * @returns the cloned texture
  92866. */
  92867. clone(): Nullable<BaseTexture>;
  92868. /**
  92869. * Get the texture underlying type (INT, FLOAT...)
  92870. */
  92871. get textureType(): number;
  92872. /**
  92873. * Get the texture underlying format (RGB, RGBA...)
  92874. */
  92875. get textureFormat(): number;
  92876. /**
  92877. * Indicates that textures need to be re-calculated for all materials
  92878. */
  92879. protected _markAllSubMeshesAsTexturesDirty(): void;
  92880. /**
  92881. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92882. * This will returns an RGBA array buffer containing either in values (0-255) or
  92883. * float values (0-1) depending of the underlying buffer type.
  92884. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92885. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92886. * @param buffer defines a user defined buffer to fill with data (can be null)
  92887. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  92888. * @returns The Array buffer promise containing the pixels data.
  92889. */
  92890. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  92891. /** @hidden */
  92892. get _lodTextureHigh(): Nullable<BaseTexture>;
  92893. /** @hidden */
  92894. get _lodTextureMid(): Nullable<BaseTexture>;
  92895. /** @hidden */
  92896. get _lodTextureLow(): Nullable<BaseTexture>;
  92897. /**
  92898. * Dispose the texture and release its associated resources.
  92899. */
  92900. dispose(): void;
  92901. /**
  92902. * Serialize the texture into a JSON representation that can be parsed later on.
  92903. * @returns the JSON representation of the texture
  92904. */
  92905. serialize(): any;
  92906. /**
  92907. * Helper function to be called back once a list of texture contains only ready textures.
  92908. * @param textures Define the list of textures to wait for
  92909. * @param callback Define the callback triggered once the entire list will be ready
  92910. */
  92911. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92912. private static _isScene;
  92913. }
  92914. }
  92915. declare module BABYLON {
  92916. /** @hidden */
  92917. export class WebGLDataBuffer extends DataBuffer {
  92918. private _buffer;
  92919. constructor(resource: WebGLBuffer);
  92920. get underlyingResource(): any;
  92921. }
  92922. }
  92923. declare module BABYLON {
  92924. /** @hidden */
  92925. export class WebGLPipelineContext implements IPipelineContext {
  92926. private _valueCache;
  92927. private _uniforms;
  92928. engine: ThinEngine;
  92929. program: Nullable<WebGLProgram>;
  92930. context?: WebGLRenderingContext;
  92931. vertexShader?: WebGLShader;
  92932. fragmentShader?: WebGLShader;
  92933. isParallelCompiled: boolean;
  92934. onCompiled?: () => void;
  92935. transformFeedback?: WebGLTransformFeedback | null;
  92936. vertexCompilationError: Nullable<string>;
  92937. fragmentCompilationError: Nullable<string>;
  92938. programLinkError: Nullable<string>;
  92939. programValidationError: Nullable<string>;
  92940. get isAsync(): boolean;
  92941. get isReady(): boolean;
  92942. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92943. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  92944. [key: string]: number;
  92945. }, uniformsNames: string[], uniforms: {
  92946. [key: string]: Nullable<WebGLUniformLocation>;
  92947. }, samplerList: string[], samplers: {
  92948. [key: string]: number;
  92949. }, attributesNames: string[], attributes: number[]): void;
  92950. /**
  92951. * Release all associated resources.
  92952. **/
  92953. dispose(): void;
  92954. /** @hidden */
  92955. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92956. /** @hidden */
  92957. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92958. /** @hidden */
  92959. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92960. /** @hidden */
  92961. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92962. /**
  92963. * Sets an interger value on a uniform variable.
  92964. * @param uniformName Name of the variable.
  92965. * @param value Value to be set.
  92966. */
  92967. setInt(uniformName: string, value: number): void;
  92968. /**
  92969. * Sets a int2 on a uniform variable.
  92970. * @param uniformName Name of the variable.
  92971. * @param x First int in int2.
  92972. * @param y Second int in int2.
  92973. */
  92974. setInt2(uniformName: string, x: number, y: number): void;
  92975. /**
  92976. * Sets a int3 on a uniform variable.
  92977. * @param uniformName Name of the variable.
  92978. * @param x First int in int3.
  92979. * @param y Second int in int3.
  92980. * @param y Third int in int3.
  92981. */
  92982. setInt3(uniformName: string, x: number, y: number, z: number): void;
  92983. /**
  92984. * Sets a int4 on a uniform variable.
  92985. * @param uniformName Name of the variable.
  92986. * @param x First int in int4.
  92987. * @param y Second int in int4.
  92988. * @param y Third int in int4.
  92989. * @param w Fourth int in int4.
  92990. */
  92991. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  92992. /**
  92993. * Sets an int array on a uniform variable.
  92994. * @param uniformName Name of the variable.
  92995. * @param array array to be set.
  92996. */
  92997. setIntArray(uniformName: string, array: Int32Array): void;
  92998. /**
  92999. * 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)
  93000. * @param uniformName Name of the variable.
  93001. * @param array array to be set.
  93002. */
  93003. setIntArray2(uniformName: string, array: Int32Array): void;
  93004. /**
  93005. * 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)
  93006. * @param uniformName Name of the variable.
  93007. * @param array array to be set.
  93008. */
  93009. setIntArray3(uniformName: string, array: Int32Array): void;
  93010. /**
  93011. * 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)
  93012. * @param uniformName Name of the variable.
  93013. * @param array array to be set.
  93014. */
  93015. setIntArray4(uniformName: string, array: Int32Array): void;
  93016. /**
  93017. * Sets an array on a uniform variable.
  93018. * @param uniformName Name of the variable.
  93019. * @param array array to be set.
  93020. */
  93021. setArray(uniformName: string, array: number[]): void;
  93022. /**
  93023. * 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)
  93024. * @param uniformName Name of the variable.
  93025. * @param array array to be set.
  93026. */
  93027. setArray2(uniformName: string, array: number[]): void;
  93028. /**
  93029. * 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)
  93030. * @param uniformName Name of the variable.
  93031. * @param array array to be set.
  93032. * @returns this effect.
  93033. */
  93034. setArray3(uniformName: string, array: number[]): void;
  93035. /**
  93036. * 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)
  93037. * @param uniformName Name of the variable.
  93038. * @param array array to be set.
  93039. */
  93040. setArray4(uniformName: string, array: number[]): void;
  93041. /**
  93042. * Sets matrices on a uniform variable.
  93043. * @param uniformName Name of the variable.
  93044. * @param matrices matrices to be set.
  93045. */
  93046. setMatrices(uniformName: string, matrices: Float32Array): void;
  93047. /**
  93048. * Sets matrix on a uniform variable.
  93049. * @param uniformName Name of the variable.
  93050. * @param matrix matrix to be set.
  93051. */
  93052. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  93053. /**
  93054. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  93055. * @param uniformName Name of the variable.
  93056. * @param matrix matrix to be set.
  93057. */
  93058. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  93059. /**
  93060. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93061. * @param uniformName Name of the variable.
  93062. * @param matrix matrix to be set.
  93063. */
  93064. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  93065. /**
  93066. * Sets a float on a uniform variable.
  93067. * @param uniformName Name of the variable.
  93068. * @param value value to be set.
  93069. * @returns this effect.
  93070. */
  93071. setFloat(uniformName: string, value: number): void;
  93072. /**
  93073. * Sets a Vector2 on a uniform variable.
  93074. * @param uniformName Name of the variable.
  93075. * @param vector2 vector2 to be set.
  93076. */
  93077. setVector2(uniformName: string, vector2: IVector2Like): void;
  93078. /**
  93079. * Sets a float2 on a uniform variable.
  93080. * @param uniformName Name of the variable.
  93081. * @param x First float in float2.
  93082. * @param y Second float in float2.
  93083. */
  93084. setFloat2(uniformName: string, x: number, y: number): void;
  93085. /**
  93086. * Sets a Vector3 on a uniform variable.
  93087. * @param uniformName Name of the variable.
  93088. * @param vector3 Value to be set.
  93089. */
  93090. setVector3(uniformName: string, vector3: IVector3Like): void;
  93091. /**
  93092. * Sets a float3 on a uniform variable.
  93093. * @param uniformName Name of the variable.
  93094. * @param x First float in float3.
  93095. * @param y Second float in float3.
  93096. * @param z Third float in float3.
  93097. */
  93098. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  93099. /**
  93100. * Sets a Vector4 on a uniform variable.
  93101. * @param uniformName Name of the variable.
  93102. * @param vector4 Value to be set.
  93103. */
  93104. setVector4(uniformName: string, vector4: IVector4Like): void;
  93105. /**
  93106. * Sets a float4 on a uniform variable.
  93107. * @param uniformName Name of the variable.
  93108. * @param x First float in float4.
  93109. * @param y Second float in float4.
  93110. * @param z Third float in float4.
  93111. * @param w Fourth float in float4.
  93112. * @returns this effect.
  93113. */
  93114. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  93115. /**
  93116. * Sets a Color3 on a uniform variable.
  93117. * @param uniformName Name of the variable.
  93118. * @param color3 Value to be set.
  93119. */
  93120. setColor3(uniformName: string, color3: IColor3Like): void;
  93121. /**
  93122. * Sets a Color4 on a uniform variable.
  93123. * @param uniformName Name of the variable.
  93124. * @param color3 Value to be set.
  93125. * @param alpha Alpha value to be set.
  93126. */
  93127. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  93128. /**
  93129. * Sets a Color4 on a uniform variable
  93130. * @param uniformName defines the name of the variable
  93131. * @param color4 defines the value to be set
  93132. */
  93133. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  93134. _getVertexShaderCode(): string | null;
  93135. _getFragmentShaderCode(): string | null;
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. interface ThinEngine {
  93140. /**
  93141. * Create an uniform buffer
  93142. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93143. * @param elements defines the content of the uniform buffer
  93144. * @returns the webGL uniform buffer
  93145. */
  93146. createUniformBuffer(elements: FloatArray): DataBuffer;
  93147. /**
  93148. * Create a dynamic uniform buffer
  93149. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93150. * @param elements defines the content of the uniform buffer
  93151. * @returns the webGL uniform buffer
  93152. */
  93153. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  93154. /**
  93155. * Update an existing uniform buffer
  93156. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93157. * @param uniformBuffer defines the target uniform buffer
  93158. * @param elements defines the content to update
  93159. * @param offset defines the offset in the uniform buffer where update should start
  93160. * @param count defines the size of the data to update
  93161. */
  93162. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  93163. /**
  93164. * Bind an uniform buffer to the current webGL context
  93165. * @param buffer defines the buffer to bind
  93166. */
  93167. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  93168. /**
  93169. * Bind a buffer to the current webGL context at a given location
  93170. * @param buffer defines the buffer to bind
  93171. * @param location defines the index where to bind the buffer
  93172. * @param name Name of the uniform variable to bind
  93173. */
  93174. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  93175. /**
  93176. * Bind a specific block at a given index in a specific shader program
  93177. * @param pipelineContext defines the pipeline context to use
  93178. * @param blockName defines the block name
  93179. * @param index defines the index where to bind the block
  93180. */
  93181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  93182. }
  93183. }
  93184. declare module BABYLON {
  93185. /**
  93186. * Uniform buffer objects.
  93187. *
  93188. * Handles blocks of uniform on the GPU.
  93189. *
  93190. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93191. *
  93192. * For more information, please refer to :
  93193. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93194. */
  93195. export class UniformBuffer {
  93196. /** @hidden */
  93197. static _updatedUbosInFrame: {
  93198. [name: string]: number;
  93199. };
  93200. private _engine;
  93201. private _buffer;
  93202. private _buffers;
  93203. private _bufferIndex;
  93204. private _createBufferOnWrite;
  93205. private _data;
  93206. private _bufferData;
  93207. private _dynamic?;
  93208. private _uniformLocations;
  93209. private _uniformSizes;
  93210. private _uniformArraySizes;
  93211. private _uniformLocationPointer;
  93212. private _needSync;
  93213. private _noUBO;
  93214. private _currentEffect;
  93215. private _currentEffectName;
  93216. private _name;
  93217. private _currentFrameId;
  93218. /** @hidden */
  93219. _alreadyBound: boolean;
  93220. private static _MAX_UNIFORM_SIZE;
  93221. private static _tempBuffer;
  93222. private static _tempBufferInt32View;
  93223. /**
  93224. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93225. * This is dynamic to allow compat with webgl 1 and 2.
  93226. * You will need to pass the name of the uniform as well as the value.
  93227. */
  93228. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93229. /**
  93230. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93231. * This is dynamic to allow compat with webgl 1 and 2.
  93232. * You will need to pass the name of the uniform as well as the value.
  93233. */
  93234. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93235. /**
  93236. * Lambda to Update a single float in a uniform buffer.
  93237. * This is dynamic to allow compat with webgl 1 and 2.
  93238. * You will need to pass the name of the uniform as well as the value.
  93239. */
  93240. updateFloat: (name: string, x: number) => void;
  93241. /**
  93242. * Lambda to Update a vec2 of float in a uniform buffer.
  93243. * This is dynamic to allow compat with webgl 1 and 2.
  93244. * You will need to pass the name of the uniform as well as the value.
  93245. */
  93246. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93247. /**
  93248. * Lambda to Update a vec3 of float in a uniform buffer.
  93249. * This is dynamic to allow compat with webgl 1 and 2.
  93250. * You will need to pass the name of the uniform as well as the value.
  93251. */
  93252. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93253. /**
  93254. * Lambda to Update a vec4 of float in a uniform buffer.
  93255. * This is dynamic to allow compat with webgl 1 and 2.
  93256. * You will need to pass the name of the uniform as well as the value.
  93257. */
  93258. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93259. /**
  93260. * Lambda to Update an array of float in a uniform buffer.
  93261. * This is dynamic to allow compat with webgl 1 and 2.
  93262. * You will need to pass the name of the uniform as well as the value.
  93263. */
  93264. updateFloatArray: (name: string, array: Float32Array) => void;
  93265. /**
  93266. * Lambda to Update an array of number in a uniform buffer.
  93267. * This is dynamic to allow compat with webgl 1 and 2.
  93268. * You will need to pass the name of the uniform as well as the value.
  93269. */
  93270. updateArray: (name: string, array: number[]) => void;
  93271. /**
  93272. * Lambda to Update an array of number in a uniform buffer.
  93273. * This is dynamic to allow compat with webgl 1 and 2.
  93274. * You will need to pass the name of the uniform as well as the value.
  93275. */
  93276. updateIntArray: (name: string, array: Int32Array) => void;
  93277. /**
  93278. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93279. * This is dynamic to allow compat with webgl 1 and 2.
  93280. * You will need to pass the name of the uniform as well as the value.
  93281. */
  93282. updateMatrix: (name: string, mat: IMatrixLike) => void;
  93283. /**
  93284. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  93285. * This is dynamic to allow compat with webgl 1 and 2.
  93286. * You will need to pass the name of the uniform as well as the value.
  93287. */
  93288. updateMatrices: (name: string, mat: Float32Array) => void;
  93289. /**
  93290. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93291. * This is dynamic to allow compat with webgl 1 and 2.
  93292. * You will need to pass the name of the uniform as well as the value.
  93293. */
  93294. updateVector3: (name: string, vector: Vector3) => void;
  93295. /**
  93296. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93297. * This is dynamic to allow compat with webgl 1 and 2.
  93298. * You will need to pass the name of the uniform as well as the value.
  93299. */
  93300. updateVector4: (name: string, vector: Vector4) => void;
  93301. /**
  93302. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93303. * This is dynamic to allow compat with webgl 1 and 2.
  93304. * You will need to pass the name of the uniform as well as the value.
  93305. */
  93306. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93307. /**
  93308. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93309. * This is dynamic to allow compat with webgl 1 and 2.
  93310. * You will need to pass the name of the uniform as well as the value.
  93311. */
  93312. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93313. /**
  93314. * Lambda to Update a int a uniform buffer.
  93315. * This is dynamic to allow compat with webgl 1 and 2.
  93316. * You will need to pass the name of the uniform as well as the value.
  93317. */
  93318. updateInt: (name: string, x: number, suffix?: string) => void;
  93319. /**
  93320. * Lambda to Update a vec2 of int in a uniform buffer.
  93321. * This is dynamic to allow compat with webgl 1 and 2.
  93322. * You will need to pass the name of the uniform as well as the value.
  93323. */
  93324. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  93325. /**
  93326. * Lambda to Update a vec3 of int in a uniform buffer.
  93327. * This is dynamic to allow compat with webgl 1 and 2.
  93328. * You will need to pass the name of the uniform as well as the value.
  93329. */
  93330. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93331. /**
  93332. * Lambda to Update a vec4 of int in a uniform buffer.
  93333. * This is dynamic to allow compat with webgl 1 and 2.
  93334. * You will need to pass the name of the uniform as well as the value.
  93335. */
  93336. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93337. /**
  93338. * Instantiates a new Uniform buffer objects.
  93339. *
  93340. * Handles blocks of uniform on the GPU.
  93341. *
  93342. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93343. *
  93344. * For more information, please refer to :
  93345. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93346. * @param engine Define the engine the buffer is associated with
  93347. * @param data Define the data contained in the buffer
  93348. * @param dynamic Define if the buffer is updatable
  93349. * @param name to assign to the buffer (debugging purpose)
  93350. */
  93351. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  93352. /**
  93353. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93354. * or just falling back on setUniformXXX calls.
  93355. */
  93356. get useUbo(): boolean;
  93357. /**
  93358. * Indicates if the WebGL underlying uniform buffer is in sync
  93359. * with the javascript cache data.
  93360. */
  93361. get isSync(): boolean;
  93362. /**
  93363. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93364. * Also, a dynamic UniformBuffer will disable cache verification and always
  93365. * update the underlying WebGL uniform buffer to the GPU.
  93366. * @returns if Dynamic, otherwise false
  93367. */
  93368. isDynamic(): boolean;
  93369. /**
  93370. * The data cache on JS side.
  93371. * @returns the underlying data as a float array
  93372. */
  93373. getData(): Float32Array;
  93374. /**
  93375. * The underlying WebGL Uniform buffer.
  93376. * @returns the webgl buffer
  93377. */
  93378. getBuffer(): Nullable<DataBuffer>;
  93379. /**
  93380. * std140 layout specifies how to align data within an UBO structure.
  93381. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93382. * for specs.
  93383. */
  93384. private _fillAlignment;
  93385. /**
  93386. * Adds an uniform in the buffer.
  93387. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93388. * for the layout to be correct !
  93389. * @param name Name of the uniform, as used in the uniform block in the shader.
  93390. * @param size Data size, or data directly.
  93391. * @param arraySize The number of elements in the array, 0 if not an array.
  93392. */
  93393. addUniform(name: string, size: number | number[], arraySize?: number): void;
  93394. /**
  93395. * Adds a Matrix 4x4 to the uniform buffer.
  93396. * @param name Name of the uniform, as used in the uniform block in the shader.
  93397. * @param mat A 4x4 matrix.
  93398. */
  93399. addMatrix(name: string, mat: Matrix): void;
  93400. /**
  93401. * Adds a vec2 to the uniform buffer.
  93402. * @param name Name of the uniform, as used in the uniform block in the shader.
  93403. * @param x Define the x component value of the vec2
  93404. * @param y Define the y component value of the vec2
  93405. */
  93406. addFloat2(name: string, x: number, y: number): void;
  93407. /**
  93408. * Adds a vec3 to the uniform buffer.
  93409. * @param name Name of the uniform, as used in the uniform block in the shader.
  93410. * @param x Define the x component value of the vec3
  93411. * @param y Define the y component value of the vec3
  93412. * @param z Define the z component value of the vec3
  93413. */
  93414. addFloat3(name: string, x: number, y: number, z: number): void;
  93415. /**
  93416. * Adds a vec3 to the uniform buffer.
  93417. * @param name Name of the uniform, as used in the uniform block in the shader.
  93418. * @param color Define the vec3 from a Color
  93419. */
  93420. addColor3(name: string, color: Color3): void;
  93421. /**
  93422. * Adds a vec4 to the uniform buffer.
  93423. * @param name Name of the uniform, as used in the uniform block in the shader.
  93424. * @param color Define the rgb components from a Color
  93425. * @param alpha Define the a component of the vec4
  93426. */
  93427. addColor4(name: string, color: Color3, alpha: number): void;
  93428. /**
  93429. * Adds a vec3 to the uniform buffer.
  93430. * @param name Name of the uniform, as used in the uniform block in the shader.
  93431. * @param vector Define the vec3 components from a Vector
  93432. */
  93433. addVector3(name: string, vector: Vector3): void;
  93434. /**
  93435. * Adds a Matrix 3x3 to the uniform buffer.
  93436. * @param name Name of the uniform, as used in the uniform block in the shader.
  93437. */
  93438. addMatrix3x3(name: string): void;
  93439. /**
  93440. * Adds a Matrix 2x2 to the uniform buffer.
  93441. * @param name Name of the uniform, as used in the uniform block in the shader.
  93442. */
  93443. addMatrix2x2(name: string): void;
  93444. /**
  93445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93446. */
  93447. create(): void;
  93448. /** @hidden */
  93449. _rebuild(): void;
  93450. /** @hidden */
  93451. get _numBuffers(): number;
  93452. /** @hidden */
  93453. get _indexBuffer(): number;
  93454. /** Gets the name of this buffer */
  93455. get name(): string;
  93456. /**
  93457. * Updates the WebGL Uniform Buffer on the GPU.
  93458. * If the `dynamic` flag is set to true, no cache comparison is done.
  93459. * Otherwise, the buffer will be updated only if the cache differs.
  93460. */
  93461. update(): void;
  93462. private _createNewBuffer;
  93463. private _checkNewFrame;
  93464. /**
  93465. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93466. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93467. * @param data Define the flattened data
  93468. * @param size Define the size of the data.
  93469. */
  93470. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93471. /**
  93472. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93473. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93474. * @param data Define the flattened data
  93475. * @param size Define the size of the data.
  93476. */
  93477. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  93478. private _valueCache;
  93479. private _cacheMatrix;
  93480. private _updateMatrix3x3ForUniform;
  93481. private _updateMatrix3x3ForEffect;
  93482. private _updateMatrix2x2ForEffect;
  93483. private _updateMatrix2x2ForUniform;
  93484. private _updateFloatForEffect;
  93485. private _updateFloatForUniform;
  93486. private _updateFloat2ForEffect;
  93487. private _updateFloat2ForUniform;
  93488. private _updateFloat3ForEffect;
  93489. private _updateFloat3ForUniform;
  93490. private _updateFloat4ForEffect;
  93491. private _updateFloat4ForUniform;
  93492. private _updateFloatArrayForEffect;
  93493. private _updateFloatArrayForUniform;
  93494. private _updateArrayForEffect;
  93495. private _updateArrayForUniform;
  93496. private _updateIntArrayForEffect;
  93497. private _updateIntArrayForUniform;
  93498. private _updateMatrixForEffect;
  93499. private _updateMatrixForUniform;
  93500. private _updateMatricesForEffect;
  93501. private _updateMatricesForUniform;
  93502. private _updateVector3ForEffect;
  93503. private _updateVector3ForUniform;
  93504. private _updateVector4ForEffect;
  93505. private _updateVector4ForUniform;
  93506. private _updateColor3ForEffect;
  93507. private _updateColor3ForUniform;
  93508. private _updateColor4ForEffect;
  93509. private _updateColor4ForUniform;
  93510. private _updateIntForEffect;
  93511. private _updateIntForUniform;
  93512. private _updateInt2ForEffect;
  93513. private _updateInt2ForUniform;
  93514. private _updateInt3ForEffect;
  93515. private _updateInt3ForUniform;
  93516. private _updateInt4ForEffect;
  93517. private _updateInt4ForUniform;
  93518. /**
  93519. * Sets a sampler uniform on the effect.
  93520. * @param name Define the name of the sampler.
  93521. * @param texture Define the texture to set in the sampler
  93522. */
  93523. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93524. /**
  93525. * Directly updates the value of the uniform in the cache AND on the GPU.
  93526. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93527. * @param data Define the flattened data
  93528. */
  93529. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93530. /**
  93531. * Binds this uniform buffer to an effect.
  93532. * @param effect Define the effect to bind the buffer to
  93533. * @param name Name of the uniform block in the shader.
  93534. */
  93535. bindToEffect(effect: Effect, name: string): void;
  93536. /**
  93537. * Disposes the uniform buffer.
  93538. */
  93539. dispose(): void;
  93540. }
  93541. }
  93542. declare module BABYLON {
  93543. /**
  93544. * Manages the defines for the Material
  93545. */
  93546. export class MaterialDefines {
  93547. /** @hidden */
  93548. protected _keys: string[];
  93549. private _isDirty;
  93550. /** @hidden */
  93551. _renderId: number;
  93552. /** @hidden */
  93553. _areLightsDirty: boolean;
  93554. /** @hidden */
  93555. _areLightsDisposed: boolean;
  93556. /** @hidden */
  93557. _areAttributesDirty: boolean;
  93558. /** @hidden */
  93559. _areTexturesDirty: boolean;
  93560. /** @hidden */
  93561. _areFresnelDirty: boolean;
  93562. /** @hidden */
  93563. _areMiscDirty: boolean;
  93564. /** @hidden */
  93565. _arePrePassDirty: boolean;
  93566. /** @hidden */
  93567. _areImageProcessingDirty: boolean;
  93568. /** @hidden */
  93569. _normals: boolean;
  93570. /** @hidden */
  93571. _uvs: boolean;
  93572. /** @hidden */
  93573. _needNormals: boolean;
  93574. /** @hidden */
  93575. _needUVs: boolean;
  93576. [id: string]: any;
  93577. /**
  93578. * Specifies if the material needs to be re-calculated
  93579. */
  93580. get isDirty(): boolean;
  93581. /**
  93582. * Marks the material to indicate that it has been re-calculated
  93583. */
  93584. markAsProcessed(): void;
  93585. /**
  93586. * Marks the material to indicate that it needs to be re-calculated
  93587. */
  93588. markAsUnprocessed(): void;
  93589. /**
  93590. * Marks the material to indicate all of its defines need to be re-calculated
  93591. */
  93592. markAllAsDirty(): void;
  93593. /**
  93594. * Marks the material to indicate that image processing needs to be re-calculated
  93595. */
  93596. markAsImageProcessingDirty(): void;
  93597. /**
  93598. * Marks the material to indicate the lights need to be re-calculated
  93599. * @param disposed Defines whether the light is dirty due to dispose or not
  93600. */
  93601. markAsLightDirty(disposed?: boolean): void;
  93602. /**
  93603. * Marks the attribute state as changed
  93604. */
  93605. markAsAttributesDirty(): void;
  93606. /**
  93607. * Marks the texture state as changed
  93608. */
  93609. markAsTexturesDirty(): void;
  93610. /**
  93611. * Marks the fresnel state as changed
  93612. */
  93613. markAsFresnelDirty(): void;
  93614. /**
  93615. * Marks the misc state as changed
  93616. */
  93617. markAsMiscDirty(): void;
  93618. /**
  93619. * Marks the prepass state as changed
  93620. */
  93621. markAsPrePassDirty(): void;
  93622. /**
  93623. * Rebuilds the material defines
  93624. */
  93625. rebuild(): void;
  93626. /**
  93627. * Specifies if two material defines are equal
  93628. * @param other - A material define instance to compare to
  93629. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  93630. */
  93631. isEqual(other: MaterialDefines): boolean;
  93632. /**
  93633. * Clones this instance's defines to another instance
  93634. * @param other - material defines to clone values to
  93635. */
  93636. cloneTo(other: MaterialDefines): void;
  93637. /**
  93638. * Resets the material define values
  93639. */
  93640. reset(): void;
  93641. /**
  93642. * Converts the material define values to a string
  93643. * @returns - String of material define information
  93644. */
  93645. toString(): string;
  93646. }
  93647. }
  93648. declare module BABYLON {
  93649. /**
  93650. * Enum that determines the text-wrapping mode to use.
  93651. */
  93652. export enum InspectableType {
  93653. /**
  93654. * Checkbox for booleans
  93655. */
  93656. Checkbox = 0,
  93657. /**
  93658. * Sliders for numbers
  93659. */
  93660. Slider = 1,
  93661. /**
  93662. * Vector3
  93663. */
  93664. Vector3 = 2,
  93665. /**
  93666. * Quaternions
  93667. */
  93668. Quaternion = 3,
  93669. /**
  93670. * Color3
  93671. */
  93672. Color3 = 4,
  93673. /**
  93674. * String
  93675. */
  93676. String = 5
  93677. }
  93678. /**
  93679. * Interface used to define custom inspectable properties.
  93680. * This interface is used by the inspector to display custom property grids
  93681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93682. */
  93683. export interface IInspectable {
  93684. /**
  93685. * Gets the label to display
  93686. */
  93687. label: string;
  93688. /**
  93689. * Gets the name of the property to edit
  93690. */
  93691. propertyName: string;
  93692. /**
  93693. * Gets the type of the editor to use
  93694. */
  93695. type: InspectableType;
  93696. /**
  93697. * Gets the minimum value of the property when using in "slider" mode
  93698. */
  93699. min?: number;
  93700. /**
  93701. * Gets the maximum value of the property when using in "slider" mode
  93702. */
  93703. max?: number;
  93704. /**
  93705. * Gets the setp to use when using in "slider" mode
  93706. */
  93707. step?: number;
  93708. }
  93709. }
  93710. declare module BABYLON {
  93711. /**
  93712. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  93713. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  93714. * 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.
  93715. */
  93716. export abstract class Light extends Node {
  93717. /**
  93718. * Falloff Default: light is falling off following the material specification:
  93719. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  93720. */
  93721. static readonly FALLOFF_DEFAULT: number;
  93722. /**
  93723. * Falloff Physical: light is falling off following the inverse squared distance law.
  93724. */
  93725. static readonly FALLOFF_PHYSICAL: number;
  93726. /**
  93727. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  93728. * to enhance interoperability with other engines.
  93729. */
  93730. static readonly FALLOFF_GLTF: number;
  93731. /**
  93732. * Falloff Standard: light is falling off like in the standard material
  93733. * to enhance interoperability with other materials.
  93734. */
  93735. static readonly FALLOFF_STANDARD: number;
  93736. /**
  93737. * If every light affecting the material is in this lightmapMode,
  93738. * material.lightmapTexture adds or multiplies
  93739. * (depends on material.useLightmapAsShadowmap)
  93740. * after every other light calculations.
  93741. */
  93742. static readonly LIGHTMAP_DEFAULT: number;
  93743. /**
  93744. * material.lightmapTexture as only diffuse lighting from this light
  93745. * adds only specular lighting from this light
  93746. * adds dynamic shadows
  93747. */
  93748. static readonly LIGHTMAP_SPECULAR: number;
  93749. /**
  93750. * material.lightmapTexture as only lighting
  93751. * no light calculation from this light
  93752. * only adds dynamic shadows from this light
  93753. */
  93754. static readonly LIGHTMAP_SHADOWSONLY: number;
  93755. /**
  93756. * Each light type uses the default quantity according to its type:
  93757. * point/spot lights use luminous intensity
  93758. * directional lights use illuminance
  93759. */
  93760. static readonly INTENSITYMODE_AUTOMATIC: number;
  93761. /**
  93762. * lumen (lm)
  93763. */
  93764. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  93765. /**
  93766. * candela (lm/sr)
  93767. */
  93768. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  93769. /**
  93770. * lux (lm/m^2)
  93771. */
  93772. static readonly INTENSITYMODE_ILLUMINANCE: number;
  93773. /**
  93774. * nit (cd/m^2)
  93775. */
  93776. static readonly INTENSITYMODE_LUMINANCE: number;
  93777. /**
  93778. * Light type const id of the point light.
  93779. */
  93780. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93781. /**
  93782. * Light type const id of the directional light.
  93783. */
  93784. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93785. /**
  93786. * Light type const id of the spot light.
  93787. */
  93788. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93789. /**
  93790. * Light type const id of the hemispheric light.
  93791. */
  93792. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93793. /**
  93794. * Diffuse gives the basic color to an object.
  93795. */
  93796. diffuse: Color3;
  93797. /**
  93798. * Specular produces a highlight color on an object.
  93799. * Note: This is note affecting PBR materials.
  93800. */
  93801. specular: Color3;
  93802. /**
  93803. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93804. * falling off base on range or angle.
  93805. * This can be set to any values in Light.FALLOFF_x.
  93806. *
  93807. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93808. * other types of materials.
  93809. */
  93810. falloffType: number;
  93811. /**
  93812. * Strength of the light.
  93813. * Note: By default it is define in the framework own unit.
  93814. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93815. */
  93816. intensity: number;
  93817. private _range;
  93818. protected _inverseSquaredRange: number;
  93819. /**
  93820. * Defines how far from the source the light is impacting in scene units.
  93821. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93822. */
  93823. get range(): number;
  93824. /**
  93825. * Defines how far from the source the light is impacting in scene units.
  93826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93827. */
  93828. set range(value: number);
  93829. /**
  93830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93831. * of light.
  93832. */
  93833. private _photometricScale;
  93834. private _intensityMode;
  93835. /**
  93836. * Gets the photometric scale used to interpret the intensity.
  93837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93838. */
  93839. get intensityMode(): number;
  93840. /**
  93841. * Sets the photometric scale used to interpret the intensity.
  93842. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93843. */
  93844. set intensityMode(value: number);
  93845. private _radius;
  93846. /**
  93847. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93848. */
  93849. get radius(): number;
  93850. /**
  93851. * sets the light radius used by PBR Materials to simulate soft area lights.
  93852. */
  93853. set radius(value: number);
  93854. private _renderPriority;
  93855. /**
  93856. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93857. * exceeding the number allowed of the materials.
  93858. */
  93859. renderPriority: number;
  93860. private _shadowEnabled;
  93861. /**
  93862. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93863. * the current shadow generator.
  93864. */
  93865. get shadowEnabled(): boolean;
  93866. /**
  93867. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93868. * the current shadow generator.
  93869. */
  93870. set shadowEnabled(value: boolean);
  93871. private _includedOnlyMeshes;
  93872. /**
  93873. * Gets the only meshes impacted by this light.
  93874. */
  93875. get includedOnlyMeshes(): AbstractMesh[];
  93876. /**
  93877. * Sets the only meshes impacted by this light.
  93878. */
  93879. set includedOnlyMeshes(value: AbstractMesh[]);
  93880. private _excludedMeshes;
  93881. /**
  93882. * Gets the meshes not impacted by this light.
  93883. */
  93884. get excludedMeshes(): AbstractMesh[];
  93885. /**
  93886. * Sets the meshes not impacted by this light.
  93887. */
  93888. set excludedMeshes(value: AbstractMesh[]);
  93889. private _excludeWithLayerMask;
  93890. /**
  93891. * Gets the layer id use to find what meshes are not impacted by the light.
  93892. * Inactive if 0
  93893. */
  93894. get excludeWithLayerMask(): number;
  93895. /**
  93896. * Sets the layer id use to find what meshes are not impacted by the light.
  93897. * Inactive if 0
  93898. */
  93899. set excludeWithLayerMask(value: number);
  93900. private _includeOnlyWithLayerMask;
  93901. /**
  93902. * Gets the layer id use to find what meshes are impacted by the light.
  93903. * Inactive if 0
  93904. */
  93905. get includeOnlyWithLayerMask(): number;
  93906. /**
  93907. * Sets the layer id use to find what meshes are impacted by the light.
  93908. * Inactive if 0
  93909. */
  93910. set includeOnlyWithLayerMask(value: number);
  93911. private _lightmapMode;
  93912. /**
  93913. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93914. */
  93915. get lightmapMode(): number;
  93916. /**
  93917. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93918. */
  93919. set lightmapMode(value: number);
  93920. /**
  93921. * Shadow generator associted to the light.
  93922. * @hidden Internal use only.
  93923. */
  93924. _shadowGenerator: Nullable<IShadowGenerator>;
  93925. /**
  93926. * @hidden Internal use only.
  93927. */
  93928. _excludedMeshesIds: string[];
  93929. /**
  93930. * @hidden Internal use only.
  93931. */
  93932. _includedOnlyMeshesIds: string[];
  93933. /**
  93934. * The current light unifom buffer.
  93935. * @hidden Internal use only.
  93936. */
  93937. _uniformBuffer: UniformBuffer;
  93938. /** @hidden */
  93939. _renderId: number;
  93940. /**
  93941. * Creates a Light object in the scene.
  93942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93943. * @param name The firendly name of the light
  93944. * @param scene The scene the light belongs too
  93945. */
  93946. constructor(name: string, scene: Scene);
  93947. protected abstract _buildUniformLayout(): void;
  93948. /**
  93949. * Sets the passed Effect "effect" with the Light information.
  93950. * @param effect The effect to update
  93951. * @param lightIndex The index of the light in the effect to update
  93952. * @returns The light
  93953. */
  93954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93955. /**
  93956. * Sets the passed Effect "effect" with the Light textures.
  93957. * @param effect The effect to update
  93958. * @param lightIndex The index of the light in the effect to update
  93959. * @returns The light
  93960. */
  93961. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93962. /**
  93963. * Binds the lights information from the scene to the effect for the given mesh.
  93964. * @param lightIndex Light index
  93965. * @param scene The scene where the light belongs to
  93966. * @param effect The effect we are binding the data to
  93967. * @param useSpecular Defines if specular is supported
  93968. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93969. */
  93970. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93971. /**
  93972. * Sets the passed Effect "effect" with the Light information.
  93973. * @param effect The effect to update
  93974. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93975. * @returns The light
  93976. */
  93977. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93978. /**
  93979. * Returns the string "Light".
  93980. * @returns the class name
  93981. */
  93982. getClassName(): string;
  93983. /** @hidden */
  93984. readonly _isLight: boolean;
  93985. /**
  93986. * Converts the light information to a readable string for debug purpose.
  93987. * @param fullDetails Supports for multiple levels of logging within scene loading
  93988. * @returns the human readable light info
  93989. */
  93990. toString(fullDetails?: boolean): string;
  93991. /** @hidden */
  93992. protected _syncParentEnabledState(): void;
  93993. /**
  93994. * Set the enabled state of this node.
  93995. * @param value - the new enabled state
  93996. */
  93997. setEnabled(value: boolean): void;
  93998. /**
  93999. * Returns the Light associated shadow generator if any.
  94000. * @return the associated shadow generator.
  94001. */
  94002. getShadowGenerator(): Nullable<IShadowGenerator>;
  94003. /**
  94004. * Returns a Vector3, the absolute light position in the World.
  94005. * @returns the world space position of the light
  94006. */
  94007. getAbsolutePosition(): Vector3;
  94008. /**
  94009. * Specifies if the light will affect the passed mesh.
  94010. * @param mesh The mesh to test against the light
  94011. * @return true the mesh is affected otherwise, false.
  94012. */
  94013. canAffectMesh(mesh: AbstractMesh): boolean;
  94014. /**
  94015. * Sort function to order lights for rendering.
  94016. * @param a First Light object to compare to second.
  94017. * @param b Second Light object to compare first.
  94018. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  94019. */
  94020. static CompareLightsPriority(a: Light, b: Light): number;
  94021. /**
  94022. * Releases resources associated with this node.
  94023. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94024. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94025. */
  94026. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94027. /**
  94028. * Returns the light type ID (integer).
  94029. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  94030. */
  94031. getTypeID(): number;
  94032. /**
  94033. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  94034. * @returns the scaled intensity in intensity mode unit
  94035. */
  94036. getScaledIntensity(): number;
  94037. /**
  94038. * Returns a new Light object, named "name", from the current one.
  94039. * @param name The name of the cloned light
  94040. * @param newParent The parent of this light, if it has one
  94041. * @returns the new created light
  94042. */
  94043. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  94044. /**
  94045. * Serializes the current light into a Serialization object.
  94046. * @returns the serialized object.
  94047. */
  94048. serialize(): any;
  94049. /**
  94050. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  94051. * This new light is named "name" and added to the passed scene.
  94052. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  94053. * @param name The friendly name of the light
  94054. * @param scene The scene the new light will belong to
  94055. * @returns the constructor function
  94056. */
  94057. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  94058. /**
  94059. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  94060. * @param parsedLight The JSON representation of the light
  94061. * @param scene The scene to create the parsed light in
  94062. * @returns the created light after parsing
  94063. */
  94064. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  94065. private _hookArrayForExcluded;
  94066. private _hookArrayForIncludedOnly;
  94067. private _resyncMeshes;
  94068. /**
  94069. * Forces the meshes to update their light related information in their rendering used effects
  94070. * @hidden Internal Use Only
  94071. */
  94072. _markMeshesAsLightDirty(): void;
  94073. /**
  94074. * Recomputes the cached photometric scale if needed.
  94075. */
  94076. private _computePhotometricScale;
  94077. /**
  94078. * Returns the Photometric Scale according to the light type and intensity mode.
  94079. */
  94080. private _getPhotometricScale;
  94081. /**
  94082. * Reorder the light in the scene according to their defined priority.
  94083. * @hidden Internal Use Only
  94084. */
  94085. _reorderLightsInScene(): void;
  94086. /**
  94087. * Prepares the list of defines specific to the light type.
  94088. * @param defines the list of defines
  94089. * @param lightIndex defines the index of the light for the effect
  94090. */
  94091. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  94092. }
  94093. }
  94094. declare module BABYLON {
  94095. /** Defines supported spaces */
  94096. export enum Space {
  94097. /** Local (object) space */
  94098. LOCAL = 0,
  94099. /** World space */
  94100. WORLD = 1,
  94101. /** Bone space */
  94102. BONE = 2
  94103. }
  94104. /** Defines the 3 main axes */
  94105. export class Axis {
  94106. /** X axis */
  94107. static X: Vector3;
  94108. /** Y axis */
  94109. static Y: Vector3;
  94110. /** Z axis */
  94111. static Z: Vector3;
  94112. }
  94113. /**
  94114. * Defines cartesian components.
  94115. */
  94116. export enum Coordinate {
  94117. /** X axis */
  94118. X = 0,
  94119. /** Y axis */
  94120. Y = 1,
  94121. /** Z axis */
  94122. Z = 2
  94123. }
  94124. }
  94125. declare module BABYLON {
  94126. /**
  94127. * Interface describing all the common properties and methods a shadow light needs to implement.
  94128. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  94129. * as well as binding the different shadow properties to the effects.
  94130. */
  94131. export interface IShadowLight extends Light {
  94132. /**
  94133. * The light id in the scene (used in scene.findLighById for instance)
  94134. */
  94135. id: string;
  94136. /**
  94137. * The position the shdow will be casted from.
  94138. */
  94139. position: Vector3;
  94140. /**
  94141. * In 2d mode (needCube being false), the direction used to cast the shadow.
  94142. */
  94143. direction: Vector3;
  94144. /**
  94145. * The transformed position. Position of the light in world space taking parenting in account.
  94146. */
  94147. transformedPosition: Vector3;
  94148. /**
  94149. * The transformed direction. Direction of the light in world space taking parenting in account.
  94150. */
  94151. transformedDirection: Vector3;
  94152. /**
  94153. * The friendly name of the light in the scene.
  94154. */
  94155. name: string;
  94156. /**
  94157. * Defines the shadow projection clipping minimum z value.
  94158. */
  94159. shadowMinZ: number;
  94160. /**
  94161. * Defines the shadow projection clipping maximum z value.
  94162. */
  94163. shadowMaxZ: number;
  94164. /**
  94165. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94166. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94167. */
  94168. computeTransformedInformation(): boolean;
  94169. /**
  94170. * Gets the scene the light belongs to.
  94171. * @returns The scene
  94172. */
  94173. getScene(): Scene;
  94174. /**
  94175. * Callback defining a custom Projection Matrix Builder.
  94176. * This can be used to override the default projection matrix computation.
  94177. */
  94178. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94179. /**
  94180. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94181. * @param matrix The materix to updated with the projection information
  94182. * @param viewMatrix The transform matrix of the light
  94183. * @param renderList The list of mesh to render in the map
  94184. * @returns The current light
  94185. */
  94186. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94187. /**
  94188. * Gets the current depth scale used in ESM.
  94189. * @returns The scale
  94190. */
  94191. getDepthScale(): number;
  94192. /**
  94193. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94194. * @returns true if a cube texture needs to be use
  94195. */
  94196. needCube(): boolean;
  94197. /**
  94198. * Detects if the projection matrix requires to be recomputed this frame.
  94199. * @returns true if it requires to be recomputed otherwise, false.
  94200. */
  94201. needProjectionMatrixCompute(): boolean;
  94202. /**
  94203. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94204. */
  94205. forceProjectionMatrixCompute(): void;
  94206. /**
  94207. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94208. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94209. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94210. */
  94211. getShadowDirection(faceIndex?: number): Vector3;
  94212. /**
  94213. * Gets the minZ used for shadow according to both the scene and the light.
  94214. * @param activeCamera The camera we are returning the min for
  94215. * @returns the depth min z
  94216. */
  94217. getDepthMinZ(activeCamera: Camera): number;
  94218. /**
  94219. * Gets the maxZ used for shadow according to both the scene and the light.
  94220. * @param activeCamera The camera we are returning the max for
  94221. * @returns the depth max z
  94222. */
  94223. getDepthMaxZ(activeCamera: Camera): number;
  94224. }
  94225. /**
  94226. * Base implementation IShadowLight
  94227. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  94228. */
  94229. export abstract class ShadowLight extends Light implements IShadowLight {
  94230. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  94231. protected _position: Vector3;
  94232. protected _setPosition(value: Vector3): void;
  94233. /**
  94234. * Sets the position the shadow will be casted from. Also use as the light position for both
  94235. * point and spot lights.
  94236. */
  94237. get position(): Vector3;
  94238. /**
  94239. * Sets the position the shadow will be casted from. Also use as the light position for both
  94240. * point and spot lights.
  94241. */
  94242. set position(value: Vector3);
  94243. protected _direction: Vector3;
  94244. protected _setDirection(value: Vector3): void;
  94245. /**
  94246. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  94247. * Also use as the light direction on spot and directional lights.
  94248. */
  94249. get direction(): Vector3;
  94250. /**
  94251. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  94252. * Also use as the light direction on spot and directional lights.
  94253. */
  94254. set direction(value: Vector3);
  94255. protected _shadowMinZ: number;
  94256. /**
  94257. * Gets the shadow projection clipping minimum z value.
  94258. */
  94259. get shadowMinZ(): number;
  94260. /**
  94261. * Sets the shadow projection clipping minimum z value.
  94262. */
  94263. set shadowMinZ(value: number);
  94264. protected _shadowMaxZ: number;
  94265. /**
  94266. * Sets the shadow projection clipping maximum z value.
  94267. */
  94268. get shadowMaxZ(): number;
  94269. /**
  94270. * Gets the shadow projection clipping maximum z value.
  94271. */
  94272. set shadowMaxZ(value: number);
  94273. /**
  94274. * Callback defining a custom Projection Matrix Builder.
  94275. * This can be used to override the default projection matrix computation.
  94276. */
  94277. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94278. /**
  94279. * The transformed position. Position of the light in world space taking parenting in account.
  94280. */
  94281. transformedPosition: Vector3;
  94282. /**
  94283. * The transformed direction. Direction of the light in world space taking parenting in account.
  94284. */
  94285. transformedDirection: Vector3;
  94286. private _needProjectionMatrixCompute;
  94287. /**
  94288. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94289. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94290. */
  94291. computeTransformedInformation(): boolean;
  94292. /**
  94293. * Return the depth scale used for the shadow map.
  94294. * @returns the depth scale.
  94295. */
  94296. getDepthScale(): number;
  94297. /**
  94298. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94299. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94300. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94301. */
  94302. getShadowDirection(faceIndex?: number): Vector3;
  94303. /**
  94304. * Returns the ShadowLight absolute position in the World.
  94305. * @returns the position vector in world space
  94306. */
  94307. getAbsolutePosition(): Vector3;
  94308. /**
  94309. * Sets the ShadowLight direction toward the passed target.
  94310. * @param target The point to target in local space
  94311. * @returns the updated ShadowLight direction
  94312. */
  94313. setDirectionToTarget(target: Vector3): Vector3;
  94314. /**
  94315. * Returns the light rotation in euler definition.
  94316. * @returns the x y z rotation in local space.
  94317. */
  94318. getRotation(): Vector3;
  94319. /**
  94320. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94321. * @returns true if a cube texture needs to be use
  94322. */
  94323. needCube(): boolean;
  94324. /**
  94325. * Detects if the projection matrix requires to be recomputed this frame.
  94326. * @returns true if it requires to be recomputed otherwise, false.
  94327. */
  94328. needProjectionMatrixCompute(): boolean;
  94329. /**
  94330. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94331. */
  94332. forceProjectionMatrixCompute(): void;
  94333. /** @hidden */
  94334. _initCache(): void;
  94335. /** @hidden */
  94336. _isSynchronized(): boolean;
  94337. /**
  94338. * Computes the world matrix of the node
  94339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94340. * @returns the world matrix
  94341. */
  94342. computeWorldMatrix(force?: boolean): Matrix;
  94343. /**
  94344. * Gets the minZ used for shadow according to both the scene and the light.
  94345. * @param activeCamera The camera we are returning the min for
  94346. * @returns the depth min z
  94347. */
  94348. getDepthMinZ(activeCamera: Camera): number;
  94349. /**
  94350. * Gets the maxZ used for shadow according to both the scene and the light.
  94351. * @param activeCamera The camera we are returning the max for
  94352. * @returns the depth max z
  94353. */
  94354. getDepthMaxZ(activeCamera: Camera): number;
  94355. /**
  94356. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94357. * @param matrix The materix to updated with the projection information
  94358. * @param viewMatrix The transform matrix of the light
  94359. * @param renderList The list of mesh to render in the map
  94360. * @returns The current light
  94361. */
  94362. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94363. }
  94364. }
  94365. declare module BABYLON {
  94366. /**
  94367. * Configuration needed for prepass-capable materials
  94368. */
  94369. export class PrePassConfiguration {
  94370. /**
  94371. * Previous world matrices of meshes carrying this material
  94372. * Used for computing velocity
  94373. */
  94374. previousWorldMatrices: {
  94375. [index: number]: Matrix;
  94376. };
  94377. /**
  94378. * Previous view project matrix
  94379. * Used for computing velocity
  94380. */
  94381. previousViewProjection: Matrix;
  94382. /**
  94383. * Previous bones of meshes carrying this material
  94384. * Used for computing velocity
  94385. */
  94386. previousBones: {
  94387. [index: number]: Float32Array;
  94388. };
  94389. /**
  94390. * Add the required uniforms to the current list.
  94391. * @param uniforms defines the current uniform list.
  94392. */
  94393. static AddUniforms(uniforms: string[]): void;
  94394. /**
  94395. * Add the required samplers to the current list.
  94396. * @param samplers defines the current sampler list.
  94397. */
  94398. static AddSamplers(samplers: string[]): void;
  94399. /**
  94400. * Binds the material data.
  94401. * @param effect defines the effect to update
  94402. * @param scene defines the scene the material belongs to.
  94403. * @param mesh The mesh
  94404. * @param world World matrix of this mesh
  94405. * @param isFrozen Is the material frozen
  94406. */
  94407. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. /**
  94412. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  94413. * This is the base of the follow, arc rotate cameras and Free camera
  94414. * @see https://doc.babylonjs.com/features/cameras
  94415. */
  94416. export class TargetCamera extends Camera {
  94417. private static _RigCamTransformMatrix;
  94418. private static _TargetTransformMatrix;
  94419. private static _TargetFocalPoint;
  94420. private _tmpUpVector;
  94421. private _tmpTargetVector;
  94422. /**
  94423. * Define the current direction the camera is moving to
  94424. */
  94425. cameraDirection: Vector3;
  94426. /**
  94427. * Define the current rotation the camera is rotating to
  94428. */
  94429. cameraRotation: Vector2;
  94430. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  94431. ignoreParentScaling: boolean;
  94432. /**
  94433. * When set, the up vector of the camera will be updated by the rotation of the camera
  94434. */
  94435. updateUpVectorFromRotation: boolean;
  94436. private _tmpQuaternion;
  94437. /**
  94438. * Define the current rotation of the camera
  94439. */
  94440. rotation: Vector3;
  94441. /**
  94442. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  94443. */
  94444. rotationQuaternion: Quaternion;
  94445. /**
  94446. * Define the current speed of the camera
  94447. */
  94448. speed: number;
  94449. /**
  94450. * Add constraint to the camera to prevent it to move freely in all directions and
  94451. * around all axis.
  94452. */
  94453. noRotationConstraint: boolean;
  94454. /**
  94455. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  94456. * panning
  94457. */
  94458. invertRotation: boolean;
  94459. /**
  94460. * Speed multiplier for inverse camera panning
  94461. */
  94462. inverseRotationSpeed: number;
  94463. /**
  94464. * Define the current target of the camera as an object or a position.
  94465. */
  94466. lockedTarget: any;
  94467. /** @hidden */
  94468. _currentTarget: Vector3;
  94469. /** @hidden */
  94470. _initialFocalDistance: number;
  94471. /** @hidden */
  94472. _viewMatrix: Matrix;
  94473. /** @hidden */
  94474. _camMatrix: Matrix;
  94475. /** @hidden */
  94476. _cameraTransformMatrix: Matrix;
  94477. /** @hidden */
  94478. _cameraRotationMatrix: Matrix;
  94479. /** @hidden */
  94480. _referencePoint: Vector3;
  94481. /** @hidden */
  94482. _transformedReferencePoint: Vector3;
  94483. /** @hidden */
  94484. _reset: () => void;
  94485. private _defaultUp;
  94486. /**
  94487. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  94488. * This is the base of the follow, arc rotate cameras and Free camera
  94489. * @see https://doc.babylonjs.com/features/cameras
  94490. * @param name Defines the name of the camera in the scene
  94491. * @param position Defines the start position of the camera in the scene
  94492. * @param scene Defines the scene the camera belongs to
  94493. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94494. */
  94495. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94496. /**
  94497. * Gets the position in front of the camera at a given distance.
  94498. * @param distance The distance from the camera we want the position to be
  94499. * @returns the position
  94500. */
  94501. getFrontPosition(distance: number): Vector3;
  94502. /** @hidden */
  94503. _getLockedTargetPosition(): Nullable<Vector3>;
  94504. private _storedPosition;
  94505. private _storedRotation;
  94506. private _storedRotationQuaternion;
  94507. /**
  94508. * Store current camera state of the camera (fov, position, rotation, etc..)
  94509. * @returns the camera
  94510. */
  94511. storeState(): Camera;
  94512. /**
  94513. * Restored camera state. You must call storeState() first
  94514. * @returns whether it was successful or not
  94515. * @hidden
  94516. */
  94517. _restoreStateValues(): boolean;
  94518. /** @hidden */
  94519. _initCache(): void;
  94520. /** @hidden */
  94521. _updateCache(ignoreParentClass?: boolean): void;
  94522. /** @hidden */
  94523. _isSynchronizedViewMatrix(): boolean;
  94524. /** @hidden */
  94525. _computeLocalCameraSpeed(): number;
  94526. /**
  94527. * Defines the target the camera should look at.
  94528. * @param target Defines the new target as a Vector or a mesh
  94529. */
  94530. setTarget(target: Vector3): void;
  94531. /**
  94532. * Defines the target point of the camera.
  94533. * The camera looks towards it form the radius distance.
  94534. */
  94535. get target(): Vector3;
  94536. set target(value: Vector3);
  94537. /**
  94538. * Return the current target position of the camera. This value is expressed in local space.
  94539. * @returns the target position
  94540. */
  94541. getTarget(): Vector3;
  94542. /** @hidden */
  94543. _decideIfNeedsToMove(): boolean;
  94544. /** @hidden */
  94545. _updatePosition(): void;
  94546. /** @hidden */
  94547. _checkInputs(): void;
  94548. protected _updateCameraRotationMatrix(): void;
  94549. /**
  94550. * 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)
  94551. * @returns the current camera
  94552. */
  94553. private _rotateUpVectorWithCameraRotationMatrix;
  94554. private _cachedRotationZ;
  94555. private _cachedQuaternionRotationZ;
  94556. /** @hidden */
  94557. _getViewMatrix(): Matrix;
  94558. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  94559. /**
  94560. * @hidden
  94561. */
  94562. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94563. /**
  94564. * @hidden
  94565. */
  94566. _updateRigCameras(): void;
  94567. private _getRigCamPositionAndTarget;
  94568. /**
  94569. * Gets the current object class name.
  94570. * @return the class name
  94571. */
  94572. getClassName(): string;
  94573. }
  94574. }
  94575. declare module BABYLON {
  94576. /**
  94577. * @ignore
  94578. * This is a list of all the different input types that are available in the application.
  94579. * Fo instance: ArcRotateCameraGamepadInput...
  94580. */
  94581. export var CameraInputTypes: {};
  94582. /**
  94583. * This is the contract to implement in order to create a new input class.
  94584. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  94585. */
  94586. export interface ICameraInput<TCamera extends Camera> {
  94587. /**
  94588. * Defines the camera the input is attached to.
  94589. */
  94590. camera: Nullable<TCamera>;
  94591. /**
  94592. * Gets the class name of the current intput.
  94593. * @returns the class name
  94594. */
  94595. getClassName(): string;
  94596. /**
  94597. * Get the friendly name associated with the input class.
  94598. * @returns the input friendly name
  94599. */
  94600. getSimpleName(): string;
  94601. /**
  94602. * Attach the input controls to a specific dom element to get the input from.
  94603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94604. */
  94605. attachControl(noPreventDefault?: boolean): void;
  94606. /**
  94607. * Detach the current controls from the specified dom element.
  94608. */
  94609. detachControl(): void;
  94610. /**
  94611. * Update the current camera state depending on the inputs that have been used this frame.
  94612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94613. */
  94614. checkInputs?: () => void;
  94615. }
  94616. /**
  94617. * Represents a map of input types to input instance or input index to input instance.
  94618. */
  94619. export interface CameraInputsMap<TCamera extends Camera> {
  94620. /**
  94621. * Accessor to the input by input type.
  94622. */
  94623. [name: string]: ICameraInput<TCamera>;
  94624. /**
  94625. * Accessor to the input by input index.
  94626. */
  94627. [idx: number]: ICameraInput<TCamera>;
  94628. }
  94629. /**
  94630. * This represents the input manager used within a camera.
  94631. * It helps dealing with all the different kind of input attached to a camera.
  94632. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94633. */
  94634. export class CameraInputsManager<TCamera extends Camera> {
  94635. /**
  94636. * Defines the list of inputs attahed to the camera.
  94637. */
  94638. attached: CameraInputsMap<TCamera>;
  94639. /**
  94640. * Defines the dom element the camera is collecting inputs from.
  94641. * This is null if the controls have not been attached.
  94642. */
  94643. attachedToElement: boolean;
  94644. /**
  94645. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94646. */
  94647. noPreventDefault: boolean;
  94648. /**
  94649. * Defined the camera the input manager belongs to.
  94650. */
  94651. camera: TCamera;
  94652. /**
  94653. * Update the current camera state depending on the inputs that have been used this frame.
  94654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94655. */
  94656. checkInputs: () => void;
  94657. /**
  94658. * Instantiate a new Camera Input Manager.
  94659. * @param camera Defines the camera the input manager blongs to
  94660. */
  94661. constructor(camera: TCamera);
  94662. /**
  94663. * Add an input method to a camera
  94664. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94665. * @param input camera input method
  94666. */
  94667. add(input: ICameraInput<TCamera>): void;
  94668. /**
  94669. * Remove a specific input method from a camera
  94670. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  94671. * @param inputToRemove camera input method
  94672. */
  94673. remove(inputToRemove: ICameraInput<TCamera>): void;
  94674. /**
  94675. * Remove a specific input type from a camera
  94676. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  94677. * @param inputType the type of the input to remove
  94678. */
  94679. removeByType(inputType: string): void;
  94680. private _addCheckInputs;
  94681. /**
  94682. * Attach the input controls to the currently attached dom element to listen the events from.
  94683. * @param input Defines the input to attach
  94684. */
  94685. attachInput(input: ICameraInput<TCamera>): void;
  94686. /**
  94687. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  94688. * @param element Defines the dom element to collect the events from
  94689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94690. */
  94691. attachElement(noPreventDefault?: boolean): void;
  94692. /**
  94693. * Detach the current manager inputs controls from a specific dom element.
  94694. * @param element Defines the dom element to collect the events from
  94695. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  94696. */
  94697. detachElement(disconnect?: boolean): void;
  94698. /**
  94699. * Rebuild the dynamic inputCheck function from the current list of
  94700. * defined inputs in the manager.
  94701. */
  94702. rebuildInputCheck(): void;
  94703. /**
  94704. * Remove all attached input methods from a camera
  94705. */
  94706. clear(): void;
  94707. /**
  94708. * Serialize the current input manager attached to a camera.
  94709. * This ensures than once parsed,
  94710. * the input associated to the camera will be identical to the current ones
  94711. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  94712. */
  94713. serialize(serializedCamera: any): void;
  94714. /**
  94715. * Parses an input manager serialized JSON to restore the previous list of inputs
  94716. * and states associated to a camera.
  94717. * @param parsedCamera Defines the JSON to parse
  94718. */
  94719. parse(parsedCamera: any): void;
  94720. }
  94721. }
  94722. declare module BABYLON {
  94723. /**
  94724. * Gather the list of keyboard event types as constants.
  94725. */
  94726. export class KeyboardEventTypes {
  94727. /**
  94728. * The keydown event is fired when a key becomes active (pressed).
  94729. */
  94730. static readonly KEYDOWN: number;
  94731. /**
  94732. * The keyup event is fired when a key has been released.
  94733. */
  94734. static readonly KEYUP: number;
  94735. }
  94736. /**
  94737. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94738. */
  94739. export class KeyboardInfo {
  94740. /**
  94741. * Defines the type of event (KeyboardEventTypes)
  94742. */
  94743. type: number;
  94744. /**
  94745. * Defines the related dom event
  94746. */
  94747. event: KeyboardEvent;
  94748. /**
  94749. * Instantiates a new keyboard info.
  94750. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94751. * @param type Defines the type of event (KeyboardEventTypes)
  94752. * @param event Defines the related dom event
  94753. */
  94754. constructor(
  94755. /**
  94756. * Defines the type of event (KeyboardEventTypes)
  94757. */
  94758. type: number,
  94759. /**
  94760. * Defines the related dom event
  94761. */
  94762. event: KeyboardEvent);
  94763. }
  94764. /**
  94765. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94766. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  94767. */
  94768. export class KeyboardInfoPre extends KeyboardInfo {
  94769. /**
  94770. * Defines the type of event (KeyboardEventTypes)
  94771. */
  94772. type: number;
  94773. /**
  94774. * Defines the related dom event
  94775. */
  94776. event: KeyboardEvent;
  94777. /**
  94778. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  94779. */
  94780. skipOnPointerObservable: boolean;
  94781. /**
  94782. * Instantiates a new keyboard pre info.
  94783. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94784. * @param type Defines the type of event (KeyboardEventTypes)
  94785. * @param event Defines the related dom event
  94786. */
  94787. constructor(
  94788. /**
  94789. * Defines the type of event (KeyboardEventTypes)
  94790. */
  94791. type: number,
  94792. /**
  94793. * Defines the related dom event
  94794. */
  94795. event: KeyboardEvent);
  94796. }
  94797. }
  94798. declare module BABYLON {
  94799. /**
  94800. * Manage the keyboard inputs to control the movement of a free camera.
  94801. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94802. */
  94803. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  94804. /**
  94805. * Defines the camera the input is attached to.
  94806. */
  94807. camera: FreeCamera;
  94808. /**
  94809. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94810. */
  94811. keysUp: number[];
  94812. /**
  94813. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94814. */
  94815. keysUpward: number[];
  94816. /**
  94817. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94818. */
  94819. keysDown: number[];
  94820. /**
  94821. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94822. */
  94823. keysDownward: number[];
  94824. /**
  94825. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94826. */
  94827. keysLeft: number[];
  94828. /**
  94829. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94830. */
  94831. keysRight: number[];
  94832. private _keys;
  94833. private _onCanvasBlurObserver;
  94834. private _onKeyboardObserver;
  94835. private _engine;
  94836. private _scene;
  94837. /**
  94838. * Attach the input controls to a specific dom element to get the input from.
  94839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94840. */
  94841. attachControl(noPreventDefault?: boolean): void;
  94842. /**
  94843. * Detach the current controls from the specified dom element.
  94844. */
  94845. detachControl(): void;
  94846. /**
  94847. * Update the current camera state depending on the inputs that have been used this frame.
  94848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94849. */
  94850. checkInputs(): void;
  94851. /**
  94852. * Gets the class name of the current intput.
  94853. * @returns the class name
  94854. */
  94855. getClassName(): string;
  94856. /** @hidden */
  94857. _onLostFocus(): void;
  94858. /**
  94859. * Get the friendly name associated with the input class.
  94860. * @returns the input friendly name
  94861. */
  94862. getSimpleName(): string;
  94863. }
  94864. }
  94865. declare module BABYLON {
  94866. /**
  94867. * Interface used to define Action
  94868. */
  94869. export interface IAction {
  94870. /**
  94871. * Trigger for the action
  94872. */
  94873. trigger: number;
  94874. /** Options of the trigger */
  94875. triggerOptions: any;
  94876. /**
  94877. * Gets the trigger parameters
  94878. * @returns the trigger parameters
  94879. */
  94880. getTriggerParameter(): any;
  94881. /**
  94882. * Internal only - executes current action event
  94883. * @hidden
  94884. */
  94885. _executeCurrent(evt?: ActionEvent): void;
  94886. /**
  94887. * Serialize placeholder for child classes
  94888. * @param parent of child
  94889. * @returns the serialized object
  94890. */
  94891. serialize(parent: any): any;
  94892. /**
  94893. * Internal only
  94894. * @hidden
  94895. */
  94896. _prepare(): void;
  94897. /**
  94898. * Internal only - manager for action
  94899. * @hidden
  94900. */
  94901. _actionManager: Nullable<AbstractActionManager>;
  94902. /**
  94903. * Adds action to chain of actions, may be a DoNothingAction
  94904. * @param action defines the next action to execute
  94905. * @returns The action passed in
  94906. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94907. */
  94908. then(action: IAction): IAction;
  94909. }
  94910. /**
  94911. * The action to be carried out following a trigger
  94912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  94913. */
  94914. export class Action implements IAction {
  94915. /** the trigger, with or without parameters, for the action */
  94916. triggerOptions: any;
  94917. /**
  94918. * Trigger for the action
  94919. */
  94920. trigger: number;
  94921. /**
  94922. * Internal only - manager for action
  94923. * @hidden
  94924. */
  94925. _actionManager: ActionManager;
  94926. private _nextActiveAction;
  94927. private _child;
  94928. private _condition?;
  94929. private _triggerParameter;
  94930. /**
  94931. * An event triggered prior to action being executed.
  94932. */
  94933. onBeforeExecuteObservable: Observable<Action>;
  94934. /**
  94935. * Creates a new Action
  94936. * @param triggerOptions the trigger, with or without parameters, for the action
  94937. * @param condition an optional determinant of action
  94938. */
  94939. constructor(
  94940. /** the trigger, with or without parameters, for the action */
  94941. triggerOptions: any, condition?: Condition);
  94942. /**
  94943. * Internal only
  94944. * @hidden
  94945. */
  94946. _prepare(): void;
  94947. /**
  94948. * Gets the trigger parameter
  94949. * @returns the trigger parameter
  94950. */
  94951. getTriggerParameter(): any;
  94952. /**
  94953. * Sets the trigger parameter
  94954. * @param value defines the new trigger parameter
  94955. */
  94956. setTriggerParameter(value: any): void;
  94957. /**
  94958. * Internal only - executes current action event
  94959. * @hidden
  94960. */
  94961. _executeCurrent(evt?: ActionEvent): void;
  94962. /**
  94963. * Execute placeholder for child classes
  94964. * @param evt optional action event
  94965. */
  94966. execute(evt?: ActionEvent): void;
  94967. /**
  94968. * Skips to next active action
  94969. */
  94970. skipToNextActiveAction(): void;
  94971. /**
  94972. * Adds action to chain of actions, may be a DoNothingAction
  94973. * @param action defines the next action to execute
  94974. * @returns The action passed in
  94975. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94976. */
  94977. then(action: Action): Action;
  94978. /**
  94979. * Internal only
  94980. * @hidden
  94981. */
  94982. _getProperty(propertyPath: string): string;
  94983. /**
  94984. * Internal only
  94985. * @hidden
  94986. */
  94987. _getEffectiveTarget(target: any, propertyPath: string): any;
  94988. /**
  94989. * Serialize placeholder for child classes
  94990. * @param parent of child
  94991. * @returns the serialized object
  94992. */
  94993. serialize(parent: any): any;
  94994. /**
  94995. * Internal only called by serialize
  94996. * @hidden
  94997. */
  94998. protected _serialize(serializedAction: any, parent?: any): any;
  94999. /**
  95000. * Internal only
  95001. * @hidden
  95002. */
  95003. static _SerializeValueAsString: (value: any) => string;
  95004. /**
  95005. * Internal only
  95006. * @hidden
  95007. */
  95008. static _GetTargetProperty: (target: Scene | Node) => {
  95009. name: string;
  95010. targetType: string;
  95011. value: string;
  95012. };
  95013. }
  95014. }
  95015. declare module BABYLON {
  95016. /**
  95017. * A Condition applied to an Action
  95018. */
  95019. export class Condition {
  95020. /**
  95021. * Internal only - manager for action
  95022. * @hidden
  95023. */
  95024. _actionManager: ActionManager;
  95025. /**
  95026. * Internal only
  95027. * @hidden
  95028. */
  95029. _evaluationId: number;
  95030. /**
  95031. * Internal only
  95032. * @hidden
  95033. */
  95034. _currentResult: boolean;
  95035. /**
  95036. * Creates a new Condition
  95037. * @param actionManager the manager of the action the condition is applied to
  95038. */
  95039. constructor(actionManager: ActionManager);
  95040. /**
  95041. * Check if the current condition is valid
  95042. * @returns a boolean
  95043. */
  95044. isValid(): boolean;
  95045. /**
  95046. * Internal only
  95047. * @hidden
  95048. */
  95049. _getProperty(propertyPath: string): string;
  95050. /**
  95051. * Internal only
  95052. * @hidden
  95053. */
  95054. _getEffectiveTarget(target: any, propertyPath: string): any;
  95055. /**
  95056. * Serialize placeholder for child classes
  95057. * @returns the serialized object
  95058. */
  95059. serialize(): any;
  95060. /**
  95061. * Internal only
  95062. * @hidden
  95063. */
  95064. protected _serialize(serializedCondition: any): any;
  95065. }
  95066. /**
  95067. * Defines specific conditional operators as extensions of Condition
  95068. */
  95069. export class ValueCondition extends Condition {
  95070. /** path to specify the property of the target the conditional operator uses */
  95071. propertyPath: string;
  95072. /** the value compared by the conditional operator against the current value of the property */
  95073. value: any;
  95074. /** the conditional operator, default ValueCondition.IsEqual */
  95075. operator: number;
  95076. /**
  95077. * Internal only
  95078. * @hidden
  95079. */
  95080. private static _IsEqual;
  95081. /**
  95082. * Internal only
  95083. * @hidden
  95084. */
  95085. private static _IsDifferent;
  95086. /**
  95087. * Internal only
  95088. * @hidden
  95089. */
  95090. private static _IsGreater;
  95091. /**
  95092. * Internal only
  95093. * @hidden
  95094. */
  95095. private static _IsLesser;
  95096. /**
  95097. * returns the number for IsEqual
  95098. */
  95099. static get IsEqual(): number;
  95100. /**
  95101. * Returns the number for IsDifferent
  95102. */
  95103. static get IsDifferent(): number;
  95104. /**
  95105. * Returns the number for IsGreater
  95106. */
  95107. static get IsGreater(): number;
  95108. /**
  95109. * Returns the number for IsLesser
  95110. */
  95111. static get IsLesser(): number;
  95112. /**
  95113. * Internal only The action manager for the condition
  95114. * @hidden
  95115. */
  95116. _actionManager: ActionManager;
  95117. /**
  95118. * Internal only
  95119. * @hidden
  95120. */
  95121. private _target;
  95122. /**
  95123. * Internal only
  95124. * @hidden
  95125. */
  95126. private _effectiveTarget;
  95127. /**
  95128. * Internal only
  95129. * @hidden
  95130. */
  95131. private _property;
  95132. /**
  95133. * Creates a new ValueCondition
  95134. * @param actionManager manager for the action the condition applies to
  95135. * @param target for the action
  95136. * @param propertyPath path to specify the property of the target the conditional operator uses
  95137. * @param value the value compared by the conditional operator against the current value of the property
  95138. * @param operator the conditional operator, default ValueCondition.IsEqual
  95139. */
  95140. constructor(actionManager: ActionManager, target: any,
  95141. /** path to specify the property of the target the conditional operator uses */
  95142. propertyPath: string,
  95143. /** the value compared by the conditional operator against the current value of the property */
  95144. value: any,
  95145. /** the conditional operator, default ValueCondition.IsEqual */
  95146. operator?: number);
  95147. /**
  95148. * Compares the given value with the property value for the specified conditional operator
  95149. * @returns the result of the comparison
  95150. */
  95151. isValid(): boolean;
  95152. /**
  95153. * Serialize the ValueCondition into a JSON compatible object
  95154. * @returns serialization object
  95155. */
  95156. serialize(): any;
  95157. /**
  95158. * Gets the name of the conditional operator for the ValueCondition
  95159. * @param operator the conditional operator
  95160. * @returns the name
  95161. */
  95162. static GetOperatorName(operator: number): string;
  95163. }
  95164. /**
  95165. * Defines a predicate condition as an extension of Condition
  95166. */
  95167. export class PredicateCondition extends Condition {
  95168. /** defines the predicate function used to validate the condition */
  95169. predicate: () => boolean;
  95170. /**
  95171. * Internal only - manager for action
  95172. * @hidden
  95173. */
  95174. _actionManager: ActionManager;
  95175. /**
  95176. * Creates a new PredicateCondition
  95177. * @param actionManager manager for the action the condition applies to
  95178. * @param predicate defines the predicate function used to validate the condition
  95179. */
  95180. constructor(actionManager: ActionManager,
  95181. /** defines the predicate function used to validate the condition */
  95182. predicate: () => boolean);
  95183. /**
  95184. * @returns the validity of the predicate condition
  95185. */
  95186. isValid(): boolean;
  95187. }
  95188. /**
  95189. * Defines a state condition as an extension of Condition
  95190. */
  95191. export class StateCondition extends Condition {
  95192. /** Value to compare with target state */
  95193. value: string;
  95194. /**
  95195. * Internal only - manager for action
  95196. * @hidden
  95197. */
  95198. _actionManager: ActionManager;
  95199. /**
  95200. * Internal only
  95201. * @hidden
  95202. */
  95203. private _target;
  95204. /**
  95205. * Creates a new StateCondition
  95206. * @param actionManager manager for the action the condition applies to
  95207. * @param target of the condition
  95208. * @param value to compare with target state
  95209. */
  95210. constructor(actionManager: ActionManager, target: any,
  95211. /** Value to compare with target state */
  95212. value: string);
  95213. /**
  95214. * Gets a boolean indicating if the current condition is met
  95215. * @returns the validity of the state
  95216. */
  95217. isValid(): boolean;
  95218. /**
  95219. * Serialize the StateCondition into a JSON compatible object
  95220. * @returns serialization object
  95221. */
  95222. serialize(): any;
  95223. }
  95224. }
  95225. declare module BABYLON {
  95226. /**
  95227. * This defines an action responsible to toggle a boolean once triggered.
  95228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95229. */
  95230. export class SwitchBooleanAction extends Action {
  95231. /**
  95232. * The path to the boolean property in the target object
  95233. */
  95234. propertyPath: string;
  95235. private _target;
  95236. private _effectiveTarget;
  95237. private _property;
  95238. /**
  95239. * Instantiate the action
  95240. * @param triggerOptions defines the trigger options
  95241. * @param target defines the object containing the boolean
  95242. * @param propertyPath defines the path to the boolean property in the target object
  95243. * @param condition defines the trigger related conditions
  95244. */
  95245. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  95246. /** @hidden */
  95247. _prepare(): void;
  95248. /**
  95249. * Execute the action toggle the boolean value.
  95250. */
  95251. execute(): void;
  95252. /**
  95253. * Serializes the actions and its related information.
  95254. * @param parent defines the object to serialize in
  95255. * @returns the serialized object
  95256. */
  95257. serialize(parent: any): any;
  95258. }
  95259. /**
  95260. * This defines an action responsible to set a the state field of the target
  95261. * to a desired value once triggered.
  95262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95263. */
  95264. export class SetStateAction extends Action {
  95265. /**
  95266. * The value to store in the state field.
  95267. */
  95268. value: string;
  95269. private _target;
  95270. /**
  95271. * Instantiate the action
  95272. * @param triggerOptions defines the trigger options
  95273. * @param target defines the object containing the state property
  95274. * @param value defines the value to store in the state field
  95275. * @param condition defines the trigger related conditions
  95276. */
  95277. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  95278. /**
  95279. * Execute the action and store the value on the target state property.
  95280. */
  95281. execute(): void;
  95282. /**
  95283. * Serializes the actions and its related information.
  95284. * @param parent defines the object to serialize in
  95285. * @returns the serialized object
  95286. */
  95287. serialize(parent: any): any;
  95288. }
  95289. /**
  95290. * This defines an action responsible to set a property of the target
  95291. * to a desired value once triggered.
  95292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95293. */
  95294. export class SetValueAction extends Action {
  95295. /**
  95296. * The path of the property to set in the target.
  95297. */
  95298. propertyPath: string;
  95299. /**
  95300. * The value to set in the property
  95301. */
  95302. value: any;
  95303. private _target;
  95304. private _effectiveTarget;
  95305. private _property;
  95306. /**
  95307. * Instantiate the action
  95308. * @param triggerOptions defines the trigger options
  95309. * @param target defines the object containing the property
  95310. * @param propertyPath defines the path of the property to set in the target
  95311. * @param value defines the value to set in the property
  95312. * @param condition defines the trigger related conditions
  95313. */
  95314. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95315. /** @hidden */
  95316. _prepare(): void;
  95317. /**
  95318. * Execute the action and set the targetted property to the desired value.
  95319. */
  95320. execute(): void;
  95321. /**
  95322. * Serializes the actions and its related information.
  95323. * @param parent defines the object to serialize in
  95324. * @returns the serialized object
  95325. */
  95326. serialize(parent: any): any;
  95327. }
  95328. /**
  95329. * This defines an action responsible to increment the target value
  95330. * to a desired value once triggered.
  95331. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95332. */
  95333. export class IncrementValueAction extends Action {
  95334. /**
  95335. * The path of the property to increment in the target.
  95336. */
  95337. propertyPath: string;
  95338. /**
  95339. * The value we should increment the property by.
  95340. */
  95341. value: any;
  95342. private _target;
  95343. private _effectiveTarget;
  95344. private _property;
  95345. /**
  95346. * Instantiate the action
  95347. * @param triggerOptions defines the trigger options
  95348. * @param target defines the object containing the property
  95349. * @param propertyPath defines the path of the property to increment in the target
  95350. * @param value defines the value value we should increment the property by
  95351. * @param condition defines the trigger related conditions
  95352. */
  95353. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95354. /** @hidden */
  95355. _prepare(): void;
  95356. /**
  95357. * Execute the action and increment the target of the value amount.
  95358. */
  95359. execute(): void;
  95360. /**
  95361. * Serializes the actions and its related information.
  95362. * @param parent defines the object to serialize in
  95363. * @returns the serialized object
  95364. */
  95365. serialize(parent: any): any;
  95366. }
  95367. /**
  95368. * This defines an action responsible to start an animation once triggered.
  95369. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95370. */
  95371. export class PlayAnimationAction extends Action {
  95372. /**
  95373. * Where the animation should start (animation frame)
  95374. */
  95375. from: number;
  95376. /**
  95377. * Where the animation should stop (animation frame)
  95378. */
  95379. to: number;
  95380. /**
  95381. * Define if the animation should loop or stop after the first play.
  95382. */
  95383. loop?: boolean;
  95384. private _target;
  95385. /**
  95386. * Instantiate the action
  95387. * @param triggerOptions defines the trigger options
  95388. * @param target defines the target animation or animation name
  95389. * @param from defines from where the animation should start (animation frame)
  95390. * @param end defines where the animation should stop (animation frame)
  95391. * @param loop defines if the animation should loop or stop after the first play
  95392. * @param condition defines the trigger related conditions
  95393. */
  95394. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  95395. /** @hidden */
  95396. _prepare(): void;
  95397. /**
  95398. * Execute the action and play the animation.
  95399. */
  95400. execute(): void;
  95401. /**
  95402. * Serializes the actions and its related information.
  95403. * @param parent defines the object to serialize in
  95404. * @returns the serialized object
  95405. */
  95406. serialize(parent: any): any;
  95407. }
  95408. /**
  95409. * This defines an action responsible to stop an animation once triggered.
  95410. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95411. */
  95412. export class StopAnimationAction extends Action {
  95413. private _target;
  95414. /**
  95415. * Instantiate the action
  95416. * @param triggerOptions defines the trigger options
  95417. * @param target defines the target animation or animation name
  95418. * @param condition defines the trigger related conditions
  95419. */
  95420. constructor(triggerOptions: any, target: any, condition?: Condition);
  95421. /** @hidden */
  95422. _prepare(): void;
  95423. /**
  95424. * Execute the action and stop the animation.
  95425. */
  95426. execute(): void;
  95427. /**
  95428. * Serializes the actions and its related information.
  95429. * @param parent defines the object to serialize in
  95430. * @returns the serialized object
  95431. */
  95432. serialize(parent: any): any;
  95433. }
  95434. /**
  95435. * This defines an action responsible that does nothing once triggered.
  95436. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95437. */
  95438. export class DoNothingAction extends Action {
  95439. /**
  95440. * Instantiate the action
  95441. * @param triggerOptions defines the trigger options
  95442. * @param condition defines the trigger related conditions
  95443. */
  95444. constructor(triggerOptions?: any, condition?: Condition);
  95445. /**
  95446. * Execute the action and do nothing.
  95447. */
  95448. execute(): void;
  95449. /**
  95450. * Serializes the actions and its related information.
  95451. * @param parent defines the object to serialize in
  95452. * @returns the serialized object
  95453. */
  95454. serialize(parent: any): any;
  95455. }
  95456. /**
  95457. * This defines an action responsible to trigger several actions once triggered.
  95458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95459. */
  95460. export class CombineAction extends Action {
  95461. /**
  95462. * The list of aggregated animations to run.
  95463. */
  95464. children: Action[];
  95465. /**
  95466. * Instantiate the action
  95467. * @param triggerOptions defines the trigger options
  95468. * @param children defines the list of aggregated animations to run
  95469. * @param condition defines the trigger related conditions
  95470. */
  95471. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  95472. /** @hidden */
  95473. _prepare(): void;
  95474. /**
  95475. * Execute the action and executes all the aggregated actions.
  95476. */
  95477. execute(evt: ActionEvent): void;
  95478. /**
  95479. * Serializes the actions and its related information.
  95480. * @param parent defines the object to serialize in
  95481. * @returns the serialized object
  95482. */
  95483. serialize(parent: any): any;
  95484. }
  95485. /**
  95486. * This defines an action responsible to run code (external event) once triggered.
  95487. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95488. */
  95489. export class ExecuteCodeAction extends Action {
  95490. /**
  95491. * The callback function to run.
  95492. */
  95493. func: (evt: ActionEvent) => void;
  95494. /**
  95495. * Instantiate the action
  95496. * @param triggerOptions defines the trigger options
  95497. * @param func defines the callback function to run
  95498. * @param condition defines the trigger related conditions
  95499. */
  95500. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  95501. /**
  95502. * Execute the action and run the attached code.
  95503. */
  95504. execute(evt: ActionEvent): void;
  95505. }
  95506. /**
  95507. * This defines an action responsible to set the parent property of the target once triggered.
  95508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95509. */
  95510. export class SetParentAction extends Action {
  95511. private _parent;
  95512. private _target;
  95513. /**
  95514. * Instantiate the action
  95515. * @param triggerOptions defines the trigger options
  95516. * @param target defines the target containing the parent property
  95517. * @param parent defines from where the animation should start (animation frame)
  95518. * @param condition defines the trigger related conditions
  95519. */
  95520. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  95521. /** @hidden */
  95522. _prepare(): void;
  95523. /**
  95524. * Execute the action and set the parent property.
  95525. */
  95526. execute(): void;
  95527. /**
  95528. * Serializes the actions and its related information.
  95529. * @param parent defines the object to serialize in
  95530. * @returns the serialized object
  95531. */
  95532. serialize(parent: any): any;
  95533. }
  95534. }
  95535. declare module BABYLON {
  95536. /**
  95537. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  95538. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  95539. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95540. */
  95541. export class ActionManager extends AbstractActionManager {
  95542. /**
  95543. * Nothing
  95544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95545. */
  95546. static readonly NothingTrigger: number;
  95547. /**
  95548. * On pick
  95549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95550. */
  95551. static readonly OnPickTrigger: number;
  95552. /**
  95553. * On left pick
  95554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95555. */
  95556. static readonly OnLeftPickTrigger: number;
  95557. /**
  95558. * On right pick
  95559. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95560. */
  95561. static readonly OnRightPickTrigger: number;
  95562. /**
  95563. * On center pick
  95564. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95565. */
  95566. static readonly OnCenterPickTrigger: number;
  95567. /**
  95568. * On pick down
  95569. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95570. */
  95571. static readonly OnPickDownTrigger: number;
  95572. /**
  95573. * On double pick
  95574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95575. */
  95576. static readonly OnDoublePickTrigger: number;
  95577. /**
  95578. * On pick up
  95579. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95580. */
  95581. static readonly OnPickUpTrigger: number;
  95582. /**
  95583. * On pick out.
  95584. * This trigger will only be raised if you also declared a OnPickDown
  95585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95586. */
  95587. static readonly OnPickOutTrigger: number;
  95588. /**
  95589. * On long press
  95590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95591. */
  95592. static readonly OnLongPressTrigger: number;
  95593. /**
  95594. * On pointer over
  95595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95596. */
  95597. static readonly OnPointerOverTrigger: number;
  95598. /**
  95599. * On pointer out
  95600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95601. */
  95602. static readonly OnPointerOutTrigger: number;
  95603. /**
  95604. * On every frame
  95605. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95606. */
  95607. static readonly OnEveryFrameTrigger: number;
  95608. /**
  95609. * On intersection enter
  95610. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95611. */
  95612. static readonly OnIntersectionEnterTrigger: number;
  95613. /**
  95614. * On intersection exit
  95615. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95616. */
  95617. static readonly OnIntersectionExitTrigger: number;
  95618. /**
  95619. * On key down
  95620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95621. */
  95622. static readonly OnKeyDownTrigger: number;
  95623. /**
  95624. * On key up
  95625. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95626. */
  95627. static readonly OnKeyUpTrigger: number;
  95628. private _scene;
  95629. /**
  95630. * Creates a new action manager
  95631. * @param scene defines the hosting scene
  95632. */
  95633. constructor(scene: Scene);
  95634. /**
  95635. * Releases all associated resources
  95636. */
  95637. dispose(): void;
  95638. /**
  95639. * Gets hosting scene
  95640. * @returns the hosting scene
  95641. */
  95642. getScene(): Scene;
  95643. /**
  95644. * Does this action manager handles actions of any of the given triggers
  95645. * @param triggers defines the triggers to be tested
  95646. * @return a boolean indicating whether one (or more) of the triggers is handled
  95647. */
  95648. hasSpecificTriggers(triggers: number[]): boolean;
  95649. /**
  95650. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95651. * speed.
  95652. * @param triggerA defines the trigger to be tested
  95653. * @param triggerB defines the trigger to be tested
  95654. * @return a boolean indicating whether one (or more) of the triggers is handled
  95655. */
  95656. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95657. /**
  95658. * Does this action manager handles actions of a given trigger
  95659. * @param trigger defines the trigger to be tested
  95660. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95661. * @return whether the trigger is handled
  95662. */
  95663. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95664. /**
  95665. * Does this action manager has pointer triggers
  95666. */
  95667. get hasPointerTriggers(): boolean;
  95668. /**
  95669. * Does this action manager has pick triggers
  95670. */
  95671. get hasPickTriggers(): boolean;
  95672. /**
  95673. * Registers an action to this action manager
  95674. * @param action defines the action to be registered
  95675. * @return the action amended (prepared) after registration
  95676. */
  95677. registerAction(action: IAction): Nullable<IAction>;
  95678. /**
  95679. * Unregisters an action to this action manager
  95680. * @param action defines the action to be unregistered
  95681. * @return a boolean indicating whether the action has been unregistered
  95682. */
  95683. unregisterAction(action: IAction): Boolean;
  95684. /**
  95685. * Process a specific trigger
  95686. * @param trigger defines the trigger to process
  95687. * @param evt defines the event details to be processed
  95688. */
  95689. processTrigger(trigger: number, evt?: IActionEvent): void;
  95690. /** @hidden */
  95691. _getEffectiveTarget(target: any, propertyPath: string): any;
  95692. /** @hidden */
  95693. _getProperty(propertyPath: string): string;
  95694. /**
  95695. * Serialize this manager to a JSON object
  95696. * @param name defines the property name to store this manager
  95697. * @returns a JSON representation of this manager
  95698. */
  95699. serialize(name: string): any;
  95700. /**
  95701. * Creates a new ActionManager from a JSON data
  95702. * @param parsedActions defines the JSON data to read from
  95703. * @param object defines the hosting mesh
  95704. * @param scene defines the hosting scene
  95705. */
  95706. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  95707. /**
  95708. * Get a trigger name by index
  95709. * @param trigger defines the trigger index
  95710. * @returns a trigger name
  95711. */
  95712. static GetTriggerName(trigger: number): string;
  95713. }
  95714. }
  95715. declare module BABYLON {
  95716. /**
  95717. * Class representing a ray with position and direction
  95718. */
  95719. export class Ray {
  95720. /** origin point */
  95721. origin: Vector3;
  95722. /** direction */
  95723. direction: Vector3;
  95724. /** length of the ray */
  95725. length: number;
  95726. private static readonly _TmpVector3;
  95727. private _tmpRay;
  95728. /**
  95729. * Creates a new ray
  95730. * @param origin origin point
  95731. * @param direction direction
  95732. * @param length length of the ray
  95733. */
  95734. constructor(
  95735. /** origin point */
  95736. origin: Vector3,
  95737. /** direction */
  95738. direction: Vector3,
  95739. /** length of the ray */
  95740. length?: number);
  95741. /**
  95742. * Checks if the ray intersects a box
  95743. * This does not account for the ray lenght by design to improve perfs.
  95744. * @param minimum bound of the box
  95745. * @param maximum bound of the box
  95746. * @param intersectionTreshold extra extend to be added to the box in all direction
  95747. * @returns if the box was hit
  95748. */
  95749. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  95750. /**
  95751. * Checks if the ray intersects a box
  95752. * This does not account for the ray lenght by design to improve perfs.
  95753. * @param box the bounding box to check
  95754. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  95755. * @returns if the box was hit
  95756. */
  95757. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  95758. /**
  95759. * If the ray hits a sphere
  95760. * @param sphere the bounding sphere to check
  95761. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  95762. * @returns true if it hits the sphere
  95763. */
  95764. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  95765. /**
  95766. * If the ray hits a triange
  95767. * @param vertex0 triangle vertex
  95768. * @param vertex1 triangle vertex
  95769. * @param vertex2 triangle vertex
  95770. * @returns intersection information if hit
  95771. */
  95772. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  95773. /**
  95774. * Checks if ray intersects a plane
  95775. * @param plane the plane to check
  95776. * @returns the distance away it was hit
  95777. */
  95778. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  95779. /**
  95780. * Calculate the intercept of a ray on a given axis
  95781. * @param axis to check 'x' | 'y' | 'z'
  95782. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  95783. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  95784. */
  95785. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  95786. /**
  95787. * Checks if ray intersects a mesh
  95788. * @param mesh the mesh to check
  95789. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95790. * @returns picking info of the intersecton
  95791. */
  95792. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  95793. /**
  95794. * Checks if ray intersects a mesh
  95795. * @param meshes the meshes to check
  95796. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95797. * @param results array to store result in
  95798. * @returns Array of picking infos
  95799. */
  95800. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  95801. private _comparePickingInfo;
  95802. private static smallnum;
  95803. private static rayl;
  95804. /**
  95805. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  95806. * @param sega the first point of the segment to test the intersection against
  95807. * @param segb the second point of the segment to test the intersection against
  95808. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  95809. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  95810. */
  95811. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  95812. /**
  95813. * Update the ray from viewport position
  95814. * @param x position
  95815. * @param y y position
  95816. * @param viewportWidth viewport width
  95817. * @param viewportHeight viewport height
  95818. * @param world world matrix
  95819. * @param view view matrix
  95820. * @param projection projection matrix
  95821. * @returns this ray updated
  95822. */
  95823. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95824. /**
  95825. * Creates a ray with origin and direction of 0,0,0
  95826. * @returns the new ray
  95827. */
  95828. static Zero(): Ray;
  95829. /**
  95830. * Creates a new ray from screen space and viewport
  95831. * @param x position
  95832. * @param y y position
  95833. * @param viewportWidth viewport width
  95834. * @param viewportHeight viewport height
  95835. * @param world world matrix
  95836. * @param view view matrix
  95837. * @param projection projection matrix
  95838. * @returns new ray
  95839. */
  95840. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95841. /**
  95842. * 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
  95843. * transformed to the given world matrix.
  95844. * @param origin The origin point
  95845. * @param end The end point
  95846. * @param world a matrix to transform the ray to. Default is the identity matrix.
  95847. * @returns the new ray
  95848. */
  95849. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  95850. /**
  95851. * Transforms a ray by a matrix
  95852. * @param ray ray to transform
  95853. * @param matrix matrix to apply
  95854. * @returns the resulting new ray
  95855. */
  95856. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  95857. /**
  95858. * Transforms a ray by a matrix
  95859. * @param ray ray to transform
  95860. * @param matrix matrix to apply
  95861. * @param result ray to store result in
  95862. */
  95863. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  95864. /**
  95865. * Unproject a ray from screen space to object space
  95866. * @param sourceX defines the screen space x coordinate to use
  95867. * @param sourceY defines the screen space y coordinate to use
  95868. * @param viewportWidth defines the current width of the viewport
  95869. * @param viewportHeight defines the current height of the viewport
  95870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  95871. * @param view defines the view matrix to use
  95872. * @param projection defines the projection matrix to use
  95873. */
  95874. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  95875. }
  95876. /**
  95877. * Type used to define predicate used to select faces when a mesh intersection is detected
  95878. */
  95879. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  95880. interface Scene {
  95881. /** @hidden */
  95882. _tempPickingRay: Nullable<Ray>;
  95883. /** @hidden */
  95884. _cachedRayForTransform: Ray;
  95885. /** @hidden */
  95886. _pickWithRayInverseMatrix: Matrix;
  95887. /** @hidden */
  95888. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  95889. /** @hidden */
  95890. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95891. /** @hidden */
  95892. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  95893. }
  95894. }
  95895. declare module BABYLON {
  95896. /**
  95897. * Groups all the scene component constants in one place to ease maintenance.
  95898. * @hidden
  95899. */
  95900. export class SceneComponentConstants {
  95901. static readonly NAME_EFFECTLAYER: string;
  95902. static readonly NAME_LAYER: string;
  95903. static readonly NAME_LENSFLARESYSTEM: string;
  95904. static readonly NAME_BOUNDINGBOXRENDERER: string;
  95905. static readonly NAME_PARTICLESYSTEM: string;
  95906. static readonly NAME_GAMEPAD: string;
  95907. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  95908. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  95909. static readonly NAME_PREPASSRENDERER: string;
  95910. static readonly NAME_DEPTHRENDERER: string;
  95911. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  95912. static readonly NAME_SPRITE: string;
  95913. static readonly NAME_SUBSURFACE: string;
  95914. static readonly NAME_OUTLINERENDERER: string;
  95915. static readonly NAME_PROCEDURALTEXTURE: string;
  95916. static readonly NAME_SHADOWGENERATOR: string;
  95917. static readonly NAME_OCTREE: string;
  95918. static readonly NAME_PHYSICSENGINE: string;
  95919. static readonly NAME_AUDIO: string;
  95920. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  95921. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95922. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  95923. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95924. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  95925. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  95926. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  95927. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  95928. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  95929. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  95930. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  95931. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  95932. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  95933. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  95934. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  95935. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  95936. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  95937. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  95938. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  95939. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  95940. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  95941. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  95942. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  95943. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  95944. static readonly STEP_AFTERRENDER_AUDIO: number;
  95945. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  95946. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  95947. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  95948. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  95949. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  95950. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  95951. static readonly STEP_POINTERMOVE_SPRITE: number;
  95952. static readonly STEP_POINTERDOWN_SPRITE: number;
  95953. static readonly STEP_POINTERUP_SPRITE: number;
  95954. }
  95955. /**
  95956. * This represents a scene component.
  95957. *
  95958. * This is used to decouple the dependency the scene is having on the different workloads like
  95959. * layers, post processes...
  95960. */
  95961. export interface ISceneComponent {
  95962. /**
  95963. * The name of the component. Each component must have a unique name.
  95964. */
  95965. name: string;
  95966. /**
  95967. * The scene the component belongs to.
  95968. */
  95969. scene: Scene;
  95970. /**
  95971. * Register the component to one instance of a scene.
  95972. */
  95973. register(): void;
  95974. /**
  95975. * Rebuilds the elements related to this component in case of
  95976. * context lost for instance.
  95977. */
  95978. rebuild(): void;
  95979. /**
  95980. * Disposes the component and the associated ressources.
  95981. */
  95982. dispose(): void;
  95983. }
  95984. /**
  95985. * This represents a SERIALIZABLE scene component.
  95986. *
  95987. * This extends Scene Component to add Serialization methods on top.
  95988. */
  95989. export interface ISceneSerializableComponent extends ISceneComponent {
  95990. /**
  95991. * Adds all the elements from the container to the scene
  95992. * @param container the container holding the elements
  95993. */
  95994. addFromContainer(container: AbstractScene): void;
  95995. /**
  95996. * Removes all the elements in the container from the scene
  95997. * @param container contains the elements to remove
  95998. * @param dispose if the removed element should be disposed (default: false)
  95999. */
  96000. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96001. /**
  96002. * Serializes the component data to the specified json object
  96003. * @param serializationObject The object to serialize to
  96004. */
  96005. serialize(serializationObject: any): void;
  96006. }
  96007. /**
  96008. * Strong typing of a Mesh related stage step action
  96009. */
  96010. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  96011. /**
  96012. * Strong typing of a Evaluate Sub Mesh related stage step action
  96013. */
  96014. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  96015. /**
  96016. * Strong typing of a pre active Mesh related stage step action
  96017. */
  96018. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  96019. /**
  96020. * Strong typing of a Camera related stage step action
  96021. */
  96022. export type CameraStageAction = (camera: Camera) => void;
  96023. /**
  96024. * Strong typing of a Camera Frame buffer related stage step action
  96025. */
  96026. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  96027. /**
  96028. * Strong typing of a Render Target related stage step action
  96029. */
  96030. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  96031. /**
  96032. * Strong typing of a RenderingGroup related stage step action
  96033. */
  96034. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  96035. /**
  96036. * Strong typing of a Mesh Render related stage step action
  96037. */
  96038. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  96039. /**
  96040. * Strong typing of a simple stage step action
  96041. */
  96042. export type SimpleStageAction = () => void;
  96043. /**
  96044. * Strong typing of a render target action.
  96045. */
  96046. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  96047. /**
  96048. * Strong typing of a pointer move action.
  96049. */
  96050. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  96051. /**
  96052. * Strong typing of a pointer up/down action.
  96053. */
  96054. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  96055. /**
  96056. * Representation of a stage in the scene (Basically a list of ordered steps)
  96057. * @hidden
  96058. */
  96059. export class Stage<T extends Function> extends Array<{
  96060. index: number;
  96061. component: ISceneComponent;
  96062. action: T;
  96063. }> {
  96064. /**
  96065. * Hide ctor from the rest of the world.
  96066. * @param items The items to add.
  96067. */
  96068. private constructor();
  96069. /**
  96070. * Creates a new Stage.
  96071. * @returns A new instance of a Stage
  96072. */
  96073. static Create<T extends Function>(): Stage<T>;
  96074. /**
  96075. * Registers a step in an ordered way in the targeted stage.
  96076. * @param index Defines the position to register the step in
  96077. * @param component Defines the component attached to the step
  96078. * @param action Defines the action to launch during the step
  96079. */
  96080. registerStep(index: number, component: ISceneComponent, action: T): void;
  96081. /**
  96082. * Clears all the steps from the stage.
  96083. */
  96084. clear(): void;
  96085. }
  96086. }
  96087. declare module BABYLON {
  96088. interface Scene {
  96089. /** @hidden */
  96090. _pointerOverSprite: Nullable<Sprite>;
  96091. /** @hidden */
  96092. _pickedDownSprite: Nullable<Sprite>;
  96093. /** @hidden */
  96094. _tempSpritePickingRay: Nullable<Ray>;
  96095. /**
  96096. * All of the sprite managers added to this scene
  96097. * @see https://doc.babylonjs.com/babylon101/sprites
  96098. */
  96099. spriteManagers: Array<ISpriteManager>;
  96100. /**
  96101. * An event triggered when sprites rendering is about to start
  96102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96103. */
  96104. onBeforeSpritesRenderingObservable: Observable<Scene>;
  96105. /**
  96106. * An event triggered when sprites rendering is done
  96107. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96108. */
  96109. onAfterSpritesRenderingObservable: Observable<Scene>;
  96110. /** @hidden */
  96111. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96112. /** Launch a ray to try to pick a sprite in the scene
  96113. * @param x position on screen
  96114. * @param y position on screen
  96115. * @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
  96116. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96117. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96118. * @returns a PickingInfo
  96119. */
  96120. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96121. /** Use the given ray to pick a sprite in the scene
  96122. * @param ray The ray (in world space) to use to pick meshes
  96123. * @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
  96124. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96126. * @returns a PickingInfo
  96127. */
  96128. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96129. /** @hidden */
  96130. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96131. /** Launch a ray to try to pick sprites in the scene
  96132. * @param x position on screen
  96133. * @param y position on screen
  96134. * @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
  96135. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96136. * @returns a PickingInfo array
  96137. */
  96138. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96139. /** Use the given ray to pick sprites in the scene
  96140. * @param ray The ray (in world space) to use to pick meshes
  96141. * @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
  96142. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96143. * @returns a PickingInfo array
  96144. */
  96145. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96146. /**
  96147. * Force the sprite under the pointer
  96148. * @param sprite defines the sprite to use
  96149. */
  96150. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  96151. /**
  96152. * Gets the sprite under the pointer
  96153. * @returns a Sprite or null if no sprite is under the pointer
  96154. */
  96155. getPointerOverSprite(): Nullable<Sprite>;
  96156. }
  96157. /**
  96158. * Defines the sprite scene component responsible to manage sprites
  96159. * in a given scene.
  96160. */
  96161. export class SpriteSceneComponent implements ISceneComponent {
  96162. /**
  96163. * The component name helpfull to identify the component in the list of scene components.
  96164. */
  96165. readonly name: string;
  96166. /**
  96167. * The scene the component belongs to.
  96168. */
  96169. scene: Scene;
  96170. /** @hidden */
  96171. private _spritePredicate;
  96172. /**
  96173. * Creates a new instance of the component for the given scene
  96174. * @param scene Defines the scene to register the component in
  96175. */
  96176. constructor(scene: Scene);
  96177. /**
  96178. * Registers the component in a given scene
  96179. */
  96180. register(): void;
  96181. /**
  96182. * Rebuilds the elements related to this component in case of
  96183. * context lost for instance.
  96184. */
  96185. rebuild(): void;
  96186. /**
  96187. * Disposes the component and the associated ressources.
  96188. */
  96189. dispose(): void;
  96190. private _pickSpriteButKeepRay;
  96191. private _pointerMove;
  96192. private _pointerDown;
  96193. private _pointerUp;
  96194. }
  96195. }
  96196. declare module BABYLON {
  96197. /**
  96198. * Class used to provide helper for timing
  96199. */
  96200. export class TimingTools {
  96201. /**
  96202. * Polyfill for setImmediate
  96203. * @param action defines the action to execute after the current execution block
  96204. */
  96205. static SetImmediate(action: () => void): void;
  96206. }
  96207. }
  96208. declare module BABYLON {
  96209. /**
  96210. * Class used to enable instatition of objects by class name
  96211. */
  96212. export class InstantiationTools {
  96213. /**
  96214. * Use this object to register external classes like custom textures or material
  96215. * to allow the laoders to instantiate them
  96216. */
  96217. static RegisteredExternalClasses: {
  96218. [key: string]: Object;
  96219. };
  96220. /**
  96221. * Tries to instantiate a new object from a given class name
  96222. * @param className defines the class name to instantiate
  96223. * @returns the new object or null if the system was not able to do the instantiation
  96224. */
  96225. static Instantiate(className: string): any;
  96226. }
  96227. }
  96228. declare module BABYLON {
  96229. /**
  96230. * Class used to host copy specific utilities
  96231. */
  96232. export class CopyTools {
  96233. /**
  96234. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  96235. * @param texture defines the texture to read pixels from
  96236. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96237. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96238. * @returns The base64 encoded string or null
  96239. */
  96240. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  96241. }
  96242. }
  96243. declare module BABYLON {
  96244. /**
  96245. * Define options used to create a depth texture
  96246. */
  96247. export class DepthTextureCreationOptions {
  96248. /** Specifies whether or not a stencil should be allocated in the texture */
  96249. generateStencil?: boolean;
  96250. /** Specifies whether or not bilinear filtering is enable on the texture */
  96251. bilinearFiltering?: boolean;
  96252. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  96253. comparisonFunction?: number;
  96254. /** Specifies if the created texture is a cube texture */
  96255. isCube?: boolean;
  96256. /** Specifies the sample count of the depth/stencil texture texture */
  96257. samples?: number;
  96258. }
  96259. }
  96260. declare module BABYLON {
  96261. interface ThinEngine {
  96262. /**
  96263. * Creates a depth stencil cube texture.
  96264. * This is only available in WebGL 2.
  96265. * @param size The size of face edge in the cube texture.
  96266. * @param options The options defining the cube texture.
  96267. * @returns The cube texture
  96268. */
  96269. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  96270. /**
  96271. * Creates a cube texture
  96272. * @param rootUrl defines the url where the files to load is located
  96273. * @param scene defines the current scene
  96274. * @param files defines the list of files to load (1 per face)
  96275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96276. * @param onLoad defines an optional callback raised when the texture is loaded
  96277. * @param onError defines an optional callback raised if there is an issue to load the texture
  96278. * @param format defines the format of the data
  96279. * @param forcedExtension defines the extension to use to pick the right loader
  96280. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96281. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96282. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96283. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  96284. * @param loaderOptions options to be passed to the loader
  96285. * @returns the cube texture as an InternalTexture
  96286. */
  96287. 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;
  96288. /**
  96289. * Creates a cube texture
  96290. * @param rootUrl defines the url where the files to load is located
  96291. * @param scene defines the current scene
  96292. * @param files defines the list of files to load (1 per face)
  96293. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96294. * @param onLoad defines an optional callback raised when the texture is loaded
  96295. * @param onError defines an optional callback raised if there is an issue to load the texture
  96296. * @param format defines the format of the data
  96297. * @param forcedExtension defines the extension to use to pick the right loader
  96298. * @returns the cube texture as an InternalTexture
  96299. */
  96300. 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;
  96301. /**
  96302. * Creates a cube texture
  96303. * @param rootUrl defines the url where the files to load is located
  96304. * @param scene defines the current scene
  96305. * @param files defines the list of files to load (1 per face)
  96306. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96307. * @param onLoad defines an optional callback raised when the texture is loaded
  96308. * @param onError defines an optional callback raised if there is an issue to load the texture
  96309. * @param format defines the format of the data
  96310. * @param forcedExtension defines the extension to use to pick the right loader
  96311. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96312. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96313. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96314. * @returns the cube texture as an InternalTexture
  96315. */
  96316. 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;
  96317. /** @hidden */
  96318. 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;
  96319. /** @hidden */
  96320. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  96321. /** @hidden */
  96322. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  96323. /** @hidden */
  96324. _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;
  96325. /** @hidden */
  96326. _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;
  96327. /**
  96328. * @hidden
  96329. */
  96330. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  96331. }
  96332. }
  96333. declare module BABYLON {
  96334. /**
  96335. * Class for creating a cube texture
  96336. */
  96337. export class CubeTexture extends BaseTexture {
  96338. private _delayedOnLoad;
  96339. /**
  96340. * Observable triggered once the texture has been loaded.
  96341. */
  96342. onLoadObservable: Observable<CubeTexture>;
  96343. /**
  96344. * The url of the texture
  96345. */
  96346. url: string;
  96347. /**
  96348. * Gets or sets the center of the bounding box associated with the cube texture.
  96349. * It must define where the camera used to render the texture was set
  96350. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96351. */
  96352. boundingBoxPosition: Vector3;
  96353. private _boundingBoxSize;
  96354. /**
  96355. * Gets or sets the size of the bounding box associated with the cube texture
  96356. * When defined, the cubemap will switch to local mode
  96357. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96358. * @example https://www.babylonjs-playground.com/#RNASML
  96359. */
  96360. set boundingBoxSize(value: Vector3);
  96361. /**
  96362. * Returns the bounding box size
  96363. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96364. */
  96365. get boundingBoxSize(): Vector3;
  96366. protected _rotationY: number;
  96367. /**
  96368. * Sets texture matrix rotation angle around Y axis in radians.
  96369. */
  96370. set rotationY(value: number);
  96371. /**
  96372. * Gets texture matrix rotation angle around Y axis radians.
  96373. */
  96374. get rotationY(): number;
  96375. /**
  96376. * Are mip maps generated for this texture or not.
  96377. */
  96378. get noMipmap(): boolean;
  96379. private _noMipmap;
  96380. private _files;
  96381. protected _forcedExtension: Nullable<string>;
  96382. private _extensions;
  96383. private _textureMatrix;
  96384. private _format;
  96385. private _createPolynomials;
  96386. private _loaderOptions;
  96387. /**
  96388. * Creates a cube texture from an array of image urls
  96389. * @param files defines an array of image urls
  96390. * @param scene defines the hosting scene
  96391. * @param noMipmap specifies if mip maps are not used
  96392. * @returns a cube texture
  96393. */
  96394. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  96395. /**
  96396. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  96397. * @param url defines the url of the prefiltered texture
  96398. * @param scene defines the scene the texture is attached to
  96399. * @param forcedExtension defines the extension of the file if different from the url
  96400. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96401. * @return the prefiltered texture
  96402. */
  96403. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  96404. /**
  96405. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  96406. * as prefiltered data.
  96407. * @param rootUrl defines the url of the texture or the root name of the six images
  96408. * @param null defines the scene or engine the texture is attached to
  96409. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  96410. * @param noMipmap defines if mipmaps should be created or not
  96411. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  96412. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  96413. * @param onError defines a callback triggered in case of error during load
  96414. * @param format defines the internal format to use for the texture once loaded
  96415. * @param prefiltered defines whether or not the texture is created from prefiltered data
  96416. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  96417. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96418. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96419. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96420. * @param loaderOptions options to be passed to the loader
  96421. * @return the cube texture
  96422. */
  96423. 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);
  96424. /**
  96425. * Get the current class name of the texture useful for serialization or dynamic coding.
  96426. * @returns "CubeTexture"
  96427. */
  96428. getClassName(): string;
  96429. /**
  96430. * Update the url (and optional buffer) of this texture if url was null during construction.
  96431. * @param url the url of the texture
  96432. * @param forcedExtension defines the extension to use
  96433. * @param onLoad callback called when the texture is loaded (defaults to null)
  96434. * @param prefiltered Defines whether the updated texture is prefiltered or not
  96435. */
  96436. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  96437. /**
  96438. * Delays loading of the cube texture
  96439. * @param forcedExtension defines the extension to use
  96440. */
  96441. delayLoad(forcedExtension?: string): void;
  96442. /**
  96443. * Returns the reflection texture matrix
  96444. * @returns the reflection texture matrix
  96445. */
  96446. getReflectionTextureMatrix(): Matrix;
  96447. /**
  96448. * Sets the reflection texture matrix
  96449. * @param value Reflection texture matrix
  96450. */
  96451. setReflectionTextureMatrix(value: Matrix): void;
  96452. /**
  96453. * Parses text to create a cube texture
  96454. * @param parsedTexture define the serialized text to read from
  96455. * @param scene defines the hosting scene
  96456. * @param rootUrl defines the root url of the cube texture
  96457. * @returns a cube texture
  96458. */
  96459. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  96460. /**
  96461. * Makes a clone, or deep copy, of the cube texture
  96462. * @returns a new cube texture
  96463. */
  96464. clone(): CubeTexture;
  96465. }
  96466. }
  96467. declare module BABYLON {
  96468. /**
  96469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96471. * 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;
  96472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96473. */
  96474. export class ColorCurves {
  96475. private _dirty;
  96476. private _tempColor;
  96477. private _globalCurve;
  96478. private _highlightsCurve;
  96479. private _midtonesCurve;
  96480. private _shadowsCurve;
  96481. private _positiveCurve;
  96482. private _negativeCurve;
  96483. private _globalHue;
  96484. private _globalDensity;
  96485. private _globalSaturation;
  96486. private _globalExposure;
  96487. /**
  96488. * Gets the global Hue value.
  96489. * 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).
  96490. */
  96491. get globalHue(): number;
  96492. /**
  96493. * Sets the global Hue value.
  96494. * 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).
  96495. */
  96496. set globalHue(value: number);
  96497. /**
  96498. * Gets the global Density value.
  96499. * 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.
  96500. * Values less than zero provide a filter of opposite hue.
  96501. */
  96502. get globalDensity(): number;
  96503. /**
  96504. * Sets the global Density value.
  96505. * 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.
  96506. * Values less than zero provide a filter of opposite hue.
  96507. */
  96508. set globalDensity(value: number);
  96509. /**
  96510. * Gets the global Saturation value.
  96511. * 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.
  96512. */
  96513. get globalSaturation(): number;
  96514. /**
  96515. * Sets the global Saturation value.
  96516. * 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.
  96517. */
  96518. set globalSaturation(value: number);
  96519. /**
  96520. * Gets the global Exposure value.
  96521. * 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.
  96522. */
  96523. get globalExposure(): number;
  96524. /**
  96525. * Sets the global Exposure value.
  96526. * 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.
  96527. */
  96528. set globalExposure(value: number);
  96529. private _highlightsHue;
  96530. private _highlightsDensity;
  96531. private _highlightsSaturation;
  96532. private _highlightsExposure;
  96533. /**
  96534. * Gets the highlights Hue value.
  96535. * 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).
  96536. */
  96537. get highlightsHue(): number;
  96538. /**
  96539. * Sets the highlights Hue value.
  96540. * 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).
  96541. */
  96542. set highlightsHue(value: number);
  96543. /**
  96544. * Gets the highlights Density value.
  96545. * 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.
  96546. * Values less than zero provide a filter of opposite hue.
  96547. */
  96548. get highlightsDensity(): number;
  96549. /**
  96550. * Sets the highlights Density value.
  96551. * 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.
  96552. * Values less than zero provide a filter of opposite hue.
  96553. */
  96554. set highlightsDensity(value: number);
  96555. /**
  96556. * Gets the highlights Saturation value.
  96557. * 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.
  96558. */
  96559. get highlightsSaturation(): number;
  96560. /**
  96561. * Sets the highlights Saturation value.
  96562. * 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.
  96563. */
  96564. set highlightsSaturation(value: number);
  96565. /**
  96566. * Gets the highlights Exposure value.
  96567. * 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.
  96568. */
  96569. get highlightsExposure(): number;
  96570. /**
  96571. * Sets the highlights Exposure value.
  96572. * 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.
  96573. */
  96574. set highlightsExposure(value: number);
  96575. private _midtonesHue;
  96576. private _midtonesDensity;
  96577. private _midtonesSaturation;
  96578. private _midtonesExposure;
  96579. /**
  96580. * Gets the midtones Hue value.
  96581. * 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).
  96582. */
  96583. get midtonesHue(): number;
  96584. /**
  96585. * Sets the midtones Hue value.
  96586. * 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).
  96587. */
  96588. set midtonesHue(value: number);
  96589. /**
  96590. * Gets the midtones Density value.
  96591. * 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.
  96592. * Values less than zero provide a filter of opposite hue.
  96593. */
  96594. get midtonesDensity(): number;
  96595. /**
  96596. * Sets the midtones Density value.
  96597. * 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.
  96598. * Values less than zero provide a filter of opposite hue.
  96599. */
  96600. set midtonesDensity(value: number);
  96601. /**
  96602. * Gets the midtones Saturation value.
  96603. * 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.
  96604. */
  96605. get midtonesSaturation(): number;
  96606. /**
  96607. * Sets the midtones Saturation value.
  96608. * 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.
  96609. */
  96610. set midtonesSaturation(value: number);
  96611. /**
  96612. * Gets the midtones Exposure value.
  96613. * 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.
  96614. */
  96615. get midtonesExposure(): number;
  96616. /**
  96617. * Sets the midtones Exposure value.
  96618. * 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.
  96619. */
  96620. set midtonesExposure(value: number);
  96621. private _shadowsHue;
  96622. private _shadowsDensity;
  96623. private _shadowsSaturation;
  96624. private _shadowsExposure;
  96625. /**
  96626. * Gets the shadows Hue value.
  96627. * 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).
  96628. */
  96629. get shadowsHue(): number;
  96630. /**
  96631. * Sets the shadows Hue value.
  96632. * 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).
  96633. */
  96634. set shadowsHue(value: number);
  96635. /**
  96636. * Gets the shadows Density value.
  96637. * 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.
  96638. * Values less than zero provide a filter of opposite hue.
  96639. */
  96640. get shadowsDensity(): number;
  96641. /**
  96642. * Sets the shadows Density value.
  96643. * 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.
  96644. * Values less than zero provide a filter of opposite hue.
  96645. */
  96646. set shadowsDensity(value: number);
  96647. /**
  96648. * Gets the shadows Saturation value.
  96649. * 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.
  96650. */
  96651. get shadowsSaturation(): number;
  96652. /**
  96653. * Sets the shadows Saturation value.
  96654. * 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.
  96655. */
  96656. set shadowsSaturation(value: number);
  96657. /**
  96658. * Gets the shadows Exposure value.
  96659. * 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.
  96660. */
  96661. get shadowsExposure(): number;
  96662. /**
  96663. * Sets the shadows Exposure value.
  96664. * 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.
  96665. */
  96666. set shadowsExposure(value: number);
  96667. /**
  96668. * Returns the class name
  96669. * @returns The class name
  96670. */
  96671. getClassName(): string;
  96672. /**
  96673. * Binds the color curves to the shader.
  96674. * @param colorCurves The color curve to bind
  96675. * @param effect The effect to bind to
  96676. * @param positiveUniform The positive uniform shader parameter
  96677. * @param neutralUniform The neutral uniform shader parameter
  96678. * @param negativeUniform The negative uniform shader parameter
  96679. */
  96680. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  96681. /**
  96682. * Prepare the list of uniforms associated with the ColorCurves effects.
  96683. * @param uniformsList The list of uniforms used in the effect
  96684. */
  96685. static PrepareUniforms(uniformsList: string[]): void;
  96686. /**
  96687. * Returns color grading data based on a hue, density, saturation and exposure value.
  96688. * @param filterHue The hue of the color filter.
  96689. * @param filterDensity The density of the color filter.
  96690. * @param saturation The saturation.
  96691. * @param exposure The exposure.
  96692. * @param result The result data container.
  96693. */
  96694. private getColorGradingDataToRef;
  96695. /**
  96696. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  96697. * @param value The input slider value in range [-100,100].
  96698. * @returns Adjusted value.
  96699. */
  96700. private static applyColorGradingSliderNonlinear;
  96701. /**
  96702. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  96703. * @param hue The hue (H) input.
  96704. * @param saturation The saturation (S) input.
  96705. * @param brightness The brightness (B) input.
  96706. * @result An RGBA color represented as Vector4.
  96707. */
  96708. private static fromHSBToRef;
  96709. /**
  96710. * Returns a value clamped between min and max
  96711. * @param value The value to clamp
  96712. * @param min The minimum of value
  96713. * @param max The maximum of value
  96714. * @returns The clamped value.
  96715. */
  96716. private static clamp;
  96717. /**
  96718. * Clones the current color curve instance.
  96719. * @return The cloned curves
  96720. */
  96721. clone(): ColorCurves;
  96722. /**
  96723. * Serializes the current color curve instance to a json representation.
  96724. * @return a JSON representation
  96725. */
  96726. serialize(): any;
  96727. /**
  96728. * Parses the color curve from a json representation.
  96729. * @param source the JSON source to parse
  96730. * @return The parsed curves
  96731. */
  96732. static Parse(source: any): ColorCurves;
  96733. }
  96734. }
  96735. declare module BABYLON {
  96736. /**
  96737. * Interface to follow in your material defines to integrate easily the
  96738. * Image proccessing functions.
  96739. * @hidden
  96740. */
  96741. export interface IImageProcessingConfigurationDefines {
  96742. IMAGEPROCESSING: boolean;
  96743. VIGNETTE: boolean;
  96744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96745. VIGNETTEBLENDMODEOPAQUE: boolean;
  96746. TONEMAPPING: boolean;
  96747. TONEMAPPING_ACES: boolean;
  96748. CONTRAST: boolean;
  96749. EXPOSURE: boolean;
  96750. COLORCURVES: boolean;
  96751. COLORGRADING: boolean;
  96752. COLORGRADING3D: boolean;
  96753. SAMPLER3DGREENDEPTH: boolean;
  96754. SAMPLER3DBGRMAP: boolean;
  96755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96756. }
  96757. /**
  96758. * @hidden
  96759. */
  96760. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96761. IMAGEPROCESSING: boolean;
  96762. VIGNETTE: boolean;
  96763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96764. VIGNETTEBLENDMODEOPAQUE: boolean;
  96765. TONEMAPPING: boolean;
  96766. TONEMAPPING_ACES: boolean;
  96767. CONTRAST: boolean;
  96768. COLORCURVES: boolean;
  96769. COLORGRADING: boolean;
  96770. COLORGRADING3D: boolean;
  96771. SAMPLER3DGREENDEPTH: boolean;
  96772. SAMPLER3DBGRMAP: boolean;
  96773. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96774. EXPOSURE: boolean;
  96775. constructor();
  96776. }
  96777. /**
  96778. * This groups together the common properties used for image processing either in direct forward pass
  96779. * or through post processing effect depending on the use of the image processing pipeline in your scene
  96780. * or not.
  96781. */
  96782. export class ImageProcessingConfiguration {
  96783. /**
  96784. * Default tone mapping applied in BabylonJS.
  96785. */
  96786. static readonly TONEMAPPING_STANDARD: number;
  96787. /**
  96788. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  96789. * to other engines rendering to increase portability.
  96790. */
  96791. static readonly TONEMAPPING_ACES: number;
  96792. /**
  96793. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  96794. */
  96795. colorCurves: Nullable<ColorCurves>;
  96796. private _colorCurvesEnabled;
  96797. /**
  96798. * Gets wether the color curves effect is enabled.
  96799. */
  96800. get colorCurvesEnabled(): boolean;
  96801. /**
  96802. * Sets wether the color curves effect is enabled.
  96803. */
  96804. set colorCurvesEnabled(value: boolean);
  96805. private _colorGradingTexture;
  96806. /**
  96807. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96808. */
  96809. get colorGradingTexture(): Nullable<BaseTexture>;
  96810. /**
  96811. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96812. */
  96813. set colorGradingTexture(value: Nullable<BaseTexture>);
  96814. private _colorGradingEnabled;
  96815. /**
  96816. * Gets wether the color grading effect is enabled.
  96817. */
  96818. get colorGradingEnabled(): boolean;
  96819. /**
  96820. * Sets wether the color grading effect is enabled.
  96821. */
  96822. set colorGradingEnabled(value: boolean);
  96823. private _colorGradingWithGreenDepth;
  96824. /**
  96825. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  96826. */
  96827. get colorGradingWithGreenDepth(): boolean;
  96828. /**
  96829. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  96830. */
  96831. set colorGradingWithGreenDepth(value: boolean);
  96832. private _colorGradingBGR;
  96833. /**
  96834. * Gets wether the color grading texture contains BGR values.
  96835. */
  96836. get colorGradingBGR(): boolean;
  96837. /**
  96838. * Sets wether the color grading texture contains BGR values.
  96839. */
  96840. set colorGradingBGR(value: boolean);
  96841. /** @hidden */
  96842. _exposure: number;
  96843. /**
  96844. * Gets the Exposure used in the effect.
  96845. */
  96846. get exposure(): number;
  96847. /**
  96848. * Sets the Exposure used in the effect.
  96849. */
  96850. set exposure(value: number);
  96851. private _toneMappingEnabled;
  96852. /**
  96853. * Gets wether the tone mapping effect is enabled.
  96854. */
  96855. get toneMappingEnabled(): boolean;
  96856. /**
  96857. * Sets wether the tone mapping effect is enabled.
  96858. */
  96859. set toneMappingEnabled(value: boolean);
  96860. private _toneMappingType;
  96861. /**
  96862. * Gets the type of tone mapping effect.
  96863. */
  96864. get toneMappingType(): number;
  96865. /**
  96866. * Sets the type of tone mapping effect used in BabylonJS.
  96867. */
  96868. set toneMappingType(value: number);
  96869. protected _contrast: number;
  96870. /**
  96871. * Gets the contrast used in the effect.
  96872. */
  96873. get contrast(): number;
  96874. /**
  96875. * Sets the contrast used in the effect.
  96876. */
  96877. set contrast(value: number);
  96878. /**
  96879. * Vignette stretch size.
  96880. */
  96881. vignetteStretch: number;
  96882. /**
  96883. * Vignette centre X Offset.
  96884. */
  96885. vignetteCentreX: number;
  96886. /**
  96887. * Vignette centre Y Offset.
  96888. */
  96889. vignetteCentreY: number;
  96890. /**
  96891. * Vignette weight or intensity of the vignette effect.
  96892. */
  96893. vignetteWeight: number;
  96894. /**
  96895. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96896. * if vignetteEnabled is set to true.
  96897. */
  96898. vignetteColor: Color4;
  96899. /**
  96900. * Camera field of view used by the Vignette effect.
  96901. */
  96902. vignetteCameraFov: number;
  96903. private _vignetteBlendMode;
  96904. /**
  96905. * Gets the vignette blend mode allowing different kind of effect.
  96906. */
  96907. get vignetteBlendMode(): number;
  96908. /**
  96909. * Sets the vignette blend mode allowing different kind of effect.
  96910. */
  96911. set vignetteBlendMode(value: number);
  96912. private _vignetteEnabled;
  96913. /**
  96914. * Gets wether the vignette effect is enabled.
  96915. */
  96916. get vignetteEnabled(): boolean;
  96917. /**
  96918. * Sets wether the vignette effect is enabled.
  96919. */
  96920. set vignetteEnabled(value: boolean);
  96921. private _applyByPostProcess;
  96922. /**
  96923. * Gets wether the image processing is applied through a post process or not.
  96924. */
  96925. get applyByPostProcess(): boolean;
  96926. /**
  96927. * Sets wether the image processing is applied through a post process or not.
  96928. */
  96929. set applyByPostProcess(value: boolean);
  96930. private _isEnabled;
  96931. /**
  96932. * Gets wether the image processing is enabled or not.
  96933. */
  96934. get isEnabled(): boolean;
  96935. /**
  96936. * Sets wether the image processing is enabled or not.
  96937. */
  96938. set isEnabled(value: boolean);
  96939. /**
  96940. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  96941. */
  96942. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  96943. /**
  96944. * Method called each time the image processing information changes requires to recompile the effect.
  96945. */
  96946. protected _updateParameters(): void;
  96947. /**
  96948. * Gets the current class name.
  96949. * @return "ImageProcessingConfiguration"
  96950. */
  96951. getClassName(): string;
  96952. /**
  96953. * Prepare the list of uniforms associated with the Image Processing effects.
  96954. * @param uniforms The list of uniforms used in the effect
  96955. * @param defines the list of defines currently in use
  96956. */
  96957. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  96958. /**
  96959. * Prepare the list of samplers associated with the Image Processing effects.
  96960. * @param samplersList The list of uniforms used in the effect
  96961. * @param defines the list of defines currently in use
  96962. */
  96963. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  96964. /**
  96965. * Prepare the list of defines associated to the shader.
  96966. * @param defines the list of defines to complete
  96967. * @param forPostProcess Define if we are currently in post process mode or not
  96968. */
  96969. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  96970. /**
  96971. * Returns true if all the image processing information are ready.
  96972. * @returns True if ready, otherwise, false
  96973. */
  96974. isReady(): boolean;
  96975. /**
  96976. * Binds the image processing to the shader.
  96977. * @param effect The effect to bind to
  96978. * @param overrideAspectRatio Override the aspect ratio of the effect
  96979. */
  96980. bind(effect: Effect, overrideAspectRatio?: number): void;
  96981. /**
  96982. * Clones the current image processing instance.
  96983. * @return The cloned image processing
  96984. */
  96985. clone(): ImageProcessingConfiguration;
  96986. /**
  96987. * Serializes the current image processing instance to a json representation.
  96988. * @return a JSON representation
  96989. */
  96990. serialize(): any;
  96991. /**
  96992. * Parses the image processing from a json representation.
  96993. * @param source the JSON source to parse
  96994. * @return The parsed image processing
  96995. */
  96996. static Parse(source: any): ImageProcessingConfiguration;
  96997. private static _VIGNETTEMODE_MULTIPLY;
  96998. private static _VIGNETTEMODE_OPAQUE;
  96999. /**
  97000. * Used to apply the vignette as a mix with the pixel color.
  97001. */
  97002. static get VIGNETTEMODE_MULTIPLY(): number;
  97003. /**
  97004. * Used to apply the vignette as a replacement of the pixel color.
  97005. */
  97006. static get VIGNETTEMODE_OPAQUE(): number;
  97007. }
  97008. }
  97009. declare module BABYLON {
  97010. /** @hidden */
  97011. export var postprocessVertexShader: {
  97012. name: string;
  97013. shader: string;
  97014. };
  97015. }
  97016. declare module BABYLON {
  97017. /**
  97018. * Type used to define a render target texture size (either with a number or with a rect width and height)
  97019. */
  97020. export type RenderTargetTextureSize = number | {
  97021. width: number;
  97022. height: number;
  97023. layers?: number;
  97024. };
  97025. interface ThinEngine {
  97026. /**
  97027. * Creates a new render target texture
  97028. * @param size defines the size of the texture
  97029. * @param options defines the options used to create the texture
  97030. * @returns a new render target texture stored in an InternalTexture
  97031. */
  97032. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97033. /**
  97034. * Creates a depth stencil texture.
  97035. * This is only available in WebGL 2 or with the depth texture extension available.
  97036. * @param size The size of face edge in the texture.
  97037. * @param options The options defining the texture.
  97038. * @returns The texture
  97039. */
  97040. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97041. /** @hidden */
  97042. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97043. }
  97044. }
  97045. declare module BABYLON {
  97046. /**
  97047. * Defines the kind of connection point for node based material
  97048. */
  97049. export enum NodeMaterialBlockConnectionPointTypes {
  97050. /** Float */
  97051. Float = 1,
  97052. /** Int */
  97053. Int = 2,
  97054. /** Vector2 */
  97055. Vector2 = 4,
  97056. /** Vector3 */
  97057. Vector3 = 8,
  97058. /** Vector4 */
  97059. Vector4 = 16,
  97060. /** Color3 */
  97061. Color3 = 32,
  97062. /** Color4 */
  97063. Color4 = 64,
  97064. /** Matrix */
  97065. Matrix = 128,
  97066. /** Custom object */
  97067. Object = 256,
  97068. /** Detect type based on connection */
  97069. AutoDetect = 1024,
  97070. /** Output type that will be defined by input type */
  97071. BasedOnInput = 2048
  97072. }
  97073. }
  97074. declare module BABYLON {
  97075. /**
  97076. * Enum used to define the target of a block
  97077. */
  97078. export enum NodeMaterialBlockTargets {
  97079. /** Vertex shader */
  97080. Vertex = 1,
  97081. /** Fragment shader */
  97082. Fragment = 2,
  97083. /** Neutral */
  97084. Neutral = 4,
  97085. /** Vertex and Fragment */
  97086. VertexAndFragment = 3
  97087. }
  97088. }
  97089. declare module BABYLON {
  97090. /**
  97091. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  97092. */
  97093. export enum NodeMaterialBlockConnectionPointMode {
  97094. /** Value is an uniform */
  97095. Uniform = 0,
  97096. /** Value is a mesh attribute */
  97097. Attribute = 1,
  97098. /** Value is a varying between vertex and fragment shaders */
  97099. Varying = 2,
  97100. /** Mode is undefined */
  97101. Undefined = 3
  97102. }
  97103. }
  97104. declare module BABYLON {
  97105. /**
  97106. * Enum used to define system values e.g. values automatically provided by the system
  97107. */
  97108. export enum NodeMaterialSystemValues {
  97109. /** World */
  97110. World = 1,
  97111. /** View */
  97112. View = 2,
  97113. /** Projection */
  97114. Projection = 3,
  97115. /** ViewProjection */
  97116. ViewProjection = 4,
  97117. /** WorldView */
  97118. WorldView = 5,
  97119. /** WorldViewProjection */
  97120. WorldViewProjection = 6,
  97121. /** CameraPosition */
  97122. CameraPosition = 7,
  97123. /** Fog Color */
  97124. FogColor = 8,
  97125. /** Delta time */
  97126. DeltaTime = 9
  97127. }
  97128. }
  97129. declare module BABYLON {
  97130. /**
  97131. * Represents a camera frustum
  97132. */
  97133. export class Frustum {
  97134. /**
  97135. * Gets the planes representing the frustum
  97136. * @param transform matrix to be applied to the returned planes
  97137. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  97138. */
  97139. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  97140. /**
  97141. * Gets the near frustum plane transformed by the transform matrix
  97142. * @param transform transformation matrix to be applied to the resulting frustum plane
  97143. * @param frustumPlane the resuling frustum plane
  97144. */
  97145. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97146. /**
  97147. * Gets the far frustum plane transformed by the transform matrix
  97148. * @param transform transformation matrix to be applied to the resulting frustum plane
  97149. * @param frustumPlane the resuling frustum plane
  97150. */
  97151. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97152. /**
  97153. * Gets the left frustum plane transformed by the transform matrix
  97154. * @param transform transformation matrix to be applied to the resulting frustum plane
  97155. * @param frustumPlane the resuling frustum plane
  97156. */
  97157. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97158. /**
  97159. * Gets the right frustum plane transformed by the transform matrix
  97160. * @param transform transformation matrix to be applied to the resulting frustum plane
  97161. * @param frustumPlane the resuling frustum plane
  97162. */
  97163. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97164. /**
  97165. * Gets the top frustum plane transformed by the transform matrix
  97166. * @param transform transformation matrix to be applied to the resulting frustum plane
  97167. * @param frustumPlane the resuling frustum plane
  97168. */
  97169. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97170. /**
  97171. * Gets the bottom frustum plane transformed by the transform matrix
  97172. * @param transform transformation matrix to be applied to the resulting frustum plane
  97173. * @param frustumPlane the resuling frustum plane
  97174. */
  97175. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97176. /**
  97177. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  97178. * @param transform transformation matrix to be applied to the resulting frustum planes
  97179. * @param frustumPlanes the resuling frustum planes
  97180. */
  97181. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  97182. }
  97183. }
  97184. declare module BABYLON {
  97185. /**
  97186. * Contains position and normal vectors for a vertex
  97187. */
  97188. export class PositionNormalVertex {
  97189. /** the position of the vertex (defaut: 0,0,0) */
  97190. position: Vector3;
  97191. /** the normal of the vertex (defaut: 0,1,0) */
  97192. normal: Vector3;
  97193. /**
  97194. * Creates a PositionNormalVertex
  97195. * @param position the position of the vertex (defaut: 0,0,0)
  97196. * @param normal the normal of the vertex (defaut: 0,1,0)
  97197. */
  97198. constructor(
  97199. /** the position of the vertex (defaut: 0,0,0) */
  97200. position?: Vector3,
  97201. /** the normal of the vertex (defaut: 0,1,0) */
  97202. normal?: Vector3);
  97203. /**
  97204. * Clones the PositionNormalVertex
  97205. * @returns the cloned PositionNormalVertex
  97206. */
  97207. clone(): PositionNormalVertex;
  97208. }
  97209. /**
  97210. * Contains position, normal and uv vectors for a vertex
  97211. */
  97212. export class PositionNormalTextureVertex {
  97213. /** the position of the vertex (defaut: 0,0,0) */
  97214. position: Vector3;
  97215. /** the normal of the vertex (defaut: 0,1,0) */
  97216. normal: Vector3;
  97217. /** the uv of the vertex (default: 0,0) */
  97218. uv: Vector2;
  97219. /**
  97220. * Creates a PositionNormalTextureVertex
  97221. * @param position the position of the vertex (defaut: 0,0,0)
  97222. * @param normal the normal of the vertex (defaut: 0,1,0)
  97223. * @param uv the uv of the vertex (default: 0,0)
  97224. */
  97225. constructor(
  97226. /** the position of the vertex (defaut: 0,0,0) */
  97227. position?: Vector3,
  97228. /** the normal of the vertex (defaut: 0,1,0) */
  97229. normal?: Vector3,
  97230. /** the uv of the vertex (default: 0,0) */
  97231. uv?: Vector2);
  97232. /**
  97233. * Clones the PositionNormalTextureVertex
  97234. * @returns the cloned PositionNormalTextureVertex
  97235. */
  97236. clone(): PositionNormalTextureVertex;
  97237. }
  97238. }
  97239. declare module BABYLON {
  97240. /**
  97241. * Enum defining the type of animations supported by InputBlock
  97242. */
  97243. export enum AnimatedInputBlockTypes {
  97244. /** No animation */
  97245. None = 0,
  97246. /** Time based animation. Will only work for floats */
  97247. Time = 1
  97248. }
  97249. }
  97250. declare module BABYLON {
  97251. /**
  97252. * Block used to expose an input value
  97253. */
  97254. export class InputBlock extends NodeMaterialBlock {
  97255. private _mode;
  97256. private _associatedVariableName;
  97257. private _storedValue;
  97258. private _valueCallback;
  97259. private _type;
  97260. private _animationType;
  97261. /** Gets or set a value used to limit the range of float values */
  97262. min: number;
  97263. /** Gets or set a value used to limit the range of float values */
  97264. max: number;
  97265. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97266. isBoolean: boolean;
  97267. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97268. matrixMode: number;
  97269. /** @hidden */
  97270. _systemValue: Nullable<NodeMaterialSystemValues>;
  97271. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97272. isConstant: boolean;
  97273. /** Gets or sets the group to use to display this block in the Inspector */
  97274. groupInInspector: string;
  97275. /** Gets an observable raised when the value is changed */
  97276. onValueChangedObservable: Observable<InputBlock>;
  97277. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  97278. convertToGammaSpace: boolean;
  97279. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  97280. convertToLinearSpace: boolean;
  97281. /**
  97282. * Gets or sets the connection point type (default is float)
  97283. */
  97284. get type(): NodeMaterialBlockConnectionPointTypes;
  97285. /**
  97286. * Creates a new InputBlock
  97287. * @param name defines the block name
  97288. * @param target defines the target of that block (Vertex by default)
  97289. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97290. */
  97291. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97292. /**
  97293. * Validates if a name is a reserve word.
  97294. * @param newName the new name to be given to the node.
  97295. * @returns false if the name is a reserve word, else true.
  97296. */
  97297. validateBlockName(newName: string): boolean;
  97298. /**
  97299. * Gets the output component
  97300. */
  97301. get output(): NodeMaterialConnectionPoint;
  97302. /**
  97303. * Set the source of this connection point to a vertex attribute
  97304. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97305. * @returns the current connection point
  97306. */
  97307. setAsAttribute(attributeName?: string): InputBlock;
  97308. /**
  97309. * Set the source of this connection point to a system value
  97310. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97311. * @returns the current connection point
  97312. */
  97313. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97314. /**
  97315. * Gets or sets the value of that point.
  97316. * Please note that this value will be ignored if valueCallback is defined
  97317. */
  97318. get value(): any;
  97319. set value(value: any);
  97320. /**
  97321. * Gets or sets a callback used to get the value of that point.
  97322. * Please note that setting this value will force the connection point to ignore the value property
  97323. */
  97324. get valueCallback(): () => any;
  97325. set valueCallback(value: () => any);
  97326. /**
  97327. * Gets or sets the associated variable name in the shader
  97328. */
  97329. get associatedVariableName(): string;
  97330. set associatedVariableName(value: string);
  97331. /** Gets or sets the type of animation applied to the input */
  97332. get animationType(): AnimatedInputBlockTypes;
  97333. set animationType(value: AnimatedInputBlockTypes);
  97334. /**
  97335. * Gets a boolean indicating that this connection point not defined yet
  97336. */
  97337. get isUndefined(): boolean;
  97338. /**
  97339. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97340. * In this case the connection point name must be the name of the uniform to use.
  97341. * Can only be set on inputs
  97342. */
  97343. get isUniform(): boolean;
  97344. set isUniform(value: boolean);
  97345. /**
  97346. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97347. * In this case the connection point name must be the name of the attribute to use
  97348. * Can only be set on inputs
  97349. */
  97350. get isAttribute(): boolean;
  97351. set isAttribute(value: boolean);
  97352. /**
  97353. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97354. * Can only be set on exit points
  97355. */
  97356. get isVarying(): boolean;
  97357. set isVarying(value: boolean);
  97358. /**
  97359. * Gets a boolean indicating that the current connection point is a system value
  97360. */
  97361. get isSystemValue(): boolean;
  97362. /**
  97363. * Gets or sets the current well known value or null if not defined as a system value
  97364. */
  97365. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97366. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97367. /**
  97368. * Gets the current class name
  97369. * @returns the class name
  97370. */
  97371. getClassName(): string;
  97372. /**
  97373. * Animate the input if animationType !== None
  97374. * @param scene defines the rendering scene
  97375. */
  97376. animate(scene: Scene): void;
  97377. private _emitDefine;
  97378. initialize(state: NodeMaterialBuildState): void;
  97379. /**
  97380. * Set the input block to its default value (based on its type)
  97381. */
  97382. setDefaultValue(): void;
  97383. private _emitConstant;
  97384. /** @hidden */
  97385. get _noContextSwitch(): boolean;
  97386. private _emit;
  97387. /** @hidden */
  97388. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97389. /** @hidden */
  97390. _transmit(effect: Effect, scene: Scene): void;
  97391. protected _buildBlock(state: NodeMaterialBuildState): void;
  97392. protected _dumpPropertiesCode(): string;
  97393. dispose(): void;
  97394. serialize(): any;
  97395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97396. }
  97397. }
  97398. declare module BABYLON {
  97399. /**
  97400. * Enum used to define the compatibility state between two connection points
  97401. */
  97402. export enum NodeMaterialConnectionPointCompatibilityStates {
  97403. /** Points are compatibles */
  97404. Compatible = 0,
  97405. /** Points are incompatible because of their types */
  97406. TypeIncompatible = 1,
  97407. /** Points are incompatible because of their targets (vertex vs fragment) */
  97408. TargetIncompatible = 2
  97409. }
  97410. /**
  97411. * Defines the direction of a connection point
  97412. */
  97413. export enum NodeMaterialConnectionPointDirection {
  97414. /** Input */
  97415. Input = 0,
  97416. /** Output */
  97417. Output = 1
  97418. }
  97419. /**
  97420. * Defines a connection point for a block
  97421. */
  97422. export class NodeMaterialConnectionPoint {
  97423. /**
  97424. * Checks if two types are equivalent
  97425. * @param type1 type 1 to check
  97426. * @param type2 type 2 to check
  97427. * @returns true if both types are equivalent, else false
  97428. */
  97429. static AreEquivalentTypes(type1: number, type2: number): boolean;
  97430. /** @hidden */
  97431. _ownerBlock: NodeMaterialBlock;
  97432. /** @hidden */
  97433. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97434. private _endpoints;
  97435. private _associatedVariableName;
  97436. private _direction;
  97437. /** @hidden */
  97438. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97439. /** @hidden */
  97440. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97441. /** @hidden */
  97442. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  97443. private _type;
  97444. /** @hidden */
  97445. _enforceAssociatedVariableName: boolean;
  97446. /** Gets the direction of the point */
  97447. get direction(): NodeMaterialConnectionPointDirection;
  97448. /** Indicates that this connection point needs dual validation before being connected to another point */
  97449. needDualDirectionValidation: boolean;
  97450. /**
  97451. * Gets or sets the additional types supported by this connection point
  97452. */
  97453. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97454. /**
  97455. * Gets or sets the additional types excluded by this connection point
  97456. */
  97457. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97458. /**
  97459. * Observable triggered when this point is connected
  97460. */
  97461. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97462. /**
  97463. * Gets or sets the associated variable name in the shader
  97464. */
  97465. get associatedVariableName(): string;
  97466. set associatedVariableName(value: string);
  97467. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97468. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97469. /**
  97470. * Gets or sets the connection point type (default is float)
  97471. */
  97472. get type(): NodeMaterialBlockConnectionPointTypes;
  97473. set type(value: NodeMaterialBlockConnectionPointTypes);
  97474. /**
  97475. * Gets or sets the connection point name
  97476. */
  97477. name: string;
  97478. /**
  97479. * Gets or sets the connection point name
  97480. */
  97481. displayName: string;
  97482. /**
  97483. * Gets or sets a boolean indicating that this connection point can be omitted
  97484. */
  97485. isOptional: boolean;
  97486. /**
  97487. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  97488. */
  97489. isExposedOnFrame: boolean;
  97490. /**
  97491. * Gets or sets number indicating the position that the port is exposed to on a frame
  97492. */
  97493. exposedPortPosition: number;
  97494. /**
  97495. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97496. */
  97497. define: string;
  97498. /** @hidden */
  97499. _prioritizeVertex: boolean;
  97500. private _target;
  97501. /** Gets or sets the target of that connection point */
  97502. get target(): NodeMaterialBlockTargets;
  97503. set target(value: NodeMaterialBlockTargets);
  97504. /**
  97505. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97506. */
  97507. get isConnected(): boolean;
  97508. /**
  97509. * Gets a boolean indicating that the current point is connected to an input block
  97510. */
  97511. get isConnectedToInputBlock(): boolean;
  97512. /**
  97513. * Gets a the connected input block (if any)
  97514. */
  97515. get connectInputBlock(): Nullable<InputBlock>;
  97516. /** Get the other side of the connection (if any) */
  97517. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97518. /** Get the block that owns this connection point */
  97519. get ownerBlock(): NodeMaterialBlock;
  97520. /** Get the block connected on the other side of this connection (if any) */
  97521. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97522. /** Get the block connected on the endpoints of this connection (if any) */
  97523. get connectedBlocks(): Array<NodeMaterialBlock>;
  97524. /** Gets the list of connected endpoints */
  97525. get endpoints(): NodeMaterialConnectionPoint[];
  97526. /** Gets a boolean indicating if that output point is connected to at least one input */
  97527. get hasEndpoints(): boolean;
  97528. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97529. get isConnectedInVertexShader(): boolean;
  97530. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97531. get isConnectedInFragmentShader(): boolean;
  97532. /**
  97533. * Creates a block suitable to be used as an input for this input point.
  97534. * If null is returned, a block based on the point type will be created.
  97535. * @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
  97536. */
  97537. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97538. /**
  97539. * Creates a new connection point
  97540. * @param name defines the connection point name
  97541. * @param ownerBlock defines the block hosting this connection point
  97542. * @param direction defines the direction of the connection point
  97543. */
  97544. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97545. /**
  97546. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97547. * @returns the class name
  97548. */
  97549. getClassName(): string;
  97550. /**
  97551. * Gets a boolean indicating if the current point can be connected to another point
  97552. * @param connectionPoint defines the other connection point
  97553. * @returns a boolean
  97554. */
  97555. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97556. /**
  97557. * Gets a number indicating if the current point can be connected to another point
  97558. * @param connectionPoint defines the other connection point
  97559. * @returns a number defining the compatibility state
  97560. */
  97561. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97562. /**
  97563. * Connect this point to another connection point
  97564. * @param connectionPoint defines the other connection point
  97565. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97566. * @returns the current connection point
  97567. */
  97568. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97569. /**
  97570. * Disconnect this point from one of his endpoint
  97571. * @param endpoint defines the other connection point
  97572. * @returns the current connection point
  97573. */
  97574. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97575. /**
  97576. * Serializes this point in a JSON representation
  97577. * @param isInput defines if the connection point is an input (default is true)
  97578. * @returns the serialized point object
  97579. */
  97580. serialize(isInput?: boolean): any;
  97581. /**
  97582. * Release resources
  97583. */
  97584. dispose(): void;
  97585. }
  97586. }
  97587. declare module BABYLON {
  97588. /**
  97589. * Enum used to define the material modes
  97590. */
  97591. export enum NodeMaterialModes {
  97592. /** Regular material */
  97593. Material = 0,
  97594. /** For post process */
  97595. PostProcess = 1,
  97596. /** For particle system */
  97597. Particle = 2,
  97598. /** For procedural texture */
  97599. ProceduralTexture = 3
  97600. }
  97601. }
  97602. declare module BABYLON {
  97603. /** @hidden */
  97604. export var helperFunctions: {
  97605. name: string;
  97606. shader: string;
  97607. };
  97608. }
  97609. declare module BABYLON {
  97610. /**
  97611. * Block used to read a texture from a sampler
  97612. */
  97613. export class TextureBlock extends NodeMaterialBlock {
  97614. private _defineName;
  97615. private _linearDefineName;
  97616. private _gammaDefineName;
  97617. private _tempTextureRead;
  97618. private _samplerName;
  97619. private _transformedUVName;
  97620. private _textureTransformName;
  97621. private _textureInfoName;
  97622. private _mainUVName;
  97623. private _mainUVDefineName;
  97624. private _fragmentOnly;
  97625. /**
  97626. * Gets or sets the texture associated with the node
  97627. */
  97628. texture: Nullable<Texture>;
  97629. /**
  97630. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97631. */
  97632. convertToGammaSpace: boolean;
  97633. /**
  97634. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97635. */
  97636. convertToLinearSpace: boolean;
  97637. /**
  97638. * Create a new TextureBlock
  97639. * @param name defines the block name
  97640. */
  97641. constructor(name: string, fragmentOnly?: boolean);
  97642. /**
  97643. * Gets the current class name
  97644. * @returns the class name
  97645. */
  97646. getClassName(): string;
  97647. /**
  97648. * Gets the uv input component
  97649. */
  97650. get uv(): NodeMaterialConnectionPoint;
  97651. /**
  97652. * Gets the rgba output component
  97653. */
  97654. get rgba(): NodeMaterialConnectionPoint;
  97655. /**
  97656. * Gets the rgb output component
  97657. */
  97658. get rgb(): NodeMaterialConnectionPoint;
  97659. /**
  97660. * Gets the r output component
  97661. */
  97662. get r(): NodeMaterialConnectionPoint;
  97663. /**
  97664. * Gets the g output component
  97665. */
  97666. get g(): NodeMaterialConnectionPoint;
  97667. /**
  97668. * Gets the b output component
  97669. */
  97670. get b(): NodeMaterialConnectionPoint;
  97671. /**
  97672. * Gets the a output component
  97673. */
  97674. get a(): NodeMaterialConnectionPoint;
  97675. get target(): NodeMaterialBlockTargets;
  97676. autoConfigure(material: NodeMaterial): void;
  97677. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97679. isReady(): boolean;
  97680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97681. private get _isMixed();
  97682. private _injectVertexCode;
  97683. private _writeTextureRead;
  97684. private _writeOutput;
  97685. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97686. protected _dumpPropertiesCode(): string;
  97687. serialize(): any;
  97688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97689. }
  97690. }
  97691. declare module BABYLON {
  97692. /** @hidden */
  97693. export var reflectionFunction: {
  97694. name: string;
  97695. shader: string;
  97696. };
  97697. }
  97698. declare module BABYLON {
  97699. /**
  97700. * Base block used to read a reflection texture from a sampler
  97701. */
  97702. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97703. /** @hidden */
  97704. _define3DName: string;
  97705. /** @hidden */
  97706. _defineCubicName: string;
  97707. /** @hidden */
  97708. _defineExplicitName: string;
  97709. /** @hidden */
  97710. _defineProjectionName: string;
  97711. /** @hidden */
  97712. _defineLocalCubicName: string;
  97713. /** @hidden */
  97714. _defineSphericalName: string;
  97715. /** @hidden */
  97716. _definePlanarName: string;
  97717. /** @hidden */
  97718. _defineEquirectangularName: string;
  97719. /** @hidden */
  97720. _defineMirroredEquirectangularFixedName: string;
  97721. /** @hidden */
  97722. _defineEquirectangularFixedName: string;
  97723. /** @hidden */
  97724. _defineSkyboxName: string;
  97725. /** @hidden */
  97726. _defineOppositeZ: string;
  97727. /** @hidden */
  97728. _cubeSamplerName: string;
  97729. /** @hidden */
  97730. _2DSamplerName: string;
  97731. protected _positionUVWName: string;
  97732. protected _directionWName: string;
  97733. protected _reflectionVectorName: string;
  97734. /** @hidden */
  97735. _reflectionCoordsName: string;
  97736. /** @hidden */
  97737. _reflectionMatrixName: string;
  97738. protected _reflectionColorName: string;
  97739. /**
  97740. * Gets or sets the texture associated with the node
  97741. */
  97742. texture: Nullable<BaseTexture>;
  97743. /**
  97744. * Create a new ReflectionTextureBaseBlock
  97745. * @param name defines the block name
  97746. */
  97747. constructor(name: string);
  97748. /**
  97749. * Gets the current class name
  97750. * @returns the class name
  97751. */
  97752. getClassName(): string;
  97753. /**
  97754. * Gets the world position input component
  97755. */
  97756. abstract get position(): NodeMaterialConnectionPoint;
  97757. /**
  97758. * Gets the world position input component
  97759. */
  97760. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97761. /**
  97762. * Gets the world normal input component
  97763. */
  97764. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97765. /**
  97766. * Gets the world input component
  97767. */
  97768. abstract get world(): NodeMaterialConnectionPoint;
  97769. /**
  97770. * Gets the camera (or eye) position component
  97771. */
  97772. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97773. /**
  97774. * Gets the view input component
  97775. */
  97776. abstract get view(): NodeMaterialConnectionPoint;
  97777. protected _getTexture(): Nullable<BaseTexture>;
  97778. autoConfigure(material: NodeMaterial): void;
  97779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97780. isReady(): boolean;
  97781. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97782. /**
  97783. * Gets the code to inject in the vertex shader
  97784. * @param state current state of the node material building
  97785. * @returns the shader code
  97786. */
  97787. handleVertexSide(state: NodeMaterialBuildState): string;
  97788. /**
  97789. * Handles the inits for the fragment code path
  97790. * @param state node material build state
  97791. */
  97792. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97793. /**
  97794. * Generates the reflection coords code for the fragment code path
  97795. * @param worldNormalVarName name of the world normal variable
  97796. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97797. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97798. * @returns the shader code
  97799. */
  97800. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97801. /**
  97802. * Generates the reflection color code for the fragment code path
  97803. * @param lodVarName name of the lod variable
  97804. * @param swizzleLookupTexture swizzle to use for the final color variable
  97805. * @returns the shader code
  97806. */
  97807. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97808. /**
  97809. * Generates the code corresponding to the connected output points
  97810. * @param state node material build state
  97811. * @param varName name of the variable to output
  97812. * @returns the shader code
  97813. */
  97814. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97815. protected _buildBlock(state: NodeMaterialBuildState): this;
  97816. protected _dumpPropertiesCode(): string;
  97817. serialize(): any;
  97818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97819. }
  97820. }
  97821. declare module BABYLON {
  97822. /**
  97823. * Defines a connection point to be used for points with a custom object type
  97824. */
  97825. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97826. private _blockType;
  97827. private _blockName;
  97828. private _nameForCheking?;
  97829. /**
  97830. * Creates a new connection point
  97831. * @param name defines the connection point name
  97832. * @param ownerBlock defines the block hosting this connection point
  97833. * @param direction defines the direction of the connection point
  97834. */
  97835. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97836. /**
  97837. * Gets a number indicating if the current point can be connected to another point
  97838. * @param connectionPoint defines the other connection point
  97839. * @returns a number defining the compatibility state
  97840. */
  97841. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97842. /**
  97843. * Creates a block suitable to be used as an input for this input point.
  97844. * If null is returned, a block based on the point type will be created.
  97845. * @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
  97846. */
  97847. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97848. }
  97849. }
  97850. declare module BABYLON {
  97851. /**
  97852. * Enum defining the type of properties that can be edited in the property pages in the NME
  97853. */
  97854. export enum PropertyTypeForEdition {
  97855. /** property is a boolean */
  97856. Boolean = 0,
  97857. /** property is a float */
  97858. Float = 1,
  97859. /** property is a Vector2 */
  97860. Vector2 = 2,
  97861. /** property is a list of values */
  97862. List = 3
  97863. }
  97864. /**
  97865. * Interface that defines an option in a variable of type list
  97866. */
  97867. export interface IEditablePropertyListOption {
  97868. /** label of the option */
  97869. "label": string;
  97870. /** value of the option */
  97871. "value": number;
  97872. }
  97873. /**
  97874. * Interface that defines the options available for an editable property
  97875. */
  97876. export interface IEditablePropertyOption {
  97877. /** min value */
  97878. "min"?: number;
  97879. /** max value */
  97880. "max"?: number;
  97881. /** notifiers: indicates which actions to take when the property is changed */
  97882. "notifiers"?: {
  97883. /** the material should be rebuilt */
  97884. "rebuild"?: boolean;
  97885. /** the preview should be updated */
  97886. "update"?: boolean;
  97887. };
  97888. /** list of the options for a variable of type list */
  97889. "options"?: IEditablePropertyListOption[];
  97890. }
  97891. /**
  97892. * Interface that describes an editable property
  97893. */
  97894. export interface IPropertyDescriptionForEdition {
  97895. /** name of the property */
  97896. "propertyName": string;
  97897. /** display name of the property */
  97898. "displayName": string;
  97899. /** type of the property */
  97900. "type": PropertyTypeForEdition;
  97901. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97902. "groupName": string;
  97903. /** options for the property */
  97904. "options": IEditablePropertyOption;
  97905. }
  97906. /**
  97907. * Decorator that flags a property in a node material block as being editable
  97908. */
  97909. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97910. }
  97911. declare module BABYLON {
  97912. /**
  97913. * Block used to implement the refraction part of the sub surface module of the PBR material
  97914. */
  97915. export class RefractionBlock extends NodeMaterialBlock {
  97916. /** @hidden */
  97917. _define3DName: string;
  97918. /** @hidden */
  97919. _refractionMatrixName: string;
  97920. /** @hidden */
  97921. _defineLODRefractionAlpha: string;
  97922. /** @hidden */
  97923. _defineLinearSpecularRefraction: string;
  97924. /** @hidden */
  97925. _defineOppositeZ: string;
  97926. /** @hidden */
  97927. _cubeSamplerName: string;
  97928. /** @hidden */
  97929. _2DSamplerName: string;
  97930. /** @hidden */
  97931. _vRefractionMicrosurfaceInfosName: string;
  97932. /** @hidden */
  97933. _vRefractionInfosName: string;
  97934. /** @hidden */
  97935. _vRefractionFilteringInfoName: string;
  97936. private _scene;
  97937. /**
  97938. * The properties below are set by the main PBR block prior to calling methods of this class.
  97939. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  97940. * It's less burden on the user side in the editor part.
  97941. */
  97942. /** @hidden */
  97943. viewConnectionPoint: NodeMaterialConnectionPoint;
  97944. /** @hidden */
  97945. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  97946. /**
  97947. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  97948. * Materials half opaque for instance using refraction could benefit from this control.
  97949. */
  97950. linkRefractionWithTransparency: boolean;
  97951. /**
  97952. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  97953. */
  97954. invertRefractionY: boolean;
  97955. /**
  97956. * Gets or sets the texture associated with the node
  97957. */
  97958. texture: Nullable<BaseTexture>;
  97959. /**
  97960. * Create a new RefractionBlock
  97961. * @param name defines the block name
  97962. */
  97963. constructor(name: string);
  97964. /**
  97965. * Gets the current class name
  97966. * @returns the class name
  97967. */
  97968. getClassName(): string;
  97969. /**
  97970. * Gets the intensity input component
  97971. */
  97972. get intensity(): NodeMaterialConnectionPoint;
  97973. /**
  97974. * Gets the tint at distance input component
  97975. */
  97976. get tintAtDistance(): NodeMaterialConnectionPoint;
  97977. /**
  97978. * Gets the view input component
  97979. */
  97980. get view(): NodeMaterialConnectionPoint;
  97981. /**
  97982. * Gets the refraction object output component
  97983. */
  97984. get refraction(): NodeMaterialConnectionPoint;
  97985. /**
  97986. * Returns true if the block has a texture
  97987. */
  97988. get hasTexture(): boolean;
  97989. protected _getTexture(): Nullable<BaseTexture>;
  97990. autoConfigure(material: NodeMaterial): void;
  97991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97992. isReady(): boolean;
  97993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  97994. /**
  97995. * Gets the main code of the block (fragment side)
  97996. * @param state current state of the node material building
  97997. * @returns the shader code
  97998. */
  97999. getCode(state: NodeMaterialBuildState): string;
  98000. protected _buildBlock(state: NodeMaterialBuildState): this;
  98001. protected _dumpPropertiesCode(): string;
  98002. serialize(): any;
  98003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98004. }
  98005. }
  98006. declare module BABYLON {
  98007. /**
  98008. * Base block used as input for post process
  98009. */
  98010. export class CurrentScreenBlock extends NodeMaterialBlock {
  98011. private _samplerName;
  98012. private _linearDefineName;
  98013. private _gammaDefineName;
  98014. private _mainUVName;
  98015. private _tempTextureRead;
  98016. /**
  98017. * Gets or sets the texture associated with the node
  98018. */
  98019. texture: Nullable<BaseTexture>;
  98020. /**
  98021. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98022. */
  98023. convertToGammaSpace: boolean;
  98024. /**
  98025. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98026. */
  98027. convertToLinearSpace: boolean;
  98028. /**
  98029. * Create a new CurrentScreenBlock
  98030. * @param name defines the block name
  98031. */
  98032. constructor(name: string);
  98033. /**
  98034. * Gets the current class name
  98035. * @returns the class name
  98036. */
  98037. getClassName(): string;
  98038. /**
  98039. * Gets the uv input component
  98040. */
  98041. get uv(): NodeMaterialConnectionPoint;
  98042. /**
  98043. * Gets the rgba output component
  98044. */
  98045. get rgba(): NodeMaterialConnectionPoint;
  98046. /**
  98047. * Gets the rgb output component
  98048. */
  98049. get rgb(): NodeMaterialConnectionPoint;
  98050. /**
  98051. * Gets the r output component
  98052. */
  98053. get r(): NodeMaterialConnectionPoint;
  98054. /**
  98055. * Gets the g output component
  98056. */
  98057. get g(): NodeMaterialConnectionPoint;
  98058. /**
  98059. * Gets the b output component
  98060. */
  98061. get b(): NodeMaterialConnectionPoint;
  98062. /**
  98063. * Gets the a output component
  98064. */
  98065. get a(): NodeMaterialConnectionPoint;
  98066. /**
  98067. * Initialize the block and prepare the context for build
  98068. * @param state defines the state that will be used for the build
  98069. */
  98070. initialize(state: NodeMaterialBuildState): void;
  98071. get target(): NodeMaterialBlockTargets;
  98072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98073. isReady(): boolean;
  98074. private _injectVertexCode;
  98075. private _writeTextureRead;
  98076. private _writeOutput;
  98077. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98078. serialize(): any;
  98079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98080. }
  98081. }
  98082. declare module BABYLON {
  98083. /**
  98084. * Base block used for the particle texture
  98085. */
  98086. export class ParticleTextureBlock extends NodeMaterialBlock {
  98087. private _samplerName;
  98088. private _linearDefineName;
  98089. private _gammaDefineName;
  98090. private _tempTextureRead;
  98091. /**
  98092. * Gets or sets the texture associated with the node
  98093. */
  98094. texture: Nullable<BaseTexture>;
  98095. /**
  98096. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98097. */
  98098. convertToGammaSpace: boolean;
  98099. /**
  98100. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98101. */
  98102. convertToLinearSpace: boolean;
  98103. /**
  98104. * Create a new ParticleTextureBlock
  98105. * @param name defines the block name
  98106. */
  98107. constructor(name: string);
  98108. /**
  98109. * Gets the current class name
  98110. * @returns the class name
  98111. */
  98112. getClassName(): string;
  98113. /**
  98114. * Gets the uv input component
  98115. */
  98116. get uv(): NodeMaterialConnectionPoint;
  98117. /**
  98118. * Gets the rgba output component
  98119. */
  98120. get rgba(): NodeMaterialConnectionPoint;
  98121. /**
  98122. * Gets the rgb output component
  98123. */
  98124. get rgb(): NodeMaterialConnectionPoint;
  98125. /**
  98126. * Gets the r output component
  98127. */
  98128. get r(): NodeMaterialConnectionPoint;
  98129. /**
  98130. * Gets the g output component
  98131. */
  98132. get g(): NodeMaterialConnectionPoint;
  98133. /**
  98134. * Gets the b output component
  98135. */
  98136. get b(): NodeMaterialConnectionPoint;
  98137. /**
  98138. * Gets the a output component
  98139. */
  98140. get a(): NodeMaterialConnectionPoint;
  98141. /**
  98142. * Initialize the block and prepare the context for build
  98143. * @param state defines the state that will be used for the build
  98144. */
  98145. initialize(state: NodeMaterialBuildState): void;
  98146. autoConfigure(material: NodeMaterial): void;
  98147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98148. isReady(): boolean;
  98149. private _writeOutput;
  98150. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98151. serialize(): any;
  98152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98153. }
  98154. }
  98155. declare module BABYLON {
  98156. /**
  98157. * Class used to store shared data between 2 NodeMaterialBuildState
  98158. */
  98159. export class NodeMaterialBuildStateSharedData {
  98160. /**
  98161. * Gets the list of emitted varyings
  98162. */
  98163. temps: string[];
  98164. /**
  98165. * Gets the list of emitted varyings
  98166. */
  98167. varyings: string[];
  98168. /**
  98169. * Gets the varying declaration string
  98170. */
  98171. varyingDeclaration: string;
  98172. /**
  98173. * Input blocks
  98174. */
  98175. inputBlocks: InputBlock[];
  98176. /**
  98177. * Input blocks
  98178. */
  98179. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98180. /**
  98181. * Bindable blocks (Blocks that need to set data to the effect)
  98182. */
  98183. bindableBlocks: NodeMaterialBlock[];
  98184. /**
  98185. * List of blocks that can provide a compilation fallback
  98186. */
  98187. blocksWithFallbacks: NodeMaterialBlock[];
  98188. /**
  98189. * List of blocks that can provide a define update
  98190. */
  98191. blocksWithDefines: NodeMaterialBlock[];
  98192. /**
  98193. * List of blocks that can provide a repeatable content
  98194. */
  98195. repeatableContentBlocks: NodeMaterialBlock[];
  98196. /**
  98197. * List of blocks that can provide a dynamic list of uniforms
  98198. */
  98199. dynamicUniformBlocks: NodeMaterialBlock[];
  98200. /**
  98201. * List of blocks that can block the isReady function for the material
  98202. */
  98203. blockingBlocks: NodeMaterialBlock[];
  98204. /**
  98205. * Gets the list of animated inputs
  98206. */
  98207. animatedInputs: InputBlock[];
  98208. /**
  98209. * Build Id used to avoid multiple recompilations
  98210. */
  98211. buildId: number;
  98212. /** List of emitted variables */
  98213. variableNames: {
  98214. [key: string]: number;
  98215. };
  98216. /** List of emitted defines */
  98217. defineNames: {
  98218. [key: string]: number;
  98219. };
  98220. /** Should emit comments? */
  98221. emitComments: boolean;
  98222. /** Emit build activity */
  98223. verbose: boolean;
  98224. /** Gets or sets the hosting scene */
  98225. scene: Scene;
  98226. /**
  98227. * Gets the compilation hints emitted at compilation time
  98228. */
  98229. hints: {
  98230. needWorldViewMatrix: boolean;
  98231. needWorldViewProjectionMatrix: boolean;
  98232. needAlphaBlending: boolean;
  98233. needAlphaTesting: boolean;
  98234. };
  98235. /**
  98236. * List of compilation checks
  98237. */
  98238. checks: {
  98239. emitVertex: boolean;
  98240. emitFragment: boolean;
  98241. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98242. };
  98243. /**
  98244. * Is vertex program allowed to be empty?
  98245. */
  98246. allowEmptyVertexProgram: boolean;
  98247. /** Creates a new shared data */
  98248. constructor();
  98249. /**
  98250. * Emits console errors and exceptions if there is a failing check
  98251. */
  98252. emitErrors(): void;
  98253. }
  98254. }
  98255. declare module BABYLON {
  98256. /**
  98257. * Class used to store node based material build state
  98258. */
  98259. export class NodeMaterialBuildState {
  98260. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98261. supportUniformBuffers: boolean;
  98262. /**
  98263. * Gets the list of emitted attributes
  98264. */
  98265. attributes: string[];
  98266. /**
  98267. * Gets the list of emitted uniforms
  98268. */
  98269. uniforms: string[];
  98270. /**
  98271. * Gets the list of emitted constants
  98272. */
  98273. constants: string[];
  98274. /**
  98275. * Gets the list of emitted samplers
  98276. */
  98277. samplers: string[];
  98278. /**
  98279. * Gets the list of emitted functions
  98280. */
  98281. functions: {
  98282. [key: string]: string;
  98283. };
  98284. /**
  98285. * Gets the list of emitted extensions
  98286. */
  98287. extensions: {
  98288. [key: string]: string;
  98289. };
  98290. /**
  98291. * Gets the target of the compilation state
  98292. */
  98293. target: NodeMaterialBlockTargets;
  98294. /**
  98295. * Gets the list of emitted counters
  98296. */
  98297. counters: {
  98298. [key: string]: number;
  98299. };
  98300. /**
  98301. * Shared data between multiple NodeMaterialBuildState instances
  98302. */
  98303. sharedData: NodeMaterialBuildStateSharedData;
  98304. /** @hidden */
  98305. _vertexState: NodeMaterialBuildState;
  98306. /** @hidden */
  98307. _attributeDeclaration: string;
  98308. /** @hidden */
  98309. _uniformDeclaration: string;
  98310. /** @hidden */
  98311. _constantDeclaration: string;
  98312. /** @hidden */
  98313. _samplerDeclaration: string;
  98314. /** @hidden */
  98315. _varyingTransfer: string;
  98316. /** @hidden */
  98317. _injectAtEnd: string;
  98318. private _repeatableContentAnchorIndex;
  98319. /** @hidden */
  98320. _builtCompilationString: string;
  98321. /**
  98322. * Gets the emitted compilation strings
  98323. */
  98324. compilationString: string;
  98325. /**
  98326. * Finalize the compilation strings
  98327. * @param state defines the current compilation state
  98328. */
  98329. finalize(state: NodeMaterialBuildState): void;
  98330. /** @hidden */
  98331. get _repeatableContentAnchor(): string;
  98332. /** @hidden */
  98333. _getFreeVariableName(prefix: string): string;
  98334. /** @hidden */
  98335. _getFreeDefineName(prefix: string): string;
  98336. /** @hidden */
  98337. _excludeVariableName(name: string): void;
  98338. /** @hidden */
  98339. _emit2DSampler(name: string): void;
  98340. /** @hidden */
  98341. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98342. /** @hidden */
  98343. _emitExtension(name: string, extension: string, define?: string): void;
  98344. /** @hidden */
  98345. _emitFunction(name: string, code: string, comments: string): void;
  98346. /** @hidden */
  98347. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98348. replaceStrings?: {
  98349. search: RegExp;
  98350. replace: string;
  98351. }[];
  98352. repeatKey?: string;
  98353. }): string;
  98354. /** @hidden */
  98355. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98356. repeatKey?: string;
  98357. removeAttributes?: boolean;
  98358. removeUniforms?: boolean;
  98359. removeVaryings?: boolean;
  98360. removeIfDef?: boolean;
  98361. replaceStrings?: {
  98362. search: RegExp;
  98363. replace: string;
  98364. }[];
  98365. }, storeKey?: string): void;
  98366. /** @hidden */
  98367. _registerTempVariable(name: string): boolean;
  98368. /** @hidden */
  98369. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98370. /** @hidden */
  98371. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98372. /** @hidden */
  98373. _emitFloat(value: number): string;
  98374. }
  98375. }
  98376. declare module BABYLON {
  98377. /**
  98378. * Helper class used to generate session unique ID
  98379. */
  98380. export class UniqueIdGenerator {
  98381. private static _UniqueIdCounter;
  98382. /**
  98383. * Gets an unique (relatively to the current scene) Id
  98384. */
  98385. static get UniqueId(): number;
  98386. }
  98387. }
  98388. declare module BABYLON {
  98389. /**
  98390. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  98391. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  98392. */
  98393. export class EffectFallbacks implements IEffectFallbacks {
  98394. private _defines;
  98395. private _currentRank;
  98396. private _maxRank;
  98397. private _mesh;
  98398. /**
  98399. * Removes the fallback from the bound mesh.
  98400. */
  98401. unBindMesh(): void;
  98402. /**
  98403. * Adds a fallback on the specified property.
  98404. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98405. * @param define The name of the define in the shader
  98406. */
  98407. addFallback(rank: number, define: string): void;
  98408. /**
  98409. * Sets the mesh to use CPU skinning when needing to fallback.
  98410. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98411. * @param mesh The mesh to use the fallbacks.
  98412. */
  98413. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  98414. /**
  98415. * Checks to see if more fallbacks are still availible.
  98416. */
  98417. get hasMoreFallbacks(): boolean;
  98418. /**
  98419. * Removes the defines that should be removed when falling back.
  98420. * @param currentDefines defines the current define statements for the shader.
  98421. * @param effect defines the current effect we try to compile
  98422. * @returns The resulting defines with defines of the current rank removed.
  98423. */
  98424. reduce(currentDefines: string, effect: Effect): string;
  98425. }
  98426. }
  98427. declare module BABYLON {
  98428. /**
  98429. * Defines a block that can be used inside a node based material
  98430. */
  98431. export class NodeMaterialBlock {
  98432. private _buildId;
  98433. private _buildTarget;
  98434. private _target;
  98435. private _isFinalMerger;
  98436. private _isInput;
  98437. private _name;
  98438. protected _isUnique: boolean;
  98439. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98440. inputsAreExclusive: boolean;
  98441. /** @hidden */
  98442. _codeVariableName: string;
  98443. /** @hidden */
  98444. _inputs: NodeMaterialConnectionPoint[];
  98445. /** @hidden */
  98446. _outputs: NodeMaterialConnectionPoint[];
  98447. /** @hidden */
  98448. _preparationId: number;
  98449. /**
  98450. * Gets the name of the block
  98451. */
  98452. get name(): string;
  98453. /**
  98454. * Sets the name of the block. Will check if the name is valid.
  98455. */
  98456. set name(newName: string);
  98457. /**
  98458. * Gets or sets the unique id of the node
  98459. */
  98460. uniqueId: number;
  98461. /**
  98462. * Gets or sets the comments associated with this block
  98463. */
  98464. comments: string;
  98465. /**
  98466. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98467. */
  98468. get isUnique(): boolean;
  98469. /**
  98470. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98471. */
  98472. get isFinalMerger(): boolean;
  98473. /**
  98474. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98475. */
  98476. get isInput(): boolean;
  98477. /**
  98478. * Gets or sets the build Id
  98479. */
  98480. get buildId(): number;
  98481. set buildId(value: number);
  98482. /**
  98483. * Gets or sets the target of the block
  98484. */
  98485. get target(): NodeMaterialBlockTargets;
  98486. set target(value: NodeMaterialBlockTargets);
  98487. /**
  98488. * Gets the list of input points
  98489. */
  98490. get inputs(): NodeMaterialConnectionPoint[];
  98491. /** Gets the list of output points */
  98492. get outputs(): NodeMaterialConnectionPoint[];
  98493. /**
  98494. * Find an input by its name
  98495. * @param name defines the name of the input to look for
  98496. * @returns the input or null if not found
  98497. */
  98498. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98499. /**
  98500. * Find an output by its name
  98501. * @param name defines the name of the outputto look for
  98502. * @returns the output or null if not found
  98503. */
  98504. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98505. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98506. visibleInInspector: boolean;
  98507. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  98508. visibleOnFrame: boolean;
  98509. /**
  98510. * Creates a new NodeMaterialBlock
  98511. * @param name defines the block name
  98512. * @param target defines the target of that block (Vertex by default)
  98513. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98514. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98515. */
  98516. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98517. /**
  98518. * Initialize the block and prepare the context for build
  98519. * @param state defines the state that will be used for the build
  98520. */
  98521. initialize(state: NodeMaterialBuildState): void;
  98522. /**
  98523. * Bind data to effect. Will only be called for blocks with isBindable === true
  98524. * @param effect defines the effect to bind data to
  98525. * @param nodeMaterial defines the hosting NodeMaterial
  98526. * @param mesh defines the mesh that will be rendered
  98527. * @param subMesh defines the submesh that will be rendered
  98528. */
  98529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98530. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98531. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98532. protected _writeFloat(value: number): string;
  98533. /**
  98534. * Gets the current class name e.g. "NodeMaterialBlock"
  98535. * @returns the class name
  98536. */
  98537. getClassName(): string;
  98538. /**
  98539. * Register a new input. Must be called inside a block constructor
  98540. * @param name defines the connection point name
  98541. * @param type defines the connection point type
  98542. * @param isOptional defines a boolean indicating that this input can be omitted
  98543. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98544. * @param point an already created connection point. If not provided, create a new one
  98545. * @returns the current block
  98546. */
  98547. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98548. /**
  98549. * Register a new output. Must be called inside a block constructor
  98550. * @param name defines the connection point name
  98551. * @param type defines the connection point type
  98552. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98553. * @param point an already created connection point. If not provided, create a new one
  98554. * @returns the current block
  98555. */
  98556. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98557. /**
  98558. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98559. * @param forOutput defines an optional connection point to check compatibility with
  98560. * @returns the first available input or null
  98561. */
  98562. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98563. /**
  98564. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98565. * @param forBlock defines an optional block to check compatibility with
  98566. * @returns the first available input or null
  98567. */
  98568. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98569. /**
  98570. * Gets the sibling of the given output
  98571. * @param current defines the current output
  98572. * @returns the next output in the list or null
  98573. */
  98574. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98575. /**
  98576. * Connect current block with another block
  98577. * @param other defines the block to connect with
  98578. * @param options define the various options to help pick the right connections
  98579. * @returns the current block
  98580. */
  98581. connectTo(other: NodeMaterialBlock, options?: {
  98582. input?: string;
  98583. output?: string;
  98584. outputSwizzle?: string;
  98585. }): this | undefined;
  98586. protected _buildBlock(state: NodeMaterialBuildState): void;
  98587. /**
  98588. * Add uniforms, samplers and uniform buffers at compilation time
  98589. * @param state defines the state to update
  98590. * @param nodeMaterial defines the node material requesting the update
  98591. * @param defines defines the material defines to update
  98592. * @param uniformBuffers defines the list of uniform buffer names
  98593. */
  98594. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98595. /**
  98596. * Add potential fallbacks if shader compilation fails
  98597. * @param mesh defines the mesh to be rendered
  98598. * @param fallbacks defines the current prioritized list of fallbacks
  98599. */
  98600. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98601. /**
  98602. * Initialize defines for shader compilation
  98603. * @param mesh defines the mesh to be rendered
  98604. * @param nodeMaterial defines the node material requesting the update
  98605. * @param defines defines the material defines to update
  98606. * @param useInstances specifies that instances should be used
  98607. */
  98608. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98609. /**
  98610. * Update defines for shader compilation
  98611. * @param mesh defines the mesh to be rendered
  98612. * @param nodeMaterial defines the node material requesting the update
  98613. * @param defines defines the material defines to update
  98614. * @param useInstances specifies that instances should be used
  98615. * @param subMesh defines which submesh to render
  98616. */
  98617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98618. /**
  98619. * Lets the block try to connect some inputs automatically
  98620. * @param material defines the hosting NodeMaterial
  98621. */
  98622. autoConfigure(material: NodeMaterial): void;
  98623. /**
  98624. * Function called when a block is declared as repeatable content generator
  98625. * @param vertexShaderState defines the current compilation state for the vertex shader
  98626. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98627. * @param mesh defines the mesh to be rendered
  98628. * @param defines defines the material defines to update
  98629. */
  98630. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98631. /**
  98632. * Checks if the block is ready
  98633. * @param mesh defines the mesh to be rendered
  98634. * @param nodeMaterial defines the node material requesting the update
  98635. * @param defines defines the material defines to update
  98636. * @param useInstances specifies that instances should be used
  98637. * @returns true if the block is ready
  98638. */
  98639. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98640. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  98641. private _processBuild;
  98642. /**
  98643. * Validates the new name for the block node.
  98644. * @param newName the new name to be given to the node.
  98645. * @returns false if the name is a reserve word, else true.
  98646. */
  98647. validateBlockName(newName: string): boolean;
  98648. /**
  98649. * Compile the current node and generate the shader code
  98650. * @param state defines the current compilation state (uniforms, samplers, current string)
  98651. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98652. * @returns true if already built
  98653. */
  98654. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98655. protected _inputRename(name: string): string;
  98656. protected _outputRename(name: string): string;
  98657. protected _dumpPropertiesCode(): string;
  98658. /** @hidden */
  98659. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98660. /** @hidden */
  98661. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98662. /**
  98663. * Clone the current block to a new identical block
  98664. * @param scene defines the hosting scene
  98665. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98666. * @returns a copy of the current block
  98667. */
  98668. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98669. /**
  98670. * Serializes this block in a JSON representation
  98671. * @returns the serialized block object
  98672. */
  98673. serialize(): any;
  98674. /** @hidden */
  98675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98676. private _deserializePortDisplayNamesAndExposedOnFrame;
  98677. /**
  98678. * Release resources
  98679. */
  98680. dispose(): void;
  98681. }
  98682. }
  98683. declare module BABYLON {
  98684. /**
  98685. * Base class of materials working in push mode in babylon JS
  98686. * @hidden
  98687. */
  98688. export class PushMaterial extends Material {
  98689. protected _activeEffect: Effect;
  98690. protected _normalMatrix: Matrix;
  98691. constructor(name: string, scene: Scene);
  98692. getEffect(): Effect;
  98693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98694. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98695. /**
  98696. * Binds the given world matrix to the active effect
  98697. *
  98698. * @param world the matrix to bind
  98699. */
  98700. bindOnlyWorldMatrix(world: Matrix): void;
  98701. /**
  98702. * Binds the given normal matrix to the active effect
  98703. *
  98704. * @param normalMatrix the matrix to bind
  98705. */
  98706. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98707. bind(world: Matrix, mesh?: Mesh): void;
  98708. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98709. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98710. }
  98711. }
  98712. declare module BABYLON {
  98713. /**
  98714. * Root class for all node material optimizers
  98715. */
  98716. export class NodeMaterialOptimizer {
  98717. /**
  98718. * Function used to optimize a NodeMaterial graph
  98719. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98720. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98721. */
  98722. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98723. }
  98724. }
  98725. declare module BABYLON {
  98726. /**
  98727. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98728. */
  98729. export class TransformBlock extends NodeMaterialBlock {
  98730. /**
  98731. * Defines the value to use to complement W value to transform it to a Vector4
  98732. */
  98733. complementW: number;
  98734. /**
  98735. * Defines the value to use to complement z value to transform it to a Vector4
  98736. */
  98737. complementZ: number;
  98738. /**
  98739. * Creates a new TransformBlock
  98740. * @param name defines the block name
  98741. */
  98742. constructor(name: string);
  98743. /**
  98744. * Gets the current class name
  98745. * @returns the class name
  98746. */
  98747. getClassName(): string;
  98748. /**
  98749. * Gets the vector input
  98750. */
  98751. get vector(): NodeMaterialConnectionPoint;
  98752. /**
  98753. * Gets the output component
  98754. */
  98755. get output(): NodeMaterialConnectionPoint;
  98756. /**
  98757. * Gets the xyz output component
  98758. */
  98759. get xyz(): NodeMaterialConnectionPoint;
  98760. /**
  98761. * Gets the matrix transform input
  98762. */
  98763. get transform(): NodeMaterialConnectionPoint;
  98764. protected _buildBlock(state: NodeMaterialBuildState): this;
  98765. /**
  98766. * Update defines for shader compilation
  98767. * @param mesh defines the mesh to be rendered
  98768. * @param nodeMaterial defines the node material requesting the update
  98769. * @param defines defines the material defines to update
  98770. * @param useInstances specifies that instances should be used
  98771. * @param subMesh defines which submesh to render
  98772. */
  98773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98774. serialize(): any;
  98775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98776. protected _dumpPropertiesCode(): string;
  98777. }
  98778. }
  98779. declare module BABYLON {
  98780. /**
  98781. * Block used to output the vertex position
  98782. */
  98783. export class VertexOutputBlock extends NodeMaterialBlock {
  98784. /**
  98785. * Creates a new VertexOutputBlock
  98786. * @param name defines the block name
  98787. */
  98788. constructor(name: string);
  98789. /**
  98790. * Gets the current class name
  98791. * @returns the class name
  98792. */
  98793. getClassName(): string;
  98794. /**
  98795. * Gets the vector input component
  98796. */
  98797. get vector(): NodeMaterialConnectionPoint;
  98798. protected _buildBlock(state: NodeMaterialBuildState): this;
  98799. }
  98800. }
  98801. declare module BABYLON {
  98802. /**
  98803. * Block used to output the final color
  98804. */
  98805. export class FragmentOutputBlock extends NodeMaterialBlock {
  98806. /**
  98807. * Create a new FragmentOutputBlock
  98808. * @param name defines the block name
  98809. */
  98810. constructor(name: string);
  98811. /**
  98812. * Gets the current class name
  98813. * @returns the class name
  98814. */
  98815. getClassName(): string;
  98816. /**
  98817. * Gets the rgba input component
  98818. */
  98819. get rgba(): NodeMaterialConnectionPoint;
  98820. /**
  98821. * Gets the rgb input component
  98822. */
  98823. get rgb(): NodeMaterialConnectionPoint;
  98824. /**
  98825. * Gets the a input component
  98826. */
  98827. get a(): NodeMaterialConnectionPoint;
  98828. protected _buildBlock(state: NodeMaterialBuildState): this;
  98829. }
  98830. }
  98831. declare module BABYLON {
  98832. /**
  98833. * Block used for the particle ramp gradient section
  98834. */
  98835. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98836. /**
  98837. * Create a new ParticleRampGradientBlock
  98838. * @param name defines the block name
  98839. */
  98840. constructor(name: string);
  98841. /**
  98842. * Gets the current class name
  98843. * @returns the class name
  98844. */
  98845. getClassName(): string;
  98846. /**
  98847. * Gets the color input component
  98848. */
  98849. get color(): NodeMaterialConnectionPoint;
  98850. /**
  98851. * Gets the rampColor output component
  98852. */
  98853. get rampColor(): NodeMaterialConnectionPoint;
  98854. /**
  98855. * Initialize the block and prepare the context for build
  98856. * @param state defines the state that will be used for the build
  98857. */
  98858. initialize(state: NodeMaterialBuildState): void;
  98859. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98860. }
  98861. }
  98862. declare module BABYLON {
  98863. /**
  98864. * Block used for the particle blend multiply section
  98865. */
  98866. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98867. /**
  98868. * Create a new ParticleBlendMultiplyBlock
  98869. * @param name defines the block name
  98870. */
  98871. constructor(name: string);
  98872. /**
  98873. * Gets the current class name
  98874. * @returns the class name
  98875. */
  98876. getClassName(): string;
  98877. /**
  98878. * Gets the color input component
  98879. */
  98880. get color(): NodeMaterialConnectionPoint;
  98881. /**
  98882. * Gets the alphaTexture input component
  98883. */
  98884. get alphaTexture(): NodeMaterialConnectionPoint;
  98885. /**
  98886. * Gets the alphaColor input component
  98887. */
  98888. get alphaColor(): NodeMaterialConnectionPoint;
  98889. /**
  98890. * Gets the blendColor output component
  98891. */
  98892. get blendColor(): NodeMaterialConnectionPoint;
  98893. /**
  98894. * Initialize the block and prepare the context for build
  98895. * @param state defines the state that will be used for the build
  98896. */
  98897. initialize(state: NodeMaterialBuildState): void;
  98898. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98899. }
  98900. }
  98901. declare module BABYLON {
  98902. /**
  98903. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98904. */
  98905. export class VectorMergerBlock extends NodeMaterialBlock {
  98906. /**
  98907. * Create a new VectorMergerBlock
  98908. * @param name defines the block name
  98909. */
  98910. constructor(name: string);
  98911. /**
  98912. * Gets the current class name
  98913. * @returns the class name
  98914. */
  98915. getClassName(): string;
  98916. /**
  98917. * Gets the xyz component (input)
  98918. */
  98919. get xyzIn(): NodeMaterialConnectionPoint;
  98920. /**
  98921. * Gets the xy component (input)
  98922. */
  98923. get xyIn(): NodeMaterialConnectionPoint;
  98924. /**
  98925. * Gets the x component (input)
  98926. */
  98927. get x(): NodeMaterialConnectionPoint;
  98928. /**
  98929. * Gets the y component (input)
  98930. */
  98931. get y(): NodeMaterialConnectionPoint;
  98932. /**
  98933. * Gets the z component (input)
  98934. */
  98935. get z(): NodeMaterialConnectionPoint;
  98936. /**
  98937. * Gets the w component (input)
  98938. */
  98939. get w(): NodeMaterialConnectionPoint;
  98940. /**
  98941. * Gets the xyzw component (output)
  98942. */
  98943. get xyzw(): NodeMaterialConnectionPoint;
  98944. /**
  98945. * Gets the xyz component (output)
  98946. */
  98947. get xyzOut(): NodeMaterialConnectionPoint;
  98948. /**
  98949. * Gets the xy component (output)
  98950. */
  98951. get xyOut(): NodeMaterialConnectionPoint;
  98952. /**
  98953. * Gets the xy component (output)
  98954. * @deprecated Please use xyOut instead.
  98955. */
  98956. get xy(): NodeMaterialConnectionPoint;
  98957. /**
  98958. * Gets the xyz component (output)
  98959. * @deprecated Please use xyzOut instead.
  98960. */
  98961. get xyz(): NodeMaterialConnectionPoint;
  98962. protected _buildBlock(state: NodeMaterialBuildState): this;
  98963. }
  98964. }
  98965. declare module BABYLON {
  98966. /**
  98967. * Block used to remap a float from a range to a new one
  98968. */
  98969. export class RemapBlock extends NodeMaterialBlock {
  98970. /**
  98971. * Gets or sets the source range
  98972. */
  98973. sourceRange: Vector2;
  98974. /**
  98975. * Gets or sets the target range
  98976. */
  98977. targetRange: Vector2;
  98978. /**
  98979. * Creates a new RemapBlock
  98980. * @param name defines the block name
  98981. */
  98982. constructor(name: string);
  98983. /**
  98984. * Gets the current class name
  98985. * @returns the class name
  98986. */
  98987. getClassName(): string;
  98988. /**
  98989. * Gets the input component
  98990. */
  98991. get input(): NodeMaterialConnectionPoint;
  98992. /**
  98993. * Gets the source min input component
  98994. */
  98995. get sourceMin(): NodeMaterialConnectionPoint;
  98996. /**
  98997. * Gets the source max input component
  98998. */
  98999. get sourceMax(): NodeMaterialConnectionPoint;
  99000. /**
  99001. * Gets the target min input component
  99002. */
  99003. get targetMin(): NodeMaterialConnectionPoint;
  99004. /**
  99005. * Gets the target max input component
  99006. */
  99007. get targetMax(): NodeMaterialConnectionPoint;
  99008. /**
  99009. * Gets the output component
  99010. */
  99011. get output(): NodeMaterialConnectionPoint;
  99012. protected _buildBlock(state: NodeMaterialBuildState): this;
  99013. protected _dumpPropertiesCode(): string;
  99014. serialize(): any;
  99015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99016. }
  99017. }
  99018. declare module BABYLON {
  99019. /**
  99020. * Block used to multiply 2 values
  99021. */
  99022. export class MultiplyBlock extends NodeMaterialBlock {
  99023. /**
  99024. * Creates a new MultiplyBlock
  99025. * @param name defines the block name
  99026. */
  99027. constructor(name: string);
  99028. /**
  99029. * Gets the current class name
  99030. * @returns the class name
  99031. */
  99032. getClassName(): string;
  99033. /**
  99034. * Gets the left operand input component
  99035. */
  99036. get left(): NodeMaterialConnectionPoint;
  99037. /**
  99038. * Gets the right operand input component
  99039. */
  99040. get right(): NodeMaterialConnectionPoint;
  99041. /**
  99042. * Gets the output component
  99043. */
  99044. get output(): NodeMaterialConnectionPoint;
  99045. protected _buildBlock(state: NodeMaterialBuildState): this;
  99046. }
  99047. }
  99048. declare module BABYLON {
  99049. /** Interface used by value gradients (color, factor, ...) */
  99050. export interface IValueGradient {
  99051. /**
  99052. * Gets or sets the gradient value (between 0 and 1)
  99053. */
  99054. gradient: number;
  99055. }
  99056. /** Class used to store color4 gradient */
  99057. export class ColorGradient implements IValueGradient {
  99058. /**
  99059. * Gets or sets the gradient value (between 0 and 1)
  99060. */
  99061. gradient: number;
  99062. /**
  99063. * Gets or sets first associated color
  99064. */
  99065. color1: Color4;
  99066. /**
  99067. * Gets or sets second associated color
  99068. */
  99069. color2?: Color4 | undefined;
  99070. /**
  99071. * Creates a new color4 gradient
  99072. * @param gradient gets or sets the gradient value (between 0 and 1)
  99073. * @param color1 gets or sets first associated color
  99074. * @param color2 gets or sets first second color
  99075. */
  99076. constructor(
  99077. /**
  99078. * Gets or sets the gradient value (between 0 and 1)
  99079. */
  99080. gradient: number,
  99081. /**
  99082. * Gets or sets first associated color
  99083. */
  99084. color1: Color4,
  99085. /**
  99086. * Gets or sets second associated color
  99087. */
  99088. color2?: Color4 | undefined);
  99089. /**
  99090. * Will get a color picked randomly between color1 and color2.
  99091. * If color2 is undefined then color1 will be used
  99092. * @param result defines the target Color4 to store the result in
  99093. */
  99094. getColorToRef(result: Color4): void;
  99095. }
  99096. /** Class used to store color 3 gradient */
  99097. export class Color3Gradient implements IValueGradient {
  99098. /**
  99099. * Gets or sets the gradient value (between 0 and 1)
  99100. */
  99101. gradient: number;
  99102. /**
  99103. * Gets or sets the associated color
  99104. */
  99105. color: Color3;
  99106. /**
  99107. * Creates a new color3 gradient
  99108. * @param gradient gets or sets the gradient value (between 0 and 1)
  99109. * @param color gets or sets associated color
  99110. */
  99111. constructor(
  99112. /**
  99113. * Gets or sets the gradient value (between 0 and 1)
  99114. */
  99115. gradient: number,
  99116. /**
  99117. * Gets or sets the associated color
  99118. */
  99119. color: Color3);
  99120. }
  99121. /** Class used to store factor gradient */
  99122. export class FactorGradient implements IValueGradient {
  99123. /**
  99124. * Gets or sets the gradient value (between 0 and 1)
  99125. */
  99126. gradient: number;
  99127. /**
  99128. * Gets or sets first associated factor
  99129. */
  99130. factor1: number;
  99131. /**
  99132. * Gets or sets second associated factor
  99133. */
  99134. factor2?: number | undefined;
  99135. /**
  99136. * Creates a new factor gradient
  99137. * @param gradient gets or sets the gradient value (between 0 and 1)
  99138. * @param factor1 gets or sets first associated factor
  99139. * @param factor2 gets or sets second associated factor
  99140. */
  99141. constructor(
  99142. /**
  99143. * Gets or sets the gradient value (between 0 and 1)
  99144. */
  99145. gradient: number,
  99146. /**
  99147. * Gets or sets first associated factor
  99148. */
  99149. factor1: number,
  99150. /**
  99151. * Gets or sets second associated factor
  99152. */
  99153. factor2?: number | undefined);
  99154. /**
  99155. * Will get a number picked randomly between factor1 and factor2.
  99156. * If factor2 is undefined then factor1 will be used
  99157. * @returns the picked number
  99158. */
  99159. getFactor(): number;
  99160. }
  99161. /**
  99162. * Helper used to simplify some generic gradient tasks
  99163. */
  99164. export class GradientHelper {
  99165. /**
  99166. * Gets the current gradient from an array of IValueGradient
  99167. * @param ratio defines the current ratio to get
  99168. * @param gradients defines the array of IValueGradient
  99169. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99170. */
  99171. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  99172. }
  99173. }
  99174. declare module BABYLON {
  99175. interface ThinEngine {
  99176. /**
  99177. * Creates a raw texture
  99178. * @param data defines the data to store in the texture
  99179. * @param width defines the width of the texture
  99180. * @param height defines the height of the texture
  99181. * @param format defines the format of the data
  99182. * @param generateMipMaps defines if the engine should generate the mip levels
  99183. * @param invertY defines if data must be stored with Y axis inverted
  99184. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  99185. * @param compression defines the compression used (null by default)
  99186. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99187. * @returns the raw texture inside an InternalTexture
  99188. */
  99189. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  99190. /**
  99191. * Update a raw texture
  99192. * @param texture defines the texture to update
  99193. * @param data defines the data to store in the texture
  99194. * @param format defines the format of the data
  99195. * @param invertY defines if data must be stored with Y axis inverted
  99196. */
  99197. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99198. /**
  99199. * Update a raw texture
  99200. * @param texture defines the texture to update
  99201. * @param data defines the data to store in the texture
  99202. * @param format defines the format of the data
  99203. * @param invertY defines if data must be stored with Y axis inverted
  99204. * @param compression defines the compression used (null by default)
  99205. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99206. */
  99207. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  99208. /**
  99209. * Creates a new raw cube texture
  99210. * @param data defines the array of data to use to create each face
  99211. * @param size defines the size of the textures
  99212. * @param format defines the format of the data
  99213. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99214. * @param generateMipMaps defines if the engine should generate the mip levels
  99215. * @param invertY defines if data must be stored with Y axis inverted
  99216. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99217. * @param compression defines the compression used (null by default)
  99218. * @returns the cube texture as an InternalTexture
  99219. */
  99220. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  99221. /**
  99222. * Update a raw cube texture
  99223. * @param texture defines the texture to udpdate
  99224. * @param data defines the data to store
  99225. * @param format defines the data format
  99226. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99227. * @param invertY defines if data must be stored with Y axis inverted
  99228. */
  99229. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  99230. /**
  99231. * Update a raw cube texture
  99232. * @param texture defines the texture to udpdate
  99233. * @param data defines the data to store
  99234. * @param format defines the data format
  99235. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99236. * @param invertY defines if data must be stored with Y axis inverted
  99237. * @param compression defines the compression used (null by default)
  99238. */
  99239. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  99240. /**
  99241. * Update a raw cube texture
  99242. * @param texture defines the texture to udpdate
  99243. * @param data defines the data to store
  99244. * @param format defines the data format
  99245. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99246. * @param invertY defines if data must be stored with Y axis inverted
  99247. * @param compression defines the compression used (null by default)
  99248. * @param level defines which level of the texture to update
  99249. */
  99250. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  99251. /**
  99252. * Creates a new raw cube texture from a specified url
  99253. * @param url defines the url where the data is located
  99254. * @param scene defines the current scene
  99255. * @param size defines the size of the textures
  99256. * @param format defines the format of the data
  99257. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99258. * @param noMipmap defines if the engine should avoid generating the mip levels
  99259. * @param callback defines a callback used to extract texture data from loaded data
  99260. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99261. * @param onLoad defines a callback called when texture is loaded
  99262. * @param onError defines a callback called if there is an error
  99263. * @returns the cube texture as an InternalTexture
  99264. */
  99265. 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;
  99266. /**
  99267. * Creates a new raw cube texture from a specified url
  99268. * @param url defines the url where the data is located
  99269. * @param scene defines the current scene
  99270. * @param size defines the size of the textures
  99271. * @param format defines the format of the data
  99272. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99273. * @param noMipmap defines if the engine should avoid generating the mip levels
  99274. * @param callback defines a callback used to extract texture data from loaded data
  99275. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99276. * @param onLoad defines a callback called when texture is loaded
  99277. * @param onError defines a callback called if there is an error
  99278. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99279. * @param invertY defines if data must be stored with Y axis inverted
  99280. * @returns the cube texture as an InternalTexture
  99281. */
  99282. 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;
  99283. /**
  99284. * Creates a new raw 3D texture
  99285. * @param data defines the data used to create the texture
  99286. * @param width defines the width of the texture
  99287. * @param height defines the height of the texture
  99288. * @param depth defines the depth of the texture
  99289. * @param format defines the format of the texture
  99290. * @param generateMipMaps defines if the engine must generate mip levels
  99291. * @param invertY defines if data must be stored with Y axis inverted
  99292. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99293. * @param compression defines the compressed used (can be null)
  99294. * @param textureType defines the compressed used (can be null)
  99295. * @returns a new raw 3D texture (stored in an InternalTexture)
  99296. */
  99297. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99298. /**
  99299. * Update a raw 3D texture
  99300. * @param texture defines the texture to update
  99301. * @param data defines the data to store
  99302. * @param format defines the data format
  99303. * @param invertY defines if data must be stored with Y axis inverted
  99304. */
  99305. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99306. /**
  99307. * Update a raw 3D texture
  99308. * @param texture defines the texture to update
  99309. * @param data defines the data to store
  99310. * @param format defines the data format
  99311. * @param invertY defines if data must be stored with Y axis inverted
  99312. * @param compression defines the used compression (can be null)
  99313. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99314. */
  99315. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99316. /**
  99317. * Creates a new raw 2D array texture
  99318. * @param data defines the data used to create the texture
  99319. * @param width defines the width of the texture
  99320. * @param height defines the height of the texture
  99321. * @param depth defines the number of layers of the texture
  99322. * @param format defines the format of the texture
  99323. * @param generateMipMaps defines if the engine must generate mip levels
  99324. * @param invertY defines if data must be stored with Y axis inverted
  99325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99326. * @param compression defines the compressed used (can be null)
  99327. * @param textureType defines the compressed used (can be null)
  99328. * @returns a new raw 2D array texture (stored in an InternalTexture)
  99329. */
  99330. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99331. /**
  99332. * Update a raw 2D array texture
  99333. * @param texture defines the texture to update
  99334. * @param data defines the data to store
  99335. * @param format defines the data format
  99336. * @param invertY defines if data must be stored with Y axis inverted
  99337. */
  99338. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99339. /**
  99340. * Update a raw 2D array texture
  99341. * @param texture defines the texture to update
  99342. * @param data defines the data to store
  99343. * @param format defines the data format
  99344. * @param invertY defines if data must be stored with Y axis inverted
  99345. * @param compression defines the used compression (can be null)
  99346. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99347. */
  99348. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99349. }
  99350. }
  99351. declare module BABYLON {
  99352. /**
  99353. * Raw texture can help creating a texture directly from an array of data.
  99354. * This can be super useful if you either get the data from an uncompressed source or
  99355. * if you wish to create your texture pixel by pixel.
  99356. */
  99357. export class RawTexture extends Texture {
  99358. /**
  99359. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99360. */
  99361. format: number;
  99362. /**
  99363. * Instantiates a new RawTexture.
  99364. * Raw texture can help creating a texture directly from an array of data.
  99365. * This can be super useful if you either get the data from an uncompressed source or
  99366. * if you wish to create your texture pixel by pixel.
  99367. * @param data define the array of data to use to create the texture
  99368. * @param width define the width of the texture
  99369. * @param height define the height of the texture
  99370. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99371. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99372. * @param generateMipMaps define whether mip maps should be generated or not
  99373. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99374. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99375. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99376. */
  99377. constructor(data: ArrayBufferView, width: number, height: number,
  99378. /**
  99379. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99380. */
  99381. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  99382. /**
  99383. * Updates the texture underlying data.
  99384. * @param data Define the new data of the texture
  99385. */
  99386. update(data: ArrayBufferView): void;
  99387. /**
  99388. * Creates a luminance texture from some data.
  99389. * @param data Define the texture data
  99390. * @param width Define the width of the texture
  99391. * @param height Define the height of the texture
  99392. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99393. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99394. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99395. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99396. * @returns the luminance texture
  99397. */
  99398. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99399. /**
  99400. * Creates a luminance alpha texture from some data.
  99401. * @param data Define the texture data
  99402. * @param width Define the width of the texture
  99403. * @param height Define the height of the texture
  99404. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99405. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99406. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99407. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99408. * @returns the luminance alpha texture
  99409. */
  99410. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99411. /**
  99412. * Creates an alpha texture from some data.
  99413. * @param data Define the texture data
  99414. * @param width Define the width of the texture
  99415. * @param height Define the height of the texture
  99416. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99420. * @returns the alpha texture
  99421. */
  99422. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99423. /**
  99424. * Creates a RGB texture from some data.
  99425. * @param data Define the texture data
  99426. * @param width Define the width of the texture
  99427. * @param height Define the height of the texture
  99428. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99432. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99433. * @returns the RGB alpha texture
  99434. */
  99435. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99436. /**
  99437. * Creates a RGBA texture from some data.
  99438. * @param data Define the texture data
  99439. * @param width Define the width of the texture
  99440. * @param height Define the height of the texture
  99441. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99442. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99443. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99444. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99445. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99446. * @returns the RGBA texture
  99447. */
  99448. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99449. /**
  99450. * Creates a R texture from some data.
  99451. * @param data Define the texture data
  99452. * @param width Define the width of the texture
  99453. * @param height Define the height of the texture
  99454. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99455. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99456. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99457. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99458. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99459. * @returns the R texture
  99460. */
  99461. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99462. }
  99463. }
  99464. declare module BABYLON {
  99465. interface ThinEngine {
  99466. /**
  99467. * Update a dynamic index buffer
  99468. * @param indexBuffer defines the target index buffer
  99469. * @param indices defines the data to update
  99470. * @param offset defines the offset in the target index buffer where update should start
  99471. */
  99472. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99473. /**
  99474. * Updates a dynamic vertex buffer.
  99475. * @param vertexBuffer the vertex buffer to update
  99476. * @param data the data used to update the vertex buffer
  99477. * @param byteOffset the byte offset of the data
  99478. * @param byteLength the byte length of the data
  99479. */
  99480. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99481. }
  99482. }
  99483. declare module BABYLON {
  99484. interface AbstractScene {
  99485. /**
  99486. * The list of procedural textures added to the scene
  99487. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99488. */
  99489. proceduralTextures: Array<ProceduralTexture>;
  99490. }
  99491. /**
  99492. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  99493. * in a given scene.
  99494. */
  99495. export class ProceduralTextureSceneComponent implements ISceneComponent {
  99496. /**
  99497. * The component name helpfull to identify the component in the list of scene components.
  99498. */
  99499. readonly name: string;
  99500. /**
  99501. * The scene the component belongs to.
  99502. */
  99503. scene: Scene;
  99504. /**
  99505. * Creates a new instance of the component for the given scene
  99506. * @param scene Defines the scene to register the component in
  99507. */
  99508. constructor(scene: Scene);
  99509. /**
  99510. * Registers the component in a given scene
  99511. */
  99512. register(): void;
  99513. /**
  99514. * Rebuilds the elements related to this component in case of
  99515. * context lost for instance.
  99516. */
  99517. rebuild(): void;
  99518. /**
  99519. * Disposes the component and the associated ressources.
  99520. */
  99521. dispose(): void;
  99522. private _beforeClear;
  99523. }
  99524. }
  99525. declare module BABYLON {
  99526. interface ThinEngine {
  99527. /**
  99528. * Creates a new render target cube texture
  99529. * @param size defines the size of the texture
  99530. * @param options defines the options used to create the texture
  99531. * @returns a new render target cube texture stored in an InternalTexture
  99532. */
  99533. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  99534. }
  99535. }
  99536. declare module BABYLON {
  99537. /** @hidden */
  99538. export var proceduralVertexShader: {
  99539. name: string;
  99540. shader: string;
  99541. };
  99542. }
  99543. declare module BABYLON {
  99544. /**
  99545. * 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.
  99546. * This is the base class of any Procedural texture and contains most of the shareable code.
  99547. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99548. */
  99549. export class ProceduralTexture extends Texture {
  99550. /**
  99551. * Define if the texture is enabled or not (disabled texture will not render)
  99552. */
  99553. isEnabled: boolean;
  99554. /**
  99555. * Define if the texture must be cleared before rendering (default is true)
  99556. */
  99557. autoClear: boolean;
  99558. /**
  99559. * Callback called when the texture is generated
  99560. */
  99561. onGenerated: () => void;
  99562. /**
  99563. * Event raised when the texture is generated
  99564. */
  99565. onGeneratedObservable: Observable<ProceduralTexture>;
  99566. /**
  99567. * Event raised before the texture is generated
  99568. */
  99569. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  99570. /**
  99571. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  99572. */
  99573. nodeMaterialSource: Nullable<NodeMaterial>;
  99574. /** @hidden */
  99575. _generateMipMaps: boolean;
  99576. /** @hidden **/
  99577. _effect: Effect;
  99578. /** @hidden */
  99579. _textures: {
  99580. [key: string]: Texture;
  99581. };
  99582. /** @hidden */
  99583. protected _fallbackTexture: Nullable<Texture>;
  99584. private _size;
  99585. private _textureType;
  99586. private _currentRefreshId;
  99587. private _frameId;
  99588. private _refreshRate;
  99589. private _vertexBuffers;
  99590. private _indexBuffer;
  99591. private _uniforms;
  99592. private _samplers;
  99593. private _fragment;
  99594. private _floats;
  99595. private _ints;
  99596. private _floatsArrays;
  99597. private _colors3;
  99598. private _colors4;
  99599. private _vectors2;
  99600. private _vectors3;
  99601. private _matrices;
  99602. private _fallbackTextureUsed;
  99603. private _fullEngine;
  99604. private _cachedDefines;
  99605. private _contentUpdateId;
  99606. private _contentData;
  99607. /**
  99608. * Instantiates a new procedural texture.
  99609. * 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.
  99610. * This is the base class of any Procedural texture and contains most of the shareable code.
  99611. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99612. * @param name Define the name of the texture
  99613. * @param size Define the size of the texture to create
  99614. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  99615. * @param scene Define the scene the texture belongs to
  99616. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  99617. * @param generateMipMaps Define if the texture should creates mip maps or not
  99618. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  99619. * @param textureType The FBO internal texture type
  99620. */
  99621. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  99622. /**
  99623. * The effect that is created when initializing the post process.
  99624. * @returns The created effect corresponding the the postprocess.
  99625. */
  99626. getEffect(): Effect;
  99627. /**
  99628. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  99629. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  99630. */
  99631. getContent(): Nullable<Promise<ArrayBufferView>>;
  99632. private _createIndexBuffer;
  99633. /** @hidden */
  99634. _rebuild(): void;
  99635. /**
  99636. * Resets the texture in order to recreate its associated resources.
  99637. * This can be called in case of context loss
  99638. */
  99639. reset(): void;
  99640. protected _getDefines(): string;
  99641. /**
  99642. * Is the texture ready to be used ? (rendered at least once)
  99643. * @returns true if ready, otherwise, false.
  99644. */
  99645. isReady(): boolean;
  99646. /**
  99647. * Resets the refresh counter of the texture and start bak from scratch.
  99648. * Could be useful to regenerate the texture if it is setup to render only once.
  99649. */
  99650. resetRefreshCounter(): void;
  99651. /**
  99652. * Set the fragment shader to use in order to render the texture.
  99653. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  99654. */
  99655. setFragment(fragment: any): void;
  99656. /**
  99657. * Define the refresh rate of the texture or the rendering frequency.
  99658. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  99659. */
  99660. get refreshRate(): number;
  99661. set refreshRate(value: number);
  99662. /** @hidden */
  99663. _shouldRender(): boolean;
  99664. /**
  99665. * Get the size the texture is rendering at.
  99666. * @returns the size (on cube texture it is always squared)
  99667. */
  99668. getRenderSize(): RenderTargetTextureSize;
  99669. /**
  99670. * Resize the texture to new value.
  99671. * @param size Define the new size the texture should have
  99672. * @param generateMipMaps Define whether the new texture should create mip maps
  99673. */
  99674. resize(size: number, generateMipMaps: boolean): void;
  99675. private _checkUniform;
  99676. /**
  99677. * Set a texture in the shader program used to render.
  99678. * @param name Define the name of the uniform samplers as defined in the shader
  99679. * @param texture Define the texture to bind to this sampler
  99680. * @return the texture itself allowing "fluent" like uniform updates
  99681. */
  99682. setTexture(name: string, texture: Texture): ProceduralTexture;
  99683. /**
  99684. * Set a float in the shader.
  99685. * @param name Define the name of the uniform as defined in the shader
  99686. * @param value Define the value to give to the uniform
  99687. * @return the texture itself allowing "fluent" like uniform updates
  99688. */
  99689. setFloat(name: string, value: number): ProceduralTexture;
  99690. /**
  99691. * Set a int in the shader.
  99692. * @param name Define the name of the uniform as defined in the shader
  99693. * @param value Define the value to give to the uniform
  99694. * @return the texture itself allowing "fluent" like uniform updates
  99695. */
  99696. setInt(name: string, value: number): ProceduralTexture;
  99697. /**
  99698. * Set an array of floats in the shader.
  99699. * @param name Define the name of the uniform as defined in the shader
  99700. * @param value Define the value to give to the uniform
  99701. * @return the texture itself allowing "fluent" like uniform updates
  99702. */
  99703. setFloats(name: string, value: number[]): ProceduralTexture;
  99704. /**
  99705. * Set a vec3 in the shader from a Color3.
  99706. * @param name Define the name of the uniform as defined in the shader
  99707. * @param value Define the value to give to the uniform
  99708. * @return the texture itself allowing "fluent" like uniform updates
  99709. */
  99710. setColor3(name: string, value: Color3): ProceduralTexture;
  99711. /**
  99712. * Set a vec4 in the shader from a Color4.
  99713. * @param name Define the name of the uniform as defined in the shader
  99714. * @param value Define the value to give to the uniform
  99715. * @return the texture itself allowing "fluent" like uniform updates
  99716. */
  99717. setColor4(name: string, value: Color4): ProceduralTexture;
  99718. /**
  99719. * Set a vec2 in the shader from a Vector2.
  99720. * @param name Define the name of the uniform as defined in the shader
  99721. * @param value Define the value to give to the uniform
  99722. * @return the texture itself allowing "fluent" like uniform updates
  99723. */
  99724. setVector2(name: string, value: Vector2): ProceduralTexture;
  99725. /**
  99726. * Set a vec3 in the shader from a Vector3.
  99727. * @param name Define the name of the uniform as defined in the shader
  99728. * @param value Define the value to give to the uniform
  99729. * @return the texture itself allowing "fluent" like uniform updates
  99730. */
  99731. setVector3(name: string, value: Vector3): ProceduralTexture;
  99732. /**
  99733. * Set a mat4 in the shader from a MAtrix.
  99734. * @param name Define the name of the uniform as defined in the shader
  99735. * @param value Define the value to give to the uniform
  99736. * @return the texture itself allowing "fluent" like uniform updates
  99737. */
  99738. setMatrix(name: string, value: Matrix): ProceduralTexture;
  99739. /**
  99740. * Render the texture to its associated render target.
  99741. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  99742. */
  99743. render(useCameraPostProcess?: boolean): void;
  99744. /**
  99745. * Clone the texture.
  99746. * @returns the cloned texture
  99747. */
  99748. clone(): ProceduralTexture;
  99749. /**
  99750. * Dispose the texture and release its asoociated resources.
  99751. */
  99752. dispose(): void;
  99753. }
  99754. }
  99755. declare module BABYLON {
  99756. /**
  99757. * This represents the base class for particle system in Babylon.
  99758. * 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.
  99759. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  99760. * @example https://doc.babylonjs.com/babylon101/particles
  99761. */
  99762. export class BaseParticleSystem {
  99763. /**
  99764. * Source color is added to the destination color without alpha affecting the result
  99765. */
  99766. static BLENDMODE_ONEONE: number;
  99767. /**
  99768. * Blend current color and particle color using particle’s alpha
  99769. */
  99770. static BLENDMODE_STANDARD: number;
  99771. /**
  99772. * Add current color and particle color multiplied by particle’s alpha
  99773. */
  99774. static BLENDMODE_ADD: number;
  99775. /**
  99776. * Multiply current color with particle color
  99777. */
  99778. static BLENDMODE_MULTIPLY: number;
  99779. /**
  99780. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  99781. */
  99782. static BLENDMODE_MULTIPLYADD: number;
  99783. /**
  99784. * List of animations used by the particle system.
  99785. */
  99786. animations: Animation[];
  99787. /**
  99788. * Gets or sets the unique id of the particle system
  99789. */
  99790. uniqueId: number;
  99791. /**
  99792. * The id of the Particle system.
  99793. */
  99794. id: string;
  99795. /**
  99796. * The friendly name of the Particle system.
  99797. */
  99798. name: string;
  99799. /**
  99800. * Snippet ID if the particle system was created from the snippet server
  99801. */
  99802. snippetId: string;
  99803. /**
  99804. * The rendering group used by the Particle system to chose when to render.
  99805. */
  99806. renderingGroupId: number;
  99807. /**
  99808. * The emitter represents the Mesh or position we are attaching the particle system to.
  99809. */
  99810. emitter: Nullable<AbstractMesh | Vector3>;
  99811. /**
  99812. * The maximum number of particles to emit per frame
  99813. */
  99814. emitRate: number;
  99815. /**
  99816. * If you want to launch only a few particles at once, that can be done, as well.
  99817. */
  99818. manualEmitCount: number;
  99819. /**
  99820. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  99821. */
  99822. updateSpeed: number;
  99823. /**
  99824. * The amount of time the particle system is running (depends of the overall update speed).
  99825. */
  99826. targetStopDuration: number;
  99827. /**
  99828. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  99829. */
  99830. disposeOnStop: boolean;
  99831. /**
  99832. * Minimum power of emitting particles.
  99833. */
  99834. minEmitPower: number;
  99835. /**
  99836. * Maximum power of emitting particles.
  99837. */
  99838. maxEmitPower: number;
  99839. /**
  99840. * Minimum life time of emitting particles.
  99841. */
  99842. minLifeTime: number;
  99843. /**
  99844. * Maximum life time of emitting particles.
  99845. */
  99846. maxLifeTime: number;
  99847. /**
  99848. * Minimum Size of emitting particles.
  99849. */
  99850. minSize: number;
  99851. /**
  99852. * Maximum Size of emitting particles.
  99853. */
  99854. maxSize: number;
  99855. /**
  99856. * Minimum scale of emitting particles on X axis.
  99857. */
  99858. minScaleX: number;
  99859. /**
  99860. * Maximum scale of emitting particles on X axis.
  99861. */
  99862. maxScaleX: number;
  99863. /**
  99864. * Minimum scale of emitting particles on Y axis.
  99865. */
  99866. minScaleY: number;
  99867. /**
  99868. * Maximum scale of emitting particles on Y axis.
  99869. */
  99870. maxScaleY: number;
  99871. /**
  99872. * Gets or sets the minimal initial rotation in radians.
  99873. */
  99874. minInitialRotation: number;
  99875. /**
  99876. * Gets or sets the maximal initial rotation in radians.
  99877. */
  99878. maxInitialRotation: number;
  99879. /**
  99880. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  99881. */
  99882. minAngularSpeed: number;
  99883. /**
  99884. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  99885. */
  99886. maxAngularSpeed: number;
  99887. /**
  99888. * The texture used to render each particle. (this can be a spritesheet)
  99889. */
  99890. particleTexture: Nullable<BaseTexture>;
  99891. /**
  99892. * The layer mask we are rendering the particles through.
  99893. */
  99894. layerMask: number;
  99895. /**
  99896. * This can help using your own shader to render the particle system.
  99897. * The according effect will be created
  99898. */
  99899. customShader: any;
  99900. /**
  99901. * By default particle system starts as soon as they are created. This prevents the
  99902. * automatic start to happen and let you decide when to start emitting particles.
  99903. */
  99904. preventAutoStart: boolean;
  99905. private _noiseTexture;
  99906. /**
  99907. * Gets or sets a texture used to add random noise to particle positions
  99908. */
  99909. get noiseTexture(): Nullable<ProceduralTexture>;
  99910. set noiseTexture(value: Nullable<ProceduralTexture>);
  99911. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  99912. noiseStrength: Vector3;
  99913. /**
  99914. * Callback triggered when the particle animation is ending.
  99915. */
  99916. onAnimationEnd: Nullable<() => void>;
  99917. /**
  99918. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  99919. */
  99920. blendMode: number;
  99921. /**
  99922. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  99923. * to override the particles.
  99924. */
  99925. forceDepthWrite: boolean;
  99926. /** 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 */
  99927. preWarmCycles: number;
  99928. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  99929. preWarmStepOffset: number;
  99930. /**
  99931. * 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)
  99932. */
  99933. spriteCellChangeSpeed: number;
  99934. /**
  99935. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  99936. */
  99937. startSpriteCellID: number;
  99938. /**
  99939. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  99940. */
  99941. endSpriteCellID: number;
  99942. /**
  99943. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  99944. */
  99945. spriteCellWidth: number;
  99946. /**
  99947. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  99948. */
  99949. spriteCellHeight: number;
  99950. /**
  99951. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  99952. */
  99953. spriteRandomStartCell: boolean;
  99954. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  99955. translationPivot: Vector2;
  99956. /** @hidden */
  99957. protected _isAnimationSheetEnabled: boolean;
  99958. /**
  99959. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  99960. */
  99961. beginAnimationOnStart: boolean;
  99962. /**
  99963. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  99964. */
  99965. beginAnimationFrom: number;
  99966. /**
  99967. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  99968. */
  99969. beginAnimationTo: number;
  99970. /**
  99971. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  99972. */
  99973. beginAnimationLoop: boolean;
  99974. /**
  99975. * Gets or sets a world offset applied to all particles
  99976. */
  99977. worldOffset: Vector3;
  99978. /**
  99979. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  99980. */
  99981. get isAnimationSheetEnabled(): boolean;
  99982. set isAnimationSheetEnabled(value: boolean);
  99983. /**
  99984. * Get hosting scene
  99985. * @returns the scene
  99986. */
  99987. getScene(): Nullable<Scene>;
  99988. /**
  99989. * You can use gravity if you want to give an orientation to your particles.
  99990. */
  99991. gravity: Vector3;
  99992. protected _colorGradients: Nullable<Array<ColorGradient>>;
  99993. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  99994. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  99995. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  99996. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  99997. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  99998. protected _dragGradients: Nullable<Array<FactorGradient>>;
  99999. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  100000. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  100001. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  100002. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  100003. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  100004. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  100005. /**
  100006. * Defines the delay in milliseconds before starting the system (0 by default)
  100007. */
  100008. startDelay: number;
  100009. /**
  100010. * Gets the current list of drag gradients.
  100011. * You must use addDragGradient and removeDragGradient to udpate this list
  100012. * @returns the list of drag gradients
  100013. */
  100014. getDragGradients(): Nullable<Array<FactorGradient>>;
  100015. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  100016. limitVelocityDamping: number;
  100017. /**
  100018. * Gets the current list of limit velocity gradients.
  100019. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  100020. * @returns the list of limit velocity gradients
  100021. */
  100022. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  100023. /**
  100024. * Gets the current list of color gradients.
  100025. * You must use addColorGradient and removeColorGradient to udpate this list
  100026. * @returns the list of color gradients
  100027. */
  100028. getColorGradients(): Nullable<Array<ColorGradient>>;
  100029. /**
  100030. * Gets the current list of size gradients.
  100031. * You must use addSizeGradient and removeSizeGradient to udpate this list
  100032. * @returns the list of size gradients
  100033. */
  100034. getSizeGradients(): Nullable<Array<FactorGradient>>;
  100035. /**
  100036. * Gets the current list of color remap gradients.
  100037. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  100038. * @returns the list of color remap gradients
  100039. */
  100040. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  100041. /**
  100042. * Gets the current list of alpha remap gradients.
  100043. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  100044. * @returns the list of alpha remap gradients
  100045. */
  100046. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  100047. /**
  100048. * Gets the current list of life time gradients.
  100049. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  100050. * @returns the list of life time gradients
  100051. */
  100052. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  100053. /**
  100054. * Gets the current list of angular speed gradients.
  100055. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  100056. * @returns the list of angular speed gradients
  100057. */
  100058. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  100059. /**
  100060. * Gets the current list of velocity gradients.
  100061. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  100062. * @returns the list of velocity gradients
  100063. */
  100064. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  100065. /**
  100066. * Gets the current list of start size gradients.
  100067. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  100068. * @returns the list of start size gradients
  100069. */
  100070. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  100071. /**
  100072. * Gets the current list of emit rate gradients.
  100073. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  100074. * @returns the list of emit rate gradients
  100075. */
  100076. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  100077. /**
  100078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100080. */
  100081. get direction1(): Vector3;
  100082. set direction1(value: Vector3);
  100083. /**
  100084. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100085. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100086. */
  100087. get direction2(): Vector3;
  100088. set direction2(value: Vector3);
  100089. /**
  100090. * 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.
  100091. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100092. */
  100093. get minEmitBox(): Vector3;
  100094. set minEmitBox(value: Vector3);
  100095. /**
  100096. * 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.
  100097. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100098. */
  100099. get maxEmitBox(): Vector3;
  100100. set maxEmitBox(value: Vector3);
  100101. /**
  100102. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100103. */
  100104. color1: Color4;
  100105. /**
  100106. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100107. */
  100108. color2: Color4;
  100109. /**
  100110. * Color the particle will have at the end of its lifetime
  100111. */
  100112. colorDead: Color4;
  100113. /**
  100114. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  100115. */
  100116. textureMask: Color4;
  100117. /**
  100118. * The particle emitter type defines the emitter used by the particle system.
  100119. * It can be for example box, sphere, or cone...
  100120. */
  100121. particleEmitterType: IParticleEmitterType;
  100122. /** @hidden */
  100123. _isSubEmitter: boolean;
  100124. /**
  100125. * Gets or sets the billboard mode to use when isBillboardBased = true.
  100126. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  100127. */
  100128. billboardMode: number;
  100129. protected _isBillboardBased: boolean;
  100130. /**
  100131. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  100132. */
  100133. get isBillboardBased(): boolean;
  100134. set isBillboardBased(value: boolean);
  100135. /**
  100136. * The scene the particle system belongs to.
  100137. */
  100138. protected _scene: Nullable<Scene>;
  100139. /**
  100140. * The engine the particle system belongs to.
  100141. */
  100142. protected _engine: ThinEngine;
  100143. /**
  100144. * Local cache of defines for image processing.
  100145. */
  100146. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  100147. /**
  100148. * Default configuration related to image processing available in the standard Material.
  100149. */
  100150. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100151. /**
  100152. * Gets the image processing configuration used either in this material.
  100153. */
  100154. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  100155. /**
  100156. * Sets the Default image processing configuration used either in the this material.
  100157. *
  100158. * If sets to null, the scene one is in use.
  100159. */
  100160. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  100161. /**
  100162. * Attaches a new image processing configuration to the Standard Material.
  100163. * @param configuration
  100164. */
  100165. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100166. /** @hidden */
  100167. protected _reset(): void;
  100168. /** @hidden */
  100169. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  100170. /**
  100171. * Instantiates a particle system.
  100172. * 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.
  100173. * @param name The name of the particle system
  100174. */
  100175. constructor(name: string);
  100176. /**
  100177. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  100178. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100179. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100180. * @returns the emitter
  100181. */
  100182. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  100183. /**
  100184. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  100185. * @param radius The radius of the hemisphere to emit from
  100186. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100187. * @returns the emitter
  100188. */
  100189. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  100190. /**
  100191. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  100192. * @param radius The radius of the sphere to emit from
  100193. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100194. * @returns the emitter
  100195. */
  100196. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  100197. /**
  100198. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  100199. * @param radius The radius of the sphere to emit from
  100200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  100201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  100202. * @returns the emitter
  100203. */
  100204. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  100205. /**
  100206. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  100207. * @param radius The radius of the emission cylinder
  100208. * @param height The height of the emission cylinder
  100209. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  100210. * @param directionRandomizer How much to randomize the particle direction [0-1]
  100211. * @returns the emitter
  100212. */
  100213. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  100214. /**
  100215. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  100216. * @param radius The radius of the cylinder to emit from
  100217. * @param height The height of the emission cylinder
  100218. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  100220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  100221. * @returns the emitter
  100222. */
  100223. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  100224. /**
  100225. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  100226. * @param radius The radius of the cone to emit from
  100227. * @param angle The base angle of the cone
  100228. * @returns the emitter
  100229. */
  100230. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  100231. /**
  100232. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  100233. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100234. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100235. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100236. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100237. * @returns the emitter
  100238. */
  100239. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  100240. }
  100241. }
  100242. declare module BABYLON {
  100243. /**
  100244. * Type of sub emitter
  100245. */
  100246. export enum SubEmitterType {
  100247. /**
  100248. * Attached to the particle over it's lifetime
  100249. */
  100250. ATTACHED = 0,
  100251. /**
  100252. * Created when the particle dies
  100253. */
  100254. END = 1
  100255. }
  100256. /**
  100257. * Sub emitter class used to emit particles from an existing particle
  100258. */
  100259. export class SubEmitter {
  100260. /**
  100261. * the particle system to be used by the sub emitter
  100262. */
  100263. particleSystem: ParticleSystem;
  100264. /**
  100265. * Type of the submitter (Default: END)
  100266. */
  100267. type: SubEmitterType;
  100268. /**
  100269. * 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)
  100270. * Note: This only is supported when using an emitter of type Mesh
  100271. */
  100272. inheritDirection: boolean;
  100273. /**
  100274. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  100275. */
  100276. inheritedVelocityAmount: number;
  100277. /**
  100278. * Creates a sub emitter
  100279. * @param particleSystem the particle system to be used by the sub emitter
  100280. */
  100281. constructor(
  100282. /**
  100283. * the particle system to be used by the sub emitter
  100284. */
  100285. particleSystem: ParticleSystem);
  100286. /**
  100287. * Clones the sub emitter
  100288. * @returns the cloned sub emitter
  100289. */
  100290. clone(): SubEmitter;
  100291. /**
  100292. * Serialize current object to a JSON object
  100293. * @returns the serialized object
  100294. */
  100295. serialize(): any;
  100296. /** @hidden */
  100297. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  100298. /**
  100299. * Creates a new SubEmitter from a serialized JSON version
  100300. * @param serializationObject defines the JSON object to read from
  100301. * @param sceneOrEngine defines the hosting scene or the hosting engine
  100302. * @param rootUrl defines the rootUrl for data loading
  100303. * @returns a new SubEmitter
  100304. */
  100305. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  100306. /** Release associated resources */
  100307. dispose(): void;
  100308. }
  100309. }
  100310. declare module BABYLON {
  100311. /** @hidden */
  100312. export var clipPlaneFragmentDeclaration: {
  100313. name: string;
  100314. shader: string;
  100315. };
  100316. }
  100317. declare module BABYLON {
  100318. /** @hidden */
  100319. export var imageProcessingDeclaration: {
  100320. name: string;
  100321. shader: string;
  100322. };
  100323. }
  100324. declare module BABYLON {
  100325. /** @hidden */
  100326. export var imageProcessingFunctions: {
  100327. name: string;
  100328. shader: string;
  100329. };
  100330. }
  100331. declare module BABYLON {
  100332. /** @hidden */
  100333. export var clipPlaneFragment: {
  100334. name: string;
  100335. shader: string;
  100336. };
  100337. }
  100338. declare module BABYLON {
  100339. /** @hidden */
  100340. export var particlesPixelShader: {
  100341. name: string;
  100342. shader: string;
  100343. };
  100344. }
  100345. declare module BABYLON {
  100346. /** @hidden */
  100347. export var clipPlaneVertexDeclaration: {
  100348. name: string;
  100349. shader: string;
  100350. };
  100351. }
  100352. declare module BABYLON {
  100353. /** @hidden */
  100354. export var clipPlaneVertex: {
  100355. name: string;
  100356. shader: string;
  100357. };
  100358. }
  100359. declare module BABYLON {
  100360. /** @hidden */
  100361. export var particlesVertexShader: {
  100362. name: string;
  100363. shader: string;
  100364. };
  100365. }
  100366. declare module BABYLON {
  100367. /**
  100368. * Interface used to define entities containing multiple clip planes
  100369. */
  100370. export interface IClipPlanesHolder {
  100371. /**
  100372. * Gets or sets the active clipplane 1
  100373. */
  100374. clipPlane: Nullable<Plane>;
  100375. /**
  100376. * Gets or sets the active clipplane 2
  100377. */
  100378. clipPlane2: Nullable<Plane>;
  100379. /**
  100380. * Gets or sets the active clipplane 3
  100381. */
  100382. clipPlane3: Nullable<Plane>;
  100383. /**
  100384. * Gets or sets the active clipplane 4
  100385. */
  100386. clipPlane4: Nullable<Plane>;
  100387. /**
  100388. * Gets or sets the active clipplane 5
  100389. */
  100390. clipPlane5: Nullable<Plane>;
  100391. /**
  100392. * Gets or sets the active clipplane 6
  100393. */
  100394. clipPlane6: Nullable<Plane>;
  100395. }
  100396. }
  100397. declare module BABYLON {
  100398. /**
  100399. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  100400. *
  100401. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  100402. *
  100403. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100404. */
  100405. export class ThinMaterialHelper {
  100406. /**
  100407. * Binds the clip plane information from the holder to the effect.
  100408. * @param effect The effect we are binding the data to
  100409. * @param holder The entity containing the clip plane information
  100410. */
  100411. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  100412. }
  100413. }
  100414. declare module BABYLON {
  100415. interface ThinEngine {
  100416. /**
  100417. * Sets alpha constants used by some alpha blending modes
  100418. * @param r defines the red component
  100419. * @param g defines the green component
  100420. * @param b defines the blue component
  100421. * @param a defines the alpha component
  100422. */
  100423. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100424. /**
  100425. * Sets the current alpha mode
  100426. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100427. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100428. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100429. */
  100430. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100431. /**
  100432. * Gets the current alpha mode
  100433. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100434. * @returns the current alpha mode
  100435. */
  100436. getAlphaMode(): number;
  100437. /**
  100438. * Sets the current alpha equation
  100439. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100440. */
  100441. setAlphaEquation(equation: number): void;
  100442. /**
  100443. * Gets the current alpha equation.
  100444. * @returns the current alpha equation
  100445. */
  100446. getAlphaEquation(): number;
  100447. }
  100448. }
  100449. declare module BABYLON {
  100450. /**
  100451. * This represents a particle system in Babylon.
  100452. * 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.
  100453. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  100454. * @example https://doc.babylonjs.com/babylon101/particles
  100455. */
  100456. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  100457. /**
  100458. * Billboard mode will only apply to Y axis
  100459. */
  100460. static readonly BILLBOARDMODE_Y: number;
  100461. /**
  100462. * Billboard mode will apply to all axes
  100463. */
  100464. static readonly BILLBOARDMODE_ALL: number;
  100465. /**
  100466. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  100467. */
  100468. static readonly BILLBOARDMODE_STRETCHED: number;
  100469. /**
  100470. * This function can be defined to provide custom update for active particles.
  100471. * This function will be called instead of regular update (age, position, color, etc.).
  100472. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  100473. */
  100474. updateFunction: (particles: Particle[]) => void;
  100475. private _emitterWorldMatrix;
  100476. /**
  100477. * This function can be defined to specify initial direction for every new particle.
  100478. * It by default use the emitterType defined function
  100479. */
  100480. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100481. /**
  100482. * This function can be defined to specify initial position for every new particle.
  100483. * It by default use the emitterType defined function
  100484. */
  100485. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100486. /**
  100487. * @hidden
  100488. */
  100489. _inheritedVelocityOffset: Vector3;
  100490. /**
  100491. * An event triggered when the system is disposed
  100492. */
  100493. onDisposeObservable: Observable<IParticleSystem>;
  100494. /**
  100495. * An event triggered when the system is stopped
  100496. */
  100497. onStoppedObservable: Observable<IParticleSystem>;
  100498. private _onDisposeObserver;
  100499. /**
  100500. * Sets a callback that will be triggered when the system is disposed
  100501. */
  100502. set onDispose(callback: () => void);
  100503. private _particles;
  100504. private _epsilon;
  100505. private _capacity;
  100506. private _stockParticles;
  100507. private _newPartsExcess;
  100508. private _vertexData;
  100509. private _vertexBuffer;
  100510. private _vertexBuffers;
  100511. private _spriteBuffer;
  100512. private _indexBuffer;
  100513. private _effect;
  100514. private _customEffect;
  100515. private _cachedDefines;
  100516. private _scaledColorStep;
  100517. private _colorDiff;
  100518. private _scaledDirection;
  100519. private _scaledGravity;
  100520. private _currentRenderId;
  100521. private _alive;
  100522. private _useInstancing;
  100523. private _vertexArrayObject;
  100524. private _started;
  100525. private _stopped;
  100526. private _actualFrame;
  100527. private _scaledUpdateSpeed;
  100528. private _vertexBufferSize;
  100529. /** @hidden */
  100530. _currentEmitRateGradient: Nullable<FactorGradient>;
  100531. /** @hidden */
  100532. _currentEmitRate1: number;
  100533. /** @hidden */
  100534. _currentEmitRate2: number;
  100535. /** @hidden */
  100536. _currentStartSizeGradient: Nullable<FactorGradient>;
  100537. /** @hidden */
  100538. _currentStartSize1: number;
  100539. /** @hidden */
  100540. _currentStartSize2: number;
  100541. private readonly _rawTextureWidth;
  100542. private _rampGradientsTexture;
  100543. private _useRampGradients;
  100544. /** Gets or sets a matrix to use to compute projection */
  100545. defaultProjectionMatrix: Matrix;
  100546. /** Gets or sets a matrix to use to compute view */
  100547. defaultViewMatrix: Matrix;
  100548. /** Gets or sets a boolean indicating that ramp gradients must be used
  100549. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  100550. */
  100551. get useRampGradients(): boolean;
  100552. set useRampGradients(value: boolean);
  100553. /**
  100554. * 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.
  100555. * 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: [])
  100556. */
  100557. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  100558. private _subEmitters;
  100559. /**
  100560. * @hidden
  100561. * If the particle systems emitter should be disposed when the particle system is disposed
  100562. */
  100563. _disposeEmitterOnDispose: boolean;
  100564. /**
  100565. * The current active Sub-systems, this property is used by the root particle system only.
  100566. */
  100567. activeSubSystems: Array<ParticleSystem>;
  100568. /**
  100569. * Specifies if the particles are updated in emitter local space or world space
  100570. */
  100571. isLocal: boolean;
  100572. private _rootParticleSystem;
  100573. /**
  100574. * Gets the current list of active particles
  100575. */
  100576. get particles(): Particle[];
  100577. /**
  100578. * Gets the number of particles active at the same time.
  100579. * @returns The number of active particles.
  100580. */
  100581. getActiveCount(): number;
  100582. /**
  100583. * Returns the string "ParticleSystem"
  100584. * @returns a string containing the class name
  100585. */
  100586. getClassName(): string;
  100587. /**
  100588. * Gets a boolean indicating that the system is stopping
  100589. * @returns true if the system is currently stopping
  100590. */
  100591. isStopping(): boolean;
  100592. /**
  100593. * Gets the custom effect used to render the particles
  100594. * @param blendMode Blend mode for which the effect should be retrieved
  100595. * @returns The effect
  100596. */
  100597. getCustomEffect(blendMode?: number): Nullable<Effect>;
  100598. /**
  100599. * Sets the custom effect used to render the particles
  100600. * @param effect The effect to set
  100601. * @param blendMode Blend mode for which the effect should be set
  100602. */
  100603. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  100604. /** @hidden */
  100605. private _onBeforeDrawParticlesObservable;
  100606. /**
  100607. * Observable that will be called just before the particles are drawn
  100608. */
  100609. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  100610. /**
  100611. * Gets the name of the particle vertex shader
  100612. */
  100613. get vertexShaderName(): string;
  100614. /**
  100615. * Instantiates a particle system.
  100616. * 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.
  100617. * @param name The name of the particle system
  100618. * @param capacity The max number of particles alive at the same time
  100619. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  100620. * @param customEffect a custom effect used to change the way particles are rendered by default
  100621. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  100622. * @param epsilon Offset used to render the particles
  100623. */
  100624. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  100625. private _addFactorGradient;
  100626. private _removeFactorGradient;
  100627. /**
  100628. * Adds a new life time gradient
  100629. * @param gradient defines the gradient to use (between 0 and 1)
  100630. * @param factor defines the life time factor to affect to the specified gradient
  100631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100632. * @returns the current particle system
  100633. */
  100634. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100635. /**
  100636. * Remove a specific life time gradient
  100637. * @param gradient defines the gradient to remove
  100638. * @returns the current particle system
  100639. */
  100640. removeLifeTimeGradient(gradient: number): IParticleSystem;
  100641. /**
  100642. * Adds a new size gradient
  100643. * @param gradient defines the gradient to use (between 0 and 1)
  100644. * @param factor defines the size factor to affect to the specified gradient
  100645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100646. * @returns the current particle system
  100647. */
  100648. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100649. /**
  100650. * Remove a specific size gradient
  100651. * @param gradient defines the gradient to remove
  100652. * @returns the current particle system
  100653. */
  100654. removeSizeGradient(gradient: number): IParticleSystem;
  100655. /**
  100656. * Adds a new color remap gradient
  100657. * @param gradient defines the gradient to use (between 0 and 1)
  100658. * @param min defines the color remap minimal range
  100659. * @param max defines the color remap maximal range
  100660. * @returns the current particle system
  100661. */
  100662. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100663. /**
  100664. * Remove a specific color remap gradient
  100665. * @param gradient defines the gradient to remove
  100666. * @returns the current particle system
  100667. */
  100668. removeColorRemapGradient(gradient: number): IParticleSystem;
  100669. /**
  100670. * Adds a new alpha remap gradient
  100671. * @param gradient defines the gradient to use (between 0 and 1)
  100672. * @param min defines the alpha remap minimal range
  100673. * @param max defines the alpha remap maximal range
  100674. * @returns the current particle system
  100675. */
  100676. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100677. /**
  100678. * Remove a specific alpha remap gradient
  100679. * @param gradient defines the gradient to remove
  100680. * @returns the current particle system
  100681. */
  100682. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  100683. /**
  100684. * Adds a new angular speed gradient
  100685. * @param gradient defines the gradient to use (between 0 and 1)
  100686. * @param factor defines the angular speed to affect to the specified gradient
  100687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100688. * @returns the current particle system
  100689. */
  100690. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100691. /**
  100692. * Remove a specific angular speed gradient
  100693. * @param gradient defines the gradient to remove
  100694. * @returns the current particle system
  100695. */
  100696. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  100697. /**
  100698. * Adds a new velocity gradient
  100699. * @param gradient defines the gradient to use (between 0 and 1)
  100700. * @param factor defines the velocity to affect to the specified gradient
  100701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100702. * @returns the current particle system
  100703. */
  100704. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100705. /**
  100706. * Remove a specific velocity gradient
  100707. * @param gradient defines the gradient to remove
  100708. * @returns the current particle system
  100709. */
  100710. removeVelocityGradient(gradient: number): IParticleSystem;
  100711. /**
  100712. * Adds a new limit velocity gradient
  100713. * @param gradient defines the gradient to use (between 0 and 1)
  100714. * @param factor defines the limit velocity value to affect to the specified gradient
  100715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100716. * @returns the current particle system
  100717. */
  100718. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100719. /**
  100720. * Remove a specific limit velocity gradient
  100721. * @param gradient defines the gradient to remove
  100722. * @returns the current particle system
  100723. */
  100724. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  100725. /**
  100726. * Adds a new drag gradient
  100727. * @param gradient defines the gradient to use (between 0 and 1)
  100728. * @param factor defines the drag value to affect to the specified gradient
  100729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100730. * @returns the current particle system
  100731. */
  100732. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100733. /**
  100734. * Remove a specific drag gradient
  100735. * @param gradient defines the gradient to remove
  100736. * @returns the current particle system
  100737. */
  100738. removeDragGradient(gradient: number): IParticleSystem;
  100739. /**
  100740. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  100741. * @param gradient defines the gradient to use (between 0 and 1)
  100742. * @param factor defines the emit rate value to affect to the specified gradient
  100743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100744. * @returns the current particle system
  100745. */
  100746. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100747. /**
  100748. * Remove a specific emit rate gradient
  100749. * @param gradient defines the gradient to remove
  100750. * @returns the current particle system
  100751. */
  100752. removeEmitRateGradient(gradient: number): IParticleSystem;
  100753. /**
  100754. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  100755. * @param gradient defines the gradient to use (between 0 and 1)
  100756. * @param factor defines the start size value to affect to the specified gradient
  100757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100758. * @returns the current particle system
  100759. */
  100760. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100761. /**
  100762. * Remove a specific start size gradient
  100763. * @param gradient defines the gradient to remove
  100764. * @returns the current particle system
  100765. */
  100766. removeStartSizeGradient(gradient: number): IParticleSystem;
  100767. private _createRampGradientTexture;
  100768. /**
  100769. * Gets the current list of ramp gradients.
  100770. * You must use addRampGradient and removeRampGradient to udpate this list
  100771. * @returns the list of ramp gradients
  100772. */
  100773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  100774. /** Force the system to rebuild all gradients that need to be resync */
  100775. forceRefreshGradients(): void;
  100776. private _syncRampGradientTexture;
  100777. /**
  100778. * Adds a new ramp gradient used to remap particle colors
  100779. * @param gradient defines the gradient to use (between 0 and 1)
  100780. * @param color defines the color to affect to the specified gradient
  100781. * @returns the current particle system
  100782. */
  100783. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  100784. /**
  100785. * Remove a specific ramp gradient
  100786. * @param gradient defines the gradient to remove
  100787. * @returns the current particle system
  100788. */
  100789. removeRampGradient(gradient: number): ParticleSystem;
  100790. /**
  100791. * Adds a new color gradient
  100792. * @param gradient defines the gradient to use (between 0 and 1)
  100793. * @param color1 defines the color to affect to the specified gradient
  100794. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  100795. * @returns this particle system
  100796. */
  100797. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  100798. /**
  100799. * Remove a specific color gradient
  100800. * @param gradient defines the gradient to remove
  100801. * @returns this particle system
  100802. */
  100803. removeColorGradient(gradient: number): IParticleSystem;
  100804. private _fetchR;
  100805. protected _reset(): void;
  100806. private _resetEffect;
  100807. private _createVertexBuffers;
  100808. private _createIndexBuffer;
  100809. /**
  100810. * Gets the maximum number of particles active at the same time.
  100811. * @returns The max number of active particles.
  100812. */
  100813. getCapacity(): number;
  100814. /**
  100815. * Gets whether there are still active particles in the system.
  100816. * @returns True if it is alive, otherwise false.
  100817. */
  100818. isAlive(): boolean;
  100819. /**
  100820. * Gets if the system has been started. (Note: this will still be true after stop is called)
  100821. * @returns True if it has been started, otherwise false.
  100822. */
  100823. isStarted(): boolean;
  100824. private _prepareSubEmitterInternalArray;
  100825. /**
  100826. * Starts the particle system and begins to emit
  100827. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  100828. */
  100829. start(delay?: number): void;
  100830. /**
  100831. * Stops the particle system.
  100832. * @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.
  100833. */
  100834. stop(stopSubEmitters?: boolean): void;
  100835. /**
  100836. * Remove all active particles
  100837. */
  100838. reset(): void;
  100839. /**
  100840. * @hidden (for internal use only)
  100841. */
  100842. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  100843. /**
  100844. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  100845. * Its lifetime will start back at 0.
  100846. */
  100847. recycleParticle: (particle: Particle) => void;
  100848. private _stopSubEmitters;
  100849. private _createParticle;
  100850. private _removeFromRoot;
  100851. private _emitFromParticle;
  100852. private _update;
  100853. /** @hidden */
  100854. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  100855. /** @hidden */
  100856. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  100857. /**
  100858. * Fill the defines array according to the current settings of the particle system
  100859. * @param defines Array to be updated
  100860. * @param blendMode blend mode to take into account when updating the array
  100861. */
  100862. fillDefines(defines: Array<string>, blendMode: number): void;
  100863. /**
  100864. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  100865. * @param uniforms Uniforms array to fill
  100866. * @param attributes Attributes array to fill
  100867. * @param samplers Samplers array to fill
  100868. */
  100869. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  100870. /** @hidden */
  100871. private _getEffect;
  100872. /**
  100873. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  100874. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  100875. */
  100876. animate(preWarmOnly?: boolean): void;
  100877. private _appendParticleVertices;
  100878. /**
  100879. * Rebuilds the particle system.
  100880. */
  100881. rebuild(): void;
  100882. /**
  100883. * Is this system ready to be used/rendered
  100884. * @return true if the system is ready
  100885. */
  100886. isReady(): boolean;
  100887. private _render;
  100888. /**
  100889. * Renders the particle system in its current state.
  100890. * @returns the current number of particles
  100891. */
  100892. render(): number;
  100893. /**
  100894. * Disposes the particle system and free the associated resources
  100895. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  100896. */
  100897. dispose(disposeTexture?: boolean): void;
  100898. /**
  100899. * Clones the particle system.
  100900. * @param name The name of the cloned object
  100901. * @param newEmitter The new emitter to use
  100902. * @returns the cloned particle system
  100903. */
  100904. clone(name: string, newEmitter: any): ParticleSystem;
  100905. /**
  100906. * Serializes the particle system to a JSON object
  100907. * @param serializeTexture defines if the texture must be serialized as well
  100908. * @returns the JSON object
  100909. */
  100910. serialize(serializeTexture?: boolean): any;
  100911. /** @hidden */
  100912. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  100913. /** @hidden */
  100914. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  100915. /**
  100916. * Parses a JSON object to create a particle system.
  100917. * @param parsedParticleSystem The JSON object to parse
  100918. * @param sceneOrEngine The scene or the engine to create the particle system in
  100919. * @param rootUrl The root url to use to load external dependencies like texture
  100920. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  100921. * @returns the Parsed particle system
  100922. */
  100923. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  100924. }
  100925. }
  100926. declare module BABYLON {
  100927. /**
  100928. * A particle represents one of the element emitted by a particle system.
  100929. * This is mainly define by its coordinates, direction, velocity and age.
  100930. */
  100931. export class Particle {
  100932. /**
  100933. * The particle system the particle belongs to.
  100934. */
  100935. particleSystem: ParticleSystem;
  100936. private static _Count;
  100937. /**
  100938. * Unique ID of the particle
  100939. */
  100940. id: number;
  100941. /**
  100942. * The world position of the particle in the scene.
  100943. */
  100944. position: Vector3;
  100945. /**
  100946. * The world direction of the particle in the scene.
  100947. */
  100948. direction: Vector3;
  100949. /**
  100950. * The color of the particle.
  100951. */
  100952. color: Color4;
  100953. /**
  100954. * The color change of the particle per step.
  100955. */
  100956. colorStep: Color4;
  100957. /**
  100958. * Defines how long will the life of the particle be.
  100959. */
  100960. lifeTime: number;
  100961. /**
  100962. * The current age of the particle.
  100963. */
  100964. age: number;
  100965. /**
  100966. * The current size of the particle.
  100967. */
  100968. size: number;
  100969. /**
  100970. * The current scale of the particle.
  100971. */
  100972. scale: Vector2;
  100973. /**
  100974. * The current angle of the particle.
  100975. */
  100976. angle: number;
  100977. /**
  100978. * Defines how fast is the angle changing.
  100979. */
  100980. angularSpeed: number;
  100981. /**
  100982. * Defines the cell index used by the particle to be rendered from a sprite.
  100983. */
  100984. cellIndex: number;
  100985. /**
  100986. * The information required to support color remapping
  100987. */
  100988. remapData: Vector4;
  100989. /** @hidden */
  100990. _randomCellOffset?: number;
  100991. /** @hidden */
  100992. _initialDirection: Nullable<Vector3>;
  100993. /** @hidden */
  100994. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  100995. /** @hidden */
  100996. _initialStartSpriteCellID: number;
  100997. /** @hidden */
  100998. _initialEndSpriteCellID: number;
  100999. /** @hidden */
  101000. _currentColorGradient: Nullable<ColorGradient>;
  101001. /** @hidden */
  101002. _currentColor1: Color4;
  101003. /** @hidden */
  101004. _currentColor2: Color4;
  101005. /** @hidden */
  101006. _currentSizeGradient: Nullable<FactorGradient>;
  101007. /** @hidden */
  101008. _currentSize1: number;
  101009. /** @hidden */
  101010. _currentSize2: number;
  101011. /** @hidden */
  101012. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  101013. /** @hidden */
  101014. _currentAngularSpeed1: number;
  101015. /** @hidden */
  101016. _currentAngularSpeed2: number;
  101017. /** @hidden */
  101018. _currentVelocityGradient: Nullable<FactorGradient>;
  101019. /** @hidden */
  101020. _currentVelocity1: number;
  101021. /** @hidden */
  101022. _currentVelocity2: number;
  101023. /** @hidden */
  101024. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  101025. /** @hidden */
  101026. _currentLimitVelocity1: number;
  101027. /** @hidden */
  101028. _currentLimitVelocity2: number;
  101029. /** @hidden */
  101030. _currentDragGradient: Nullable<FactorGradient>;
  101031. /** @hidden */
  101032. _currentDrag1: number;
  101033. /** @hidden */
  101034. _currentDrag2: number;
  101035. /** @hidden */
  101036. _randomNoiseCoordinates1: Vector3;
  101037. /** @hidden */
  101038. _randomNoiseCoordinates2: Vector3;
  101039. /** @hidden */
  101040. _localPosition?: Vector3;
  101041. /**
  101042. * Creates a new instance Particle
  101043. * @param particleSystem the particle system the particle belongs to
  101044. */
  101045. constructor(
  101046. /**
  101047. * The particle system the particle belongs to.
  101048. */
  101049. particleSystem: ParticleSystem);
  101050. private updateCellInfoFromSystem;
  101051. /**
  101052. * Defines how the sprite cell index is updated for the particle
  101053. */
  101054. updateCellIndex(): void;
  101055. /** @hidden */
  101056. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  101057. /** @hidden */
  101058. _inheritParticleInfoToSubEmitters(): void;
  101059. /** @hidden */
  101060. _reset(): void;
  101061. /**
  101062. * Copy the properties of particle to another one.
  101063. * @param other the particle to copy the information to.
  101064. */
  101065. copyTo(other: Particle): void;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * Particle emitter represents a volume emitting particles.
  101071. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  101072. */
  101073. export interface IParticleEmitterType {
  101074. /**
  101075. * Called by the particle System when the direction is computed for the created particle.
  101076. * @param worldMatrix is the world matrix of the particle system
  101077. * @param directionToUpdate is the direction vector to update with the result
  101078. * @param particle is the particle we are computed the direction for
  101079. * @param isLocal defines if the direction should be set in local space
  101080. */
  101081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101082. /**
  101083. * Called by the particle System when the position is computed for the created particle.
  101084. * @param worldMatrix is the world matrix of the particle system
  101085. * @param positionToUpdate is the position vector to update with the result
  101086. * @param particle is the particle we are computed the position for
  101087. * @param isLocal defines if the position should be set in local space
  101088. */
  101089. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101090. /**
  101091. * Clones the current emitter and returns a copy of it
  101092. * @returns the new emitter
  101093. */
  101094. clone(): IParticleEmitterType;
  101095. /**
  101096. * Called by the GPUParticleSystem to setup the update shader
  101097. * @param effect defines the update shader
  101098. */
  101099. applyToShader(effect: Effect): void;
  101100. /**
  101101. * Returns a string to use to update the GPU particles update shader
  101102. * @returns the effect defines string
  101103. */
  101104. getEffectDefines(): string;
  101105. /**
  101106. * Returns a string representing the class name
  101107. * @returns a string containing the class name
  101108. */
  101109. getClassName(): string;
  101110. /**
  101111. * Serializes the particle system to a JSON object.
  101112. * @returns the JSON object
  101113. */
  101114. serialize(): any;
  101115. /**
  101116. * Parse properties from a JSON object
  101117. * @param serializationObject defines the JSON object
  101118. * @param scene defines the hosting scene
  101119. */
  101120. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101121. }
  101122. }
  101123. declare module BABYLON {
  101124. /**
  101125. * Particle emitter emitting particles from the inside of a box.
  101126. * It emits the particles randomly between 2 given directions.
  101127. */
  101128. export class BoxParticleEmitter implements IParticleEmitterType {
  101129. /**
  101130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101131. */
  101132. direction1: Vector3;
  101133. /**
  101134. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101135. */
  101136. direction2: Vector3;
  101137. /**
  101138. * 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.
  101139. */
  101140. minEmitBox: Vector3;
  101141. /**
  101142. * 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.
  101143. */
  101144. maxEmitBox: Vector3;
  101145. /**
  101146. * Creates a new instance BoxParticleEmitter
  101147. */
  101148. constructor();
  101149. /**
  101150. * Called by the particle System when the direction is computed for the created particle.
  101151. * @param worldMatrix is the world matrix of the particle system
  101152. * @param directionToUpdate is the direction vector to update with the result
  101153. * @param particle is the particle we are computed the direction for
  101154. * @param isLocal defines if the direction should be set in local space
  101155. */
  101156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101157. /**
  101158. * Called by the particle System when the position is computed for the created particle.
  101159. * @param worldMatrix is the world matrix of the particle system
  101160. * @param positionToUpdate is the position vector to update with the result
  101161. * @param particle is the particle we are computed the position for
  101162. * @param isLocal defines if the position should be set in local space
  101163. */
  101164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101165. /**
  101166. * Clones the current emitter and returns a copy of it
  101167. * @returns the new emitter
  101168. */
  101169. clone(): BoxParticleEmitter;
  101170. /**
  101171. * Called by the GPUParticleSystem to setup the update shader
  101172. * @param effect defines the update shader
  101173. */
  101174. applyToShader(effect: Effect): void;
  101175. /**
  101176. * Returns a string to use to update the GPU particles update shader
  101177. * @returns a string containng the defines string
  101178. */
  101179. getEffectDefines(): string;
  101180. /**
  101181. * Returns the string "BoxParticleEmitter"
  101182. * @returns a string containing the class name
  101183. */
  101184. getClassName(): string;
  101185. /**
  101186. * Serializes the particle system to a JSON object.
  101187. * @returns the JSON object
  101188. */
  101189. serialize(): any;
  101190. /**
  101191. * Parse properties from a JSON object
  101192. * @param serializationObject defines the JSON object
  101193. */
  101194. parse(serializationObject: any): void;
  101195. }
  101196. }
  101197. declare module BABYLON {
  101198. /**
  101199. * Particle emitter emitting particles from the inside of a cone.
  101200. * It emits the particles alongside the cone volume from the base to the particle.
  101201. * The emission direction might be randomized.
  101202. */
  101203. export class ConeParticleEmitter implements IParticleEmitterType {
  101204. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101205. directionRandomizer: number;
  101206. private _radius;
  101207. private _angle;
  101208. private _height;
  101209. /**
  101210. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101211. */
  101212. radiusRange: number;
  101213. /**
  101214. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101215. */
  101216. heightRange: number;
  101217. /**
  101218. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101219. */
  101220. emitFromSpawnPointOnly: boolean;
  101221. /**
  101222. * Gets or sets the radius of the emission cone
  101223. */
  101224. get radius(): number;
  101225. set radius(value: number);
  101226. /**
  101227. * Gets or sets the angle of the emission cone
  101228. */
  101229. get angle(): number;
  101230. set angle(value: number);
  101231. private _buildHeight;
  101232. /**
  101233. * Creates a new instance ConeParticleEmitter
  101234. * @param radius the radius of the emission cone (1 by default)
  101235. * @param angle the cone base angle (PI by default)
  101236. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101237. */
  101238. constructor(radius?: number, angle?: number,
  101239. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101240. directionRandomizer?: number);
  101241. /**
  101242. * Called by the particle System when the direction is computed for the created particle.
  101243. * @param worldMatrix is the world matrix of the particle system
  101244. * @param directionToUpdate is the direction vector to update with the result
  101245. * @param particle is the particle we are computed the direction for
  101246. * @param isLocal defines if the direction should be set in local space
  101247. */
  101248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101249. /**
  101250. * Called by the particle System when the position is computed for the created particle.
  101251. * @param worldMatrix is the world matrix of the particle system
  101252. * @param positionToUpdate is the position vector to update with the result
  101253. * @param particle is the particle we are computed the position for
  101254. * @param isLocal defines if the position should be set in local space
  101255. */
  101256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101257. /**
  101258. * Clones the current emitter and returns a copy of it
  101259. * @returns the new emitter
  101260. */
  101261. clone(): ConeParticleEmitter;
  101262. /**
  101263. * Called by the GPUParticleSystem to setup the update shader
  101264. * @param effect defines the update shader
  101265. */
  101266. applyToShader(effect: Effect): void;
  101267. /**
  101268. * Returns a string to use to update the GPU particles update shader
  101269. * @returns a string containng the defines string
  101270. */
  101271. getEffectDefines(): string;
  101272. /**
  101273. * Returns the string "ConeParticleEmitter"
  101274. * @returns a string containing the class name
  101275. */
  101276. getClassName(): string;
  101277. /**
  101278. * Serializes the particle system to a JSON object.
  101279. * @returns the JSON object
  101280. */
  101281. serialize(): any;
  101282. /**
  101283. * Parse properties from a JSON object
  101284. * @param serializationObject defines the JSON object
  101285. */
  101286. parse(serializationObject: any): void;
  101287. }
  101288. }
  101289. declare module BABYLON {
  101290. /**
  101291. * Particle emitter emitting particles from the inside of a cylinder.
  101292. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101293. */
  101294. export class CylinderParticleEmitter implements IParticleEmitterType {
  101295. /**
  101296. * The radius of the emission cylinder.
  101297. */
  101298. radius: number;
  101299. /**
  101300. * The height of the emission cylinder.
  101301. */
  101302. height: number;
  101303. /**
  101304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101305. */
  101306. radiusRange: number;
  101307. /**
  101308. * How much to randomize the particle direction [0-1].
  101309. */
  101310. directionRandomizer: number;
  101311. /**
  101312. * Creates a new instance CylinderParticleEmitter
  101313. * @param radius the radius of the emission cylinder (1 by default)
  101314. * @param height the height of the emission cylinder (1 by default)
  101315. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101316. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101317. */
  101318. constructor(
  101319. /**
  101320. * The radius of the emission cylinder.
  101321. */
  101322. radius?: number,
  101323. /**
  101324. * The height of the emission cylinder.
  101325. */
  101326. height?: number,
  101327. /**
  101328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101329. */
  101330. radiusRange?: number,
  101331. /**
  101332. * How much to randomize the particle direction [0-1].
  101333. */
  101334. directionRandomizer?: number);
  101335. /**
  101336. * Called by the particle System when the direction is computed for the created particle.
  101337. * @param worldMatrix is the world matrix of the particle system
  101338. * @param directionToUpdate is the direction vector to update with the result
  101339. * @param particle is the particle we are computed the direction for
  101340. * @param isLocal defines if the direction should be set in local space
  101341. */
  101342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101343. /**
  101344. * Called by the particle System when the position is computed for the created particle.
  101345. * @param worldMatrix is the world matrix of the particle system
  101346. * @param positionToUpdate is the position vector to update with the result
  101347. * @param particle is the particle we are computed the position for
  101348. * @param isLocal defines if the position should be set in local space
  101349. */
  101350. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101351. /**
  101352. * Clones the current emitter and returns a copy of it
  101353. * @returns the new emitter
  101354. */
  101355. clone(): CylinderParticleEmitter;
  101356. /**
  101357. * Called by the GPUParticleSystem to setup the update shader
  101358. * @param effect defines the update shader
  101359. */
  101360. applyToShader(effect: Effect): void;
  101361. /**
  101362. * Returns a string to use to update the GPU particles update shader
  101363. * @returns a string containng the defines string
  101364. */
  101365. getEffectDefines(): string;
  101366. /**
  101367. * Returns the string "CylinderParticleEmitter"
  101368. * @returns a string containing the class name
  101369. */
  101370. getClassName(): string;
  101371. /**
  101372. * Serializes the particle system to a JSON object.
  101373. * @returns the JSON object
  101374. */
  101375. serialize(): any;
  101376. /**
  101377. * Parse properties from a JSON object
  101378. * @param serializationObject defines the JSON object
  101379. */
  101380. parse(serializationObject: any): void;
  101381. }
  101382. /**
  101383. * Particle emitter emitting particles from the inside of a cylinder.
  101384. * It emits the particles randomly between two vectors.
  101385. */
  101386. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  101387. /**
  101388. * The min limit of the emission direction.
  101389. */
  101390. direction1: Vector3;
  101391. /**
  101392. * The max limit of the emission direction.
  101393. */
  101394. direction2: Vector3;
  101395. /**
  101396. * Creates a new instance CylinderDirectedParticleEmitter
  101397. * @param radius the radius of the emission cylinder (1 by default)
  101398. * @param height the height of the emission cylinder (1 by default)
  101399. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101400. * @param direction1 the min limit of the emission direction (up vector by default)
  101401. * @param direction2 the max limit of the emission direction (up vector by default)
  101402. */
  101403. constructor(radius?: number, height?: number, radiusRange?: number,
  101404. /**
  101405. * The min limit of the emission direction.
  101406. */
  101407. direction1?: Vector3,
  101408. /**
  101409. * The max limit of the emission direction.
  101410. */
  101411. direction2?: Vector3);
  101412. /**
  101413. * Called by the particle System when the direction is computed for the created particle.
  101414. * @param worldMatrix is the world matrix of the particle system
  101415. * @param directionToUpdate is the direction vector to update with the result
  101416. * @param particle is the particle we are computed the direction for
  101417. */
  101418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101419. /**
  101420. * Clones the current emitter and returns a copy of it
  101421. * @returns the new emitter
  101422. */
  101423. clone(): CylinderDirectedParticleEmitter;
  101424. /**
  101425. * Called by the GPUParticleSystem to setup the update shader
  101426. * @param effect defines the update shader
  101427. */
  101428. applyToShader(effect: Effect): void;
  101429. /**
  101430. * Returns a string to use to update the GPU particles update shader
  101431. * @returns a string containng the defines string
  101432. */
  101433. getEffectDefines(): string;
  101434. /**
  101435. * Returns the string "CylinderDirectedParticleEmitter"
  101436. * @returns a string containing the class name
  101437. */
  101438. getClassName(): string;
  101439. /**
  101440. * Serializes the particle system to a JSON object.
  101441. * @returns the JSON object
  101442. */
  101443. serialize(): any;
  101444. /**
  101445. * Parse properties from a JSON object
  101446. * @param serializationObject defines the JSON object
  101447. */
  101448. parse(serializationObject: any): void;
  101449. }
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * Particle emitter emitting particles from the inside of a hemisphere.
  101454. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101455. */
  101456. export class HemisphericParticleEmitter implements IParticleEmitterType {
  101457. /**
  101458. * The radius of the emission hemisphere.
  101459. */
  101460. radius: number;
  101461. /**
  101462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101463. */
  101464. radiusRange: number;
  101465. /**
  101466. * How much to randomize the particle direction [0-1].
  101467. */
  101468. directionRandomizer: number;
  101469. /**
  101470. * Creates a new instance HemisphericParticleEmitter
  101471. * @param radius the radius of the emission hemisphere (1 by default)
  101472. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101473. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101474. */
  101475. constructor(
  101476. /**
  101477. * The radius of the emission hemisphere.
  101478. */
  101479. radius?: number,
  101480. /**
  101481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101482. */
  101483. radiusRange?: number,
  101484. /**
  101485. * How much to randomize the particle direction [0-1].
  101486. */
  101487. directionRandomizer?: number);
  101488. /**
  101489. * Called by the particle System when the direction is computed for the created particle.
  101490. * @param worldMatrix is the world matrix of the particle system
  101491. * @param directionToUpdate is the direction vector to update with the result
  101492. * @param particle is the particle we are computed the direction for
  101493. * @param isLocal defines if the direction should be set in local space
  101494. */
  101495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101496. /**
  101497. * Called by the particle System when the position is computed for the created particle.
  101498. * @param worldMatrix is the world matrix of the particle system
  101499. * @param positionToUpdate is the position vector to update with the result
  101500. * @param particle is the particle we are computed the position for
  101501. * @param isLocal defines if the position should be set in local space
  101502. */
  101503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101504. /**
  101505. * Clones the current emitter and returns a copy of it
  101506. * @returns the new emitter
  101507. */
  101508. clone(): HemisphericParticleEmitter;
  101509. /**
  101510. * Called by the GPUParticleSystem to setup the update shader
  101511. * @param effect defines the update shader
  101512. */
  101513. applyToShader(effect: Effect): void;
  101514. /**
  101515. * Returns a string to use to update the GPU particles update shader
  101516. * @returns a string containng the defines string
  101517. */
  101518. getEffectDefines(): string;
  101519. /**
  101520. * Returns the string "HemisphericParticleEmitter"
  101521. * @returns a string containing the class name
  101522. */
  101523. getClassName(): string;
  101524. /**
  101525. * Serializes the particle system to a JSON object.
  101526. * @returns the JSON object
  101527. */
  101528. serialize(): any;
  101529. /**
  101530. * Parse properties from a JSON object
  101531. * @param serializationObject defines the JSON object
  101532. */
  101533. parse(serializationObject: any): void;
  101534. }
  101535. }
  101536. declare module BABYLON {
  101537. /**
  101538. * Particle emitter emitting particles from a point.
  101539. * It emits the particles randomly between 2 given directions.
  101540. */
  101541. export class PointParticleEmitter implements IParticleEmitterType {
  101542. /**
  101543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101544. */
  101545. direction1: Vector3;
  101546. /**
  101547. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101548. */
  101549. direction2: Vector3;
  101550. /**
  101551. * Creates a new instance PointParticleEmitter
  101552. */
  101553. constructor();
  101554. /**
  101555. * Called by the particle System when the direction is computed for the created particle.
  101556. * @param worldMatrix is the world matrix of the particle system
  101557. * @param directionToUpdate is the direction vector to update with the result
  101558. * @param particle is the particle we are computed the direction for
  101559. * @param isLocal defines if the direction should be set in local space
  101560. */
  101561. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101562. /**
  101563. * Called by the particle System when the position is computed for the created particle.
  101564. * @param worldMatrix is the world matrix of the particle system
  101565. * @param positionToUpdate is the position vector to update with the result
  101566. * @param particle is the particle we are computed the position for
  101567. * @param isLocal defines if the position should be set in local space
  101568. */
  101569. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101570. /**
  101571. * Clones the current emitter and returns a copy of it
  101572. * @returns the new emitter
  101573. */
  101574. clone(): PointParticleEmitter;
  101575. /**
  101576. * Called by the GPUParticleSystem to setup the update shader
  101577. * @param effect defines the update shader
  101578. */
  101579. applyToShader(effect: Effect): void;
  101580. /**
  101581. * Returns a string to use to update the GPU particles update shader
  101582. * @returns a string containng the defines string
  101583. */
  101584. getEffectDefines(): string;
  101585. /**
  101586. * Returns the string "PointParticleEmitter"
  101587. * @returns a string containing the class name
  101588. */
  101589. getClassName(): string;
  101590. /**
  101591. * Serializes the particle system to a JSON object.
  101592. * @returns the JSON object
  101593. */
  101594. serialize(): any;
  101595. /**
  101596. * Parse properties from a JSON object
  101597. * @param serializationObject defines the JSON object
  101598. */
  101599. parse(serializationObject: any): void;
  101600. }
  101601. }
  101602. declare module BABYLON {
  101603. /**
  101604. * Particle emitter emitting particles from the inside of a sphere.
  101605. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101606. */
  101607. export class SphereParticleEmitter implements IParticleEmitterType {
  101608. /**
  101609. * The radius of the emission sphere.
  101610. */
  101611. radius: number;
  101612. /**
  101613. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101614. */
  101615. radiusRange: number;
  101616. /**
  101617. * How much to randomize the particle direction [0-1].
  101618. */
  101619. directionRandomizer: number;
  101620. /**
  101621. * Creates a new instance SphereParticleEmitter
  101622. * @param radius the radius of the emission sphere (1 by default)
  101623. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101624. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101625. */
  101626. constructor(
  101627. /**
  101628. * The radius of the emission sphere.
  101629. */
  101630. radius?: number,
  101631. /**
  101632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101633. */
  101634. radiusRange?: number,
  101635. /**
  101636. * How much to randomize the particle direction [0-1].
  101637. */
  101638. directionRandomizer?: number);
  101639. /**
  101640. * Called by the particle System when the direction is computed for the created particle.
  101641. * @param worldMatrix is the world matrix of the particle system
  101642. * @param directionToUpdate is the direction vector to update with the result
  101643. * @param particle is the particle we are computed the direction for
  101644. * @param isLocal defines if the direction should be set in local space
  101645. */
  101646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101647. /**
  101648. * Called by the particle System when the position is computed for the created particle.
  101649. * @param worldMatrix is the world matrix of the particle system
  101650. * @param positionToUpdate is the position vector to update with the result
  101651. * @param particle is the particle we are computed the position for
  101652. * @param isLocal defines if the position should be set in local space
  101653. */
  101654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101655. /**
  101656. * Clones the current emitter and returns a copy of it
  101657. * @returns the new emitter
  101658. */
  101659. clone(): SphereParticleEmitter;
  101660. /**
  101661. * Called by the GPUParticleSystem to setup the update shader
  101662. * @param effect defines the update shader
  101663. */
  101664. applyToShader(effect: Effect): void;
  101665. /**
  101666. * Returns a string to use to update the GPU particles update shader
  101667. * @returns a string containng the defines string
  101668. */
  101669. getEffectDefines(): string;
  101670. /**
  101671. * Returns the string "SphereParticleEmitter"
  101672. * @returns a string containing the class name
  101673. */
  101674. getClassName(): string;
  101675. /**
  101676. * Serializes the particle system to a JSON object.
  101677. * @returns the JSON object
  101678. */
  101679. serialize(): any;
  101680. /**
  101681. * Parse properties from a JSON object
  101682. * @param serializationObject defines the JSON object
  101683. */
  101684. parse(serializationObject: any): void;
  101685. }
  101686. /**
  101687. * Particle emitter emitting particles from the inside of a sphere.
  101688. * It emits the particles randomly between two vectors.
  101689. */
  101690. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  101691. /**
  101692. * The min limit of the emission direction.
  101693. */
  101694. direction1: Vector3;
  101695. /**
  101696. * The max limit of the emission direction.
  101697. */
  101698. direction2: Vector3;
  101699. /**
  101700. * Creates a new instance SphereDirectedParticleEmitter
  101701. * @param radius the radius of the emission sphere (1 by default)
  101702. * @param direction1 the min limit of the emission direction (up vector by default)
  101703. * @param direction2 the max limit of the emission direction (up vector by default)
  101704. */
  101705. constructor(radius?: number,
  101706. /**
  101707. * The min limit of the emission direction.
  101708. */
  101709. direction1?: Vector3,
  101710. /**
  101711. * The max limit of the emission direction.
  101712. */
  101713. direction2?: Vector3);
  101714. /**
  101715. * Called by the particle System when the direction is computed for the created particle.
  101716. * @param worldMatrix is the world matrix of the particle system
  101717. * @param directionToUpdate is the direction vector to update with the result
  101718. * @param particle is the particle we are computed the direction for
  101719. */
  101720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101721. /**
  101722. * Clones the current emitter and returns a copy of it
  101723. * @returns the new emitter
  101724. */
  101725. clone(): SphereDirectedParticleEmitter;
  101726. /**
  101727. * Called by the GPUParticleSystem to setup the update shader
  101728. * @param effect defines the update shader
  101729. */
  101730. applyToShader(effect: Effect): void;
  101731. /**
  101732. * Returns a string to use to update the GPU particles update shader
  101733. * @returns a string containng the defines string
  101734. */
  101735. getEffectDefines(): string;
  101736. /**
  101737. * Returns the string "SphereDirectedParticleEmitter"
  101738. * @returns a string containing the class name
  101739. */
  101740. getClassName(): string;
  101741. /**
  101742. * Serializes the particle system to a JSON object.
  101743. * @returns the JSON object
  101744. */
  101745. serialize(): any;
  101746. /**
  101747. * Parse properties from a JSON object
  101748. * @param serializationObject defines the JSON object
  101749. */
  101750. parse(serializationObject: any): void;
  101751. }
  101752. }
  101753. declare module BABYLON {
  101754. /**
  101755. * Particle emitter emitting particles from a custom list of positions.
  101756. */
  101757. export class CustomParticleEmitter implements IParticleEmitterType {
  101758. /**
  101759. * Gets or sets the position generator that will create the inital position of each particle.
  101760. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101761. */
  101762. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  101763. /**
  101764. * Gets or sets the destination generator that will create the final destination of each particle.
  101765. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101766. */
  101767. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  101768. /**
  101769. * Creates a new instance CustomParticleEmitter
  101770. */
  101771. constructor();
  101772. /**
  101773. * Called by the particle System when the direction is computed for the created particle.
  101774. * @param worldMatrix is the world matrix of the particle system
  101775. * @param directionToUpdate is the direction vector to update with the result
  101776. * @param particle is the particle we are computed the direction for
  101777. * @param isLocal defines if the direction should be set in local space
  101778. */
  101779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101780. /**
  101781. * Called by the particle System when the position is computed for the created particle.
  101782. * @param worldMatrix is the world matrix of the particle system
  101783. * @param positionToUpdate is the position vector to update with the result
  101784. * @param particle is the particle we are computed the position for
  101785. * @param isLocal defines if the position should be set in local space
  101786. */
  101787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101788. /**
  101789. * Clones the current emitter and returns a copy of it
  101790. * @returns the new emitter
  101791. */
  101792. clone(): CustomParticleEmitter;
  101793. /**
  101794. * Called by the GPUParticleSystem to setup the update shader
  101795. * @param effect defines the update shader
  101796. */
  101797. applyToShader(effect: Effect): void;
  101798. /**
  101799. * Returns a string to use to update the GPU particles update shader
  101800. * @returns a string containng the defines string
  101801. */
  101802. getEffectDefines(): string;
  101803. /**
  101804. * Returns the string "PointParticleEmitter"
  101805. * @returns a string containing the class name
  101806. */
  101807. getClassName(): string;
  101808. /**
  101809. * Serializes the particle system to a JSON object.
  101810. * @returns the JSON object
  101811. */
  101812. serialize(): any;
  101813. /**
  101814. * Parse properties from a JSON object
  101815. * @param serializationObject defines the JSON object
  101816. */
  101817. parse(serializationObject: any): void;
  101818. }
  101819. }
  101820. declare module BABYLON {
  101821. /**
  101822. * Particle emitter emitting particles from the inside of a box.
  101823. * It emits the particles randomly between 2 given directions.
  101824. */
  101825. export class MeshParticleEmitter implements IParticleEmitterType {
  101826. private _indices;
  101827. private _positions;
  101828. private _normals;
  101829. private _storedNormal;
  101830. private _mesh;
  101831. /**
  101832. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101833. */
  101834. direction1: Vector3;
  101835. /**
  101836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101837. */
  101838. direction2: Vector3;
  101839. /**
  101840. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  101841. */
  101842. useMeshNormalsForDirection: boolean;
  101843. /** Defines the mesh to use as source */
  101844. get mesh(): Nullable<AbstractMesh>;
  101845. set mesh(value: Nullable<AbstractMesh>);
  101846. /**
  101847. * Creates a new instance MeshParticleEmitter
  101848. * @param mesh defines the mesh to use as source
  101849. */
  101850. constructor(mesh?: Nullable<AbstractMesh>);
  101851. /**
  101852. * Called by the particle System when the direction is computed for the created particle.
  101853. * @param worldMatrix is the world matrix of the particle system
  101854. * @param directionToUpdate is the direction vector to update with the result
  101855. * @param particle is the particle we are computed the direction for
  101856. * @param isLocal defines if the direction should be set in local space
  101857. */
  101858. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101859. /**
  101860. * Called by the particle System when the position is computed for the created particle.
  101861. * @param worldMatrix is the world matrix of the particle system
  101862. * @param positionToUpdate is the position vector to update with the result
  101863. * @param particle is the particle we are computed the position for
  101864. * @param isLocal defines if the position should be set in local space
  101865. */
  101866. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101867. /**
  101868. * Clones the current emitter and returns a copy of it
  101869. * @returns the new emitter
  101870. */
  101871. clone(): MeshParticleEmitter;
  101872. /**
  101873. * Called by the GPUParticleSystem to setup the update shader
  101874. * @param effect defines the update shader
  101875. */
  101876. applyToShader(effect: Effect): void;
  101877. /**
  101878. * Returns a string to use to update the GPU particles update shader
  101879. * @returns a string containng the defines string
  101880. */
  101881. getEffectDefines(): string;
  101882. /**
  101883. * Returns the string "BoxParticleEmitter"
  101884. * @returns a string containing the class name
  101885. */
  101886. getClassName(): string;
  101887. /**
  101888. * Serializes the particle system to a JSON object.
  101889. * @returns the JSON object
  101890. */
  101891. serialize(): any;
  101892. /**
  101893. * Parse properties from a JSON object
  101894. * @param serializationObject defines the JSON object
  101895. * @param scene defines the hosting scene
  101896. */
  101897. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * Interface representing a particle system in Babylon.js.
  101903. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  101904. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  101905. */
  101906. export interface IParticleSystem {
  101907. /**
  101908. * List of animations used by the particle system.
  101909. */
  101910. animations: Animation[];
  101911. /**
  101912. * The id of the Particle system.
  101913. */
  101914. id: string;
  101915. /**
  101916. * The name of the Particle system.
  101917. */
  101918. name: string;
  101919. /**
  101920. * The emitter represents the Mesh or position we are attaching the particle system to.
  101921. */
  101922. emitter: Nullable<AbstractMesh | Vector3>;
  101923. /**
  101924. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  101925. */
  101926. isBillboardBased: boolean;
  101927. /**
  101928. * The rendering group used by the Particle system to chose when to render.
  101929. */
  101930. renderingGroupId: number;
  101931. /**
  101932. * The layer mask we are rendering the particles through.
  101933. */
  101934. layerMask: number;
  101935. /**
  101936. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101937. */
  101938. updateSpeed: number;
  101939. /**
  101940. * The amount of time the particle system is running (depends of the overall update speed).
  101941. */
  101942. targetStopDuration: number;
  101943. /**
  101944. * The texture used to render each particle. (this can be a spritesheet)
  101945. */
  101946. particleTexture: Nullable<BaseTexture>;
  101947. /**
  101948. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  101949. */
  101950. blendMode: number;
  101951. /**
  101952. * Minimum life time of emitting particles.
  101953. */
  101954. minLifeTime: number;
  101955. /**
  101956. * Maximum life time of emitting particles.
  101957. */
  101958. maxLifeTime: number;
  101959. /**
  101960. * Minimum Size of emitting particles.
  101961. */
  101962. minSize: number;
  101963. /**
  101964. * Maximum Size of emitting particles.
  101965. */
  101966. maxSize: number;
  101967. /**
  101968. * Minimum scale of emitting particles on X axis.
  101969. */
  101970. minScaleX: number;
  101971. /**
  101972. * Maximum scale of emitting particles on X axis.
  101973. */
  101974. maxScaleX: number;
  101975. /**
  101976. * Minimum scale of emitting particles on Y axis.
  101977. */
  101978. minScaleY: number;
  101979. /**
  101980. * Maximum scale of emitting particles on Y axis.
  101981. */
  101982. maxScaleY: number;
  101983. /**
  101984. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101985. */
  101986. color1: Color4;
  101987. /**
  101988. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101989. */
  101990. color2: Color4;
  101991. /**
  101992. * Color the particle will have at the end of its lifetime.
  101993. */
  101994. colorDead: Color4;
  101995. /**
  101996. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  101997. */
  101998. emitRate: number;
  101999. /**
  102000. * You can use gravity if you want to give an orientation to your particles.
  102001. */
  102002. gravity: Vector3;
  102003. /**
  102004. * Minimum power of emitting particles.
  102005. */
  102006. minEmitPower: number;
  102007. /**
  102008. * Maximum power of emitting particles.
  102009. */
  102010. maxEmitPower: number;
  102011. /**
  102012. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102013. */
  102014. minAngularSpeed: number;
  102015. /**
  102016. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102017. */
  102018. maxAngularSpeed: number;
  102019. /**
  102020. * Gets or sets the minimal initial rotation in radians.
  102021. */
  102022. minInitialRotation: number;
  102023. /**
  102024. * Gets or sets the maximal initial rotation in radians.
  102025. */
  102026. maxInitialRotation: number;
  102027. /**
  102028. * The particle emitter type defines the emitter used by the particle system.
  102029. * It can be for example box, sphere, or cone...
  102030. */
  102031. particleEmitterType: Nullable<IParticleEmitterType>;
  102032. /**
  102033. * Defines the delay in milliseconds before starting the system (0 by default)
  102034. */
  102035. startDelay: number;
  102036. /**
  102037. * 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
  102038. */
  102039. preWarmCycles: number;
  102040. /**
  102041. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  102042. */
  102043. preWarmStepOffset: number;
  102044. /**
  102045. * 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)
  102046. */
  102047. spriteCellChangeSpeed: number;
  102048. /**
  102049. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102050. */
  102051. startSpriteCellID: number;
  102052. /**
  102053. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102054. */
  102055. endSpriteCellID: number;
  102056. /**
  102057. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102058. */
  102059. spriteCellWidth: number;
  102060. /**
  102061. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102062. */
  102063. spriteCellHeight: number;
  102064. /**
  102065. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102066. */
  102067. spriteRandomStartCell: boolean;
  102068. /**
  102069. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  102070. */
  102071. isAnimationSheetEnabled: boolean;
  102072. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102073. translationPivot: Vector2;
  102074. /**
  102075. * Gets or sets a texture used to add random noise to particle positions
  102076. */
  102077. noiseTexture: Nullable<BaseTexture>;
  102078. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102079. noiseStrength: Vector3;
  102080. /**
  102081. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102082. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102083. */
  102084. billboardMode: number;
  102085. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102086. limitVelocityDamping: number;
  102087. /**
  102088. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102089. */
  102090. beginAnimationOnStart: boolean;
  102091. /**
  102092. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102093. */
  102094. beginAnimationFrom: number;
  102095. /**
  102096. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102097. */
  102098. beginAnimationTo: number;
  102099. /**
  102100. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102101. */
  102102. beginAnimationLoop: boolean;
  102103. /**
  102104. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102105. */
  102106. disposeOnStop: boolean;
  102107. /**
  102108. * Specifies if the particles are updated in emitter local space or world space
  102109. */
  102110. isLocal: boolean;
  102111. /** Snippet ID if the particle system was created from the snippet server */
  102112. snippetId: string;
  102113. /** Gets or sets a matrix to use to compute projection */
  102114. defaultProjectionMatrix: Matrix;
  102115. /**
  102116. * Gets the maximum number of particles active at the same time.
  102117. * @returns The max number of active particles.
  102118. */
  102119. getCapacity(): number;
  102120. /**
  102121. * Gets the number of particles active at the same time.
  102122. * @returns The number of active particles.
  102123. */
  102124. getActiveCount(): number;
  102125. /**
  102126. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102127. * @returns True if it has been started, otherwise false.
  102128. */
  102129. isStarted(): boolean;
  102130. /**
  102131. * Animates the particle system for this frame.
  102132. */
  102133. animate(): void;
  102134. /**
  102135. * Renders the particle system in its current state.
  102136. * @returns the current number of particles
  102137. */
  102138. render(): number;
  102139. /**
  102140. * Dispose the particle system and frees its associated resources.
  102141. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  102142. */
  102143. dispose(disposeTexture?: boolean): void;
  102144. /**
  102145. * An event triggered when the system is disposed
  102146. */
  102147. onDisposeObservable: Observable<IParticleSystem>;
  102148. /**
  102149. * An event triggered when the system is stopped
  102150. */
  102151. onStoppedObservable: Observable<IParticleSystem>;
  102152. /**
  102153. * Clones the particle system.
  102154. * @param name The name of the cloned object
  102155. * @param newEmitter The new emitter to use
  102156. * @returns the cloned particle system
  102157. */
  102158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  102159. /**
  102160. * Serializes the particle system to a JSON object
  102161. * @param serializeTexture defines if the texture must be serialized as well
  102162. * @returns the JSON object
  102163. */
  102164. serialize(serializeTexture: boolean): any;
  102165. /**
  102166. * Rebuild the particle system
  102167. */
  102168. rebuild(): void;
  102169. /** Force the system to rebuild all gradients that need to be resync */
  102170. forceRefreshGradients(): void;
  102171. /**
  102172. * Starts the particle system and begins to emit
  102173. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  102174. */
  102175. start(delay?: number): void;
  102176. /**
  102177. * Stops the particle system.
  102178. */
  102179. stop(): void;
  102180. /**
  102181. * Remove all active particles
  102182. */
  102183. reset(): void;
  102184. /**
  102185. * Gets a boolean indicating that the system is stopping
  102186. * @returns true if the system is currently stopping
  102187. */
  102188. isStopping(): boolean;
  102189. /**
  102190. * Is this system ready to be used/rendered
  102191. * @return true if the system is ready
  102192. */
  102193. isReady(): boolean;
  102194. /**
  102195. * Returns the string "ParticleSystem"
  102196. * @returns a string containing the class name
  102197. */
  102198. getClassName(): string;
  102199. /**
  102200. * Gets the custom effect used to render the particles
  102201. * @param blendMode Blend mode for which the effect should be retrieved
  102202. * @returns The effect
  102203. */
  102204. getCustomEffect(blendMode: number): Nullable<Effect>;
  102205. /**
  102206. * Sets the custom effect used to render the particles
  102207. * @param effect The effect to set
  102208. * @param blendMode Blend mode for which the effect should be set
  102209. */
  102210. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  102211. /**
  102212. * Fill the defines array according to the current settings of the particle system
  102213. * @param defines Array to be updated
  102214. * @param blendMode blend mode to take into account when updating the array
  102215. */
  102216. fillDefines(defines: Array<string>, blendMode: number): void;
  102217. /**
  102218. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  102219. * @param uniforms Uniforms array to fill
  102220. * @param attributes Attributes array to fill
  102221. * @param samplers Samplers array to fill
  102222. */
  102223. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  102224. /**
  102225. * Observable that will be called just before the particles are drawn
  102226. */
  102227. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  102228. /**
  102229. * Gets the name of the particle vertex shader
  102230. */
  102231. vertexShaderName: string;
  102232. /**
  102233. * Adds a new color gradient
  102234. * @param gradient defines the gradient to use (between 0 and 1)
  102235. * @param color1 defines the color to affect to the specified gradient
  102236. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102237. * @returns the current particle system
  102238. */
  102239. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  102240. /**
  102241. * Remove a specific color gradient
  102242. * @param gradient defines the gradient to remove
  102243. * @returns the current particle system
  102244. */
  102245. removeColorGradient(gradient: number): IParticleSystem;
  102246. /**
  102247. * Adds a new size gradient
  102248. * @param gradient defines the gradient to use (between 0 and 1)
  102249. * @param factor defines the size factor to affect to the specified gradient
  102250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102251. * @returns the current particle system
  102252. */
  102253. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102254. /**
  102255. * Remove a specific size gradient
  102256. * @param gradient defines the gradient to remove
  102257. * @returns the current particle system
  102258. */
  102259. removeSizeGradient(gradient: number): IParticleSystem;
  102260. /**
  102261. * Gets the current list of color gradients.
  102262. * You must use addColorGradient and removeColorGradient to udpate this list
  102263. * @returns the list of color gradients
  102264. */
  102265. getColorGradients(): Nullable<Array<ColorGradient>>;
  102266. /**
  102267. * Gets the current list of size gradients.
  102268. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102269. * @returns the list of size gradients
  102270. */
  102271. getSizeGradients(): Nullable<Array<FactorGradient>>;
  102272. /**
  102273. * Gets the current list of angular speed gradients.
  102274. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  102275. * @returns the list of angular speed gradients
  102276. */
  102277. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  102278. /**
  102279. * Adds a new angular speed gradient
  102280. * @param gradient defines the gradient to use (between 0 and 1)
  102281. * @param factor defines the angular speed to affect to the specified gradient
  102282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102283. * @returns the current particle system
  102284. */
  102285. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102286. /**
  102287. * Remove a specific angular speed gradient
  102288. * @param gradient defines the gradient to remove
  102289. * @returns the current particle system
  102290. */
  102291. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  102292. /**
  102293. * Gets the current list of velocity gradients.
  102294. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  102295. * @returns the list of velocity gradients
  102296. */
  102297. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  102298. /**
  102299. * Adds a new velocity gradient
  102300. * @param gradient defines the gradient to use (between 0 and 1)
  102301. * @param factor defines the velocity to affect to the specified gradient
  102302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102303. * @returns the current particle system
  102304. */
  102305. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102306. /**
  102307. * Remove a specific velocity gradient
  102308. * @param gradient defines the gradient to remove
  102309. * @returns the current particle system
  102310. */
  102311. removeVelocityGradient(gradient: number): IParticleSystem;
  102312. /**
  102313. * Gets the current list of limit velocity gradients.
  102314. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  102315. * @returns the list of limit velocity gradients
  102316. */
  102317. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  102318. /**
  102319. * Adds a new limit velocity gradient
  102320. * @param gradient defines the gradient to use (between 0 and 1)
  102321. * @param factor defines the limit velocity to affect to the specified gradient
  102322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102323. * @returns the current particle system
  102324. */
  102325. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102326. /**
  102327. * Remove a specific limit velocity gradient
  102328. * @param gradient defines the gradient to remove
  102329. * @returns the current particle system
  102330. */
  102331. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  102332. /**
  102333. * Adds a new drag gradient
  102334. * @param gradient defines the gradient to use (between 0 and 1)
  102335. * @param factor defines the drag to affect to the specified gradient
  102336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102337. * @returns the current particle system
  102338. */
  102339. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102340. /**
  102341. * Remove a specific drag gradient
  102342. * @param gradient defines the gradient to remove
  102343. * @returns the current particle system
  102344. */
  102345. removeDragGradient(gradient: number): IParticleSystem;
  102346. /**
  102347. * Gets the current list of drag gradients.
  102348. * You must use addDragGradient and removeDragGradient to udpate this list
  102349. * @returns the list of drag gradients
  102350. */
  102351. getDragGradients(): Nullable<Array<FactorGradient>>;
  102352. /**
  102353. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  102354. * @param gradient defines the gradient to use (between 0 and 1)
  102355. * @param factor defines the emit rate to affect to the specified gradient
  102356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102357. * @returns the current particle system
  102358. */
  102359. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102360. /**
  102361. * Remove a specific emit rate gradient
  102362. * @param gradient defines the gradient to remove
  102363. * @returns the current particle system
  102364. */
  102365. removeEmitRateGradient(gradient: number): IParticleSystem;
  102366. /**
  102367. * Gets the current list of emit rate gradients.
  102368. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  102369. * @returns the list of emit rate gradients
  102370. */
  102371. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  102372. /**
  102373. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  102374. * @param gradient defines the gradient to use (between 0 and 1)
  102375. * @param factor defines the start size to affect to the specified gradient
  102376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102377. * @returns the current particle system
  102378. */
  102379. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102380. /**
  102381. * Remove a specific start size gradient
  102382. * @param gradient defines the gradient to remove
  102383. * @returns the current particle system
  102384. */
  102385. removeStartSizeGradient(gradient: number): IParticleSystem;
  102386. /**
  102387. * Gets the current list of start size gradients.
  102388. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  102389. * @returns the list of start size gradients
  102390. */
  102391. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  102392. /**
  102393. * Adds a new life time gradient
  102394. * @param gradient defines the gradient to use (between 0 and 1)
  102395. * @param factor defines the life time factor to affect to the specified gradient
  102396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102397. * @returns the current particle system
  102398. */
  102399. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102400. /**
  102401. * Remove a specific life time gradient
  102402. * @param gradient defines the gradient to remove
  102403. * @returns the current particle system
  102404. */
  102405. removeLifeTimeGradient(gradient: number): IParticleSystem;
  102406. /**
  102407. * Gets the current list of life time gradients.
  102408. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102409. * @returns the list of life time gradients
  102410. */
  102411. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  102412. /**
  102413. * Gets the current list of color gradients.
  102414. * You must use addColorGradient and removeColorGradient to udpate this list
  102415. * @returns the list of color gradients
  102416. */
  102417. getColorGradients(): Nullable<Array<ColorGradient>>;
  102418. /**
  102419. * Adds a new ramp gradient used to remap particle colors
  102420. * @param gradient defines the gradient to use (between 0 and 1)
  102421. * @param color defines the color to affect to the specified gradient
  102422. * @returns the current particle system
  102423. */
  102424. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  102425. /**
  102426. * Gets the current list of ramp gradients.
  102427. * You must use addRampGradient and removeRampGradient to udpate this list
  102428. * @returns the list of ramp gradients
  102429. */
  102430. getRampGradients(): Nullable<Array<Color3Gradient>>;
  102431. /** Gets or sets a boolean indicating that ramp gradients must be used
  102432. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102433. */
  102434. useRampGradients: boolean;
  102435. /**
  102436. * Adds a new color remap gradient
  102437. * @param gradient defines the gradient to use (between 0 and 1)
  102438. * @param min defines the color remap minimal range
  102439. * @param max defines the color remap maximal range
  102440. * @returns the current particle system
  102441. */
  102442. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102443. /**
  102444. * Gets the current list of color remap gradients.
  102445. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102446. * @returns the list of color remap gradients
  102447. */
  102448. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  102449. /**
  102450. * Adds a new alpha remap gradient
  102451. * @param gradient defines the gradient to use (between 0 and 1)
  102452. * @param min defines the alpha remap minimal range
  102453. * @param max defines the alpha remap maximal range
  102454. * @returns the current particle system
  102455. */
  102456. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102457. /**
  102458. * Gets the current list of alpha remap gradients.
  102459. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102460. * @returns the list of alpha remap gradients
  102461. */
  102462. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  102463. /**
  102464. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102467. * @returns the emitter
  102468. */
  102469. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  102470. /**
  102471. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102472. * @param radius The radius of the hemisphere to emit from
  102473. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102474. * @returns the emitter
  102475. */
  102476. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  102477. /**
  102478. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102479. * @param radius The radius of the sphere to emit from
  102480. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102481. * @returns the emitter
  102482. */
  102483. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  102484. /**
  102485. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102486. * @param radius The radius of the sphere to emit from
  102487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102489. * @returns the emitter
  102490. */
  102491. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102492. /**
  102493. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102494. * @param radius The radius of the emission cylinder
  102495. * @param height The height of the emission cylinder
  102496. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102497. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102498. * @returns the emitter
  102499. */
  102500. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  102501. /**
  102502. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102503. * @param radius The radius of the cylinder to emit from
  102504. * @param height The height of the emission cylinder
  102505. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102508. * @returns the emitter
  102509. */
  102510. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102511. /**
  102512. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102513. * @param radius The radius of the cone to emit from
  102514. * @param angle The base angle of the cone
  102515. * @returns the emitter
  102516. */
  102517. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  102518. /**
  102519. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102522. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102523. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102524. * @returns the emitter
  102525. */
  102526. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  102527. /**
  102528. * Get hosting scene
  102529. * @returns the scene
  102530. */
  102531. getScene(): Nullable<Scene>;
  102532. }
  102533. }
  102534. declare module BABYLON {
  102535. /**
  102536. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102537. */
  102538. export class ColorSplitterBlock extends NodeMaterialBlock {
  102539. /**
  102540. * Create a new ColorSplitterBlock
  102541. * @param name defines the block name
  102542. */
  102543. constructor(name: string);
  102544. /**
  102545. * Gets the current class name
  102546. * @returns the class name
  102547. */
  102548. getClassName(): string;
  102549. /**
  102550. * Gets the rgba component (input)
  102551. */
  102552. get rgba(): NodeMaterialConnectionPoint;
  102553. /**
  102554. * Gets the rgb component (input)
  102555. */
  102556. get rgbIn(): NodeMaterialConnectionPoint;
  102557. /**
  102558. * Gets the rgb component (output)
  102559. */
  102560. get rgbOut(): NodeMaterialConnectionPoint;
  102561. /**
  102562. * Gets the r component (output)
  102563. */
  102564. get r(): NodeMaterialConnectionPoint;
  102565. /**
  102566. * Gets the g component (output)
  102567. */
  102568. get g(): NodeMaterialConnectionPoint;
  102569. /**
  102570. * Gets the b component (output)
  102571. */
  102572. get b(): NodeMaterialConnectionPoint;
  102573. /**
  102574. * Gets the a component (output)
  102575. */
  102576. get a(): NodeMaterialConnectionPoint;
  102577. protected _inputRename(name: string): string;
  102578. protected _outputRename(name: string): string;
  102579. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Operations supported by the Trigonometry block
  102585. */
  102586. export enum TrigonometryBlockOperations {
  102587. /** Cos */
  102588. Cos = 0,
  102589. /** Sin */
  102590. Sin = 1,
  102591. /** Abs */
  102592. Abs = 2,
  102593. /** Exp */
  102594. Exp = 3,
  102595. /** Exp2 */
  102596. Exp2 = 4,
  102597. /** Round */
  102598. Round = 5,
  102599. /** Floor */
  102600. Floor = 6,
  102601. /** Ceiling */
  102602. Ceiling = 7,
  102603. /** Square root */
  102604. Sqrt = 8,
  102605. /** Log */
  102606. Log = 9,
  102607. /** Tangent */
  102608. Tan = 10,
  102609. /** Arc tangent */
  102610. ArcTan = 11,
  102611. /** Arc cosinus */
  102612. ArcCos = 12,
  102613. /** Arc sinus */
  102614. ArcSin = 13,
  102615. /** Fraction */
  102616. Fract = 14,
  102617. /** Sign */
  102618. Sign = 15,
  102619. /** To radians (from degrees) */
  102620. Radians = 16,
  102621. /** To degrees (from radians) */
  102622. Degrees = 17
  102623. }
  102624. /**
  102625. * Block used to apply trigonometry operation to floats
  102626. */
  102627. export class TrigonometryBlock extends NodeMaterialBlock {
  102628. /**
  102629. * Gets or sets the operation applied by the block
  102630. */
  102631. operation: TrigonometryBlockOperations;
  102632. /**
  102633. * Creates a new TrigonometryBlock
  102634. * @param name defines the block name
  102635. */
  102636. constructor(name: string);
  102637. /**
  102638. * Gets the current class name
  102639. * @returns the class name
  102640. */
  102641. getClassName(): string;
  102642. /**
  102643. * Gets the input component
  102644. */
  102645. get input(): NodeMaterialConnectionPoint;
  102646. /**
  102647. * Gets the output component
  102648. */
  102649. get output(): NodeMaterialConnectionPoint;
  102650. protected _buildBlock(state: NodeMaterialBuildState): this;
  102651. serialize(): any;
  102652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102653. protected _dumpPropertiesCode(): string;
  102654. }
  102655. }
  102656. declare module BABYLON {
  102657. /**
  102658. * Interface used to configure the node material editor
  102659. */
  102660. export interface INodeMaterialEditorOptions {
  102661. /** Define the URl to load node editor script */
  102662. editorURL?: string;
  102663. }
  102664. /** @hidden */
  102665. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102666. NORMAL: boolean;
  102667. TANGENT: boolean;
  102668. UV1: boolean;
  102669. /** BONES */
  102670. NUM_BONE_INFLUENCERS: number;
  102671. BonesPerMesh: number;
  102672. BONETEXTURE: boolean;
  102673. /** MORPH TARGETS */
  102674. MORPHTARGETS: boolean;
  102675. MORPHTARGETS_NORMAL: boolean;
  102676. MORPHTARGETS_TANGENT: boolean;
  102677. MORPHTARGETS_UV: boolean;
  102678. NUM_MORPH_INFLUENCERS: number;
  102679. /** IMAGE PROCESSING */
  102680. IMAGEPROCESSING: boolean;
  102681. VIGNETTE: boolean;
  102682. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102683. VIGNETTEBLENDMODEOPAQUE: boolean;
  102684. TONEMAPPING: boolean;
  102685. TONEMAPPING_ACES: boolean;
  102686. CONTRAST: boolean;
  102687. EXPOSURE: boolean;
  102688. COLORCURVES: boolean;
  102689. COLORGRADING: boolean;
  102690. COLORGRADING3D: boolean;
  102691. SAMPLER3DGREENDEPTH: boolean;
  102692. SAMPLER3DBGRMAP: boolean;
  102693. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102694. /** MISC. */
  102695. BUMPDIRECTUV: number;
  102696. constructor();
  102697. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102698. }
  102699. /**
  102700. * Class used to configure NodeMaterial
  102701. */
  102702. export interface INodeMaterialOptions {
  102703. /**
  102704. * Defines if blocks should emit comments
  102705. */
  102706. emitComments: boolean;
  102707. }
  102708. /**
  102709. * Class used to create a node based material built by assembling shader blocks
  102710. */
  102711. export class NodeMaterial extends PushMaterial {
  102712. private static _BuildIdGenerator;
  102713. private _options;
  102714. private _vertexCompilationState;
  102715. private _fragmentCompilationState;
  102716. private _sharedData;
  102717. private _buildId;
  102718. private _buildWasSuccessful;
  102719. private _cachedWorldViewMatrix;
  102720. private _cachedWorldViewProjectionMatrix;
  102721. private _optimizers;
  102722. private _animationFrame;
  102723. /** Define the Url to load node editor script */
  102724. static EditorURL: string;
  102725. /** Define the Url to load snippets */
  102726. static SnippetUrl: string;
  102727. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102728. static IgnoreTexturesAtLoadTime: boolean;
  102729. private BJSNODEMATERIALEDITOR;
  102730. /** Get the inspector from bundle or global */
  102731. private _getGlobalNodeMaterialEditor;
  102732. /**
  102733. * Snippet ID if the material was created from the snippet server
  102734. */
  102735. snippetId: string;
  102736. /**
  102737. * Gets or sets data used by visual editor
  102738. * @see https://nme.babylonjs.com
  102739. */
  102740. editorData: any;
  102741. /**
  102742. * 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)
  102743. */
  102744. ignoreAlpha: boolean;
  102745. /**
  102746. * Defines the maximum number of lights that can be used in the material
  102747. */
  102748. maxSimultaneousLights: number;
  102749. /**
  102750. * Observable raised when the material is built
  102751. */
  102752. onBuildObservable: Observable<NodeMaterial>;
  102753. /**
  102754. * Gets or sets the root nodes of the material vertex shader
  102755. */
  102756. _vertexOutputNodes: NodeMaterialBlock[];
  102757. /**
  102758. * Gets or sets the root nodes of the material fragment (pixel) shader
  102759. */
  102760. _fragmentOutputNodes: NodeMaterialBlock[];
  102761. /** Gets or sets options to control the node material overall behavior */
  102762. get options(): INodeMaterialOptions;
  102763. set options(options: INodeMaterialOptions);
  102764. /**
  102765. * Default configuration related to image processing available in the standard Material.
  102766. */
  102767. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102768. /**
  102769. * Gets the image processing configuration used either in this material.
  102770. */
  102771. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102772. /**
  102773. * Sets the Default image processing configuration used either in the this material.
  102774. *
  102775. * If sets to null, the scene one is in use.
  102776. */
  102777. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102778. /**
  102779. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102780. */
  102781. attachedBlocks: NodeMaterialBlock[];
  102782. /**
  102783. * Specifies the mode of the node material
  102784. * @hidden
  102785. */
  102786. _mode: NodeMaterialModes;
  102787. /**
  102788. * Gets the mode property
  102789. */
  102790. get mode(): NodeMaterialModes;
  102791. /**
  102792. * A free comment about the material
  102793. */
  102794. comment: string;
  102795. /**
  102796. * Create a new node based material
  102797. * @param name defines the material name
  102798. * @param scene defines the hosting scene
  102799. * @param options defines creation option
  102800. */
  102801. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102802. /**
  102803. * Gets the current class name of the material e.g. "NodeMaterial"
  102804. * @returns the class name
  102805. */
  102806. getClassName(): string;
  102807. /**
  102808. * Keep track of the image processing observer to allow dispose and replace.
  102809. */
  102810. private _imageProcessingObserver;
  102811. /**
  102812. * Attaches a new image processing configuration to the Standard Material.
  102813. * @param configuration
  102814. */
  102815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102816. /**
  102817. * Get a block by its name
  102818. * @param name defines the name of the block to retrieve
  102819. * @returns the required block or null if not found
  102820. */
  102821. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102822. /**
  102823. * Get a block by its name
  102824. * @param predicate defines the predicate used to find the good candidate
  102825. * @returns the required block or null if not found
  102826. */
  102827. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102828. /**
  102829. * Get an input block by its name
  102830. * @param predicate defines the predicate used to find the good candidate
  102831. * @returns the required input block or null if not found
  102832. */
  102833. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102834. /**
  102835. * Gets the list of input blocks attached to this material
  102836. * @returns an array of InputBlocks
  102837. */
  102838. getInputBlocks(): InputBlock[];
  102839. /**
  102840. * Adds a new optimizer to the list of optimizers
  102841. * @param optimizer defines the optimizers to add
  102842. * @returns the current material
  102843. */
  102844. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102845. /**
  102846. * Remove an optimizer from the list of optimizers
  102847. * @param optimizer defines the optimizers to remove
  102848. * @returns the current material
  102849. */
  102850. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102851. /**
  102852. * Add a new block to the list of output nodes
  102853. * @param node defines the node to add
  102854. * @returns the current material
  102855. */
  102856. addOutputNode(node: NodeMaterialBlock): this;
  102857. /**
  102858. * Remove a block from the list of root nodes
  102859. * @param node defines the node to remove
  102860. * @returns the current material
  102861. */
  102862. removeOutputNode(node: NodeMaterialBlock): this;
  102863. private _addVertexOutputNode;
  102864. private _removeVertexOutputNode;
  102865. private _addFragmentOutputNode;
  102866. private _removeFragmentOutputNode;
  102867. /**
  102868. * Specifies if the material will require alpha blending
  102869. * @returns a boolean specifying if alpha blending is needed
  102870. */
  102871. needAlphaBlending(): boolean;
  102872. /**
  102873. * Specifies if this material should be rendered in alpha test mode
  102874. * @returns a boolean specifying if an alpha test is needed.
  102875. */
  102876. needAlphaTesting(): boolean;
  102877. private _initializeBlock;
  102878. private _resetDualBlocks;
  102879. /**
  102880. * Remove a block from the current node material
  102881. * @param block defines the block to remove
  102882. */
  102883. removeBlock(block: NodeMaterialBlock): void;
  102884. /**
  102885. * Build the material and generates the inner effect
  102886. * @param verbose defines if the build should log activity
  102887. */
  102888. build(verbose?: boolean): void;
  102889. /**
  102890. * Runs an otpimization phase to try to improve the shader code
  102891. */
  102892. optimize(): void;
  102893. private _prepareDefinesForAttributes;
  102894. /**
  102895. * Create a post process from the material
  102896. * @param camera The camera to apply the render pass to.
  102897. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102899. * @param engine The engine which the post process will be applied. (default: current engine)
  102900. * @param reusable If the post process can be reused on the same frame. (default: false)
  102901. * @param textureType Type of textures used when performing the post process. (default: 0)
  102902. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102903. * @returns the post process created
  102904. */
  102905. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102906. /**
  102907. * Create the post process effect from the material
  102908. * @param postProcess The post process to create the effect for
  102909. */
  102910. createEffectForPostProcess(postProcess: PostProcess): void;
  102911. private _createEffectForPostProcess;
  102912. /**
  102913. * Create a new procedural texture based on this node material
  102914. * @param size defines the size of the texture
  102915. * @param scene defines the hosting scene
  102916. * @returns the new procedural texture attached to this node material
  102917. */
  102918. createProceduralTexture(size: number | {
  102919. width: number;
  102920. height: number;
  102921. layers?: number;
  102922. }, scene: Scene): Nullable<ProceduralTexture>;
  102923. private _createEffectForParticles;
  102924. private _checkInternals;
  102925. /**
  102926. * Create the effect to be used as the custom effect for a particle system
  102927. * @param particleSystem Particle system to create the effect for
  102928. * @param onCompiled defines a function to call when the effect creation is successful
  102929. * @param onError defines a function to call when the effect creation has failed
  102930. */
  102931. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102932. private _processDefines;
  102933. /**
  102934. * Get if the submesh is ready to be used and all its information available.
  102935. * Child classes can use it to update shaders
  102936. * @param mesh defines the mesh to check
  102937. * @param subMesh defines which submesh to check
  102938. * @param useInstances specifies that instances should be used
  102939. * @returns a boolean indicating that the submesh is ready or not
  102940. */
  102941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102942. /**
  102943. * Get a string representing the shaders built by the current node graph
  102944. */
  102945. get compiledShaders(): string;
  102946. /**
  102947. * Binds the world matrix to the material
  102948. * @param world defines the world transformation matrix
  102949. */
  102950. bindOnlyWorldMatrix(world: Matrix): void;
  102951. /**
  102952. * Binds the submesh to this material by preparing the effect and shader to draw
  102953. * @param world defines the world transformation matrix
  102954. * @param mesh defines the mesh containing the submesh
  102955. * @param subMesh defines the submesh to bind the material to
  102956. */
  102957. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102958. /**
  102959. * Gets the active textures from the material
  102960. * @returns an array of textures
  102961. */
  102962. getActiveTextures(): BaseTexture[];
  102963. /**
  102964. * Gets the list of texture blocks
  102965. * @returns an array of texture blocks
  102966. */
  102967. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102968. /**
  102969. * Specifies if the material uses a texture
  102970. * @param texture defines the texture to check against the material
  102971. * @returns a boolean specifying if the material uses the texture
  102972. */
  102973. hasTexture(texture: BaseTexture): boolean;
  102974. /**
  102975. * Disposes the material
  102976. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102977. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102978. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102979. */
  102980. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102981. /** Creates the node editor window. */
  102982. private _createNodeEditor;
  102983. /**
  102984. * Launch the node material editor
  102985. * @param config Define the configuration of the editor
  102986. * @return a promise fulfilled when the node editor is visible
  102987. */
  102988. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102989. /**
  102990. * Clear the current material
  102991. */
  102992. clear(): void;
  102993. /**
  102994. * Clear the current material and set it to a default state
  102995. */
  102996. setToDefault(): void;
  102997. /**
  102998. * Clear the current material and set it to a default state for post process
  102999. */
  103000. setToDefaultPostProcess(): void;
  103001. /**
  103002. * Clear the current material and set it to a default state for procedural texture
  103003. */
  103004. setToDefaultProceduralTexture(): void;
  103005. /**
  103006. * Clear the current material and set it to a default state for particle
  103007. */
  103008. setToDefaultParticle(): void;
  103009. /**
  103010. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103011. * @param url defines the url to load from
  103012. * @returns a promise that will fullfil when the material is fully loaded
  103013. */
  103014. loadAsync(url: string): Promise<void>;
  103015. private _gatherBlocks;
  103016. /**
  103017. * Generate a string containing the code declaration required to create an equivalent of this material
  103018. * @returns a string
  103019. */
  103020. generateCode(): string;
  103021. /**
  103022. * Serializes this material in a JSON representation
  103023. * @returns the serialized material object
  103024. */
  103025. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103026. private _restoreConnections;
  103027. /**
  103028. * Clear the current graph and load a new one from a serialization object
  103029. * @param source defines the JSON representation of the material
  103030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103031. * @param merge defines whether or not the source must be merged or replace the current content
  103032. */
  103033. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103034. /**
  103035. * Makes a duplicate of the current material.
  103036. * @param name - name to use for the new material.
  103037. */
  103038. clone(name: string): NodeMaterial;
  103039. /**
  103040. * Creates a node material from parsed material data
  103041. * @param source defines the JSON representation of the material
  103042. * @param scene defines the hosting scene
  103043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103044. * @returns a new node material
  103045. */
  103046. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103047. /**
  103048. * Creates a node material from a snippet saved in a remote file
  103049. * @param name defines the name of the material to create
  103050. * @param url defines the url to load from
  103051. * @param scene defines the hosting scene
  103052. * @returns a promise that will resolve to the new node material
  103053. */
  103054. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103055. /**
  103056. * Creates a node material from a snippet saved by the node material editor
  103057. * @param snippetId defines the snippet to load
  103058. * @param scene defines the hosting scene
  103059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103060. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103061. * @returns a promise that will resolve to the new node material
  103062. */
  103063. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103064. /**
  103065. * Creates a new node material set to default basic configuration
  103066. * @param name defines the name of the material
  103067. * @param scene defines the hosting scene
  103068. * @returns a new NodeMaterial
  103069. */
  103070. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103071. }
  103072. }
  103073. declare module BABYLON {
  103074. interface ThinEngine {
  103075. /**
  103076. * Unbind a list of render target textures from the webGL context
  103077. * This is used only when drawBuffer extension or webGL2 are active
  103078. * @param textures defines the render target textures to unbind
  103079. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103080. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103081. */
  103082. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103083. /**
  103084. * Create a multi render target texture
  103085. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103086. * @param size defines the size of the texture
  103087. * @param options defines the creation options
  103088. * @returns the cube texture as an InternalTexture
  103089. */
  103090. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103091. /**
  103092. * Update the sample count for a given multiple render target texture
  103093. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103094. * @param textures defines the textures to update
  103095. * @param samples defines the sample count to set
  103096. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103097. */
  103098. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103099. /**
  103100. * Select a subsets of attachments to draw to.
  103101. * @param attachments gl attachments
  103102. */
  103103. bindAttachments(attachments: number[]): void;
  103104. /**
  103105. * Creates a layout object to draw/clear on specific textures in a MRT
  103106. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103107. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103108. */
  103109. buildTextureLayout(textureStatus: boolean[]): number[];
  103110. /**
  103111. * Restores the webgl state to only draw on the main color attachment
  103112. */
  103113. restoreSingleAttachment(): void;
  103114. /**
  103115. * Clears a list of attachments
  103116. * @param attachments list of the attachments
  103117. * @param colorMain clear color for the main attachment (the first one)
  103118. * @param colorOthers clear color for the other attachments
  103119. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  103120. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  103121. */
  103122. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  103123. }
  103124. }
  103125. declare module BABYLON {
  103126. /**
  103127. * Creation options of the multi render target texture.
  103128. */
  103129. export interface IMultiRenderTargetOptions {
  103130. /**
  103131. * Define if the texture needs to create mip maps after render.
  103132. */
  103133. generateMipMaps?: boolean;
  103134. /**
  103135. * Define the types of all the draw buffers we want to create
  103136. */
  103137. types?: number[];
  103138. /**
  103139. * Define the sampling modes of all the draw buffers we want to create
  103140. */
  103141. samplingModes?: number[];
  103142. /**
  103143. * Define if a depth buffer is required
  103144. */
  103145. generateDepthBuffer?: boolean;
  103146. /**
  103147. * Define if a stencil buffer is required
  103148. */
  103149. generateStencilBuffer?: boolean;
  103150. /**
  103151. * Define if a depth texture is required instead of a depth buffer
  103152. */
  103153. generateDepthTexture?: boolean;
  103154. /**
  103155. * Define the number of desired draw buffers
  103156. */
  103157. textureCount?: number;
  103158. /**
  103159. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103160. */
  103161. doNotChangeAspectRatio?: boolean;
  103162. /**
  103163. * Define the default type of the buffers we are creating
  103164. */
  103165. defaultType?: number;
  103166. }
  103167. /**
  103168. * A multi render target, like a render target provides the ability to render to a texture.
  103169. * Unlike the render target, it can render to several draw buffers in one draw.
  103170. * This is specially interesting in deferred rendering or for any effects requiring more than
  103171. * just one color from a single pass.
  103172. */
  103173. export class MultiRenderTarget extends RenderTargetTexture {
  103174. private _internalTextures;
  103175. private _textures;
  103176. private _multiRenderTargetOptions;
  103177. private _count;
  103178. /**
  103179. * Get if draw buffers are currently supported by the used hardware and browser.
  103180. */
  103181. get isSupported(): boolean;
  103182. /**
  103183. * Get the list of textures generated by the multi render target.
  103184. */
  103185. get textures(): Texture[];
  103186. /**
  103187. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103188. */
  103189. get count(): number;
  103190. /**
  103191. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103192. */
  103193. get depthTexture(): Texture;
  103194. /**
  103195. * Set the wrapping mode on U of all the textures we are rendering to.
  103196. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103197. */
  103198. set wrapU(wrap: number);
  103199. /**
  103200. * Set the wrapping mode on V of all the textures we are rendering to.
  103201. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103202. */
  103203. set wrapV(wrap: number);
  103204. /**
  103205. * Instantiate a new multi render target texture.
  103206. * A multi render target, like a render target provides the ability to render to a texture.
  103207. * Unlike the render target, it can render to several draw buffers in one draw.
  103208. * This is specially interesting in deferred rendering or for any effects requiring more than
  103209. * just one color from a single pass.
  103210. * @param name Define the name of the texture
  103211. * @param size Define the size of the buffers to render to
  103212. * @param count Define the number of target we are rendering into
  103213. * @param scene Define the scene the texture belongs to
  103214. * @param options Define the options used to create the multi render target
  103215. */
  103216. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103217. private _initTypes;
  103218. /** @hidden */
  103219. _rebuild(forceFullRebuild?: boolean): void;
  103220. private _createInternalTextures;
  103221. private _createTextures;
  103222. /**
  103223. * Replaces a texture within the MRT.
  103224. * @param texture The new texture to insert in the MRT
  103225. * @param index The index of the texture to replace
  103226. */
  103227. replaceTexture(texture: Texture, index: number): void;
  103228. /**
  103229. * Define the number of samples used if MSAA is enabled.
  103230. */
  103231. get samples(): number;
  103232. set samples(value: number);
  103233. /**
  103234. * Resize all the textures in the multi render target.
  103235. * Be careful as it will recreate all the data in the new texture.
  103236. * @param size Define the new size
  103237. */
  103238. resize(size: any): void;
  103239. /**
  103240. * Changes the number of render targets in this MRT
  103241. * Be careful as it will recreate all the data in the new texture.
  103242. * @param count new texture count
  103243. * @param options Specifies texture types and sampling modes for new textures
  103244. */
  103245. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103246. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103247. /**
  103248. * Dispose the render targets and their associated resources
  103249. */
  103250. dispose(): void;
  103251. /**
  103252. * Release all the underlying texture used as draw buffers.
  103253. */
  103254. releaseInternalTextures(): void;
  103255. }
  103256. }
  103257. declare module BABYLON {
  103258. /** @hidden */
  103259. export var imageProcessingPixelShader: {
  103260. name: string;
  103261. shader: string;
  103262. };
  103263. }
  103264. declare module BABYLON {
  103265. /**
  103266. * ImageProcessingPostProcess
  103267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103268. */
  103269. export class ImageProcessingPostProcess extends PostProcess {
  103270. /**
  103271. * Default configuration related to image processing available in the PBR Material.
  103272. */
  103273. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103274. /**
  103275. * Gets the image processing configuration used either in this material.
  103276. */
  103277. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103278. /**
  103279. * Sets the Default image processing configuration used either in the this material.
  103280. *
  103281. * If sets to null, the scene one is in use.
  103282. */
  103283. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103284. /**
  103285. * Keep track of the image processing observer to allow dispose and replace.
  103286. */
  103287. private _imageProcessingObserver;
  103288. /**
  103289. * Attaches a new image processing configuration to the PBR Material.
  103290. * @param configuration
  103291. */
  103292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103293. /**
  103294. * If the post process is supported.
  103295. */
  103296. get isSupported(): boolean;
  103297. /**
  103298. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103299. */
  103300. get colorCurves(): Nullable<ColorCurves>;
  103301. /**
  103302. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103303. */
  103304. set colorCurves(value: Nullable<ColorCurves>);
  103305. /**
  103306. * Gets wether the color curves effect is enabled.
  103307. */
  103308. get colorCurvesEnabled(): boolean;
  103309. /**
  103310. * Sets wether the color curves effect is enabled.
  103311. */
  103312. set colorCurvesEnabled(value: boolean);
  103313. /**
  103314. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103315. */
  103316. get colorGradingTexture(): Nullable<BaseTexture>;
  103317. /**
  103318. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103319. */
  103320. set colorGradingTexture(value: Nullable<BaseTexture>);
  103321. /**
  103322. * Gets wether the color grading effect is enabled.
  103323. */
  103324. get colorGradingEnabled(): boolean;
  103325. /**
  103326. * Gets wether the color grading effect is enabled.
  103327. */
  103328. set colorGradingEnabled(value: boolean);
  103329. /**
  103330. * Gets exposure used in the effect.
  103331. */
  103332. get exposure(): number;
  103333. /**
  103334. * Sets exposure used in the effect.
  103335. */
  103336. set exposure(value: number);
  103337. /**
  103338. * Gets wether tonemapping is enabled or not.
  103339. */
  103340. get toneMappingEnabled(): boolean;
  103341. /**
  103342. * Sets wether tonemapping is enabled or not
  103343. */
  103344. set toneMappingEnabled(value: boolean);
  103345. /**
  103346. * Gets the type of tone mapping effect.
  103347. */
  103348. get toneMappingType(): number;
  103349. /**
  103350. * Sets the type of tone mapping effect.
  103351. */
  103352. set toneMappingType(value: number);
  103353. /**
  103354. * Gets contrast used in the effect.
  103355. */
  103356. get contrast(): number;
  103357. /**
  103358. * Sets contrast used in the effect.
  103359. */
  103360. set contrast(value: number);
  103361. /**
  103362. * Gets Vignette stretch size.
  103363. */
  103364. get vignetteStretch(): number;
  103365. /**
  103366. * Sets Vignette stretch size.
  103367. */
  103368. set vignetteStretch(value: number);
  103369. /**
  103370. * Gets Vignette centre X Offset.
  103371. */
  103372. get vignetteCentreX(): number;
  103373. /**
  103374. * Sets Vignette centre X Offset.
  103375. */
  103376. set vignetteCentreX(value: number);
  103377. /**
  103378. * Gets Vignette centre Y Offset.
  103379. */
  103380. get vignetteCentreY(): number;
  103381. /**
  103382. * Sets Vignette centre Y Offset.
  103383. */
  103384. set vignetteCentreY(value: number);
  103385. /**
  103386. * Gets Vignette weight or intensity of the vignette effect.
  103387. */
  103388. get vignetteWeight(): number;
  103389. /**
  103390. * Sets Vignette weight or intensity of the vignette effect.
  103391. */
  103392. set vignetteWeight(value: number);
  103393. /**
  103394. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103395. * if vignetteEnabled is set to true.
  103396. */
  103397. get vignetteColor(): Color4;
  103398. /**
  103399. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103400. * if vignetteEnabled is set to true.
  103401. */
  103402. set vignetteColor(value: Color4);
  103403. /**
  103404. * Gets Camera field of view used by the Vignette effect.
  103405. */
  103406. get vignetteCameraFov(): number;
  103407. /**
  103408. * Sets Camera field of view used by the Vignette effect.
  103409. */
  103410. set vignetteCameraFov(value: number);
  103411. /**
  103412. * Gets the vignette blend mode allowing different kind of effect.
  103413. */
  103414. get vignetteBlendMode(): number;
  103415. /**
  103416. * Sets the vignette blend mode allowing different kind of effect.
  103417. */
  103418. set vignetteBlendMode(value: number);
  103419. /**
  103420. * Gets wether the vignette effect is enabled.
  103421. */
  103422. get vignetteEnabled(): boolean;
  103423. /**
  103424. * Sets wether the vignette effect is enabled.
  103425. */
  103426. set vignetteEnabled(value: boolean);
  103427. private _fromLinearSpace;
  103428. /**
  103429. * Gets wether the input of the processing is in Gamma or Linear Space.
  103430. */
  103431. get fromLinearSpace(): boolean;
  103432. /**
  103433. * Sets wether the input of the processing is in Gamma or Linear Space.
  103434. */
  103435. set fromLinearSpace(value: boolean);
  103436. /**
  103437. * Defines cache preventing GC.
  103438. */
  103439. private _defines;
  103440. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103441. /**
  103442. * "ImageProcessingPostProcess"
  103443. * @returns "ImageProcessingPostProcess"
  103444. */
  103445. getClassName(): string;
  103446. /**
  103447. * @hidden
  103448. */
  103449. _updateParameters(): void;
  103450. dispose(camera?: Camera): void;
  103451. }
  103452. }
  103453. declare module BABYLON {
  103454. /**
  103455. * Interface for defining prepass effects in the prepass post-process pipeline
  103456. */
  103457. export interface PrePassEffectConfiguration {
  103458. /**
  103459. * Name of the effect
  103460. */
  103461. name: string;
  103462. /**
  103463. * Post process to attach for this effect
  103464. */
  103465. postProcess?: PostProcess;
  103466. /**
  103467. * Textures required in the MRT
  103468. */
  103469. texturesRequired: number[];
  103470. /**
  103471. * Is the effect enabled
  103472. */
  103473. enabled: boolean;
  103474. /**
  103475. * Disposes the effect configuration
  103476. */
  103477. dispose?: () => void;
  103478. /**
  103479. * Creates the associated post process
  103480. */
  103481. createPostProcess?: () => PostProcess;
  103482. }
  103483. }
  103484. declare module BABYLON {
  103485. /**
  103486. * Options to be used when creating a FresnelParameters.
  103487. */
  103488. export type IFresnelParametersCreationOptions = {
  103489. /**
  103490. * Define the color used on edges (grazing angle)
  103491. */
  103492. leftColor?: Color3;
  103493. /**
  103494. * Define the color used on center
  103495. */
  103496. rightColor?: Color3;
  103497. /**
  103498. * Define bias applied to computed fresnel term
  103499. */
  103500. bias?: number;
  103501. /**
  103502. * Defined the power exponent applied to fresnel term
  103503. */
  103504. power?: number;
  103505. /**
  103506. * Define if the fresnel effect is enable or not.
  103507. */
  103508. isEnabled?: boolean;
  103509. };
  103510. /**
  103511. * Serialized format for FresnelParameters.
  103512. */
  103513. export type IFresnelParametersSerialized = {
  103514. /**
  103515. * Define the color used on edges (grazing angle) [as an array]
  103516. */
  103517. leftColor: number[];
  103518. /**
  103519. * Define the color used on center [as an array]
  103520. */
  103521. rightColor: number[];
  103522. /**
  103523. * Define bias applied to computed fresnel term
  103524. */
  103525. bias: number;
  103526. /**
  103527. * Defined the power exponent applied to fresnel term
  103528. */
  103529. power?: number;
  103530. /**
  103531. * Define if the fresnel effect is enable or not.
  103532. */
  103533. isEnabled: boolean;
  103534. };
  103535. /**
  103536. * This represents all the required information to add a fresnel effect on a material:
  103537. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103538. */
  103539. export class FresnelParameters {
  103540. private _isEnabled;
  103541. /**
  103542. * Define if the fresnel effect is enable or not.
  103543. */
  103544. get isEnabled(): boolean;
  103545. set isEnabled(value: boolean);
  103546. /**
  103547. * Define the color used on edges (grazing angle)
  103548. */
  103549. leftColor: Color3;
  103550. /**
  103551. * Define the color used on center
  103552. */
  103553. rightColor: Color3;
  103554. /**
  103555. * Define bias applied to computed fresnel term
  103556. */
  103557. bias: number;
  103558. /**
  103559. * Defined the power exponent applied to fresnel term
  103560. */
  103561. power: number;
  103562. /**
  103563. * Creates a new FresnelParameters object.
  103564. *
  103565. * @param options provide your own settings to optionally to override defaults
  103566. */
  103567. constructor(options?: IFresnelParametersCreationOptions);
  103568. /**
  103569. * Clones the current fresnel and its valuues
  103570. * @returns a clone fresnel configuration
  103571. */
  103572. clone(): FresnelParameters;
  103573. /**
  103574. * Determines equality between FresnelParameters objects
  103575. * @param otherFresnelParameters defines the second operand
  103576. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103577. */
  103578. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103579. /**
  103580. * Serializes the current fresnel parameters to a JSON representation.
  103581. * @return the JSON serialization
  103582. */
  103583. serialize(): IFresnelParametersSerialized;
  103584. /**
  103585. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103586. * @param parsedFresnelParameters Define the JSON representation
  103587. * @returns the parsed parameters
  103588. */
  103589. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103590. }
  103591. }
  103592. declare module BABYLON {
  103593. /**
  103594. * This groups all the flags used to control the materials channel.
  103595. */
  103596. export class MaterialFlags {
  103597. private static _DiffuseTextureEnabled;
  103598. /**
  103599. * Are diffuse textures enabled in the application.
  103600. */
  103601. static get DiffuseTextureEnabled(): boolean;
  103602. static set DiffuseTextureEnabled(value: boolean);
  103603. private static _DetailTextureEnabled;
  103604. /**
  103605. * Are detail textures enabled in the application.
  103606. */
  103607. static get DetailTextureEnabled(): boolean;
  103608. static set DetailTextureEnabled(value: boolean);
  103609. private static _AmbientTextureEnabled;
  103610. /**
  103611. * Are ambient textures enabled in the application.
  103612. */
  103613. static get AmbientTextureEnabled(): boolean;
  103614. static set AmbientTextureEnabled(value: boolean);
  103615. private static _OpacityTextureEnabled;
  103616. /**
  103617. * Are opacity textures enabled in the application.
  103618. */
  103619. static get OpacityTextureEnabled(): boolean;
  103620. static set OpacityTextureEnabled(value: boolean);
  103621. private static _ReflectionTextureEnabled;
  103622. /**
  103623. * Are reflection textures enabled in the application.
  103624. */
  103625. static get ReflectionTextureEnabled(): boolean;
  103626. static set ReflectionTextureEnabled(value: boolean);
  103627. private static _EmissiveTextureEnabled;
  103628. /**
  103629. * Are emissive textures enabled in the application.
  103630. */
  103631. static get EmissiveTextureEnabled(): boolean;
  103632. static set EmissiveTextureEnabled(value: boolean);
  103633. private static _SpecularTextureEnabled;
  103634. /**
  103635. * Are specular textures enabled in the application.
  103636. */
  103637. static get SpecularTextureEnabled(): boolean;
  103638. static set SpecularTextureEnabled(value: boolean);
  103639. private static _BumpTextureEnabled;
  103640. /**
  103641. * Are bump textures enabled in the application.
  103642. */
  103643. static get BumpTextureEnabled(): boolean;
  103644. static set BumpTextureEnabled(value: boolean);
  103645. private static _LightmapTextureEnabled;
  103646. /**
  103647. * Are lightmap textures enabled in the application.
  103648. */
  103649. static get LightmapTextureEnabled(): boolean;
  103650. static set LightmapTextureEnabled(value: boolean);
  103651. private static _RefractionTextureEnabled;
  103652. /**
  103653. * Are refraction textures enabled in the application.
  103654. */
  103655. static get RefractionTextureEnabled(): boolean;
  103656. static set RefractionTextureEnabled(value: boolean);
  103657. private static _ColorGradingTextureEnabled;
  103658. /**
  103659. * Are color grading textures enabled in the application.
  103660. */
  103661. static get ColorGradingTextureEnabled(): boolean;
  103662. static set ColorGradingTextureEnabled(value: boolean);
  103663. private static _FresnelEnabled;
  103664. /**
  103665. * Are fresnels enabled in the application.
  103666. */
  103667. static get FresnelEnabled(): boolean;
  103668. static set FresnelEnabled(value: boolean);
  103669. private static _ClearCoatTextureEnabled;
  103670. /**
  103671. * Are clear coat textures enabled in the application.
  103672. */
  103673. static get ClearCoatTextureEnabled(): boolean;
  103674. static set ClearCoatTextureEnabled(value: boolean);
  103675. private static _ClearCoatBumpTextureEnabled;
  103676. /**
  103677. * Are clear coat bump textures enabled in the application.
  103678. */
  103679. static get ClearCoatBumpTextureEnabled(): boolean;
  103680. static set ClearCoatBumpTextureEnabled(value: boolean);
  103681. private static _ClearCoatTintTextureEnabled;
  103682. /**
  103683. * Are clear coat tint textures enabled in the application.
  103684. */
  103685. static get ClearCoatTintTextureEnabled(): boolean;
  103686. static set ClearCoatTintTextureEnabled(value: boolean);
  103687. private static _SheenTextureEnabled;
  103688. /**
  103689. * Are sheen textures enabled in the application.
  103690. */
  103691. static get SheenTextureEnabled(): boolean;
  103692. static set SheenTextureEnabled(value: boolean);
  103693. private static _AnisotropicTextureEnabled;
  103694. /**
  103695. * Are anisotropic textures enabled in the application.
  103696. */
  103697. static get AnisotropicTextureEnabled(): boolean;
  103698. static set AnisotropicTextureEnabled(value: boolean);
  103699. private static _ThicknessTextureEnabled;
  103700. /**
  103701. * Are thickness textures enabled in the application.
  103702. */
  103703. static get ThicknessTextureEnabled(): boolean;
  103704. static set ThicknessTextureEnabled(value: boolean);
  103705. }
  103706. }
  103707. declare module BABYLON {
  103708. /** @hidden */
  103709. export var defaultFragmentDeclaration: {
  103710. name: string;
  103711. shader: string;
  103712. };
  103713. }
  103714. declare module BABYLON {
  103715. /** @hidden */
  103716. export var sceneUboDeclaration: {
  103717. name: string;
  103718. shader: string;
  103719. };
  103720. }
  103721. declare module BABYLON {
  103722. /** @hidden */
  103723. export var meshUboDeclaration: {
  103724. name: string;
  103725. shader: string;
  103726. };
  103727. }
  103728. declare module BABYLON {
  103729. /** @hidden */
  103730. export var defaultUboDeclaration: {
  103731. name: string;
  103732. shader: string;
  103733. };
  103734. }
  103735. declare module BABYLON {
  103736. /** @hidden */
  103737. export var prePassDeclaration: {
  103738. name: string;
  103739. shader: string;
  103740. };
  103741. }
  103742. declare module BABYLON {
  103743. /** @hidden */
  103744. export var lightFragmentDeclaration: {
  103745. name: string;
  103746. shader: string;
  103747. };
  103748. }
  103749. declare module BABYLON {
  103750. /** @hidden */
  103751. export var lightUboDeclaration: {
  103752. name: string;
  103753. shader: string;
  103754. };
  103755. }
  103756. declare module BABYLON {
  103757. /** @hidden */
  103758. export var lightsFragmentFunctions: {
  103759. name: string;
  103760. shader: string;
  103761. };
  103762. }
  103763. declare module BABYLON {
  103764. /** @hidden */
  103765. export var shadowsFragmentFunctions: {
  103766. name: string;
  103767. shader: string;
  103768. };
  103769. }
  103770. declare module BABYLON {
  103771. /** @hidden */
  103772. export var fresnelFunction: {
  103773. name: string;
  103774. shader: string;
  103775. };
  103776. }
  103777. declare module BABYLON {
  103778. /** @hidden */
  103779. export var bumpFragmentMainFunctions: {
  103780. name: string;
  103781. shader: string;
  103782. };
  103783. }
  103784. declare module BABYLON {
  103785. /** @hidden */
  103786. export var bumpFragmentFunctions: {
  103787. name: string;
  103788. shader: string;
  103789. };
  103790. }
  103791. declare module BABYLON {
  103792. /** @hidden */
  103793. export var logDepthDeclaration: {
  103794. name: string;
  103795. shader: string;
  103796. };
  103797. }
  103798. declare module BABYLON {
  103799. /** @hidden */
  103800. export var fogFragmentDeclaration: {
  103801. name: string;
  103802. shader: string;
  103803. };
  103804. }
  103805. declare module BABYLON {
  103806. /** @hidden */
  103807. export var bumpFragment: {
  103808. name: string;
  103809. shader: string;
  103810. };
  103811. }
  103812. declare module BABYLON {
  103813. /** @hidden */
  103814. export var depthPrePass: {
  103815. name: string;
  103816. shader: string;
  103817. };
  103818. }
  103819. declare module BABYLON {
  103820. /** @hidden */
  103821. export var lightFragment: {
  103822. name: string;
  103823. shader: string;
  103824. };
  103825. }
  103826. declare module BABYLON {
  103827. /** @hidden */
  103828. export var logDepthFragment: {
  103829. name: string;
  103830. shader: string;
  103831. };
  103832. }
  103833. declare module BABYLON {
  103834. /** @hidden */
  103835. export var fogFragment: {
  103836. name: string;
  103837. shader: string;
  103838. };
  103839. }
  103840. declare module BABYLON {
  103841. /** @hidden */
  103842. export var defaultPixelShader: {
  103843. name: string;
  103844. shader: string;
  103845. };
  103846. }
  103847. declare module BABYLON {
  103848. /** @hidden */
  103849. export var defaultVertexDeclaration: {
  103850. name: string;
  103851. shader: string;
  103852. };
  103853. }
  103854. declare module BABYLON {
  103855. /** @hidden */
  103856. export var bonesDeclaration: {
  103857. name: string;
  103858. shader: string;
  103859. };
  103860. }
  103861. declare module BABYLON {
  103862. /** @hidden */
  103863. export var prePassVertexDeclaration: {
  103864. name: string;
  103865. shader: string;
  103866. };
  103867. }
  103868. declare module BABYLON {
  103869. /** @hidden */
  103870. export var bumpVertexDeclaration: {
  103871. name: string;
  103872. shader: string;
  103873. };
  103874. }
  103875. declare module BABYLON {
  103876. /** @hidden */
  103877. export var fogVertexDeclaration: {
  103878. name: string;
  103879. shader: string;
  103880. };
  103881. }
  103882. declare module BABYLON {
  103883. /** @hidden */
  103884. export var lightVxFragmentDeclaration: {
  103885. name: string;
  103886. shader: string;
  103887. };
  103888. }
  103889. declare module BABYLON {
  103890. /** @hidden */
  103891. export var lightVxUboDeclaration: {
  103892. name: string;
  103893. shader: string;
  103894. };
  103895. }
  103896. declare module BABYLON {
  103897. /** @hidden */
  103898. export var morphTargetsVertexGlobalDeclaration: {
  103899. name: string;
  103900. shader: string;
  103901. };
  103902. }
  103903. declare module BABYLON {
  103904. /** @hidden */
  103905. export var morphTargetsVertexDeclaration: {
  103906. name: string;
  103907. shader: string;
  103908. };
  103909. }
  103910. declare module BABYLON {
  103911. /** @hidden */
  103912. export var morphTargetsVertex: {
  103913. name: string;
  103914. shader: string;
  103915. };
  103916. }
  103917. declare module BABYLON {
  103918. /** @hidden */
  103919. export var instancesVertex: {
  103920. name: string;
  103921. shader: string;
  103922. };
  103923. }
  103924. declare module BABYLON {
  103925. /** @hidden */
  103926. export var bonesVertex: {
  103927. name: string;
  103928. shader: string;
  103929. };
  103930. }
  103931. declare module BABYLON {
  103932. /** @hidden */
  103933. export var prePassVertex: {
  103934. name: string;
  103935. shader: string;
  103936. };
  103937. }
  103938. declare module BABYLON {
  103939. /** @hidden */
  103940. export var bumpVertex: {
  103941. name: string;
  103942. shader: string;
  103943. };
  103944. }
  103945. declare module BABYLON {
  103946. /** @hidden */
  103947. export var fogVertex: {
  103948. name: string;
  103949. shader: string;
  103950. };
  103951. }
  103952. declare module BABYLON {
  103953. /** @hidden */
  103954. export var shadowsVertex: {
  103955. name: string;
  103956. shader: string;
  103957. };
  103958. }
  103959. declare module BABYLON {
  103960. /** @hidden */
  103961. export var pointCloudVertex: {
  103962. name: string;
  103963. shader: string;
  103964. };
  103965. }
  103966. declare module BABYLON {
  103967. /** @hidden */
  103968. export var logDepthVertex: {
  103969. name: string;
  103970. shader: string;
  103971. };
  103972. }
  103973. declare module BABYLON {
  103974. /** @hidden */
  103975. export var defaultVertexShader: {
  103976. name: string;
  103977. shader: string;
  103978. };
  103979. }
  103980. declare module BABYLON {
  103981. /**
  103982. * @hidden
  103983. */
  103984. export interface IMaterialDetailMapDefines {
  103985. DETAIL: boolean;
  103986. DETAILDIRECTUV: number;
  103987. DETAIL_NORMALBLENDMETHOD: number;
  103988. /** @hidden */
  103989. _areTexturesDirty: boolean;
  103990. }
  103991. /**
  103992. * Define the code related to the detail map parameters of a material
  103993. *
  103994. * Inspired from:
  103995. * 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
  103996. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  103997. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  103998. */
  103999. export class DetailMapConfiguration {
  104000. private _texture;
  104001. /**
  104002. * The detail texture of the material.
  104003. */
  104004. texture: Nullable<BaseTexture>;
  104005. /**
  104006. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104007. * Bigger values mean stronger blending
  104008. */
  104009. diffuseBlendLevel: number;
  104010. /**
  104011. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104012. * Bigger values mean stronger blending. Only used with PBR materials
  104013. */
  104014. roughnessBlendLevel: number;
  104015. /**
  104016. * Defines how strong the bump effect from the detail map is
  104017. * Bigger values mean stronger effect
  104018. */
  104019. bumpLevel: number;
  104020. private _normalBlendMethod;
  104021. /**
  104022. * The method used to blend the bump and detail normals together
  104023. */
  104024. normalBlendMethod: number;
  104025. private _isEnabled;
  104026. /**
  104027. * Enable or disable the detail map on this material
  104028. */
  104029. isEnabled: boolean;
  104030. /** @hidden */
  104031. private _internalMarkAllSubMeshesAsTexturesDirty;
  104032. /** @hidden */
  104033. _markAllSubMeshesAsTexturesDirty(): void;
  104034. /**
  104035. * Instantiate a new detail map
  104036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104037. */
  104038. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104039. /**
  104040. * Gets whether the submesh is ready to be used or not.
  104041. * @param defines the list of "defines" to update.
  104042. * @param scene defines the scene the material belongs to.
  104043. * @returns - boolean indicating that the submesh is ready or not.
  104044. */
  104045. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104046. /**
  104047. * Update the defines for detail map usage
  104048. * @param defines the list of "defines" to update.
  104049. * @param scene defines the scene the material belongs to.
  104050. */
  104051. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104052. /**
  104053. * Binds the material data.
  104054. * @param uniformBuffer defines the Uniform buffer to fill in.
  104055. * @param scene defines the scene the material belongs to.
  104056. * @param isFrozen defines whether the material is frozen or not.
  104057. */
  104058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104059. /**
  104060. * Checks to see if a texture is used in the material.
  104061. * @param texture - Base texture to use.
  104062. * @returns - Boolean specifying if a texture is used in the material.
  104063. */
  104064. hasTexture(texture: BaseTexture): boolean;
  104065. /**
  104066. * Returns an array of the actively used textures.
  104067. * @param activeTextures Array of BaseTextures
  104068. */
  104069. getActiveTextures(activeTextures: BaseTexture[]): void;
  104070. /**
  104071. * Returns the animatable textures.
  104072. * @param animatables Array of animatable textures.
  104073. */
  104074. getAnimatables(animatables: IAnimatable[]): void;
  104075. /**
  104076. * Disposes the resources of the material.
  104077. * @param forceDisposeTextures - Forces the disposal of all textures.
  104078. */
  104079. dispose(forceDisposeTextures?: boolean): void;
  104080. /**
  104081. * Get the current class name useful for serialization or dynamic coding.
  104082. * @returns "DetailMap"
  104083. */
  104084. getClassName(): string;
  104085. /**
  104086. * Add the required uniforms to the current list.
  104087. * @param uniforms defines the current uniform list.
  104088. */
  104089. static AddUniforms(uniforms: string[]): void;
  104090. /**
  104091. * Add the required samplers to the current list.
  104092. * @param samplers defines the current sampler list.
  104093. */
  104094. static AddSamplers(samplers: string[]): void;
  104095. /**
  104096. * Add the required uniforms to the current buffer.
  104097. * @param uniformBuffer defines the current uniform buffer.
  104098. */
  104099. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104100. /**
  104101. * Makes a duplicate of the current instance into another one.
  104102. * @param detailMap define the instance where to copy the info
  104103. */
  104104. copyTo(detailMap: DetailMapConfiguration): void;
  104105. /**
  104106. * Serializes this detail map instance
  104107. * @returns - An object with the serialized instance.
  104108. */
  104109. serialize(): any;
  104110. /**
  104111. * Parses a detail map setting from a serialized object.
  104112. * @param source - Serialized object.
  104113. * @param scene Defines the scene we are parsing for
  104114. * @param rootUrl Defines the rootUrl to load from
  104115. */
  104116. parse(source: any, scene: Scene, rootUrl: string): void;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /** @hidden */
  104121. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104122. MAINUV1: boolean;
  104123. MAINUV2: boolean;
  104124. DIFFUSE: boolean;
  104125. DIFFUSEDIRECTUV: number;
  104126. DETAIL: boolean;
  104127. DETAILDIRECTUV: number;
  104128. DETAIL_NORMALBLENDMETHOD: number;
  104129. AMBIENT: boolean;
  104130. AMBIENTDIRECTUV: number;
  104131. OPACITY: boolean;
  104132. OPACITYDIRECTUV: number;
  104133. OPACITYRGB: boolean;
  104134. REFLECTION: boolean;
  104135. EMISSIVE: boolean;
  104136. EMISSIVEDIRECTUV: number;
  104137. SPECULAR: boolean;
  104138. SPECULARDIRECTUV: number;
  104139. BUMP: boolean;
  104140. BUMPDIRECTUV: number;
  104141. PARALLAX: boolean;
  104142. PARALLAXOCCLUSION: boolean;
  104143. SPECULAROVERALPHA: boolean;
  104144. CLIPPLANE: boolean;
  104145. CLIPPLANE2: boolean;
  104146. CLIPPLANE3: boolean;
  104147. CLIPPLANE4: boolean;
  104148. CLIPPLANE5: boolean;
  104149. CLIPPLANE6: boolean;
  104150. ALPHATEST: boolean;
  104151. DEPTHPREPASS: boolean;
  104152. ALPHAFROMDIFFUSE: boolean;
  104153. POINTSIZE: boolean;
  104154. FOG: boolean;
  104155. SPECULARTERM: boolean;
  104156. DIFFUSEFRESNEL: boolean;
  104157. OPACITYFRESNEL: boolean;
  104158. REFLECTIONFRESNEL: boolean;
  104159. REFRACTIONFRESNEL: boolean;
  104160. EMISSIVEFRESNEL: boolean;
  104161. FRESNEL: boolean;
  104162. NORMAL: boolean;
  104163. UV1: boolean;
  104164. UV2: boolean;
  104165. VERTEXCOLOR: boolean;
  104166. VERTEXALPHA: boolean;
  104167. NUM_BONE_INFLUENCERS: number;
  104168. BonesPerMesh: number;
  104169. BONETEXTURE: boolean;
  104170. BONES_VELOCITY_ENABLED: boolean;
  104171. INSTANCES: boolean;
  104172. THIN_INSTANCES: boolean;
  104173. GLOSSINESS: boolean;
  104174. ROUGHNESS: boolean;
  104175. EMISSIVEASILLUMINATION: boolean;
  104176. LINKEMISSIVEWITHDIFFUSE: boolean;
  104177. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104178. LIGHTMAP: boolean;
  104179. LIGHTMAPDIRECTUV: number;
  104180. OBJECTSPACE_NORMALMAP: boolean;
  104181. USELIGHTMAPASSHADOWMAP: boolean;
  104182. REFLECTIONMAP_3D: boolean;
  104183. REFLECTIONMAP_SPHERICAL: boolean;
  104184. REFLECTIONMAP_PLANAR: boolean;
  104185. REFLECTIONMAP_CUBIC: boolean;
  104186. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104187. REFLECTIONMAP_PROJECTION: boolean;
  104188. REFLECTIONMAP_SKYBOX: boolean;
  104189. REFLECTIONMAP_EXPLICIT: boolean;
  104190. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104191. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104192. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104193. INVERTCUBICMAP: boolean;
  104194. LOGARITHMICDEPTH: boolean;
  104195. REFRACTION: boolean;
  104196. REFRACTIONMAP_3D: boolean;
  104197. REFLECTIONOVERALPHA: boolean;
  104198. TWOSIDEDLIGHTING: boolean;
  104199. SHADOWFLOAT: boolean;
  104200. MORPHTARGETS: boolean;
  104201. MORPHTARGETS_NORMAL: boolean;
  104202. MORPHTARGETS_TANGENT: boolean;
  104203. MORPHTARGETS_UV: boolean;
  104204. NUM_MORPH_INFLUENCERS: number;
  104205. NONUNIFORMSCALING: boolean;
  104206. PREMULTIPLYALPHA: boolean;
  104207. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104208. ALPHABLEND: boolean;
  104209. PREPASS: boolean;
  104210. PREPASS_IRRADIANCE: boolean;
  104211. PREPASS_IRRADIANCE_INDEX: number;
  104212. PREPASS_ALBEDO: boolean;
  104213. PREPASS_ALBEDO_INDEX: number;
  104214. PREPASS_DEPTHNORMAL: boolean;
  104215. PREPASS_DEPTHNORMAL_INDEX: number;
  104216. PREPASS_POSITION: boolean;
  104217. PREPASS_POSITION_INDEX: number;
  104218. PREPASS_VELOCITY: boolean;
  104219. PREPASS_VELOCITY_INDEX: number;
  104220. PREPASS_REFLECTIVITY: boolean;
  104221. PREPASS_REFLECTIVITY_INDEX: number;
  104222. SCENE_MRT_COUNT: number;
  104223. RGBDLIGHTMAP: boolean;
  104224. RGBDREFLECTION: boolean;
  104225. RGBDREFRACTION: boolean;
  104226. IMAGEPROCESSING: boolean;
  104227. VIGNETTE: boolean;
  104228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104229. VIGNETTEBLENDMODEOPAQUE: boolean;
  104230. TONEMAPPING: boolean;
  104231. TONEMAPPING_ACES: boolean;
  104232. CONTRAST: boolean;
  104233. COLORCURVES: boolean;
  104234. COLORGRADING: boolean;
  104235. COLORGRADING3D: boolean;
  104236. SAMPLER3DGREENDEPTH: boolean;
  104237. SAMPLER3DBGRMAP: boolean;
  104238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104239. MULTIVIEW: boolean;
  104240. /**
  104241. * If the reflection texture on this material is in linear color space
  104242. * @hidden
  104243. */
  104244. IS_REFLECTION_LINEAR: boolean;
  104245. /**
  104246. * If the refraction texture on this material is in linear color space
  104247. * @hidden
  104248. */
  104249. IS_REFRACTION_LINEAR: boolean;
  104250. EXPOSURE: boolean;
  104251. constructor();
  104252. setReflectionMode(modeToEnable: string): void;
  104253. }
  104254. /**
  104255. * This is the default material used in Babylon. It is the best trade off between quality
  104256. * and performances.
  104257. * @see https://doc.babylonjs.com/babylon101/materials
  104258. */
  104259. export class StandardMaterial extends PushMaterial {
  104260. private _diffuseTexture;
  104261. /**
  104262. * The basic texture of the material as viewed under a light.
  104263. */
  104264. diffuseTexture: Nullable<BaseTexture>;
  104265. private _ambientTexture;
  104266. /**
  104267. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104268. */
  104269. ambientTexture: Nullable<BaseTexture>;
  104270. private _opacityTexture;
  104271. /**
  104272. * Define the transparency of the material from a texture.
  104273. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104274. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104275. */
  104276. opacityTexture: Nullable<BaseTexture>;
  104277. private _reflectionTexture;
  104278. /**
  104279. * Define the texture used to display the reflection.
  104280. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104281. */
  104282. reflectionTexture: Nullable<BaseTexture>;
  104283. private _emissiveTexture;
  104284. /**
  104285. * Define texture of the material as if self lit.
  104286. * This will be mixed in the final result even in the absence of light.
  104287. */
  104288. emissiveTexture: Nullable<BaseTexture>;
  104289. private _specularTexture;
  104290. /**
  104291. * Define how the color and intensity of the highlight given by the light in the material.
  104292. */
  104293. specularTexture: Nullable<BaseTexture>;
  104294. private _bumpTexture;
  104295. /**
  104296. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104297. * 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.
  104298. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104299. */
  104300. bumpTexture: Nullable<BaseTexture>;
  104301. private _lightmapTexture;
  104302. /**
  104303. * Complex lighting can be computationally expensive to compute at runtime.
  104304. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104305. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104306. */
  104307. lightmapTexture: Nullable<BaseTexture>;
  104308. private _refractionTexture;
  104309. /**
  104310. * Define the texture used to display the refraction.
  104311. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104312. */
  104313. refractionTexture: Nullable<BaseTexture>;
  104314. /**
  104315. * The color of the material lit by the environmental background lighting.
  104316. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104317. */
  104318. ambientColor: Color3;
  104319. /**
  104320. * The basic color of the material as viewed under a light.
  104321. */
  104322. diffuseColor: Color3;
  104323. /**
  104324. * Define how the color and intensity of the highlight given by the light in the material.
  104325. */
  104326. specularColor: Color3;
  104327. /**
  104328. * Define the color of the material as if self lit.
  104329. * This will be mixed in the final result even in the absence of light.
  104330. */
  104331. emissiveColor: Color3;
  104332. /**
  104333. * Defines how sharp are the highlights in the material.
  104334. * The bigger the value the sharper giving a more glossy feeling to the result.
  104335. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104336. */
  104337. specularPower: number;
  104338. private _useAlphaFromDiffuseTexture;
  104339. /**
  104340. * Does the transparency come from the diffuse texture alpha channel.
  104341. */
  104342. useAlphaFromDiffuseTexture: boolean;
  104343. private _useEmissiveAsIllumination;
  104344. /**
  104345. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104346. */
  104347. useEmissiveAsIllumination: boolean;
  104348. private _linkEmissiveWithDiffuse;
  104349. /**
  104350. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104351. * the emissive level when the final color is close to one.
  104352. */
  104353. linkEmissiveWithDiffuse: boolean;
  104354. private _useSpecularOverAlpha;
  104355. /**
  104356. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104357. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104358. */
  104359. useSpecularOverAlpha: boolean;
  104360. private _useReflectionOverAlpha;
  104361. /**
  104362. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104363. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104364. */
  104365. useReflectionOverAlpha: boolean;
  104366. private _disableLighting;
  104367. /**
  104368. * Does lights from the scene impacts this material.
  104369. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104370. */
  104371. disableLighting: boolean;
  104372. private _useObjectSpaceNormalMap;
  104373. /**
  104374. * Allows using an object space normal map (instead of tangent space).
  104375. */
  104376. useObjectSpaceNormalMap: boolean;
  104377. private _useParallax;
  104378. /**
  104379. * Is parallax enabled or not.
  104380. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104381. */
  104382. useParallax: boolean;
  104383. private _useParallaxOcclusion;
  104384. /**
  104385. * Is parallax occlusion enabled or not.
  104386. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104387. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104388. */
  104389. useParallaxOcclusion: boolean;
  104390. /**
  104391. * 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.
  104392. */
  104393. parallaxScaleBias: number;
  104394. private _roughness;
  104395. /**
  104396. * Helps to define how blurry the reflections should appears in the material.
  104397. */
  104398. roughness: number;
  104399. /**
  104400. * In case of refraction, define the value of the index of refraction.
  104401. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104402. */
  104403. indexOfRefraction: number;
  104404. /**
  104405. * Invert the refraction texture alongside the y axis.
  104406. * It can be useful with procedural textures or probe for instance.
  104407. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104408. */
  104409. invertRefractionY: boolean;
  104410. /**
  104411. * Defines the alpha limits in alpha test mode.
  104412. */
  104413. alphaCutOff: number;
  104414. private _useLightmapAsShadowmap;
  104415. /**
  104416. * In case of light mapping, define whether the map contains light or shadow informations.
  104417. */
  104418. useLightmapAsShadowmap: boolean;
  104419. private _diffuseFresnelParameters;
  104420. /**
  104421. * Define the diffuse fresnel parameters of the material.
  104422. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104423. */
  104424. diffuseFresnelParameters: FresnelParameters;
  104425. private _opacityFresnelParameters;
  104426. /**
  104427. * Define the opacity fresnel parameters of the material.
  104428. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104429. */
  104430. opacityFresnelParameters: FresnelParameters;
  104431. private _reflectionFresnelParameters;
  104432. /**
  104433. * Define the reflection fresnel parameters of the material.
  104434. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104435. */
  104436. reflectionFresnelParameters: FresnelParameters;
  104437. private _refractionFresnelParameters;
  104438. /**
  104439. * Define the refraction fresnel parameters of the material.
  104440. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104441. */
  104442. refractionFresnelParameters: FresnelParameters;
  104443. private _emissiveFresnelParameters;
  104444. /**
  104445. * Define the emissive fresnel parameters of the material.
  104446. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104447. */
  104448. emissiveFresnelParameters: FresnelParameters;
  104449. private _useReflectionFresnelFromSpecular;
  104450. /**
  104451. * If true automatically deducts the fresnels values from the material specularity.
  104452. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104453. */
  104454. useReflectionFresnelFromSpecular: boolean;
  104455. private _useGlossinessFromSpecularMapAlpha;
  104456. /**
  104457. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104458. */
  104459. useGlossinessFromSpecularMapAlpha: boolean;
  104460. private _maxSimultaneousLights;
  104461. /**
  104462. * Defines the maximum number of lights that can be used in the material
  104463. */
  104464. maxSimultaneousLights: number;
  104465. private _invertNormalMapX;
  104466. /**
  104467. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104468. */
  104469. invertNormalMapX: boolean;
  104470. private _invertNormalMapY;
  104471. /**
  104472. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104473. */
  104474. invertNormalMapY: boolean;
  104475. private _twoSidedLighting;
  104476. /**
  104477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104478. */
  104479. twoSidedLighting: boolean;
  104480. /**
  104481. * Default configuration related to image processing available in the standard Material.
  104482. */
  104483. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104484. /**
  104485. * Gets the image processing configuration used either in this material.
  104486. */
  104487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104488. /**
  104489. * Sets the Default image processing configuration used either in the this material.
  104490. *
  104491. * If sets to null, the scene one is in use.
  104492. */
  104493. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104494. /**
  104495. * Keep track of the image processing observer to allow dispose and replace.
  104496. */
  104497. private _imageProcessingObserver;
  104498. /**
  104499. * Attaches a new image processing configuration to the Standard Material.
  104500. * @param configuration
  104501. */
  104502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104503. /**
  104504. * Defines additionnal PrePass parameters for the material.
  104505. */
  104506. readonly prePassConfiguration: PrePassConfiguration;
  104507. /**
  104508. * Gets wether the color curves effect is enabled.
  104509. */
  104510. get cameraColorCurvesEnabled(): boolean;
  104511. /**
  104512. * Sets wether the color curves effect is enabled.
  104513. */
  104514. set cameraColorCurvesEnabled(value: boolean);
  104515. /**
  104516. * Gets wether the color grading effect is enabled.
  104517. */
  104518. get cameraColorGradingEnabled(): boolean;
  104519. /**
  104520. * Gets wether the color grading effect is enabled.
  104521. */
  104522. set cameraColorGradingEnabled(value: boolean);
  104523. /**
  104524. * Gets wether tonemapping is enabled or not.
  104525. */
  104526. get cameraToneMappingEnabled(): boolean;
  104527. /**
  104528. * Sets wether tonemapping is enabled or not
  104529. */
  104530. set cameraToneMappingEnabled(value: boolean);
  104531. /**
  104532. * The camera exposure used on this material.
  104533. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104534. * This corresponds to a photographic exposure.
  104535. */
  104536. get cameraExposure(): number;
  104537. /**
  104538. * The camera exposure used on this material.
  104539. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104540. * This corresponds to a photographic exposure.
  104541. */
  104542. set cameraExposure(value: number);
  104543. /**
  104544. * Gets The camera contrast used on this material.
  104545. */
  104546. get cameraContrast(): number;
  104547. /**
  104548. * Sets The camera contrast used on this material.
  104549. */
  104550. set cameraContrast(value: number);
  104551. /**
  104552. * Gets the Color Grading 2D Lookup Texture.
  104553. */
  104554. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104555. /**
  104556. * Sets the Color Grading 2D Lookup Texture.
  104557. */
  104558. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104559. /**
  104560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104562. * 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;
  104563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104564. */
  104565. get cameraColorCurves(): Nullable<ColorCurves>;
  104566. /**
  104567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104569. * 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;
  104570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104571. */
  104572. set cameraColorCurves(value: Nullable<ColorCurves>);
  104573. /**
  104574. * Can this material render to several textures at once
  104575. */
  104576. get canRenderToMRT(): boolean;
  104577. /**
  104578. * Defines the detail map parameters for the material.
  104579. */
  104580. readonly detailMap: DetailMapConfiguration;
  104581. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104582. protected _worldViewProjectionMatrix: Matrix;
  104583. protected _globalAmbientColor: Color3;
  104584. protected _useLogarithmicDepth: boolean;
  104585. protected _rebuildInParallel: boolean;
  104586. /**
  104587. * Instantiates a new standard material.
  104588. * This is the default material used in Babylon. It is the best trade off between quality
  104589. * and performances.
  104590. * @see https://doc.babylonjs.com/babylon101/materials
  104591. * @param name Define the name of the material in the scene
  104592. * @param scene Define the scene the material belong to
  104593. */
  104594. constructor(name: string, scene: Scene);
  104595. /**
  104596. * Gets a boolean indicating that current material needs to register RTT
  104597. */
  104598. get hasRenderTargetTextures(): boolean;
  104599. /**
  104600. * Gets the current class name of the material e.g. "StandardMaterial"
  104601. * Mainly use in serialization.
  104602. * @returns the class name
  104603. */
  104604. getClassName(): string;
  104605. /**
  104606. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104607. * You can try switching to logarithmic depth.
  104608. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104609. */
  104610. get useLogarithmicDepth(): boolean;
  104611. set useLogarithmicDepth(value: boolean);
  104612. /**
  104613. * Specifies if the material will require alpha blending
  104614. * @returns a boolean specifying if alpha blending is needed
  104615. */
  104616. needAlphaBlending(): boolean;
  104617. /**
  104618. * Specifies if this material should be rendered in alpha test mode
  104619. * @returns a boolean specifying if an alpha test is needed.
  104620. */
  104621. needAlphaTesting(): boolean;
  104622. /**
  104623. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  104624. */
  104625. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104626. /**
  104627. * Specifies whether or not there is a usable alpha channel for transparency.
  104628. */
  104629. protected _hasAlphaChannel(): boolean;
  104630. /**
  104631. * Get the texture used for alpha test purpose.
  104632. * @returns the diffuse texture in case of the standard material.
  104633. */
  104634. getAlphaTestTexture(): Nullable<BaseTexture>;
  104635. /**
  104636. * Get if the submesh is ready to be used and all its information available.
  104637. * Child classes can use it to update shaders
  104638. * @param mesh defines the mesh to check
  104639. * @param subMesh defines which submesh to check
  104640. * @param useInstances specifies that instances should be used
  104641. * @returns a boolean indicating that the submesh is ready or not
  104642. */
  104643. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104644. /**
  104645. * Builds the material UBO layouts.
  104646. * Used internally during the effect preparation.
  104647. */
  104648. buildUniformLayout(): void;
  104649. /**
  104650. * Unbinds the material from the mesh
  104651. */
  104652. unbind(): void;
  104653. /**
  104654. * Binds the submesh to this material by preparing the effect and shader to draw
  104655. * @param world defines the world transformation matrix
  104656. * @param mesh defines the mesh containing the submesh
  104657. * @param subMesh defines the submesh to bind the material to
  104658. */
  104659. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104660. /**
  104661. * Get the list of animatables in the material.
  104662. * @returns the list of animatables object used in the material
  104663. */
  104664. getAnimatables(): IAnimatable[];
  104665. /**
  104666. * Gets the active textures from the material
  104667. * @returns an array of textures
  104668. */
  104669. getActiveTextures(): BaseTexture[];
  104670. /**
  104671. * Specifies if the material uses a texture
  104672. * @param texture defines the texture to check against the material
  104673. * @returns a boolean specifying if the material uses the texture
  104674. */
  104675. hasTexture(texture: BaseTexture): boolean;
  104676. /**
  104677. * Disposes the material
  104678. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104679. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104680. */
  104681. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104682. /**
  104683. * Makes a duplicate of the material, and gives it a new name
  104684. * @param name defines the new name for the duplicated material
  104685. * @returns the cloned material
  104686. */
  104687. clone(name: string): StandardMaterial;
  104688. /**
  104689. * Serializes this material in a JSON representation
  104690. * @returns the serialized material object
  104691. */
  104692. serialize(): any;
  104693. /**
  104694. * Creates a standard material from parsed material data
  104695. * @param source defines the JSON representation of the material
  104696. * @param scene defines the hosting scene
  104697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104698. * @returns a new standard material
  104699. */
  104700. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104701. /**
  104702. * Are diffuse textures enabled in the application.
  104703. */
  104704. static get DiffuseTextureEnabled(): boolean;
  104705. static set DiffuseTextureEnabled(value: boolean);
  104706. /**
  104707. * Are detail textures enabled in the application.
  104708. */
  104709. static get DetailTextureEnabled(): boolean;
  104710. static set DetailTextureEnabled(value: boolean);
  104711. /**
  104712. * Are ambient textures enabled in the application.
  104713. */
  104714. static get AmbientTextureEnabled(): boolean;
  104715. static set AmbientTextureEnabled(value: boolean);
  104716. /**
  104717. * Are opacity textures enabled in the application.
  104718. */
  104719. static get OpacityTextureEnabled(): boolean;
  104720. static set OpacityTextureEnabled(value: boolean);
  104721. /**
  104722. * Are reflection textures enabled in the application.
  104723. */
  104724. static get ReflectionTextureEnabled(): boolean;
  104725. static set ReflectionTextureEnabled(value: boolean);
  104726. /**
  104727. * Are emissive textures enabled in the application.
  104728. */
  104729. static get EmissiveTextureEnabled(): boolean;
  104730. static set EmissiveTextureEnabled(value: boolean);
  104731. /**
  104732. * Are specular textures enabled in the application.
  104733. */
  104734. static get SpecularTextureEnabled(): boolean;
  104735. static set SpecularTextureEnabled(value: boolean);
  104736. /**
  104737. * Are bump textures enabled in the application.
  104738. */
  104739. static get BumpTextureEnabled(): boolean;
  104740. static set BumpTextureEnabled(value: boolean);
  104741. /**
  104742. * Are lightmap textures enabled in the application.
  104743. */
  104744. static get LightmapTextureEnabled(): boolean;
  104745. static set LightmapTextureEnabled(value: boolean);
  104746. /**
  104747. * Are refraction textures enabled in the application.
  104748. */
  104749. static get RefractionTextureEnabled(): boolean;
  104750. static set RefractionTextureEnabled(value: boolean);
  104751. /**
  104752. * Are color grading textures enabled in the application.
  104753. */
  104754. static get ColorGradingTextureEnabled(): boolean;
  104755. static set ColorGradingTextureEnabled(value: boolean);
  104756. /**
  104757. * Are fresnels enabled in the application.
  104758. */
  104759. static get FresnelEnabled(): boolean;
  104760. static set FresnelEnabled(value: boolean);
  104761. }
  104762. }
  104763. declare module BABYLON {
  104764. /** @hidden */
  104765. export var rgbdDecodePixelShader: {
  104766. name: string;
  104767. shader: string;
  104768. };
  104769. }
  104770. declare module BABYLON {
  104771. /** @hidden */
  104772. export var passPixelShader: {
  104773. name: string;
  104774. shader: string;
  104775. };
  104776. }
  104777. declare module BABYLON {
  104778. /** @hidden */
  104779. export var passCubePixelShader: {
  104780. name: string;
  104781. shader: string;
  104782. };
  104783. }
  104784. declare module BABYLON {
  104785. /**
  104786. * PassPostProcess which produces an output the same as it's input
  104787. */
  104788. export class PassPostProcess extends PostProcess {
  104789. /**
  104790. * Gets a string identifying the name of the class
  104791. * @returns "PassPostProcess" string
  104792. */
  104793. getClassName(): string;
  104794. /**
  104795. * Creates the PassPostProcess
  104796. * @param name The name of the effect.
  104797. * @param options The required width/height ratio to downsize to before computing the render pass.
  104798. * @param camera The camera to apply the render pass to.
  104799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104800. * @param engine The engine which the post process will be applied. (default: current engine)
  104801. * @param reusable If the post process can be reused on the same frame. (default: false)
  104802. * @param textureType The type of texture to be used when performing the post processing.
  104803. * @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)
  104804. */
  104805. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104806. /** @hidden */
  104807. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  104808. }
  104809. /**
  104810. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104811. */
  104812. export class PassCubePostProcess extends PostProcess {
  104813. private _face;
  104814. /**
  104815. * Gets or sets the cube face to display.
  104816. * * 0 is +X
  104817. * * 1 is -X
  104818. * * 2 is +Y
  104819. * * 3 is -Y
  104820. * * 4 is +Z
  104821. * * 5 is -Z
  104822. */
  104823. get face(): number;
  104824. set face(value: number);
  104825. /**
  104826. * Gets a string identifying the name of the class
  104827. * @returns "PassCubePostProcess" string
  104828. */
  104829. getClassName(): string;
  104830. /**
  104831. * Creates the PassCubePostProcess
  104832. * @param name The name of the effect.
  104833. * @param options The required width/height ratio to downsize to before computing the render pass.
  104834. * @param camera The camera to apply the render pass to.
  104835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104836. * @param engine The engine which the post process will be applied. (default: current engine)
  104837. * @param reusable If the post process can be reused on the same frame. (default: false)
  104838. * @param textureType The type of texture to be used when performing the post processing.
  104839. * @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)
  104840. */
  104841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104842. /** @hidden */
  104843. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  104844. }
  104845. }
  104846. declare module BABYLON {
  104847. /**
  104848. * Class used to host texture specific utilities
  104849. */
  104850. export class TextureTools {
  104851. /**
  104852. * Uses the GPU to create a copy texture rescaled at a given size
  104853. * @param texture Texture to copy from
  104854. * @param width defines the desired width
  104855. * @param height defines the desired height
  104856. * @param useBilinearMode defines if bilinear mode has to be used
  104857. * @return the generated texture
  104858. */
  104859. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  104860. /**
  104861. * Apply a post process to a texture
  104862. * @param postProcessName name of the fragment post process
  104863. * @param internalTexture the texture to encode
  104864. * @param scene the scene hosting the texture
  104865. * @param type type of the output texture. If not provided, use the one from internalTexture
  104866. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  104867. * @param format format of the output texture. If not provided, use the one from internalTexture
  104868. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104869. */
  104870. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  104871. }
  104872. }
  104873. declare module BABYLON {
  104874. /**
  104875. * Class used to host RGBD texture specific utilities
  104876. */
  104877. export class RGBDTextureTools {
  104878. /**
  104879. * Expand the RGBD Texture from RGBD to Half Float if possible.
  104880. * @param texture the texture to expand.
  104881. */
  104882. static ExpandRGBDTexture(texture: Texture): void;
  104883. /**
  104884. * Encode the texture to RGBD if possible.
  104885. * @param internalTexture the texture to encode
  104886. * @param scene the scene hosting the texture
  104887. * @param outputTextureType type of the texture in which the encoding is performed
  104888. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104889. */
  104890. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  104891. }
  104892. }
  104893. declare module BABYLON {
  104894. /**
  104895. * Class used to host texture specific utilities
  104896. */
  104897. export class BRDFTextureTools {
  104898. /**
  104899. * Prevents texture cache collision
  104900. */
  104901. private static _instanceNumber;
  104902. /**
  104903. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  104904. * @param scene defines the hosting scene
  104905. * @returns the environment BRDF texture
  104906. */
  104907. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  104908. private static _environmentBRDFBase64Texture;
  104909. }
  104910. }
  104911. declare module BABYLON {
  104912. /**
  104913. * @hidden
  104914. */
  104915. export interface IMaterialClearCoatDefines {
  104916. CLEARCOAT: boolean;
  104917. CLEARCOAT_DEFAULTIOR: boolean;
  104918. CLEARCOAT_TEXTURE: boolean;
  104919. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  104920. CLEARCOAT_TEXTUREDIRECTUV: number;
  104921. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  104922. CLEARCOAT_BUMP: boolean;
  104923. CLEARCOAT_BUMPDIRECTUV: number;
  104924. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  104925. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  104926. CLEARCOAT_REMAP_F0: boolean;
  104927. CLEARCOAT_TINT: boolean;
  104928. CLEARCOAT_TINT_TEXTURE: boolean;
  104929. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104930. /** @hidden */
  104931. _areTexturesDirty: boolean;
  104932. }
  104933. /**
  104934. * Define the code related to the clear coat parameters of the pbr material.
  104935. */
  104936. export class PBRClearCoatConfiguration {
  104937. /**
  104938. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104939. * The default fits with a polyurethane material.
  104940. * @hidden
  104941. */
  104942. static readonly _DefaultIndexOfRefraction: number;
  104943. private _isEnabled;
  104944. /**
  104945. * Defines if the clear coat is enabled in the material.
  104946. */
  104947. isEnabled: boolean;
  104948. /**
  104949. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104950. */
  104951. intensity: number;
  104952. /**
  104953. * Defines the clear coat layer roughness.
  104954. */
  104955. roughness: number;
  104956. private _indexOfRefraction;
  104957. /**
  104958. * Defines the index of refraction of the clear coat.
  104959. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104960. * The default fits with a polyurethane material.
  104961. * Changing the default value is more performance intensive.
  104962. */
  104963. indexOfRefraction: number;
  104964. private _texture;
  104965. /**
  104966. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  104967. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  104968. * if textureRoughness is not empty, else no texture roughness is used
  104969. */
  104970. texture: Nullable<BaseTexture>;
  104971. private _useRoughnessFromMainTexture;
  104972. /**
  104973. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  104974. * If false, the green channel from textureRoughness is used for roughness
  104975. */
  104976. useRoughnessFromMainTexture: boolean;
  104977. private _textureRoughness;
  104978. /**
  104979. * Stores the clear coat roughness in a texture (green channel)
  104980. * Not used if useRoughnessFromMainTexture is true
  104981. */
  104982. textureRoughness: Nullable<BaseTexture>;
  104983. private _remapF0OnInterfaceChange;
  104984. /**
  104985. * Defines if the F0 value should be remapped to account for the interface change in the material.
  104986. */
  104987. remapF0OnInterfaceChange: boolean;
  104988. private _bumpTexture;
  104989. /**
  104990. * Define the clear coat specific bump texture.
  104991. */
  104992. bumpTexture: Nullable<BaseTexture>;
  104993. private _isTintEnabled;
  104994. /**
  104995. * Defines if the clear coat tint is enabled in the material.
  104996. */
  104997. isTintEnabled: boolean;
  104998. /**
  104999. * Defines the clear coat tint of the material.
  105000. * This is only use if tint is enabled
  105001. */
  105002. tintColor: Color3;
  105003. /**
  105004. * Defines the distance at which the tint color should be found in the
  105005. * clear coat media.
  105006. * This is only use if tint is enabled
  105007. */
  105008. tintColorAtDistance: number;
  105009. /**
  105010. * Defines the clear coat layer thickness.
  105011. * This is only use if tint is enabled
  105012. */
  105013. tintThickness: number;
  105014. private _tintTexture;
  105015. /**
  105016. * Stores the clear tint values in a texture.
  105017. * rgb is tint
  105018. * a is a thickness factor
  105019. */
  105020. tintTexture: Nullable<BaseTexture>;
  105021. /** @hidden */
  105022. private _internalMarkAllSubMeshesAsTexturesDirty;
  105023. /** @hidden */
  105024. _markAllSubMeshesAsTexturesDirty(): void;
  105025. /**
  105026. * Instantiate a new istance of clear coat configuration.
  105027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105028. */
  105029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105030. /**
  105031. * Gets wehter the submesh is ready to be used or not.
  105032. * @param defines the list of "defines" to update.
  105033. * @param scene defines the scene the material belongs to.
  105034. * @param engine defines the engine the material belongs to.
  105035. * @param disableBumpMap defines wether the material disables bump or not.
  105036. * @returns - boolean indicating that the submesh is ready or not.
  105037. */
  105038. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105039. /**
  105040. * Checks to see if a texture is used in the material.
  105041. * @param defines the list of "defines" to update.
  105042. * @param scene defines the scene to the material belongs to.
  105043. */
  105044. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105045. /**
  105046. * Binds the material data.
  105047. * @param uniformBuffer defines the Uniform buffer to fill in.
  105048. * @param scene defines the scene the material belongs to.
  105049. * @param engine defines the engine the material belongs to.
  105050. * @param disableBumpMap defines wether the material disables bump or not.
  105051. * @param isFrozen defines wether the material is frozen or not.
  105052. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105053. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105054. * @param subMesh the submesh to bind data for
  105055. */
  105056. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105057. /**
  105058. * Checks to see if a texture is used in the material.
  105059. * @param texture - Base texture to use.
  105060. * @returns - Boolean specifying if a texture is used in the material.
  105061. */
  105062. hasTexture(texture: BaseTexture): boolean;
  105063. /**
  105064. * Returns an array of the actively used textures.
  105065. * @param activeTextures Array of BaseTextures
  105066. */
  105067. getActiveTextures(activeTextures: BaseTexture[]): void;
  105068. /**
  105069. * Returns the animatable textures.
  105070. * @param animatables Array of animatable textures.
  105071. */
  105072. getAnimatables(animatables: IAnimatable[]): void;
  105073. /**
  105074. * Disposes the resources of the material.
  105075. * @param forceDisposeTextures - Forces the disposal of all textures.
  105076. */
  105077. dispose(forceDisposeTextures?: boolean): void;
  105078. /**
  105079. * Get the current class name of the texture useful for serialization or dynamic coding.
  105080. * @returns "PBRClearCoatConfiguration"
  105081. */
  105082. getClassName(): string;
  105083. /**
  105084. * Add fallbacks to the effect fallbacks list.
  105085. * @param defines defines the Base texture to use.
  105086. * @param fallbacks defines the current fallback list.
  105087. * @param currentRank defines the current fallback rank.
  105088. * @returns the new fallback rank.
  105089. */
  105090. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105091. /**
  105092. * Add the required uniforms to the current list.
  105093. * @param uniforms defines the current uniform list.
  105094. */
  105095. static AddUniforms(uniforms: string[]): void;
  105096. /**
  105097. * Add the required samplers to the current list.
  105098. * @param samplers defines the current sampler list.
  105099. */
  105100. static AddSamplers(samplers: string[]): void;
  105101. /**
  105102. * Add the required uniforms to the current buffer.
  105103. * @param uniformBuffer defines the current uniform buffer.
  105104. */
  105105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105106. /**
  105107. * Makes a duplicate of the current configuration into another one.
  105108. * @param clearCoatConfiguration define the config where to copy the info
  105109. */
  105110. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105111. /**
  105112. * Serializes this clear coat configuration.
  105113. * @returns - An object with the serialized config.
  105114. */
  105115. serialize(): any;
  105116. /**
  105117. * Parses a anisotropy Configuration from a serialized object.
  105118. * @param source - Serialized object.
  105119. * @param scene Defines the scene we are parsing for
  105120. * @param rootUrl Defines the rootUrl to load from
  105121. */
  105122. parse(source: any, scene: Scene, rootUrl: string): void;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * @hidden
  105128. */
  105129. export interface IMaterialAnisotropicDefines {
  105130. ANISOTROPIC: boolean;
  105131. ANISOTROPIC_TEXTURE: boolean;
  105132. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105133. MAINUV1: boolean;
  105134. _areTexturesDirty: boolean;
  105135. _needUVs: boolean;
  105136. }
  105137. /**
  105138. * Define the code related to the anisotropic parameters of the pbr material.
  105139. */
  105140. export class PBRAnisotropicConfiguration {
  105141. private _isEnabled;
  105142. /**
  105143. * Defines if the anisotropy is enabled in the material.
  105144. */
  105145. isEnabled: boolean;
  105146. /**
  105147. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105148. */
  105149. intensity: number;
  105150. /**
  105151. * Defines if the effect is along the tangents, bitangents or in between.
  105152. * By default, the effect is "strectching" the highlights along the tangents.
  105153. */
  105154. direction: Vector2;
  105155. private _texture;
  105156. /**
  105157. * Stores the anisotropy values in a texture.
  105158. * rg is direction (like normal from -1 to 1)
  105159. * b is a intensity
  105160. */
  105161. texture: Nullable<BaseTexture>;
  105162. /** @hidden */
  105163. private _internalMarkAllSubMeshesAsTexturesDirty;
  105164. /** @hidden */
  105165. _markAllSubMeshesAsTexturesDirty(): void;
  105166. /**
  105167. * Instantiate a new istance of anisotropy configuration.
  105168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105169. */
  105170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105171. /**
  105172. * Specifies that the submesh is ready to be used.
  105173. * @param defines the list of "defines" to update.
  105174. * @param scene defines the scene the material belongs to.
  105175. * @returns - boolean indicating that the submesh is ready or not.
  105176. */
  105177. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105178. /**
  105179. * Checks to see if a texture is used in the material.
  105180. * @param defines the list of "defines" to update.
  105181. * @param mesh the mesh we are preparing the defines for.
  105182. * @param scene defines the scene the material belongs to.
  105183. */
  105184. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105185. /**
  105186. * Binds the material data.
  105187. * @param uniformBuffer defines the Uniform buffer to fill in.
  105188. * @param scene defines the scene the material belongs to.
  105189. * @param isFrozen defines wether the material is frozen or not.
  105190. */
  105191. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105192. /**
  105193. * Checks to see if a texture is used in the material.
  105194. * @param texture - Base texture to use.
  105195. * @returns - Boolean specifying if a texture is used in the material.
  105196. */
  105197. hasTexture(texture: BaseTexture): boolean;
  105198. /**
  105199. * Returns an array of the actively used textures.
  105200. * @param activeTextures Array of BaseTextures
  105201. */
  105202. getActiveTextures(activeTextures: BaseTexture[]): void;
  105203. /**
  105204. * Returns the animatable textures.
  105205. * @param animatables Array of animatable textures.
  105206. */
  105207. getAnimatables(animatables: IAnimatable[]): void;
  105208. /**
  105209. * Disposes the resources of the material.
  105210. * @param forceDisposeTextures - Forces the disposal of all textures.
  105211. */
  105212. dispose(forceDisposeTextures?: boolean): void;
  105213. /**
  105214. * Get the current class name of the texture useful for serialization or dynamic coding.
  105215. * @returns "PBRAnisotropicConfiguration"
  105216. */
  105217. getClassName(): string;
  105218. /**
  105219. * Add fallbacks to the effect fallbacks list.
  105220. * @param defines defines the Base texture to use.
  105221. * @param fallbacks defines the current fallback list.
  105222. * @param currentRank defines the current fallback rank.
  105223. * @returns the new fallback rank.
  105224. */
  105225. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105226. /**
  105227. * Add the required uniforms to the current list.
  105228. * @param uniforms defines the current uniform list.
  105229. */
  105230. static AddUniforms(uniforms: string[]): void;
  105231. /**
  105232. * Add the required uniforms to the current buffer.
  105233. * @param uniformBuffer defines the current uniform buffer.
  105234. */
  105235. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105236. /**
  105237. * Add the required samplers to the current list.
  105238. * @param samplers defines the current sampler list.
  105239. */
  105240. static AddSamplers(samplers: string[]): void;
  105241. /**
  105242. * Makes a duplicate of the current configuration into another one.
  105243. * @param anisotropicConfiguration define the config where to copy the info
  105244. */
  105245. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105246. /**
  105247. * Serializes this anisotropy configuration.
  105248. * @returns - An object with the serialized config.
  105249. */
  105250. serialize(): any;
  105251. /**
  105252. * Parses a anisotropy Configuration from a serialized object.
  105253. * @param source - Serialized object.
  105254. * @param scene Defines the scene we are parsing for
  105255. * @param rootUrl Defines the rootUrl to load from
  105256. */
  105257. parse(source: any, scene: Scene, rootUrl: string): void;
  105258. }
  105259. }
  105260. declare module BABYLON {
  105261. /**
  105262. * @hidden
  105263. */
  105264. export interface IMaterialBRDFDefines {
  105265. BRDF_V_HEIGHT_CORRELATED: boolean;
  105266. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105267. SPHERICAL_HARMONICS: boolean;
  105268. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105269. /** @hidden */
  105270. _areMiscDirty: boolean;
  105271. }
  105272. /**
  105273. * Define the code related to the BRDF parameters of the pbr material.
  105274. */
  105275. export class PBRBRDFConfiguration {
  105276. /**
  105277. * Default value used for the energy conservation.
  105278. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105279. */
  105280. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105281. /**
  105282. * Default value used for the Smith Visibility Height Correlated mode.
  105283. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105284. */
  105285. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105286. /**
  105287. * Default value used for the IBL diffuse part.
  105288. * This can help switching back to the polynomials mode globally which is a tiny bit
  105289. * less GPU intensive at the drawback of a lower quality.
  105290. */
  105291. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105292. /**
  105293. * Default value used for activating energy conservation for the specular workflow.
  105294. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105295. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105296. */
  105297. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105298. private _useEnergyConservation;
  105299. /**
  105300. * Defines if the material uses energy conservation.
  105301. */
  105302. useEnergyConservation: boolean;
  105303. private _useSmithVisibilityHeightCorrelated;
  105304. /**
  105305. * LEGACY Mode set to false
  105306. * Defines if the material uses height smith correlated visibility term.
  105307. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105308. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105309. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105310. * Not relying on height correlated will also disable energy conservation.
  105311. */
  105312. useSmithVisibilityHeightCorrelated: boolean;
  105313. private _useSphericalHarmonics;
  105314. /**
  105315. * LEGACY Mode set to false
  105316. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105317. * diffuse part of the IBL.
  105318. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105319. * to the ground truth.
  105320. */
  105321. useSphericalHarmonics: boolean;
  105322. private _useSpecularGlossinessInputEnergyConservation;
  105323. /**
  105324. * Defines if the material uses energy conservation, when the specular workflow is active.
  105325. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105326. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105327. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105328. */
  105329. useSpecularGlossinessInputEnergyConservation: boolean;
  105330. /** @hidden */
  105331. private _internalMarkAllSubMeshesAsMiscDirty;
  105332. /** @hidden */
  105333. _markAllSubMeshesAsMiscDirty(): void;
  105334. /**
  105335. * Instantiate a new istance of clear coat configuration.
  105336. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105337. */
  105338. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105339. /**
  105340. * Checks to see if a texture is used in the material.
  105341. * @param defines the list of "defines" to update.
  105342. */
  105343. prepareDefines(defines: IMaterialBRDFDefines): void;
  105344. /**
  105345. * Get the current class name of the texture useful for serialization or dynamic coding.
  105346. * @returns "PBRClearCoatConfiguration"
  105347. */
  105348. getClassName(): string;
  105349. /**
  105350. * Makes a duplicate of the current configuration into another one.
  105351. * @param brdfConfiguration define the config where to copy the info
  105352. */
  105353. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105354. /**
  105355. * Serializes this BRDF configuration.
  105356. * @returns - An object with the serialized config.
  105357. */
  105358. serialize(): any;
  105359. /**
  105360. * Parses a anisotropy Configuration from a serialized object.
  105361. * @param source - Serialized object.
  105362. * @param scene Defines the scene we are parsing for
  105363. * @param rootUrl Defines the rootUrl to load from
  105364. */
  105365. parse(source: any, scene: Scene, rootUrl: string): void;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * @hidden
  105371. */
  105372. export interface IMaterialSheenDefines {
  105373. SHEEN: boolean;
  105374. SHEEN_TEXTURE: boolean;
  105375. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105376. SHEEN_TEXTUREDIRECTUV: number;
  105377. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105378. SHEEN_LINKWITHALBEDO: boolean;
  105379. SHEEN_ROUGHNESS: boolean;
  105380. SHEEN_ALBEDOSCALING: boolean;
  105381. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105382. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105383. /** @hidden */
  105384. _areTexturesDirty: boolean;
  105385. }
  105386. /**
  105387. * Define the code related to the Sheen parameters of the pbr material.
  105388. */
  105389. export class PBRSheenConfiguration {
  105390. private _isEnabled;
  105391. /**
  105392. * Defines if the material uses sheen.
  105393. */
  105394. isEnabled: boolean;
  105395. private _linkSheenWithAlbedo;
  105396. /**
  105397. * Defines if the sheen is linked to the sheen color.
  105398. */
  105399. linkSheenWithAlbedo: boolean;
  105400. /**
  105401. * Defines the sheen intensity.
  105402. */
  105403. intensity: number;
  105404. /**
  105405. * Defines the sheen color.
  105406. */
  105407. color: Color3;
  105408. private _texture;
  105409. /**
  105410. * Stores the sheen tint values in a texture.
  105411. * rgb is tint
  105412. * 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)
  105413. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105414. */
  105415. texture: Nullable<BaseTexture>;
  105416. private _useRoughnessFromMainTexture;
  105417. /**
  105418. * Indicates that the alpha channel of the texture property will be used for roughness.
  105419. * Has no effect if the roughness (and texture!) property is not defined
  105420. */
  105421. useRoughnessFromMainTexture: boolean;
  105422. private _roughness;
  105423. /**
  105424. * Defines the sheen roughness.
  105425. * It is not taken into account if linkSheenWithAlbedo is true.
  105426. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105427. */
  105428. roughness: Nullable<number>;
  105429. private _textureRoughness;
  105430. /**
  105431. * Stores the sheen roughness in a texture.
  105432. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105433. */
  105434. textureRoughness: Nullable<BaseTexture>;
  105435. private _albedoScaling;
  105436. /**
  105437. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105438. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105439. * making it easier to setup and tweak the effect
  105440. */
  105441. albedoScaling: boolean;
  105442. /** @hidden */
  105443. private _internalMarkAllSubMeshesAsTexturesDirty;
  105444. /** @hidden */
  105445. _markAllSubMeshesAsTexturesDirty(): void;
  105446. /**
  105447. * Instantiate a new istance of clear coat configuration.
  105448. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105449. */
  105450. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105451. /**
  105452. * Specifies that the submesh is ready to be used.
  105453. * @param defines the list of "defines" to update.
  105454. * @param scene defines the scene the material belongs to.
  105455. * @returns - boolean indicating that the submesh is ready or not.
  105456. */
  105457. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105458. /**
  105459. * Checks to see if a texture is used in the material.
  105460. * @param defines the list of "defines" to update.
  105461. * @param scene defines the scene the material belongs to.
  105462. */
  105463. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105464. /**
  105465. * Binds the material data.
  105466. * @param uniformBuffer defines the Uniform buffer to fill in.
  105467. * @param scene defines the scene the material belongs to.
  105468. * @param isFrozen defines wether the material is frozen or not.
  105469. * @param subMesh the submesh to bind data for
  105470. */
  105471. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105472. /**
  105473. * Checks to see if a texture is used in the material.
  105474. * @param texture - Base texture to use.
  105475. * @returns - Boolean specifying if a texture is used in the material.
  105476. */
  105477. hasTexture(texture: BaseTexture): boolean;
  105478. /**
  105479. * Returns an array of the actively used textures.
  105480. * @param activeTextures Array of BaseTextures
  105481. */
  105482. getActiveTextures(activeTextures: BaseTexture[]): void;
  105483. /**
  105484. * Returns the animatable textures.
  105485. * @param animatables Array of animatable textures.
  105486. */
  105487. getAnimatables(animatables: IAnimatable[]): void;
  105488. /**
  105489. * Disposes the resources of the material.
  105490. * @param forceDisposeTextures - Forces the disposal of all textures.
  105491. */
  105492. dispose(forceDisposeTextures?: boolean): void;
  105493. /**
  105494. * Get the current class name of the texture useful for serialization or dynamic coding.
  105495. * @returns "PBRSheenConfiguration"
  105496. */
  105497. getClassName(): string;
  105498. /**
  105499. * Add fallbacks to the effect fallbacks list.
  105500. * @param defines defines the Base texture to use.
  105501. * @param fallbacks defines the current fallback list.
  105502. * @param currentRank defines the current fallback rank.
  105503. * @returns the new fallback rank.
  105504. */
  105505. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105506. /**
  105507. * Add the required uniforms to the current list.
  105508. * @param uniforms defines the current uniform list.
  105509. */
  105510. static AddUniforms(uniforms: string[]): void;
  105511. /**
  105512. * Add the required uniforms to the current buffer.
  105513. * @param uniformBuffer defines the current uniform buffer.
  105514. */
  105515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105516. /**
  105517. * Add the required samplers to the current list.
  105518. * @param samplers defines the current sampler list.
  105519. */
  105520. static AddSamplers(samplers: string[]): void;
  105521. /**
  105522. * Makes a duplicate of the current configuration into another one.
  105523. * @param sheenConfiguration define the config where to copy the info
  105524. */
  105525. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105526. /**
  105527. * Serializes this BRDF configuration.
  105528. * @returns - An object with the serialized config.
  105529. */
  105530. serialize(): any;
  105531. /**
  105532. * Parses a anisotropy Configuration from a serialized object.
  105533. * @param source - Serialized object.
  105534. * @param scene Defines the scene we are parsing for
  105535. * @param rootUrl Defines the rootUrl to load from
  105536. */
  105537. parse(source: any, scene: Scene, rootUrl: string): void;
  105538. }
  105539. }
  105540. declare module BABYLON {
  105541. /**
  105542. * @hidden
  105543. */
  105544. export interface IMaterialSubSurfaceDefines {
  105545. SUBSURFACE: boolean;
  105546. SS_REFRACTION: boolean;
  105547. SS_TRANSLUCENCY: boolean;
  105548. SS_SCATTERING: boolean;
  105549. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105550. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105551. SS_REFRACTIONMAP_3D: boolean;
  105552. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105553. SS_LODINREFRACTIONALPHA: boolean;
  105554. SS_GAMMAREFRACTION: boolean;
  105555. SS_RGBDREFRACTION: boolean;
  105556. SS_LINEARSPECULARREFRACTION: boolean;
  105557. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105558. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105559. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105560. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  105561. /** @hidden */
  105562. _areTexturesDirty: boolean;
  105563. }
  105564. /**
  105565. * Define the code related to the sub surface parameters of the pbr material.
  105566. */
  105567. export class PBRSubSurfaceConfiguration {
  105568. private _isRefractionEnabled;
  105569. /**
  105570. * Defines if the refraction is enabled in the material.
  105571. */
  105572. isRefractionEnabled: boolean;
  105573. private _isTranslucencyEnabled;
  105574. /**
  105575. * Defines if the translucency is enabled in the material.
  105576. */
  105577. isTranslucencyEnabled: boolean;
  105578. private _isScatteringEnabled;
  105579. /**
  105580. * Defines if the sub surface scattering is enabled in the material.
  105581. */
  105582. isScatteringEnabled: boolean;
  105583. private _scatteringDiffusionProfileIndex;
  105584. /**
  105585. * Diffusion profile for subsurface scattering.
  105586. * Useful for better scattering in the skins or foliages.
  105587. */
  105588. get scatteringDiffusionProfile(): Nullable<Color3>;
  105589. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105590. /**
  105591. * Defines the refraction intensity of the material.
  105592. * The refraction when enabled replaces the Diffuse part of the material.
  105593. * The intensity helps transitionning between diffuse and refraction.
  105594. */
  105595. refractionIntensity: number;
  105596. /**
  105597. * Defines the translucency intensity of the material.
  105598. * When translucency has been enabled, this defines how much of the "translucency"
  105599. * is addded to the diffuse part of the material.
  105600. */
  105601. translucencyIntensity: number;
  105602. /**
  105603. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105604. */
  105605. useAlbedoToTintRefraction: boolean;
  105606. private _thicknessTexture;
  105607. /**
  105608. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105609. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105610. * 0 would mean minimumThickness
  105611. * 1 would mean maximumThickness
  105612. * The other channels might be use as a mask to vary the different effects intensity.
  105613. */
  105614. thicknessTexture: Nullable<BaseTexture>;
  105615. private _refractionTexture;
  105616. /**
  105617. * Defines the texture to use for refraction.
  105618. */
  105619. refractionTexture: Nullable<BaseTexture>;
  105620. private _indexOfRefraction;
  105621. /**
  105622. * Index of refraction of the material base layer.
  105623. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105624. *
  105625. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105626. *
  105627. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105628. */
  105629. indexOfRefraction: number;
  105630. private _volumeIndexOfRefraction;
  105631. /**
  105632. * Index of refraction of the material's volume.
  105633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105634. *
  105635. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105636. * the volume will use the same IOR as the surface.
  105637. */
  105638. get volumeIndexOfRefraction(): number;
  105639. set volumeIndexOfRefraction(value: number);
  105640. private _invertRefractionY;
  105641. /**
  105642. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105643. */
  105644. invertRefractionY: boolean;
  105645. private _linkRefractionWithTransparency;
  105646. /**
  105647. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105648. * Materials half opaque for instance using refraction could benefit from this control.
  105649. */
  105650. linkRefractionWithTransparency: boolean;
  105651. /**
  105652. * Defines the minimum thickness stored in the thickness map.
  105653. * If no thickness map is defined, this value will be used to simulate thickness.
  105654. */
  105655. minimumThickness: number;
  105656. /**
  105657. * Defines the maximum thickness stored in the thickness map.
  105658. */
  105659. maximumThickness: number;
  105660. /**
  105661. * Defines the volume tint of the material.
  105662. * This is used for both translucency and scattering.
  105663. */
  105664. tintColor: Color3;
  105665. /**
  105666. * Defines the distance at which the tint color should be found in the media.
  105667. * This is used for refraction only.
  105668. */
  105669. tintColorAtDistance: number;
  105670. /**
  105671. * Defines how far each channel transmit through the media.
  105672. * It is defined as a color to simplify it selection.
  105673. */
  105674. diffusionDistance: Color3;
  105675. private _useMaskFromThicknessTexture;
  105676. /**
  105677. * Stores the intensity of the different subsurface effects in the thickness texture.
  105678. * * the green channel is the translucency intensity.
  105679. * * the blue channel is the scattering intensity.
  105680. * * the alpha channel is the refraction intensity.
  105681. */
  105682. useMaskFromThicknessTexture: boolean;
  105683. private _scene;
  105684. private _useMaskFromThicknessTextureGltf;
  105685. /**
  105686. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  105687. * matches the channel-packing that is used by glTF.
  105688. * * the red channel is the transmission/translucency intensity.
  105689. * * the green channel is the thickness.
  105690. */
  105691. useMaskFromThicknessTextureGltf: boolean;
  105692. /** @hidden */
  105693. private _internalMarkAllSubMeshesAsTexturesDirty;
  105694. private _internalMarkScenePrePassDirty;
  105695. /** @hidden */
  105696. _markAllSubMeshesAsTexturesDirty(): void;
  105697. /** @hidden */
  105698. _markScenePrePassDirty(): void;
  105699. /**
  105700. * Instantiate a new istance of sub surface configuration.
  105701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105702. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105703. * @param scene The scene
  105704. */
  105705. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105706. /**
  105707. * Gets wehter the submesh is ready to be used or not.
  105708. * @param defines the list of "defines" to update.
  105709. * @param scene defines the scene the material belongs to.
  105710. * @returns - boolean indicating that the submesh is ready or not.
  105711. */
  105712. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105713. /**
  105714. * Checks to see if a texture is used in the material.
  105715. * @param defines the list of "defines" to update.
  105716. * @param scene defines the scene to the material belongs to.
  105717. */
  105718. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105719. /**
  105720. * Binds the material data.
  105721. * @param uniformBuffer defines the Uniform buffer to fill in.
  105722. * @param scene defines the scene the material belongs to.
  105723. * @param engine defines the engine the material belongs to.
  105724. * @param isFrozen defines whether the material is frozen or not.
  105725. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105726. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105727. */
  105728. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105729. /**
  105730. * Unbinds the material from the mesh.
  105731. * @param activeEffect defines the effect that should be unbound from.
  105732. * @returns true if unbound, otherwise false
  105733. */
  105734. unbind(activeEffect: Effect): boolean;
  105735. /**
  105736. * Returns the texture used for refraction or null if none is used.
  105737. * @param scene defines the scene the material belongs to.
  105738. * @returns - Refraction texture if present. If no refraction texture and refraction
  105739. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105740. */
  105741. private _getRefractionTexture;
  105742. /**
  105743. * Returns true if alpha blending should be disabled.
  105744. */
  105745. get disableAlphaBlending(): boolean;
  105746. /**
  105747. * Fills the list of render target textures.
  105748. * @param renderTargets the list of render targets to update
  105749. */
  105750. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105751. /**
  105752. * Checks to see if a texture is used in the material.
  105753. * @param texture - Base texture to use.
  105754. * @returns - Boolean specifying if a texture is used in the material.
  105755. */
  105756. hasTexture(texture: BaseTexture): boolean;
  105757. /**
  105758. * Gets a boolean indicating that current material needs to register RTT
  105759. * @returns true if this uses a render target otherwise false.
  105760. */
  105761. hasRenderTargetTextures(): boolean;
  105762. /**
  105763. * Returns an array of the actively used textures.
  105764. * @param activeTextures Array of BaseTextures
  105765. */
  105766. getActiveTextures(activeTextures: BaseTexture[]): void;
  105767. /**
  105768. * Returns the animatable textures.
  105769. * @param animatables Array of animatable textures.
  105770. */
  105771. getAnimatables(animatables: IAnimatable[]): void;
  105772. /**
  105773. * Disposes the resources of the material.
  105774. * @param forceDisposeTextures - Forces the disposal of all textures.
  105775. */
  105776. dispose(forceDisposeTextures?: boolean): void;
  105777. /**
  105778. * Get the current class name of the texture useful for serialization or dynamic coding.
  105779. * @returns "PBRSubSurfaceConfiguration"
  105780. */
  105781. getClassName(): string;
  105782. /**
  105783. * Add fallbacks to the effect fallbacks list.
  105784. * @param defines defines the Base texture to use.
  105785. * @param fallbacks defines the current fallback list.
  105786. * @param currentRank defines the current fallback rank.
  105787. * @returns the new fallback rank.
  105788. */
  105789. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105790. /**
  105791. * Add the required uniforms to the current list.
  105792. * @param uniforms defines the current uniform list.
  105793. */
  105794. static AddUniforms(uniforms: string[]): void;
  105795. /**
  105796. * Add the required samplers to the current list.
  105797. * @param samplers defines the current sampler list.
  105798. */
  105799. static AddSamplers(samplers: string[]): void;
  105800. /**
  105801. * Add the required uniforms to the current buffer.
  105802. * @param uniformBuffer defines the current uniform buffer.
  105803. */
  105804. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105805. /**
  105806. * Makes a duplicate of the current configuration into another one.
  105807. * @param configuration define the config where to copy the info
  105808. */
  105809. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105810. /**
  105811. * Serializes this Sub Surface configuration.
  105812. * @returns - An object with the serialized config.
  105813. */
  105814. serialize(): any;
  105815. /**
  105816. * Parses a anisotropy Configuration from a serialized object.
  105817. * @param source - Serialized object.
  105818. * @param scene Defines the scene we are parsing for
  105819. * @param rootUrl Defines the rootUrl to load from
  105820. */
  105821. parse(source: any, scene: Scene, rootUrl: string): void;
  105822. }
  105823. }
  105824. declare module BABYLON {
  105825. /**
  105826. * Class representing spherical harmonics coefficients to the 3rd degree
  105827. */
  105828. export class SphericalHarmonics {
  105829. /**
  105830. * Defines whether or not the harmonics have been prescaled for rendering.
  105831. */
  105832. preScaled: boolean;
  105833. /**
  105834. * The l0,0 coefficients of the spherical harmonics
  105835. */
  105836. l00: Vector3;
  105837. /**
  105838. * The l1,-1 coefficients of the spherical harmonics
  105839. */
  105840. l1_1: Vector3;
  105841. /**
  105842. * The l1,0 coefficients of the spherical harmonics
  105843. */
  105844. l10: Vector3;
  105845. /**
  105846. * The l1,1 coefficients of the spherical harmonics
  105847. */
  105848. l11: Vector3;
  105849. /**
  105850. * The l2,-2 coefficients of the spherical harmonics
  105851. */
  105852. l2_2: Vector3;
  105853. /**
  105854. * The l2,-1 coefficients of the spherical harmonics
  105855. */
  105856. l2_1: Vector3;
  105857. /**
  105858. * The l2,0 coefficients of the spherical harmonics
  105859. */
  105860. l20: Vector3;
  105861. /**
  105862. * The l2,1 coefficients of the spherical harmonics
  105863. */
  105864. l21: Vector3;
  105865. /**
  105866. * The l2,2 coefficients of the spherical harmonics
  105867. */
  105868. l22: Vector3;
  105869. /**
  105870. * Adds a light to the spherical harmonics
  105871. * @param direction the direction of the light
  105872. * @param color the color of the light
  105873. * @param deltaSolidAngle the delta solid angle of the light
  105874. */
  105875. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105876. /**
  105877. * Scales the spherical harmonics by the given amount
  105878. * @param scale the amount to scale
  105879. */
  105880. scaleInPlace(scale: number): void;
  105881. /**
  105882. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105883. *
  105884. * ```
  105885. * E_lm = A_l * L_lm
  105886. * ```
  105887. *
  105888. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105889. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105890. * the scaling factors are given in equation 9.
  105891. */
  105892. convertIncidentRadianceToIrradiance(): void;
  105893. /**
  105894. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105895. *
  105896. * ```
  105897. * L = (1/pi) * E * rho
  105898. * ```
  105899. *
  105900. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105901. */
  105902. convertIrradianceToLambertianRadiance(): void;
  105903. /**
  105904. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105905. * required operations at run time.
  105906. *
  105907. * This is simply done by scaling back the SH with Ylm constants parameter.
  105908. * The trigonometric part being applied by the shader at run time.
  105909. */
  105910. preScaleForRendering(): void;
  105911. /**
  105912. * Constructs a spherical harmonics from an array.
  105913. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105914. * @returns the spherical harmonics
  105915. */
  105916. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105917. /**
  105918. * Gets the spherical harmonics from polynomial
  105919. * @param polynomial the spherical polynomial
  105920. * @returns the spherical harmonics
  105921. */
  105922. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105923. }
  105924. /**
  105925. * Class representing spherical polynomial coefficients to the 3rd degree
  105926. */
  105927. export class SphericalPolynomial {
  105928. private _harmonics;
  105929. /**
  105930. * The spherical harmonics used to create the polynomials.
  105931. */
  105932. get preScaledHarmonics(): SphericalHarmonics;
  105933. /**
  105934. * The x coefficients of the spherical polynomial
  105935. */
  105936. x: Vector3;
  105937. /**
  105938. * The y coefficients of the spherical polynomial
  105939. */
  105940. y: Vector3;
  105941. /**
  105942. * The z coefficients of the spherical polynomial
  105943. */
  105944. z: Vector3;
  105945. /**
  105946. * The xx coefficients of the spherical polynomial
  105947. */
  105948. xx: Vector3;
  105949. /**
  105950. * The yy coefficients of the spherical polynomial
  105951. */
  105952. yy: Vector3;
  105953. /**
  105954. * The zz coefficients of the spherical polynomial
  105955. */
  105956. zz: Vector3;
  105957. /**
  105958. * The xy coefficients of the spherical polynomial
  105959. */
  105960. xy: Vector3;
  105961. /**
  105962. * The yz coefficients of the spherical polynomial
  105963. */
  105964. yz: Vector3;
  105965. /**
  105966. * The zx coefficients of the spherical polynomial
  105967. */
  105968. zx: Vector3;
  105969. /**
  105970. * Adds an ambient color to the spherical polynomial
  105971. * @param color the color to add
  105972. */
  105973. addAmbient(color: Color3): void;
  105974. /**
  105975. * Scales the spherical polynomial by the given amount
  105976. * @param scale the amount to scale
  105977. */
  105978. scaleInPlace(scale: number): void;
  105979. /**
  105980. * Gets the spherical polynomial from harmonics
  105981. * @param harmonics the spherical harmonics
  105982. * @returns the spherical polynomial
  105983. */
  105984. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105985. /**
  105986. * Constructs a spherical polynomial from an array.
  105987. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105988. * @returns the spherical polynomial
  105989. */
  105990. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105991. }
  105992. }
  105993. declare module BABYLON {
  105994. /**
  105995. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  105996. */
  105997. export interface CubeMapInfo {
  105998. /**
  105999. * The pixel array for the front face.
  106000. * This is stored in format, left to right, up to down format.
  106001. */
  106002. front: Nullable<ArrayBufferView>;
  106003. /**
  106004. * The pixel array for the back face.
  106005. * This is stored in format, left to right, up to down format.
  106006. */
  106007. back: Nullable<ArrayBufferView>;
  106008. /**
  106009. * The pixel array for the left face.
  106010. * This is stored in format, left to right, up to down format.
  106011. */
  106012. left: Nullable<ArrayBufferView>;
  106013. /**
  106014. * The pixel array for the right face.
  106015. * This is stored in format, left to right, up to down format.
  106016. */
  106017. right: Nullable<ArrayBufferView>;
  106018. /**
  106019. * The pixel array for the up face.
  106020. * This is stored in format, left to right, up to down format.
  106021. */
  106022. up: Nullable<ArrayBufferView>;
  106023. /**
  106024. * The pixel array for the down face.
  106025. * This is stored in format, left to right, up to down format.
  106026. */
  106027. down: Nullable<ArrayBufferView>;
  106028. /**
  106029. * The size of the cubemap stored.
  106030. *
  106031. * Each faces will be size * size pixels.
  106032. */
  106033. size: number;
  106034. /**
  106035. * The format of the texture.
  106036. *
  106037. * RGBA, RGB.
  106038. */
  106039. format: number;
  106040. /**
  106041. * The type of the texture data.
  106042. *
  106043. * UNSIGNED_INT, FLOAT.
  106044. */
  106045. type: number;
  106046. /**
  106047. * Specifies whether the texture is in gamma space.
  106048. */
  106049. gammaSpace: boolean;
  106050. }
  106051. /**
  106052. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106053. */
  106054. export class PanoramaToCubeMapTools {
  106055. private static FACE_LEFT;
  106056. private static FACE_RIGHT;
  106057. private static FACE_FRONT;
  106058. private static FACE_BACK;
  106059. private static FACE_DOWN;
  106060. private static FACE_UP;
  106061. /**
  106062. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106063. *
  106064. * @param float32Array The source data.
  106065. * @param inputWidth The width of the input panorama.
  106066. * @param inputHeight The height of the input panorama.
  106067. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106068. * @return The cubemap data
  106069. */
  106070. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106071. private static CreateCubemapTexture;
  106072. private static CalcProjectionSpherical;
  106073. }
  106074. }
  106075. declare module BABYLON {
  106076. /**
  106077. * Helper class dealing with the extraction of spherical polynomial dataArray
  106078. * from a cube map.
  106079. */
  106080. export class CubeMapToSphericalPolynomialTools {
  106081. private static FileFaces;
  106082. /**
  106083. * Converts a texture to the according Spherical Polynomial data.
  106084. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106085. *
  106086. * @param texture The texture to extract the information from.
  106087. * @return The Spherical Polynomial data.
  106088. */
  106089. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  106090. /**
  106091. * Converts a cubemap to the according Spherical Polynomial data.
  106092. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106093. *
  106094. * @param cubeInfo The Cube map to extract the information from.
  106095. * @return The Spherical Polynomial data.
  106096. */
  106097. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106098. }
  106099. }
  106100. declare module BABYLON {
  106101. interface BaseTexture {
  106102. /**
  106103. * Get the polynomial representation of the texture data.
  106104. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106105. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106106. */
  106107. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106108. }
  106109. }
  106110. declare module BABYLON {
  106111. /** @hidden */
  106112. export var pbrFragmentDeclaration: {
  106113. name: string;
  106114. shader: string;
  106115. };
  106116. }
  106117. declare module BABYLON {
  106118. /** @hidden */
  106119. export var pbrUboDeclaration: {
  106120. name: string;
  106121. shader: string;
  106122. };
  106123. }
  106124. declare module BABYLON {
  106125. /** @hidden */
  106126. export var pbrFragmentExtraDeclaration: {
  106127. name: string;
  106128. shader: string;
  106129. };
  106130. }
  106131. declare module BABYLON {
  106132. /** @hidden */
  106133. export var pbrFragmentSamplersDeclaration: {
  106134. name: string;
  106135. shader: string;
  106136. };
  106137. }
  106138. declare module BABYLON {
  106139. /** @hidden */
  106140. export var subSurfaceScatteringFunctions: {
  106141. name: string;
  106142. shader: string;
  106143. };
  106144. }
  106145. declare module BABYLON {
  106146. /** @hidden */
  106147. export var importanceSampling: {
  106148. name: string;
  106149. shader: string;
  106150. };
  106151. }
  106152. declare module BABYLON {
  106153. /** @hidden */
  106154. export var pbrHelperFunctions: {
  106155. name: string;
  106156. shader: string;
  106157. };
  106158. }
  106159. declare module BABYLON {
  106160. /** @hidden */
  106161. export var harmonicsFunctions: {
  106162. name: string;
  106163. shader: string;
  106164. };
  106165. }
  106166. declare module BABYLON {
  106167. /** @hidden */
  106168. export var pbrDirectLightingSetupFunctions: {
  106169. name: string;
  106170. shader: string;
  106171. };
  106172. }
  106173. declare module BABYLON {
  106174. /** @hidden */
  106175. export var pbrDirectLightingFalloffFunctions: {
  106176. name: string;
  106177. shader: string;
  106178. };
  106179. }
  106180. declare module BABYLON {
  106181. /** @hidden */
  106182. export var pbrBRDFFunctions: {
  106183. name: string;
  106184. shader: string;
  106185. };
  106186. }
  106187. declare module BABYLON {
  106188. /** @hidden */
  106189. export var hdrFilteringFunctions: {
  106190. name: string;
  106191. shader: string;
  106192. };
  106193. }
  106194. declare module BABYLON {
  106195. /** @hidden */
  106196. export var pbrDirectLightingFunctions: {
  106197. name: string;
  106198. shader: string;
  106199. };
  106200. }
  106201. declare module BABYLON {
  106202. /** @hidden */
  106203. export var pbrIBLFunctions: {
  106204. name: string;
  106205. shader: string;
  106206. };
  106207. }
  106208. declare module BABYLON {
  106209. /** @hidden */
  106210. export var pbrBlockAlbedoOpacity: {
  106211. name: string;
  106212. shader: string;
  106213. };
  106214. }
  106215. declare module BABYLON {
  106216. /** @hidden */
  106217. export var pbrBlockReflectivity: {
  106218. name: string;
  106219. shader: string;
  106220. };
  106221. }
  106222. declare module BABYLON {
  106223. /** @hidden */
  106224. export var pbrBlockAmbientOcclusion: {
  106225. name: string;
  106226. shader: string;
  106227. };
  106228. }
  106229. declare module BABYLON {
  106230. /** @hidden */
  106231. export var pbrBlockAlphaFresnel: {
  106232. name: string;
  106233. shader: string;
  106234. };
  106235. }
  106236. declare module BABYLON {
  106237. /** @hidden */
  106238. export var pbrBlockAnisotropic: {
  106239. name: string;
  106240. shader: string;
  106241. };
  106242. }
  106243. declare module BABYLON {
  106244. /** @hidden */
  106245. export var pbrBlockReflection: {
  106246. name: string;
  106247. shader: string;
  106248. };
  106249. }
  106250. declare module BABYLON {
  106251. /** @hidden */
  106252. export var pbrBlockSheen: {
  106253. name: string;
  106254. shader: string;
  106255. };
  106256. }
  106257. declare module BABYLON {
  106258. /** @hidden */
  106259. export var pbrBlockClearcoat: {
  106260. name: string;
  106261. shader: string;
  106262. };
  106263. }
  106264. declare module BABYLON {
  106265. /** @hidden */
  106266. export var pbrBlockSubSurface: {
  106267. name: string;
  106268. shader: string;
  106269. };
  106270. }
  106271. declare module BABYLON {
  106272. /** @hidden */
  106273. export var pbrBlockNormalGeometric: {
  106274. name: string;
  106275. shader: string;
  106276. };
  106277. }
  106278. declare module BABYLON {
  106279. /** @hidden */
  106280. export var pbrBlockNormalFinal: {
  106281. name: string;
  106282. shader: string;
  106283. };
  106284. }
  106285. declare module BABYLON {
  106286. /** @hidden */
  106287. export var pbrBlockLightmapInit: {
  106288. name: string;
  106289. shader: string;
  106290. };
  106291. }
  106292. declare module BABYLON {
  106293. /** @hidden */
  106294. export var pbrBlockGeometryInfo: {
  106295. name: string;
  106296. shader: string;
  106297. };
  106298. }
  106299. declare module BABYLON {
  106300. /** @hidden */
  106301. export var pbrBlockReflectance0: {
  106302. name: string;
  106303. shader: string;
  106304. };
  106305. }
  106306. declare module BABYLON {
  106307. /** @hidden */
  106308. export var pbrBlockReflectance: {
  106309. name: string;
  106310. shader: string;
  106311. };
  106312. }
  106313. declare module BABYLON {
  106314. /** @hidden */
  106315. export var pbrBlockDirectLighting: {
  106316. name: string;
  106317. shader: string;
  106318. };
  106319. }
  106320. declare module BABYLON {
  106321. /** @hidden */
  106322. export var pbrBlockFinalLitComponents: {
  106323. name: string;
  106324. shader: string;
  106325. };
  106326. }
  106327. declare module BABYLON {
  106328. /** @hidden */
  106329. export var pbrBlockFinalUnlitComponents: {
  106330. name: string;
  106331. shader: string;
  106332. };
  106333. }
  106334. declare module BABYLON {
  106335. /** @hidden */
  106336. export var pbrBlockFinalColorComposition: {
  106337. name: string;
  106338. shader: string;
  106339. };
  106340. }
  106341. declare module BABYLON {
  106342. /** @hidden */
  106343. export var pbrBlockImageProcessing: {
  106344. name: string;
  106345. shader: string;
  106346. };
  106347. }
  106348. declare module BABYLON {
  106349. /** @hidden */
  106350. export var pbrDebug: {
  106351. name: string;
  106352. shader: string;
  106353. };
  106354. }
  106355. declare module BABYLON {
  106356. /** @hidden */
  106357. export var pbrPixelShader: {
  106358. name: string;
  106359. shader: string;
  106360. };
  106361. }
  106362. declare module BABYLON {
  106363. /** @hidden */
  106364. export var pbrVertexDeclaration: {
  106365. name: string;
  106366. shader: string;
  106367. };
  106368. }
  106369. declare module BABYLON {
  106370. /** @hidden */
  106371. export var pbrVertexShader: {
  106372. name: string;
  106373. shader: string;
  106374. };
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * Manages the defines for the PBR Material.
  106379. * @hidden
  106380. */
  106381. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106382. PBR: boolean;
  106383. NUM_SAMPLES: string;
  106384. REALTIME_FILTERING: boolean;
  106385. MAINUV1: boolean;
  106386. MAINUV2: boolean;
  106387. UV1: boolean;
  106388. UV2: boolean;
  106389. ALBEDO: boolean;
  106390. GAMMAALBEDO: boolean;
  106391. ALBEDODIRECTUV: number;
  106392. VERTEXCOLOR: boolean;
  106393. DETAIL: boolean;
  106394. DETAILDIRECTUV: number;
  106395. DETAIL_NORMALBLENDMETHOD: number;
  106396. AMBIENT: boolean;
  106397. AMBIENTDIRECTUV: number;
  106398. AMBIENTINGRAYSCALE: boolean;
  106399. OPACITY: boolean;
  106400. VERTEXALPHA: boolean;
  106401. OPACITYDIRECTUV: number;
  106402. OPACITYRGB: boolean;
  106403. ALPHATEST: boolean;
  106404. DEPTHPREPASS: boolean;
  106405. ALPHABLEND: boolean;
  106406. ALPHAFROMALBEDO: boolean;
  106407. ALPHATESTVALUE: string;
  106408. SPECULAROVERALPHA: boolean;
  106409. RADIANCEOVERALPHA: boolean;
  106410. ALPHAFRESNEL: boolean;
  106411. LINEARALPHAFRESNEL: boolean;
  106412. PREMULTIPLYALPHA: boolean;
  106413. EMISSIVE: boolean;
  106414. EMISSIVEDIRECTUV: number;
  106415. REFLECTIVITY: boolean;
  106416. REFLECTIVITYDIRECTUV: number;
  106417. SPECULARTERM: boolean;
  106418. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106419. MICROSURFACEAUTOMATIC: boolean;
  106420. LODBASEDMICROSFURACE: boolean;
  106421. MICROSURFACEMAP: boolean;
  106422. MICROSURFACEMAPDIRECTUV: number;
  106423. METALLICWORKFLOW: boolean;
  106424. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106425. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106426. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106427. AOSTOREINMETALMAPRED: boolean;
  106428. METALLIC_REFLECTANCE: boolean;
  106429. METALLIC_REFLECTANCEDIRECTUV: number;
  106430. ENVIRONMENTBRDF: boolean;
  106431. ENVIRONMENTBRDF_RGBD: boolean;
  106432. NORMAL: boolean;
  106433. TANGENT: boolean;
  106434. BUMP: boolean;
  106435. BUMPDIRECTUV: number;
  106436. OBJECTSPACE_NORMALMAP: boolean;
  106437. PARALLAX: boolean;
  106438. PARALLAXOCCLUSION: boolean;
  106439. NORMALXYSCALE: boolean;
  106440. LIGHTMAP: boolean;
  106441. LIGHTMAPDIRECTUV: number;
  106442. USELIGHTMAPASSHADOWMAP: boolean;
  106443. GAMMALIGHTMAP: boolean;
  106444. RGBDLIGHTMAP: boolean;
  106445. REFLECTION: boolean;
  106446. REFLECTIONMAP_3D: boolean;
  106447. REFLECTIONMAP_SPHERICAL: boolean;
  106448. REFLECTIONMAP_PLANAR: boolean;
  106449. REFLECTIONMAP_CUBIC: boolean;
  106450. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106451. REFLECTIONMAP_PROJECTION: boolean;
  106452. REFLECTIONMAP_SKYBOX: boolean;
  106453. REFLECTIONMAP_EXPLICIT: boolean;
  106454. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106455. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106456. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106457. INVERTCUBICMAP: boolean;
  106458. USESPHERICALFROMREFLECTIONMAP: boolean;
  106459. USEIRRADIANCEMAP: boolean;
  106460. SPHERICAL_HARMONICS: boolean;
  106461. USESPHERICALINVERTEX: boolean;
  106462. REFLECTIONMAP_OPPOSITEZ: boolean;
  106463. LODINREFLECTIONALPHA: boolean;
  106464. GAMMAREFLECTION: boolean;
  106465. RGBDREFLECTION: boolean;
  106466. LINEARSPECULARREFLECTION: boolean;
  106467. RADIANCEOCCLUSION: boolean;
  106468. HORIZONOCCLUSION: boolean;
  106469. INSTANCES: boolean;
  106470. THIN_INSTANCES: boolean;
  106471. PREPASS: boolean;
  106472. PREPASS_IRRADIANCE: boolean;
  106473. PREPASS_IRRADIANCE_INDEX: number;
  106474. PREPASS_ALBEDO: boolean;
  106475. PREPASS_ALBEDO_INDEX: number;
  106476. PREPASS_DEPTHNORMAL: boolean;
  106477. PREPASS_DEPTHNORMAL_INDEX: number;
  106478. PREPASS_POSITION: boolean;
  106479. PREPASS_POSITION_INDEX: number;
  106480. PREPASS_VELOCITY: boolean;
  106481. PREPASS_VELOCITY_INDEX: number;
  106482. PREPASS_REFLECTIVITY: boolean;
  106483. PREPASS_REFLECTIVITY_INDEX: number;
  106484. SCENE_MRT_COUNT: number;
  106485. NUM_BONE_INFLUENCERS: number;
  106486. BonesPerMesh: number;
  106487. BONETEXTURE: boolean;
  106488. BONES_VELOCITY_ENABLED: boolean;
  106489. NONUNIFORMSCALING: boolean;
  106490. MORPHTARGETS: boolean;
  106491. MORPHTARGETS_NORMAL: boolean;
  106492. MORPHTARGETS_TANGENT: boolean;
  106493. MORPHTARGETS_UV: boolean;
  106494. NUM_MORPH_INFLUENCERS: number;
  106495. IMAGEPROCESSING: boolean;
  106496. VIGNETTE: boolean;
  106497. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106498. VIGNETTEBLENDMODEOPAQUE: boolean;
  106499. TONEMAPPING: boolean;
  106500. TONEMAPPING_ACES: boolean;
  106501. CONTRAST: boolean;
  106502. COLORCURVES: boolean;
  106503. COLORGRADING: boolean;
  106504. COLORGRADING3D: boolean;
  106505. SAMPLER3DGREENDEPTH: boolean;
  106506. SAMPLER3DBGRMAP: boolean;
  106507. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106508. EXPOSURE: boolean;
  106509. MULTIVIEW: boolean;
  106510. USEPHYSICALLIGHTFALLOFF: boolean;
  106511. USEGLTFLIGHTFALLOFF: boolean;
  106512. TWOSIDEDLIGHTING: boolean;
  106513. SHADOWFLOAT: boolean;
  106514. CLIPPLANE: boolean;
  106515. CLIPPLANE2: boolean;
  106516. CLIPPLANE3: boolean;
  106517. CLIPPLANE4: boolean;
  106518. CLIPPLANE5: boolean;
  106519. CLIPPLANE6: boolean;
  106520. POINTSIZE: boolean;
  106521. FOG: boolean;
  106522. LOGARITHMICDEPTH: boolean;
  106523. FORCENORMALFORWARD: boolean;
  106524. SPECULARAA: boolean;
  106525. CLEARCOAT: boolean;
  106526. CLEARCOAT_DEFAULTIOR: boolean;
  106527. CLEARCOAT_TEXTURE: boolean;
  106528. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106529. CLEARCOAT_TEXTUREDIRECTUV: number;
  106530. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106531. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106532. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106533. CLEARCOAT_BUMP: boolean;
  106534. CLEARCOAT_BUMPDIRECTUV: number;
  106535. CLEARCOAT_REMAP_F0: boolean;
  106536. CLEARCOAT_TINT: boolean;
  106537. CLEARCOAT_TINT_TEXTURE: boolean;
  106538. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106539. ANISOTROPIC: boolean;
  106540. ANISOTROPIC_TEXTURE: boolean;
  106541. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106542. BRDF_V_HEIGHT_CORRELATED: boolean;
  106543. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106544. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106545. SHEEN: boolean;
  106546. SHEEN_TEXTURE: boolean;
  106547. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106548. SHEEN_TEXTUREDIRECTUV: number;
  106549. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106550. SHEEN_LINKWITHALBEDO: boolean;
  106551. SHEEN_ROUGHNESS: boolean;
  106552. SHEEN_ALBEDOSCALING: boolean;
  106553. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106554. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106555. SUBSURFACE: boolean;
  106556. SS_REFRACTION: boolean;
  106557. SS_TRANSLUCENCY: boolean;
  106558. SS_SCATTERING: boolean;
  106559. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106560. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106561. SS_REFRACTIONMAP_3D: boolean;
  106562. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106563. SS_LODINREFRACTIONALPHA: boolean;
  106564. SS_GAMMAREFRACTION: boolean;
  106565. SS_RGBDREFRACTION: boolean;
  106566. SS_LINEARSPECULARREFRACTION: boolean;
  106567. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106568. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106569. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106570. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  106571. UNLIT: boolean;
  106572. DEBUGMODE: number;
  106573. /**
  106574. * Initializes the PBR Material defines.
  106575. */
  106576. constructor();
  106577. /**
  106578. * Resets the PBR Material defines.
  106579. */
  106580. reset(): void;
  106581. }
  106582. /**
  106583. * The Physically based material base class of BJS.
  106584. *
  106585. * This offers the main features of a standard PBR material.
  106586. * For more information, please refer to the documentation :
  106587. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106588. */
  106589. export abstract class PBRBaseMaterial extends PushMaterial {
  106590. /**
  106591. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106592. */
  106593. static readonly PBRMATERIAL_OPAQUE: number;
  106594. /**
  106595. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106596. */
  106597. static readonly PBRMATERIAL_ALPHATEST: number;
  106598. /**
  106599. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106600. */
  106601. static readonly PBRMATERIAL_ALPHABLEND: number;
  106602. /**
  106603. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106604. * They are also discarded below the alpha cutoff threshold to improve performances.
  106605. */
  106606. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106607. /**
  106608. * Defines the default value of how much AO map is occluding the analytical lights
  106609. * (point spot...).
  106610. */
  106611. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106612. /**
  106613. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106614. */
  106615. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106616. /**
  106617. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106618. * to enhance interoperability with other engines.
  106619. */
  106620. static readonly LIGHTFALLOFF_GLTF: number;
  106621. /**
  106622. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106623. * to enhance interoperability with other materials.
  106624. */
  106625. static readonly LIGHTFALLOFF_STANDARD: number;
  106626. /**
  106627. * Intensity of the direct lights e.g. the four lights available in your scene.
  106628. * This impacts both the direct diffuse and specular highlights.
  106629. */
  106630. protected _directIntensity: number;
  106631. /**
  106632. * Intensity of the emissive part of the material.
  106633. * This helps controlling the emissive effect without modifying the emissive color.
  106634. */
  106635. protected _emissiveIntensity: number;
  106636. /**
  106637. * Intensity of the environment e.g. how much the environment will light the object
  106638. * either through harmonics for rough material or through the refelction for shiny ones.
  106639. */
  106640. protected _environmentIntensity: number;
  106641. /**
  106642. * This is a special control allowing the reduction of the specular highlights coming from the
  106643. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106644. */
  106645. protected _specularIntensity: number;
  106646. /**
  106647. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106648. */
  106649. private _lightingInfos;
  106650. /**
  106651. * Debug Control allowing disabling the bump map on this material.
  106652. */
  106653. protected _disableBumpMap: boolean;
  106654. /**
  106655. * AKA Diffuse Texture in standard nomenclature.
  106656. */
  106657. protected _albedoTexture: Nullable<BaseTexture>;
  106658. /**
  106659. * AKA Occlusion Texture in other nomenclature.
  106660. */
  106661. protected _ambientTexture: Nullable<BaseTexture>;
  106662. /**
  106663. * AKA Occlusion Texture Intensity in other nomenclature.
  106664. */
  106665. protected _ambientTextureStrength: number;
  106666. /**
  106667. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106668. * 1 means it completely occludes it
  106669. * 0 mean it has no impact
  106670. */
  106671. protected _ambientTextureImpactOnAnalyticalLights: number;
  106672. /**
  106673. * Stores the alpha values in a texture.
  106674. */
  106675. protected _opacityTexture: Nullable<BaseTexture>;
  106676. /**
  106677. * Stores the reflection values in a texture.
  106678. */
  106679. protected _reflectionTexture: Nullable<BaseTexture>;
  106680. /**
  106681. * Stores the emissive values in a texture.
  106682. */
  106683. protected _emissiveTexture: Nullable<BaseTexture>;
  106684. /**
  106685. * AKA Specular texture in other nomenclature.
  106686. */
  106687. protected _reflectivityTexture: Nullable<BaseTexture>;
  106688. /**
  106689. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106690. */
  106691. protected _metallicTexture: Nullable<BaseTexture>;
  106692. /**
  106693. * Specifies the metallic scalar of the metallic/roughness workflow.
  106694. * Can also be used to scale the metalness values of the metallic texture.
  106695. */
  106696. protected _metallic: Nullable<number>;
  106697. /**
  106698. * Specifies the roughness scalar of the metallic/roughness workflow.
  106699. * Can also be used to scale the roughness values of the metallic texture.
  106700. */
  106701. protected _roughness: Nullable<number>;
  106702. /**
  106703. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106704. * By default the indexOfrefraction is used to compute F0;
  106705. *
  106706. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106707. *
  106708. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106709. * F90 = metallicReflectanceColor;
  106710. */
  106711. protected _metallicF0Factor: number;
  106712. /**
  106713. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106714. * By default the F90 is always 1;
  106715. *
  106716. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106717. *
  106718. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106719. * F90 = metallicReflectanceColor;
  106720. */
  106721. protected _metallicReflectanceColor: Color3;
  106722. /**
  106723. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106724. * This is multiply against the scalar values defined in the material.
  106725. */
  106726. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106727. /**
  106728. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106729. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106730. */
  106731. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106732. /**
  106733. * Stores surface normal data used to displace a mesh in a texture.
  106734. */
  106735. protected _bumpTexture: Nullable<BaseTexture>;
  106736. /**
  106737. * Stores the pre-calculated light information of a mesh in a texture.
  106738. */
  106739. protected _lightmapTexture: Nullable<BaseTexture>;
  106740. /**
  106741. * The color of a material in ambient lighting.
  106742. */
  106743. protected _ambientColor: Color3;
  106744. /**
  106745. * AKA Diffuse Color in other nomenclature.
  106746. */
  106747. protected _albedoColor: Color3;
  106748. /**
  106749. * AKA Specular Color in other nomenclature.
  106750. */
  106751. protected _reflectivityColor: Color3;
  106752. /**
  106753. * The color applied when light is reflected from a material.
  106754. */
  106755. protected _reflectionColor: Color3;
  106756. /**
  106757. * The color applied when light is emitted from a material.
  106758. */
  106759. protected _emissiveColor: Color3;
  106760. /**
  106761. * AKA Glossiness in other nomenclature.
  106762. */
  106763. protected _microSurface: number;
  106764. /**
  106765. * Specifies that the material will use the light map as a show map.
  106766. */
  106767. protected _useLightmapAsShadowmap: boolean;
  106768. /**
  106769. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106770. * makes the reflect vector face the model (under horizon).
  106771. */
  106772. protected _useHorizonOcclusion: boolean;
  106773. /**
  106774. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106775. * too much the area relying on ambient texture to define their ambient occlusion.
  106776. */
  106777. protected _useRadianceOcclusion: boolean;
  106778. /**
  106779. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106780. */
  106781. protected _useAlphaFromAlbedoTexture: boolean;
  106782. /**
  106783. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106784. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106785. */
  106786. protected _useSpecularOverAlpha: boolean;
  106787. /**
  106788. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106789. */
  106790. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106791. /**
  106792. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106793. */
  106794. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106795. /**
  106796. * Specifies if the metallic texture contains the roughness information in its green channel.
  106797. */
  106798. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106799. /**
  106800. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106801. */
  106802. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106803. /**
  106804. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106805. */
  106806. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106807. /**
  106808. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106809. */
  106810. protected _useAmbientInGrayScale: boolean;
  106811. /**
  106812. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106813. * The material will try to infer what glossiness each pixel should be.
  106814. */
  106815. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106816. /**
  106817. * Defines the falloff type used in this material.
  106818. * It by default is Physical.
  106819. */
  106820. protected _lightFalloff: number;
  106821. /**
  106822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106824. */
  106825. protected _useRadianceOverAlpha: boolean;
  106826. /**
  106827. * Allows using an object space normal map (instead of tangent space).
  106828. */
  106829. protected _useObjectSpaceNormalMap: boolean;
  106830. /**
  106831. * Allows using the bump map in parallax mode.
  106832. */
  106833. protected _useParallax: boolean;
  106834. /**
  106835. * Allows using the bump map in parallax occlusion mode.
  106836. */
  106837. protected _useParallaxOcclusion: boolean;
  106838. /**
  106839. * Controls the scale bias of the parallax mode.
  106840. */
  106841. protected _parallaxScaleBias: number;
  106842. /**
  106843. * If sets to true, disables all the lights affecting the material.
  106844. */
  106845. protected _disableLighting: boolean;
  106846. /**
  106847. * Number of Simultaneous lights allowed on the material.
  106848. */
  106849. protected _maxSimultaneousLights: number;
  106850. /**
  106851. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106852. */
  106853. protected _invertNormalMapX: boolean;
  106854. /**
  106855. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106856. */
  106857. protected _invertNormalMapY: boolean;
  106858. /**
  106859. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106860. */
  106861. protected _twoSidedLighting: boolean;
  106862. /**
  106863. * Defines the alpha limits in alpha test mode.
  106864. */
  106865. protected _alphaCutOff: number;
  106866. /**
  106867. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106868. */
  106869. protected _forceAlphaTest: boolean;
  106870. /**
  106871. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106872. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  106873. */
  106874. protected _useAlphaFresnel: boolean;
  106875. /**
  106876. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106877. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  106878. */
  106879. protected _useLinearAlphaFresnel: boolean;
  106880. /**
  106881. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  106882. * from cos thetav and roughness:
  106883. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  106884. */
  106885. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  106886. /**
  106887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  106888. */
  106889. protected _forceIrradianceInFragment: boolean;
  106890. private _realTimeFiltering;
  106891. /**
  106892. * Enables realtime filtering on the texture.
  106893. */
  106894. get realTimeFiltering(): boolean;
  106895. set realTimeFiltering(b: boolean);
  106896. private _realTimeFilteringQuality;
  106897. /**
  106898. * Quality switch for realtime filtering
  106899. */
  106900. get realTimeFilteringQuality(): number;
  106901. set realTimeFilteringQuality(n: number);
  106902. /**
  106903. * Can this material render to several textures at once
  106904. */
  106905. get canRenderToMRT(): boolean;
  106906. /**
  106907. * Force normal to face away from face.
  106908. */
  106909. protected _forceNormalForward: boolean;
  106910. /**
  106911. * Enables specular anti aliasing in the PBR shader.
  106912. * It will both interacts on the Geometry for analytical and IBL lighting.
  106913. * It also prefilter the roughness map based on the bump values.
  106914. */
  106915. protected _enableSpecularAntiAliasing: boolean;
  106916. /**
  106917. * Default configuration related to image processing available in the PBR Material.
  106918. */
  106919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106920. /**
  106921. * Keep track of the image processing observer to allow dispose and replace.
  106922. */
  106923. private _imageProcessingObserver;
  106924. /**
  106925. * Attaches a new image processing configuration to the PBR Material.
  106926. * @param configuration
  106927. */
  106928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106929. /**
  106930. * Stores the available render targets.
  106931. */
  106932. private _renderTargets;
  106933. /**
  106934. * Sets the global ambient color for the material used in lighting calculations.
  106935. */
  106936. private _globalAmbientColor;
  106937. /**
  106938. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  106939. */
  106940. private _useLogarithmicDepth;
  106941. /**
  106942. * If set to true, no lighting calculations will be applied.
  106943. */
  106944. private _unlit;
  106945. private _debugMode;
  106946. /**
  106947. * @hidden
  106948. * This is reserved for the inspector.
  106949. * Defines the material debug mode.
  106950. * It helps seeing only some components of the material while troubleshooting.
  106951. */
  106952. debugMode: number;
  106953. /**
  106954. * @hidden
  106955. * This is reserved for the inspector.
  106956. * Specify from where on screen the debug mode should start.
  106957. * The value goes from -1 (full screen) to 1 (not visible)
  106958. * It helps with side by side comparison against the final render
  106959. * This defaults to -1
  106960. */
  106961. private debugLimit;
  106962. /**
  106963. * @hidden
  106964. * This is reserved for the inspector.
  106965. * As the default viewing range might not be enough (if the ambient is really small for instance)
  106966. * You can use the factor to better multiply the final value.
  106967. */
  106968. private debugFactor;
  106969. /**
  106970. * Defines the clear coat layer parameters for the material.
  106971. */
  106972. readonly clearCoat: PBRClearCoatConfiguration;
  106973. /**
  106974. * Defines the anisotropic parameters for the material.
  106975. */
  106976. readonly anisotropy: PBRAnisotropicConfiguration;
  106977. /**
  106978. * Defines the BRDF parameters for the material.
  106979. */
  106980. readonly brdf: PBRBRDFConfiguration;
  106981. /**
  106982. * Defines the Sheen parameters for the material.
  106983. */
  106984. readonly sheen: PBRSheenConfiguration;
  106985. /**
  106986. * Defines the SubSurface parameters for the material.
  106987. */
  106988. readonly subSurface: PBRSubSurfaceConfiguration;
  106989. /**
  106990. * Defines additionnal PrePass parameters for the material.
  106991. */
  106992. readonly prePassConfiguration: PrePassConfiguration;
  106993. /**
  106994. * Defines the detail map parameters for the material.
  106995. */
  106996. readonly detailMap: DetailMapConfiguration;
  106997. protected _rebuildInParallel: boolean;
  106998. /**
  106999. * Instantiates a new PBRMaterial instance.
  107000. *
  107001. * @param name The material name
  107002. * @param scene The scene the material will be use in.
  107003. */
  107004. constructor(name: string, scene: Scene);
  107005. /**
  107006. * Gets a boolean indicating that current material needs to register RTT
  107007. */
  107008. get hasRenderTargetTextures(): boolean;
  107009. /**
  107010. * Gets the name of the material class.
  107011. */
  107012. getClassName(): string;
  107013. /**
  107014. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107015. */
  107016. get useLogarithmicDepth(): boolean;
  107017. /**
  107018. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107019. */
  107020. set useLogarithmicDepth(value: boolean);
  107021. /**
  107022. * Returns true if alpha blending should be disabled.
  107023. */
  107024. protected get _disableAlphaBlending(): boolean;
  107025. /**
  107026. * Specifies whether or not this material should be rendered in alpha blend mode.
  107027. */
  107028. needAlphaBlending(): boolean;
  107029. /**
  107030. * Specifies whether or not this material should be rendered in alpha test mode.
  107031. */
  107032. needAlphaTesting(): boolean;
  107033. /**
  107034. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107035. */
  107036. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107037. /**
  107038. * Specifies whether or not there is a usable alpha channel for transparency.
  107039. */
  107040. protected _hasAlphaChannel(): boolean;
  107041. /**
  107042. * Gets the texture used for the alpha test.
  107043. */
  107044. getAlphaTestTexture(): Nullable<BaseTexture>;
  107045. /**
  107046. * Specifies that the submesh is ready to be used.
  107047. * @param mesh - BJS mesh.
  107048. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107049. * @param useInstances - Specifies that instances should be used.
  107050. * @returns - boolean indicating that the submesh is ready or not.
  107051. */
  107052. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107053. /**
  107054. * Specifies if the material uses metallic roughness workflow.
  107055. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107056. */
  107057. isMetallicWorkflow(): boolean;
  107058. private _prepareEffect;
  107059. private _prepareDefines;
  107060. /**
  107061. * Force shader compilation
  107062. */
  107063. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107064. /**
  107065. * Initializes the uniform buffer layout for the shader.
  107066. */
  107067. buildUniformLayout(): void;
  107068. /**
  107069. * Unbinds the material from the mesh
  107070. */
  107071. unbind(): void;
  107072. /**
  107073. * Binds the submesh data.
  107074. * @param world - The world matrix.
  107075. * @param mesh - The BJS mesh.
  107076. * @param subMesh - A submesh of the BJS mesh.
  107077. */
  107078. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107079. /**
  107080. * Returns the animatable textures.
  107081. * @returns - Array of animatable textures.
  107082. */
  107083. getAnimatables(): IAnimatable[];
  107084. /**
  107085. * Returns the texture used for reflections.
  107086. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107087. */
  107088. private _getReflectionTexture;
  107089. /**
  107090. * Returns an array of the actively used textures.
  107091. * @returns - Array of BaseTextures
  107092. */
  107093. getActiveTextures(): BaseTexture[];
  107094. /**
  107095. * Checks to see if a texture is used in the material.
  107096. * @param texture - Base texture to use.
  107097. * @returns - Boolean specifying if a texture is used in the material.
  107098. */
  107099. hasTexture(texture: BaseTexture): boolean;
  107100. /**
  107101. * Sets the required values to the prepass renderer.
  107102. * @param prePassRenderer defines the prepass renderer to setup
  107103. */
  107104. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107105. /**
  107106. * Disposes the resources of the material.
  107107. * @param forceDisposeEffect - Forces the disposal of effects.
  107108. * @param forceDisposeTextures - Forces the disposal of all textures.
  107109. */
  107110. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107111. }
  107112. }
  107113. declare module BABYLON {
  107114. /**
  107115. * The Physically based material of BJS.
  107116. *
  107117. * This offers the main features of a standard PBR material.
  107118. * For more information, please refer to the documentation :
  107119. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107120. */
  107121. export class PBRMaterial extends PBRBaseMaterial {
  107122. /**
  107123. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107124. */
  107125. static readonly PBRMATERIAL_OPAQUE: number;
  107126. /**
  107127. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107128. */
  107129. static readonly PBRMATERIAL_ALPHATEST: number;
  107130. /**
  107131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107132. */
  107133. static readonly PBRMATERIAL_ALPHABLEND: number;
  107134. /**
  107135. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107136. * They are also discarded below the alpha cutoff threshold to improve performances.
  107137. */
  107138. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107139. /**
  107140. * Defines the default value of how much AO map is occluding the analytical lights
  107141. * (point spot...).
  107142. */
  107143. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107144. /**
  107145. * Intensity of the direct lights e.g. the four lights available in your scene.
  107146. * This impacts both the direct diffuse and specular highlights.
  107147. */
  107148. directIntensity: number;
  107149. /**
  107150. * Intensity of the emissive part of the material.
  107151. * This helps controlling the emissive effect without modifying the emissive color.
  107152. */
  107153. emissiveIntensity: number;
  107154. /**
  107155. * Intensity of the environment e.g. how much the environment will light the object
  107156. * either through harmonics for rough material or through the refelction for shiny ones.
  107157. */
  107158. environmentIntensity: number;
  107159. /**
  107160. * This is a special control allowing the reduction of the specular highlights coming from the
  107161. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107162. */
  107163. specularIntensity: number;
  107164. /**
  107165. * Debug Control allowing disabling the bump map on this material.
  107166. */
  107167. disableBumpMap: boolean;
  107168. /**
  107169. * AKA Diffuse Texture in standard nomenclature.
  107170. */
  107171. albedoTexture: BaseTexture;
  107172. /**
  107173. * AKA Occlusion Texture in other nomenclature.
  107174. */
  107175. ambientTexture: BaseTexture;
  107176. /**
  107177. * AKA Occlusion Texture Intensity in other nomenclature.
  107178. */
  107179. ambientTextureStrength: number;
  107180. /**
  107181. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107182. * 1 means it completely occludes it
  107183. * 0 mean it has no impact
  107184. */
  107185. ambientTextureImpactOnAnalyticalLights: number;
  107186. /**
  107187. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107188. */
  107189. opacityTexture: BaseTexture;
  107190. /**
  107191. * Stores the reflection values in a texture.
  107192. */
  107193. reflectionTexture: Nullable<BaseTexture>;
  107194. /**
  107195. * Stores the emissive values in a texture.
  107196. */
  107197. emissiveTexture: BaseTexture;
  107198. /**
  107199. * AKA Specular texture in other nomenclature.
  107200. */
  107201. reflectivityTexture: BaseTexture;
  107202. /**
  107203. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107204. */
  107205. metallicTexture: BaseTexture;
  107206. /**
  107207. * Specifies the metallic scalar of the metallic/roughness workflow.
  107208. * Can also be used to scale the metalness values of the metallic texture.
  107209. */
  107210. metallic: Nullable<number>;
  107211. /**
  107212. * Specifies the roughness scalar of the metallic/roughness workflow.
  107213. * Can also be used to scale the roughness values of the metallic texture.
  107214. */
  107215. roughness: Nullable<number>;
  107216. /**
  107217. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107218. * By default the indexOfrefraction is used to compute F0;
  107219. *
  107220. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107221. *
  107222. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107223. * F90 = metallicReflectanceColor;
  107224. */
  107225. metallicF0Factor: number;
  107226. /**
  107227. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107228. * By default the F90 is always 1;
  107229. *
  107230. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107231. *
  107232. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107233. * F90 = metallicReflectanceColor;
  107234. */
  107235. metallicReflectanceColor: Color3;
  107236. /**
  107237. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107238. * This is multiply against the scalar values defined in the material.
  107239. */
  107240. metallicReflectanceTexture: Nullable<BaseTexture>;
  107241. /**
  107242. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107243. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107244. */
  107245. microSurfaceTexture: BaseTexture;
  107246. /**
  107247. * Stores surface normal data used to displace a mesh in a texture.
  107248. */
  107249. bumpTexture: BaseTexture;
  107250. /**
  107251. * Stores the pre-calculated light information of a mesh in a texture.
  107252. */
  107253. lightmapTexture: BaseTexture;
  107254. /**
  107255. * Stores the refracted light information in a texture.
  107256. */
  107257. get refractionTexture(): Nullable<BaseTexture>;
  107258. set refractionTexture(value: Nullable<BaseTexture>);
  107259. /**
  107260. * The color of a material in ambient lighting.
  107261. */
  107262. ambientColor: Color3;
  107263. /**
  107264. * AKA Diffuse Color in other nomenclature.
  107265. */
  107266. albedoColor: Color3;
  107267. /**
  107268. * AKA Specular Color in other nomenclature.
  107269. */
  107270. reflectivityColor: Color3;
  107271. /**
  107272. * The color reflected from the material.
  107273. */
  107274. reflectionColor: Color3;
  107275. /**
  107276. * The color emitted from the material.
  107277. */
  107278. emissiveColor: Color3;
  107279. /**
  107280. * AKA Glossiness in other nomenclature.
  107281. */
  107282. microSurface: number;
  107283. /**
  107284. * Index of refraction of the material base layer.
  107285. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107286. *
  107287. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107288. *
  107289. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107290. */
  107291. get indexOfRefraction(): number;
  107292. set indexOfRefraction(value: number);
  107293. /**
  107294. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107295. */
  107296. get invertRefractionY(): boolean;
  107297. set invertRefractionY(value: boolean);
  107298. /**
  107299. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107300. * Materials half opaque for instance using refraction could benefit from this control.
  107301. */
  107302. get linkRefractionWithTransparency(): boolean;
  107303. set linkRefractionWithTransparency(value: boolean);
  107304. /**
  107305. * If true, the light map contains occlusion information instead of lighting info.
  107306. */
  107307. useLightmapAsShadowmap: boolean;
  107308. /**
  107309. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107310. */
  107311. useAlphaFromAlbedoTexture: boolean;
  107312. /**
  107313. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107314. */
  107315. forceAlphaTest: boolean;
  107316. /**
  107317. * Defines the alpha limits in alpha test mode.
  107318. */
  107319. alphaCutOff: number;
  107320. /**
  107321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107323. */
  107324. useSpecularOverAlpha: boolean;
  107325. /**
  107326. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107327. */
  107328. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107329. /**
  107330. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107331. */
  107332. useRoughnessFromMetallicTextureAlpha: boolean;
  107333. /**
  107334. * Specifies if the metallic texture contains the roughness information in its green channel.
  107335. */
  107336. useRoughnessFromMetallicTextureGreen: boolean;
  107337. /**
  107338. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107339. */
  107340. useMetallnessFromMetallicTextureBlue: boolean;
  107341. /**
  107342. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107343. */
  107344. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107345. /**
  107346. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107347. */
  107348. useAmbientInGrayScale: boolean;
  107349. /**
  107350. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107351. * The material will try to infer what glossiness each pixel should be.
  107352. */
  107353. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107354. /**
  107355. * BJS is using an harcoded light falloff based on a manually sets up range.
  107356. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107357. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107358. */
  107359. get usePhysicalLightFalloff(): boolean;
  107360. /**
  107361. * BJS is using an harcoded light falloff based on a manually sets up range.
  107362. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107363. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107364. */
  107365. set usePhysicalLightFalloff(value: boolean);
  107366. /**
  107367. * In order to support the falloff compatibility with gltf, a special mode has been added
  107368. * to reproduce the gltf light falloff.
  107369. */
  107370. get useGLTFLightFalloff(): boolean;
  107371. /**
  107372. * In order to support the falloff compatibility with gltf, a special mode has been added
  107373. * to reproduce the gltf light falloff.
  107374. */
  107375. set useGLTFLightFalloff(value: boolean);
  107376. /**
  107377. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107378. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107379. */
  107380. useRadianceOverAlpha: boolean;
  107381. /**
  107382. * Allows using an object space normal map (instead of tangent space).
  107383. */
  107384. useObjectSpaceNormalMap: boolean;
  107385. /**
  107386. * Allows using the bump map in parallax mode.
  107387. */
  107388. useParallax: boolean;
  107389. /**
  107390. * Allows using the bump map in parallax occlusion mode.
  107391. */
  107392. useParallaxOcclusion: boolean;
  107393. /**
  107394. * Controls the scale bias of the parallax mode.
  107395. */
  107396. parallaxScaleBias: number;
  107397. /**
  107398. * If sets to true, disables all the lights affecting the material.
  107399. */
  107400. disableLighting: boolean;
  107401. /**
  107402. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107403. */
  107404. forceIrradianceInFragment: boolean;
  107405. /**
  107406. * Number of Simultaneous lights allowed on the material.
  107407. */
  107408. maxSimultaneousLights: number;
  107409. /**
  107410. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107411. */
  107412. invertNormalMapX: boolean;
  107413. /**
  107414. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107415. */
  107416. invertNormalMapY: boolean;
  107417. /**
  107418. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107419. */
  107420. twoSidedLighting: boolean;
  107421. /**
  107422. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107423. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107424. */
  107425. useAlphaFresnel: boolean;
  107426. /**
  107427. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107428. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107429. */
  107430. useLinearAlphaFresnel: boolean;
  107431. /**
  107432. * Let user defines the brdf lookup texture used for IBL.
  107433. * A default 8bit version is embedded but you could point at :
  107434. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107435. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107436. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107437. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107438. */
  107439. environmentBRDFTexture: Nullable<BaseTexture>;
  107440. /**
  107441. * Force normal to face away from face.
  107442. */
  107443. forceNormalForward: boolean;
  107444. /**
  107445. * Enables specular anti aliasing in the PBR shader.
  107446. * It will both interacts on the Geometry for analytical and IBL lighting.
  107447. * It also prefilter the roughness map based on the bump values.
  107448. */
  107449. enableSpecularAntiAliasing: boolean;
  107450. /**
  107451. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107452. * makes the reflect vector face the model (under horizon).
  107453. */
  107454. useHorizonOcclusion: boolean;
  107455. /**
  107456. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107457. * too much the area relying on ambient texture to define their ambient occlusion.
  107458. */
  107459. useRadianceOcclusion: boolean;
  107460. /**
  107461. * If set to true, no lighting calculations will be applied.
  107462. */
  107463. unlit: boolean;
  107464. /**
  107465. * Gets the image processing configuration used either in this material.
  107466. */
  107467. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107468. /**
  107469. * Sets the Default image processing configuration used either in the this material.
  107470. *
  107471. * If sets to null, the scene one is in use.
  107472. */
  107473. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107474. /**
  107475. * Gets wether the color curves effect is enabled.
  107476. */
  107477. get cameraColorCurvesEnabled(): boolean;
  107478. /**
  107479. * Sets wether the color curves effect is enabled.
  107480. */
  107481. set cameraColorCurvesEnabled(value: boolean);
  107482. /**
  107483. * Gets wether the color grading effect is enabled.
  107484. */
  107485. get cameraColorGradingEnabled(): boolean;
  107486. /**
  107487. * Gets wether the color grading effect is enabled.
  107488. */
  107489. set cameraColorGradingEnabled(value: boolean);
  107490. /**
  107491. * Gets wether tonemapping is enabled or not.
  107492. */
  107493. get cameraToneMappingEnabled(): boolean;
  107494. /**
  107495. * Sets wether tonemapping is enabled or not
  107496. */
  107497. set cameraToneMappingEnabled(value: boolean);
  107498. /**
  107499. * The camera exposure used on this material.
  107500. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107501. * This corresponds to a photographic exposure.
  107502. */
  107503. get cameraExposure(): number;
  107504. /**
  107505. * The camera exposure used on this material.
  107506. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107507. * This corresponds to a photographic exposure.
  107508. */
  107509. set cameraExposure(value: number);
  107510. /**
  107511. * Gets The camera contrast used on this material.
  107512. */
  107513. get cameraContrast(): number;
  107514. /**
  107515. * Sets The camera contrast used on this material.
  107516. */
  107517. set cameraContrast(value: number);
  107518. /**
  107519. * Gets the Color Grading 2D Lookup Texture.
  107520. */
  107521. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107522. /**
  107523. * Sets the Color Grading 2D Lookup Texture.
  107524. */
  107525. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107526. /**
  107527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107529. * 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;
  107530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107531. */
  107532. get cameraColorCurves(): Nullable<ColorCurves>;
  107533. /**
  107534. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107535. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107536. * 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;
  107537. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107538. */
  107539. set cameraColorCurves(value: Nullable<ColorCurves>);
  107540. /**
  107541. * Instantiates a new PBRMaterial instance.
  107542. *
  107543. * @param name The material name
  107544. * @param scene The scene the material will be use in.
  107545. */
  107546. constructor(name: string, scene: Scene);
  107547. /**
  107548. * Returns the name of this material class.
  107549. */
  107550. getClassName(): string;
  107551. /**
  107552. * Makes a duplicate of the current material.
  107553. * @param name - name to use for the new material.
  107554. */
  107555. clone(name: string): PBRMaterial;
  107556. /**
  107557. * Serializes this PBR Material.
  107558. * @returns - An object with the serialized material.
  107559. */
  107560. serialize(): any;
  107561. /**
  107562. * Parses a PBR Material from a serialized object.
  107563. * @param source - Serialized object.
  107564. * @param scene - BJS scene instance.
  107565. * @param rootUrl - url for the scene object
  107566. * @returns - PBRMaterial
  107567. */
  107568. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107569. }
  107570. }
  107571. declare module BABYLON {
  107572. /** @hidden */
  107573. export var mrtFragmentDeclaration: {
  107574. name: string;
  107575. shader: string;
  107576. };
  107577. }
  107578. declare module BABYLON {
  107579. /** @hidden */
  107580. export var geometryPixelShader: {
  107581. name: string;
  107582. shader: string;
  107583. };
  107584. }
  107585. declare module BABYLON {
  107586. /** @hidden */
  107587. export var instancesDeclaration: {
  107588. name: string;
  107589. shader: string;
  107590. };
  107591. }
  107592. declare module BABYLON {
  107593. /** @hidden */
  107594. export var geometryVertexShader: {
  107595. name: string;
  107596. shader: string;
  107597. };
  107598. }
  107599. declare module BABYLON {
  107600. /** @hidden */
  107601. interface ISavedTransformationMatrix {
  107602. world: Matrix;
  107603. viewProjection: Matrix;
  107604. }
  107605. /**
  107606. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107607. */
  107608. export class GeometryBufferRenderer {
  107609. /**
  107610. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107611. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107612. */
  107613. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107614. /**
  107615. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107616. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107617. */
  107618. static readonly POSITION_TEXTURE_TYPE: number;
  107619. /**
  107620. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107621. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107622. */
  107623. static readonly VELOCITY_TEXTURE_TYPE: number;
  107624. /**
  107625. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107626. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107627. */
  107628. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107629. /**
  107630. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107631. * in order to compute objects velocities when enableVelocity is set to "true"
  107632. * @hidden
  107633. */
  107634. _previousTransformationMatrices: {
  107635. [index: number]: ISavedTransformationMatrix;
  107636. };
  107637. /**
  107638. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107639. * in order to compute objects velocities when enableVelocity is set to "true"
  107640. * @hidden
  107641. */
  107642. _previousBonesTransformationMatrices: {
  107643. [index: number]: Float32Array;
  107644. };
  107645. /**
  107646. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107647. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107648. */
  107649. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107650. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107651. renderTransparentMeshes: boolean;
  107652. private _scene;
  107653. private _resizeObserver;
  107654. private _multiRenderTarget;
  107655. private _ratio;
  107656. private _enablePosition;
  107657. private _enableVelocity;
  107658. private _enableReflectivity;
  107659. private _positionIndex;
  107660. private _velocityIndex;
  107661. private _reflectivityIndex;
  107662. private _depthNormalIndex;
  107663. private _linkedWithPrePass;
  107664. private _prePassRenderer;
  107665. private _attachments;
  107666. protected _effect: Effect;
  107667. protected _cachedDefines: string;
  107668. /**
  107669. * @hidden
  107670. * Sets up internal structures to share outputs with PrePassRenderer
  107671. * This method should only be called by the PrePassRenderer itself
  107672. */
  107673. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107674. /**
  107675. * @hidden
  107676. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107677. * This method should only be called by the PrePassRenderer itself
  107678. */
  107679. _unlinkPrePassRenderer(): void;
  107680. /**
  107681. * @hidden
  107682. * Resets the geometry buffer layout
  107683. */
  107684. _resetLayout(): void;
  107685. /**
  107686. * @hidden
  107687. * Replaces a texture in the geometry buffer renderer
  107688. * Useful when linking textures of the prepass renderer
  107689. */
  107690. _forceTextureType(geometryBufferType: number, index: number): void;
  107691. /**
  107692. * @hidden
  107693. * Sets texture attachments
  107694. * Useful when linking textures of the prepass renderer
  107695. */
  107696. _setAttachments(attachments: number[]): void;
  107697. /**
  107698. * @hidden
  107699. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107700. * Useful when linking textures of the prepass renderer
  107701. */
  107702. _linkInternalTexture(internalTexture: InternalTexture): void;
  107703. /**
  107704. * Gets the render list (meshes to be rendered) used in the G buffer.
  107705. */
  107706. get renderList(): Nullable<AbstractMesh[]>;
  107707. /**
  107708. * Set the render list (meshes to be rendered) used in the G buffer.
  107709. */
  107710. set renderList(meshes: Nullable<AbstractMesh[]>);
  107711. /**
  107712. * Gets wether or not G buffer are supported by the running hardware.
  107713. * This requires draw buffer supports
  107714. */
  107715. get isSupported(): boolean;
  107716. /**
  107717. * Returns the index of the given texture type in the G-Buffer textures array
  107718. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107719. * @returns the index of the given texture type in the G-Buffer textures array
  107720. */
  107721. getTextureIndex(textureType: number): number;
  107722. /**
  107723. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107724. */
  107725. get enablePosition(): boolean;
  107726. /**
  107727. * Sets whether or not objects positions are enabled for the G buffer.
  107728. */
  107729. set enablePosition(enable: boolean);
  107730. /**
  107731. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107732. */
  107733. get enableVelocity(): boolean;
  107734. /**
  107735. * Sets wether or not objects velocities are enabled for the G buffer.
  107736. */
  107737. set enableVelocity(enable: boolean);
  107738. /**
  107739. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107740. */
  107741. get enableReflectivity(): boolean;
  107742. /**
  107743. * Sets wether or not objects roughness are enabled for the G buffer.
  107744. */
  107745. set enableReflectivity(enable: boolean);
  107746. /**
  107747. * Gets the scene associated with the buffer.
  107748. */
  107749. get scene(): Scene;
  107750. /**
  107751. * Gets the ratio used by the buffer during its creation.
  107752. * How big is the buffer related to the main canvas.
  107753. */
  107754. get ratio(): number;
  107755. /** @hidden */
  107756. static _SceneComponentInitialization: (scene: Scene) => void;
  107757. /**
  107758. * Creates a new G Buffer for the scene
  107759. * @param scene The scene the buffer belongs to
  107760. * @param ratio How big is the buffer related to the main canvas.
  107761. */
  107762. constructor(scene: Scene, ratio?: number);
  107763. /**
  107764. * Checks wether everything is ready to render a submesh to the G buffer.
  107765. * @param subMesh the submesh to check readiness for
  107766. * @param useInstances is the mesh drawn using instance or not
  107767. * @returns true if ready otherwise false
  107768. */
  107769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107770. /**
  107771. * Gets the current underlying G Buffer.
  107772. * @returns the buffer
  107773. */
  107774. getGBuffer(): MultiRenderTarget;
  107775. /**
  107776. * Gets the number of samples used to render the buffer (anti aliasing).
  107777. */
  107778. get samples(): number;
  107779. /**
  107780. * Sets the number of samples used to render the buffer (anti aliasing).
  107781. */
  107782. set samples(value: number);
  107783. /**
  107784. * Disposes the renderer and frees up associated resources.
  107785. */
  107786. dispose(): void;
  107787. private _assignRenderTargetIndices;
  107788. protected _createRenderTargets(): void;
  107789. private _copyBonesTransformationMatrices;
  107790. }
  107791. }
  107792. declare module BABYLON {
  107793. /**
  107794. * Renders a pre pass of the scene
  107795. * This means every mesh in the scene will be rendered to a render target texture
  107796. * And then this texture will be composited to the rendering canvas with post processes
  107797. * It is necessary for effects like subsurface scattering or deferred shading
  107798. */
  107799. export class PrePassRenderer {
  107800. /** @hidden */
  107801. static _SceneComponentInitialization: (scene: Scene) => void;
  107802. private _textureFormats;
  107803. /**
  107804. * To save performance, we can excluded skinned meshes from the prepass
  107805. */
  107806. excludedSkinnedMesh: AbstractMesh[];
  107807. /**
  107808. * Force material to be excluded from the prepass
  107809. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107810. * and you don't want a material to show in the effect.
  107811. */
  107812. excludedMaterials: Material[];
  107813. private _textureIndices;
  107814. private _scene;
  107815. private _engine;
  107816. private _isDirty;
  107817. /**
  107818. * Number of textures in the multi render target texture where the scene is directly rendered
  107819. */
  107820. mrtCount: number;
  107821. /**
  107822. * The render target where the scene is directly rendered
  107823. */
  107824. prePassRT: MultiRenderTarget;
  107825. private _multiRenderAttachments;
  107826. private _defaultAttachments;
  107827. private _postProcesses;
  107828. private readonly _clearColor;
  107829. /**
  107830. * Image processing post process for composition
  107831. */
  107832. imageProcessingPostProcess: ImageProcessingPostProcess;
  107833. /**
  107834. * Configuration for prepass effects
  107835. */
  107836. private _effectConfigurations;
  107837. private _mrtFormats;
  107838. private _mrtLayout;
  107839. private _enabled;
  107840. /**
  107841. * Indicates if the prepass is enabled
  107842. */
  107843. get enabled(): boolean;
  107844. /**
  107845. * How many samples are used for MSAA of the scene render target
  107846. */
  107847. get samples(): number;
  107848. set samples(n: number);
  107849. private _geometryBuffer;
  107850. private _useGeometryBufferFallback;
  107851. /**
  107852. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107853. */
  107854. get useGeometryBufferFallback(): boolean;
  107855. set useGeometryBufferFallback(value: boolean);
  107856. /**
  107857. * Set to true to disable gamma transform in PrePass.
  107858. * Can be useful in case you already proceed to gamma transform on a material level
  107859. * and your post processes don't need to be in linear color space.
  107860. */
  107861. disableGammaTransform: boolean;
  107862. /**
  107863. * Instanciates a prepass renderer
  107864. * @param scene The scene
  107865. */
  107866. constructor(scene: Scene);
  107867. private _initializeAttachments;
  107868. private _createCompositionEffect;
  107869. /**
  107870. * Indicates if rendering a prepass is supported
  107871. */
  107872. get isSupported(): boolean;
  107873. /**
  107874. * Sets the proper output textures to draw in the engine.
  107875. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  107876. * @param subMesh Submesh on which the effect is applied
  107877. */
  107878. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  107879. /**
  107880. * Restores attachments for single texture draw.
  107881. */
  107882. restoreAttachments(): void;
  107883. /**
  107884. * @hidden
  107885. */
  107886. _beforeCameraDraw(): void;
  107887. /**
  107888. * @hidden
  107889. */
  107890. _afterCameraDraw(): void;
  107891. private _checkRTSize;
  107892. private _bindFrameBuffer;
  107893. /**
  107894. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  107895. */
  107896. clear(): void;
  107897. private _setState;
  107898. private _updateGeometryBufferLayout;
  107899. /**
  107900. * Adds an effect configuration to the prepass.
  107901. * If an effect has already been added, it won't add it twice and will return the configuration
  107902. * already present.
  107903. * @param cfg the effect configuration
  107904. * @return the effect configuration now used by the prepass
  107905. */
  107906. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  107907. /**
  107908. * Returns the index of a texture in the multi render target texture array.
  107909. * @param type Texture type
  107910. * @return The index
  107911. */
  107912. getIndex(type: number): number;
  107913. private _enable;
  107914. private _disable;
  107915. private _resetLayout;
  107916. private _resetPostProcessChain;
  107917. private _bindPostProcessChain;
  107918. /**
  107919. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  107920. */
  107921. markAsDirty(): void;
  107922. /**
  107923. * Enables a texture on the MultiRenderTarget for prepass
  107924. */
  107925. private _enableTextures;
  107926. private _update;
  107927. private _markAllMaterialsAsPrePassDirty;
  107928. /**
  107929. * Disposes the prepass renderer.
  107930. */
  107931. dispose(): void;
  107932. }
  107933. }
  107934. declare module BABYLON {
  107935. /**
  107936. * Size options for a post process
  107937. */
  107938. export type PostProcessOptions = {
  107939. width: number;
  107940. height: number;
  107941. };
  107942. /**
  107943. * PostProcess can be used to apply a shader to a texture after it has been rendered
  107944. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107945. */
  107946. export class PostProcess {
  107947. /**
  107948. * Gets or sets the unique id of the post process
  107949. */
  107950. uniqueId: number;
  107951. /** Name of the PostProcess. */
  107952. name: string;
  107953. /**
  107954. * Width of the texture to apply the post process on
  107955. */
  107956. width: number;
  107957. /**
  107958. * Height of the texture to apply the post process on
  107959. */
  107960. height: number;
  107961. /**
  107962. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  107963. */
  107964. nodeMaterialSource: Nullable<NodeMaterial>;
  107965. /**
  107966. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  107967. * @hidden
  107968. */
  107969. _outputTexture: Nullable<InternalTexture>;
  107970. /**
  107971. * Sampling mode used by the shader
  107972. * See https://doc.babylonjs.com/classes/3.1/texture
  107973. */
  107974. renderTargetSamplingMode: number;
  107975. /**
  107976. * Clear color to use when screen clearing
  107977. */
  107978. clearColor: Color4;
  107979. /**
  107980. * If the buffer needs to be cleared before applying the post process. (default: true)
  107981. * Should be set to false if shader will overwrite all previous pixels.
  107982. */
  107983. autoClear: boolean;
  107984. /**
  107985. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  107986. */
  107987. alphaMode: number;
  107988. /**
  107989. * Sets the setAlphaBlendConstants of the babylon engine
  107990. */
  107991. alphaConstants: Color4;
  107992. /**
  107993. * Animations to be used for the post processing
  107994. */
  107995. animations: Animation[];
  107996. /**
  107997. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  107998. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  107999. */
  108000. enablePixelPerfectMode: boolean;
  108001. /**
  108002. * Force the postprocess to be applied without taking in account viewport
  108003. */
  108004. forceFullscreenViewport: boolean;
  108005. /**
  108006. * List of inspectable custom properties (used by the Inspector)
  108007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108008. */
  108009. inspectableCustomProperties: IInspectable[];
  108010. /**
  108011. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108012. *
  108013. * | Value | Type | Description |
  108014. * | ----- | ----------------------------------- | ----------- |
  108015. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108016. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108017. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108018. *
  108019. */
  108020. scaleMode: number;
  108021. /**
  108022. * Force textures to be a power of two (default: false)
  108023. */
  108024. alwaysForcePOT: boolean;
  108025. private _samples;
  108026. /**
  108027. * Number of sample textures (default: 1)
  108028. */
  108029. get samples(): number;
  108030. set samples(n: number);
  108031. /**
  108032. * Modify the scale of the post process to be the same as the viewport (default: false)
  108033. */
  108034. adaptScaleToCurrentViewport: boolean;
  108035. private _camera;
  108036. protected _scene: Scene;
  108037. private _engine;
  108038. private _options;
  108039. private _reusable;
  108040. private _textureType;
  108041. private _textureFormat;
  108042. /**
  108043. * Smart array of input and output textures for the post process.
  108044. * @hidden
  108045. */
  108046. _textures: SmartArray<InternalTexture>;
  108047. /**
  108048. * The index in _textures that corresponds to the output texture.
  108049. * @hidden
  108050. */
  108051. _currentRenderTextureInd: number;
  108052. private _effect;
  108053. private _samplers;
  108054. private _fragmentUrl;
  108055. private _vertexUrl;
  108056. private _parameters;
  108057. private _scaleRatio;
  108058. protected _indexParameters: any;
  108059. private _shareOutputWithPostProcess;
  108060. private _texelSize;
  108061. private _forcedOutputTexture;
  108062. /**
  108063. * Prepass configuration in case this post process needs a texture from prepass
  108064. * @hidden
  108065. */
  108066. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108067. /**
  108068. * Returns the fragment url or shader name used in the post process.
  108069. * @returns the fragment url or name in the shader store.
  108070. */
  108071. getEffectName(): string;
  108072. /**
  108073. * An event triggered when the postprocess is activated.
  108074. */
  108075. onActivateObservable: Observable<Camera>;
  108076. private _onActivateObserver;
  108077. /**
  108078. * A function that is added to the onActivateObservable
  108079. */
  108080. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108081. /**
  108082. * An event triggered when the postprocess changes its size.
  108083. */
  108084. onSizeChangedObservable: Observable<PostProcess>;
  108085. private _onSizeChangedObserver;
  108086. /**
  108087. * A function that is added to the onSizeChangedObservable
  108088. */
  108089. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108090. /**
  108091. * An event triggered when the postprocess applies its effect.
  108092. */
  108093. onApplyObservable: Observable<Effect>;
  108094. private _onApplyObserver;
  108095. /**
  108096. * A function that is added to the onApplyObservable
  108097. */
  108098. set onApply(callback: (effect: Effect) => void);
  108099. /**
  108100. * An event triggered before rendering the postprocess
  108101. */
  108102. onBeforeRenderObservable: Observable<Effect>;
  108103. private _onBeforeRenderObserver;
  108104. /**
  108105. * A function that is added to the onBeforeRenderObservable
  108106. */
  108107. set onBeforeRender(callback: (effect: Effect) => void);
  108108. /**
  108109. * An event triggered after rendering the postprocess
  108110. */
  108111. onAfterRenderObservable: Observable<Effect>;
  108112. private _onAfterRenderObserver;
  108113. /**
  108114. * A function that is added to the onAfterRenderObservable
  108115. */
  108116. set onAfterRender(callback: (efect: Effect) => void);
  108117. /**
  108118. * 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
  108119. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108120. */
  108121. get inputTexture(): InternalTexture;
  108122. set inputTexture(value: InternalTexture);
  108123. /**
  108124. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108125. * the only way to unset it is to use this function to restore its internal state
  108126. */
  108127. restoreDefaultInputTexture(): void;
  108128. /**
  108129. * Gets the camera which post process is applied to.
  108130. * @returns The camera the post process is applied to.
  108131. */
  108132. getCamera(): Camera;
  108133. /**
  108134. * Gets the texel size of the postprocess.
  108135. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108136. */
  108137. get texelSize(): Vector2;
  108138. /**
  108139. * Creates a new instance PostProcess
  108140. * @param name The name of the PostProcess.
  108141. * @param fragmentUrl The url of the fragment shader to be used.
  108142. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108143. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108144. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108145. * @param camera The camera to apply the render pass to.
  108146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108147. * @param engine The engine which the post process will be applied. (default: current engine)
  108148. * @param reusable If the post process can be reused on the same frame. (default: false)
  108149. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108150. * @param textureType Type of textures used when performing the post process. (default: 0)
  108151. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108152. * @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
  108153. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108154. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108155. */
  108156. 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);
  108157. /**
  108158. * Gets a string identifying the name of the class
  108159. * @returns "PostProcess" string
  108160. */
  108161. getClassName(): string;
  108162. /**
  108163. * Gets the engine which this post process belongs to.
  108164. * @returns The engine the post process was enabled with.
  108165. */
  108166. getEngine(): Engine;
  108167. /**
  108168. * The effect that is created when initializing the post process.
  108169. * @returns The created effect corresponding the the postprocess.
  108170. */
  108171. getEffect(): Effect;
  108172. /**
  108173. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108174. * @param postProcess The post process to share the output with.
  108175. * @returns This post process.
  108176. */
  108177. shareOutputWith(postProcess: PostProcess): PostProcess;
  108178. /**
  108179. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108180. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108181. */
  108182. useOwnOutput(): void;
  108183. /**
  108184. * Updates the effect with the current post process compile time values and recompiles the shader.
  108185. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108186. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108187. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108188. * @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
  108189. * @param onCompiled Called when the shader has been compiled.
  108190. * @param onError Called if there is an error when compiling a shader.
  108191. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108192. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108193. */
  108194. 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;
  108195. /**
  108196. * The post process is reusable if it can be used multiple times within one frame.
  108197. * @returns If the post process is reusable
  108198. */
  108199. isReusable(): boolean;
  108200. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108201. markTextureDirty(): void;
  108202. /**
  108203. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108204. * 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.
  108205. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108206. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108207. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108208. * @returns The target texture that was bound to be written to.
  108209. */
  108210. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108211. /**
  108212. * If the post process is supported.
  108213. */
  108214. get isSupported(): boolean;
  108215. /**
  108216. * The aspect ratio of the output texture.
  108217. */
  108218. get aspectRatio(): number;
  108219. /**
  108220. * Get a value indicating if the post-process is ready to be used
  108221. * @returns true if the post-process is ready (shader is compiled)
  108222. */
  108223. isReady(): boolean;
  108224. /**
  108225. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108226. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108227. */
  108228. apply(): Nullable<Effect>;
  108229. private _disposeTextures;
  108230. /**
  108231. * Sets the required values to the prepass renderer.
  108232. * @param prePassRenderer defines the prepass renderer to setup.
  108233. * @returns true if the pre pass is needed.
  108234. */
  108235. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108236. /**
  108237. * Disposes the post process.
  108238. * @param camera The camera to dispose the post process on.
  108239. */
  108240. dispose(camera?: Camera): void;
  108241. /**
  108242. * Serializes the particle system to a JSON object
  108243. * @returns the JSON object
  108244. */
  108245. serialize(): any;
  108246. /**
  108247. * Creates a material from parsed material data
  108248. * @param parsedPostProcess defines parsed post process data
  108249. * @param scene defines the hosting scene
  108250. * @param rootUrl defines the root URL to use to load textures
  108251. * @returns a new post process
  108252. */
  108253. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108254. }
  108255. }
  108256. declare module BABYLON {
  108257. /** @hidden */
  108258. export var kernelBlurVaryingDeclaration: {
  108259. name: string;
  108260. shader: string;
  108261. };
  108262. }
  108263. declare module BABYLON {
  108264. /** @hidden */
  108265. export var packingFunctions: {
  108266. name: string;
  108267. shader: string;
  108268. };
  108269. }
  108270. declare module BABYLON {
  108271. /** @hidden */
  108272. export var kernelBlurFragment: {
  108273. name: string;
  108274. shader: string;
  108275. };
  108276. }
  108277. declare module BABYLON {
  108278. /** @hidden */
  108279. export var kernelBlurFragment2: {
  108280. name: string;
  108281. shader: string;
  108282. };
  108283. }
  108284. declare module BABYLON {
  108285. /** @hidden */
  108286. export var kernelBlurPixelShader: {
  108287. name: string;
  108288. shader: string;
  108289. };
  108290. }
  108291. declare module BABYLON {
  108292. /** @hidden */
  108293. export var kernelBlurVertex: {
  108294. name: string;
  108295. shader: string;
  108296. };
  108297. }
  108298. declare module BABYLON {
  108299. /** @hidden */
  108300. export var kernelBlurVertexShader: {
  108301. name: string;
  108302. shader: string;
  108303. };
  108304. }
  108305. declare module BABYLON {
  108306. /**
  108307. * The Blur Post Process which blurs an image based on a kernel and direction.
  108308. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108309. */
  108310. export class BlurPostProcess extends PostProcess {
  108311. private blockCompilation;
  108312. protected _kernel: number;
  108313. protected _idealKernel: number;
  108314. protected _packedFloat: boolean;
  108315. private _staticDefines;
  108316. /** The direction in which to blur the image. */
  108317. direction: Vector2;
  108318. /**
  108319. * Sets the length in pixels of the blur sample region
  108320. */
  108321. set kernel(v: number);
  108322. /**
  108323. * Gets the length in pixels of the blur sample region
  108324. */
  108325. get kernel(): number;
  108326. /**
  108327. * Sets wether or not the blur needs to unpack/repack floats
  108328. */
  108329. set packedFloat(v: boolean);
  108330. /**
  108331. * Gets wether or not the blur is unpacking/repacking floats
  108332. */
  108333. get packedFloat(): boolean;
  108334. /**
  108335. * Gets a string identifying the name of the class
  108336. * @returns "BlurPostProcess" string
  108337. */
  108338. getClassName(): string;
  108339. /**
  108340. * Creates a new instance BlurPostProcess
  108341. * @param name The name of the effect.
  108342. * @param direction The direction in which to blur the image.
  108343. * @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.
  108344. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108345. * @param camera The camera to apply the render pass to.
  108346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108347. * @param engine The engine which the post process will be applied. (default: current engine)
  108348. * @param reusable If the post process can be reused on the same frame. (default: false)
  108349. * @param textureType Type of textures used when performing the post process. (default: 0)
  108350. * @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)
  108351. */
  108352. 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);
  108353. /**
  108354. * Updates the effect with the current post process compile time values and recompiles the shader.
  108355. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108356. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108357. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108358. * @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
  108359. * @param onCompiled Called when the shader has been compiled.
  108360. * @param onError Called if there is an error when compiling a shader.
  108361. */
  108362. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108363. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108364. /**
  108365. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108366. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108367. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108368. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108369. * The gaps between physical kernels are compensated for in the weighting of the samples
  108370. * @param idealKernel Ideal blur kernel.
  108371. * @return Nearest best kernel.
  108372. */
  108373. protected _nearestBestKernel(idealKernel: number): number;
  108374. /**
  108375. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108376. * @param x The point on the Gaussian distribution to sample.
  108377. * @return the value of the Gaussian function at x.
  108378. */
  108379. protected _gaussianWeight(x: number): number;
  108380. /**
  108381. * Generates a string that can be used as a floating point number in GLSL.
  108382. * @param x Value to print.
  108383. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108384. * @return GLSL float string.
  108385. */
  108386. protected _glslFloat(x: number, decimalFigures?: number): string;
  108387. /** @hidden */
  108388. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108389. }
  108390. }
  108391. declare module BABYLON {
  108392. /**
  108393. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108394. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108395. * You can then easily use it as a reflectionTexture on a flat surface.
  108396. * In case the surface is not a plane, please consider relying on reflection probes.
  108397. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108398. */
  108399. export class MirrorTexture extends RenderTargetTexture {
  108400. private scene;
  108401. /**
  108402. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108403. * 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.
  108404. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108405. */
  108406. mirrorPlane: Plane;
  108407. /**
  108408. * Define the blur ratio used to blur the reflection if needed.
  108409. */
  108410. set blurRatio(value: number);
  108411. get blurRatio(): number;
  108412. /**
  108413. * Define the adaptive blur kernel used to blur the reflection if needed.
  108414. * This will autocompute the closest best match for the `blurKernel`
  108415. */
  108416. set adaptiveBlurKernel(value: number);
  108417. /**
  108418. * Define the blur kernel used to blur the reflection if needed.
  108419. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108420. */
  108421. set blurKernel(value: number);
  108422. /**
  108423. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108425. */
  108426. set blurKernelX(value: number);
  108427. get blurKernelX(): number;
  108428. /**
  108429. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108430. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108431. */
  108432. set blurKernelY(value: number);
  108433. get blurKernelY(): number;
  108434. private _autoComputeBlurKernel;
  108435. protected _onRatioRescale(): void;
  108436. private _updateGammaSpace;
  108437. private _imageProcessingConfigChangeObserver;
  108438. private _transformMatrix;
  108439. private _mirrorMatrix;
  108440. private _savedViewMatrix;
  108441. private _blurX;
  108442. private _blurY;
  108443. private _adaptiveBlurKernel;
  108444. private _blurKernelX;
  108445. private _blurKernelY;
  108446. private _blurRatio;
  108447. /**
  108448. * Instantiates a Mirror Texture.
  108449. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108450. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108451. * You can then easily use it as a reflectionTexture on a flat surface.
  108452. * In case the surface is not a plane, please consider relying on reflection probes.
  108453. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108454. * @param name
  108455. * @param size
  108456. * @param scene
  108457. * @param generateMipMaps
  108458. * @param type
  108459. * @param samplingMode
  108460. * @param generateDepthBuffer
  108461. */
  108462. constructor(name: string, size: number | {
  108463. width: number;
  108464. height: number;
  108465. } | {
  108466. ratio: number;
  108467. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108468. private _preparePostProcesses;
  108469. /**
  108470. * Clone the mirror texture.
  108471. * @returns the cloned texture
  108472. */
  108473. clone(): MirrorTexture;
  108474. /**
  108475. * Serialize the texture to a JSON representation you could use in Parse later on
  108476. * @returns the serialized JSON representation
  108477. */
  108478. serialize(): any;
  108479. /**
  108480. * Dispose the texture and release its associated resources.
  108481. */
  108482. dispose(): void;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108488. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108489. */
  108490. export class Texture extends BaseTexture {
  108491. /**
  108492. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108493. */
  108494. static SerializeBuffers: boolean;
  108495. /**
  108496. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  108497. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  108498. */
  108499. static ForceSerializeBuffers: boolean;
  108500. /** @hidden */
  108501. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108502. /** @hidden */
  108503. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108504. /** @hidden */
  108505. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108506. /** nearest is mag = nearest and min = nearest and mip = linear */
  108507. static readonly NEAREST_SAMPLINGMODE: number;
  108508. /** nearest is mag = nearest and min = nearest and mip = linear */
  108509. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108511. static readonly BILINEAR_SAMPLINGMODE: number;
  108512. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108513. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108514. /** Trilinear is mag = linear and min = linear and mip = linear */
  108515. static readonly TRILINEAR_SAMPLINGMODE: number;
  108516. /** Trilinear is mag = linear and min = linear and mip = linear */
  108517. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108518. /** mag = nearest and min = nearest and mip = nearest */
  108519. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108520. /** mag = nearest and min = linear and mip = nearest */
  108521. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108522. /** mag = nearest and min = linear and mip = linear */
  108523. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108524. /** mag = nearest and min = linear and mip = none */
  108525. static readonly NEAREST_LINEAR: number;
  108526. /** mag = nearest and min = nearest and mip = none */
  108527. static readonly NEAREST_NEAREST: number;
  108528. /** mag = linear and min = nearest and mip = nearest */
  108529. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108530. /** mag = linear and min = nearest and mip = linear */
  108531. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108532. /** mag = linear and min = linear and mip = none */
  108533. static readonly LINEAR_LINEAR: number;
  108534. /** mag = linear and min = nearest and mip = none */
  108535. static readonly LINEAR_NEAREST: number;
  108536. /** Explicit coordinates mode */
  108537. static readonly EXPLICIT_MODE: number;
  108538. /** Spherical coordinates mode */
  108539. static readonly SPHERICAL_MODE: number;
  108540. /** Planar coordinates mode */
  108541. static readonly PLANAR_MODE: number;
  108542. /** Cubic coordinates mode */
  108543. static readonly CUBIC_MODE: number;
  108544. /** Projection coordinates mode */
  108545. static readonly PROJECTION_MODE: number;
  108546. /** Inverse Cubic coordinates mode */
  108547. static readonly SKYBOX_MODE: number;
  108548. /** Inverse Cubic coordinates mode */
  108549. static readonly INVCUBIC_MODE: number;
  108550. /** Equirectangular coordinates mode */
  108551. static readonly EQUIRECTANGULAR_MODE: number;
  108552. /** Equirectangular Fixed coordinates mode */
  108553. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108554. /** Equirectangular Fixed Mirrored coordinates mode */
  108555. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108556. /** Texture is not repeating outside of 0..1 UVs */
  108557. static readonly CLAMP_ADDRESSMODE: number;
  108558. /** Texture is repeating outside of 0..1 UVs */
  108559. static readonly WRAP_ADDRESSMODE: number;
  108560. /** Texture is repeating and mirrored */
  108561. static readonly MIRROR_ADDRESSMODE: number;
  108562. /**
  108563. * 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
  108564. */
  108565. static UseSerializedUrlIfAny: boolean;
  108566. /**
  108567. * Define the url of the texture.
  108568. */
  108569. url: Nullable<string>;
  108570. /**
  108571. * Define an offset on the texture to offset the u coordinates of the UVs
  108572. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108573. */
  108574. uOffset: number;
  108575. /**
  108576. * Define an offset on the texture to offset the v coordinates of the UVs
  108577. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108578. */
  108579. vOffset: number;
  108580. /**
  108581. * Define an offset on the texture to scale the u coordinates of the UVs
  108582. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108583. */
  108584. uScale: number;
  108585. /**
  108586. * Define an offset on the texture to scale the v coordinates of the UVs
  108587. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108588. */
  108589. vScale: number;
  108590. /**
  108591. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108592. * @see https://doc.babylonjs.com/how_to/more_materials
  108593. */
  108594. uAng: number;
  108595. /**
  108596. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108597. * @see https://doc.babylonjs.com/how_to/more_materials
  108598. */
  108599. vAng: number;
  108600. /**
  108601. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108602. * @see https://doc.babylonjs.com/how_to/more_materials
  108603. */
  108604. wAng: number;
  108605. /**
  108606. * Defines the center of rotation (U)
  108607. */
  108608. uRotationCenter: number;
  108609. /**
  108610. * Defines the center of rotation (V)
  108611. */
  108612. vRotationCenter: number;
  108613. /**
  108614. * Defines the center of rotation (W)
  108615. */
  108616. wRotationCenter: number;
  108617. /**
  108618. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108619. */
  108620. homogeneousRotationInUVTransform: boolean;
  108621. /**
  108622. * Are mip maps generated for this texture or not.
  108623. */
  108624. get noMipmap(): boolean;
  108625. /**
  108626. * List of inspectable custom properties (used by the Inspector)
  108627. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108628. */
  108629. inspectableCustomProperties: Nullable<IInspectable[]>;
  108630. private _noMipmap;
  108631. /** @hidden */
  108632. _invertY: boolean;
  108633. private _rowGenerationMatrix;
  108634. private _cachedTextureMatrix;
  108635. private _projectionModeMatrix;
  108636. private _t0;
  108637. private _t1;
  108638. private _t2;
  108639. private _cachedUOffset;
  108640. private _cachedVOffset;
  108641. private _cachedUScale;
  108642. private _cachedVScale;
  108643. private _cachedUAng;
  108644. private _cachedVAng;
  108645. private _cachedWAng;
  108646. private _cachedProjectionMatrixId;
  108647. private _cachedURotationCenter;
  108648. private _cachedVRotationCenter;
  108649. private _cachedWRotationCenter;
  108650. private _cachedHomogeneousRotationInUVTransform;
  108651. private _cachedCoordinatesMode;
  108652. /** @hidden */
  108653. protected _initialSamplingMode: number;
  108654. /** @hidden */
  108655. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108656. private _deleteBuffer;
  108657. protected _format: Nullable<number>;
  108658. private _delayedOnLoad;
  108659. private _delayedOnError;
  108660. private _mimeType?;
  108661. private _loaderOptions?;
  108662. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108663. get mimeType(): string | undefined;
  108664. /**
  108665. * Observable triggered once the texture has been loaded.
  108666. */
  108667. onLoadObservable: Observable<Texture>;
  108668. protected _isBlocking: boolean;
  108669. /**
  108670. * Is the texture preventing material to render while loading.
  108671. * If false, a default texture will be used instead of the loading one during the preparation step.
  108672. */
  108673. set isBlocking(value: boolean);
  108674. get isBlocking(): boolean;
  108675. /**
  108676. * Get the current sampling mode associated with the texture.
  108677. */
  108678. get samplingMode(): number;
  108679. /**
  108680. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108681. */
  108682. get invertY(): boolean;
  108683. /**
  108684. * Instantiates a new texture.
  108685. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108686. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108687. * @param url defines the url of the picture to load as a texture
  108688. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108689. * @param noMipmap defines if the texture will require mip maps or not
  108690. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108691. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108692. * @param onLoad defines a callback triggered when the texture has been loaded
  108693. * @param onError defines a callback triggered when an error occurred during the loading session
  108694. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108695. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108696. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108697. * @param mimeType defines an optional mime type information
  108698. * @param loaderOptions options to be passed to the loader
  108699. */
  108700. 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);
  108701. /**
  108702. * Update the url (and optional buffer) of this texture if url was null during construction.
  108703. * @param url the url of the texture
  108704. * @param buffer the buffer of the texture (defaults to null)
  108705. * @param onLoad callback called when the texture is loaded (defaults to null)
  108706. */
  108707. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108708. /**
  108709. * Finish the loading sequence of a texture flagged as delayed load.
  108710. * @hidden
  108711. */
  108712. delayLoad(): void;
  108713. private _prepareRowForTextureGeneration;
  108714. /**
  108715. * Checks if the texture has the same transform matrix than another texture
  108716. * @param texture texture to check against
  108717. * @returns true if the transforms are the same, else false
  108718. */
  108719. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108720. /**
  108721. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108722. * @returns the transform matrix of the texture.
  108723. */
  108724. getTextureMatrix(uBase?: number): Matrix;
  108725. /**
  108726. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108727. * @returns The reflection texture transform
  108728. */
  108729. getReflectionTextureMatrix(): Matrix;
  108730. /**
  108731. * Clones the texture.
  108732. * @returns the cloned texture
  108733. */
  108734. clone(): Texture;
  108735. /**
  108736. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108737. * @returns The JSON representation of the texture
  108738. */
  108739. serialize(): any;
  108740. /**
  108741. * Get the current class name of the texture useful for serialization or dynamic coding.
  108742. * @returns "Texture"
  108743. */
  108744. getClassName(): string;
  108745. /**
  108746. * Dispose the texture and release its associated resources.
  108747. */
  108748. dispose(): void;
  108749. /**
  108750. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108751. * @param parsedTexture Define the JSON representation of the texture
  108752. * @param scene Define the scene the parsed texture should be instantiated in
  108753. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108754. * @returns The parsed texture if successful
  108755. */
  108756. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108757. /**
  108758. * Creates a texture from its base 64 representation.
  108759. * @param data Define the base64 payload without the data: prefix
  108760. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108761. * @param scene Define the scene the texture should belong to
  108762. * @param noMipmap Forces the texture to not create mip map information if true
  108763. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108764. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108765. * @param onLoad define a callback triggered when the texture has been loaded
  108766. * @param onError define a callback triggered when an error occurred during the loading session
  108767. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108768. * @returns the created texture
  108769. */
  108770. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108771. /**
  108772. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108773. * @param data Define the base64 payload without the data: prefix
  108774. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108775. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108776. * @param scene Define the scene the texture should belong to
  108777. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108778. * @param noMipmap Forces the texture to not create mip map information if true
  108779. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108780. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108781. * @param onLoad define a callback triggered when the texture has been loaded
  108782. * @param onError define a callback triggered when an error occurred during the loading session
  108783. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108784. * @returns the created texture
  108785. */
  108786. 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;
  108787. }
  108788. }
  108789. declare module BABYLON {
  108790. /**
  108791. * ThinSprite Class used to represent a thin sprite
  108792. * This is the base class for sprites but can also directly be used with ThinEngine
  108793. * @see https://doc.babylonjs.com/babylon101/sprites
  108794. */
  108795. export class ThinSprite {
  108796. /** Gets or sets the cell index in the sprite sheet */
  108797. cellIndex: number;
  108798. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  108799. cellRef: string;
  108800. /** Gets or sets the current world position */
  108801. position: IVector3Like;
  108802. /** Gets or sets the main color */
  108803. color: IColor4Like;
  108804. /** Gets or sets the width */
  108805. width: number;
  108806. /** Gets or sets the height */
  108807. height: number;
  108808. /** Gets or sets rotation angle */
  108809. angle: number;
  108810. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  108811. invertU: boolean;
  108812. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  108813. invertV: boolean;
  108814. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  108815. isVisible: boolean;
  108816. /**
  108817. * Returns a boolean indicating if the animation is started
  108818. */
  108819. get animationStarted(): boolean;
  108820. /** Gets the initial key for the animation (setting it will restart the animation) */
  108821. get fromIndex(): number;
  108822. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  108823. get toIndex(): number;
  108824. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  108825. get loopAnimation(): boolean;
  108826. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  108827. get delay(): number;
  108828. /** @hidden */
  108829. _xOffset: number;
  108830. /** @hidden */
  108831. _yOffset: number;
  108832. /** @hidden */
  108833. _xSize: number;
  108834. /** @hidden */
  108835. _ySize: number;
  108836. private _animationStarted;
  108837. protected _loopAnimation: boolean;
  108838. protected _fromIndex: number;
  108839. protected _toIndex: number;
  108840. protected _delay: number;
  108841. private _direction;
  108842. private _time;
  108843. private _onBaseAnimationEnd;
  108844. /**
  108845. * Creates a new Thin Sprite
  108846. */
  108847. constructor();
  108848. /**
  108849. * Starts an animation
  108850. * @param from defines the initial key
  108851. * @param to defines the end key
  108852. * @param loop defines if the animation must loop
  108853. * @param delay defines the start delay (in ms)
  108854. * @param onAnimationEnd defines a callback for when the animation ends
  108855. */
  108856. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  108857. /** Stops current animation (if any) */
  108858. stopAnimation(): void;
  108859. /** @hidden */
  108860. _animate(deltaTime: number): void;
  108861. }
  108862. }
  108863. declare module BABYLON {
  108864. /** @hidden */
  108865. export var imageProcessingCompatibility: {
  108866. name: string;
  108867. shader: string;
  108868. };
  108869. }
  108870. declare module BABYLON {
  108871. /** @hidden */
  108872. export var spritesPixelShader: {
  108873. name: string;
  108874. shader: string;
  108875. };
  108876. }
  108877. declare module BABYLON {
  108878. /** @hidden */
  108879. export var spritesVertexShader: {
  108880. name: string;
  108881. shader: string;
  108882. };
  108883. }
  108884. declare module BABYLON {
  108885. /**
  108886. * Class used to render sprites.
  108887. *
  108888. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  108889. */
  108890. export class SpriteRenderer {
  108891. /**
  108892. * Defines the texture of the spritesheet
  108893. */
  108894. texture: Nullable<ThinTexture>;
  108895. /**
  108896. * Defines the default width of a cell in the spritesheet
  108897. */
  108898. cellWidth: number;
  108899. /**
  108900. * Defines the default height of a cell in the spritesheet
  108901. */
  108902. cellHeight: number;
  108903. /**
  108904. * Blend mode use to render the particle, it can be any of
  108905. * the static Constants.ALPHA_x properties provided in this class.
  108906. * Default value is Constants.ALPHA_COMBINE
  108907. */
  108908. blendMode: number;
  108909. /**
  108910. * Gets or sets a boolean indicating if alpha mode is automatically
  108911. * reset.
  108912. */
  108913. autoResetAlpha: boolean;
  108914. /**
  108915. * Disables writing to the depth buffer when rendering the sprites.
  108916. * It can be handy to disable depth writing when using textures without alpha channel
  108917. * and setting some specific blend modes.
  108918. */
  108919. disableDepthWrite: boolean;
  108920. /**
  108921. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  108922. */
  108923. fogEnabled: boolean;
  108924. /**
  108925. * Gets the capacity of the manager
  108926. */
  108927. get capacity(): number;
  108928. private readonly _engine;
  108929. private readonly _useVAO;
  108930. private readonly _useInstancing;
  108931. private readonly _scene;
  108932. private readonly _capacity;
  108933. private readonly _epsilon;
  108934. private _vertexBufferSize;
  108935. private _vertexData;
  108936. private _buffer;
  108937. private _vertexBuffers;
  108938. private _spriteBuffer;
  108939. private _indexBuffer;
  108940. private _effectBase;
  108941. private _effectFog;
  108942. private _vertexArrayObject;
  108943. /**
  108944. * Creates a new sprite Renderer
  108945. * @param engine defines the engine the renderer works with
  108946. * @param capacity defines the maximum allowed number of sprites
  108947. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  108948. * @param scene defines the hosting scene
  108949. */
  108950. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  108951. /**
  108952. * Render all child sprites
  108953. * @param sprites defines the list of sprites to render
  108954. * @param deltaTime defines the time since last frame
  108955. * @param viewMatrix defines the viewMatrix to use to render the sprites
  108956. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  108957. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  108958. */
  108959. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  108960. private _appendSpriteVertex;
  108961. /**
  108962. * Release associated resources
  108963. */
  108964. dispose(): void;
  108965. }
  108966. }
  108967. declare module BABYLON {
  108968. /**
  108969. * Defines the minimum interface to fullfil in order to be a sprite manager.
  108970. */
  108971. export interface ISpriteManager extends IDisposable {
  108972. /**
  108973. * Gets manager's name
  108974. */
  108975. name: string;
  108976. /**
  108977. * Restricts the camera to viewing objects with the same layerMask.
  108978. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  108979. */
  108980. layerMask: number;
  108981. /**
  108982. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108983. */
  108984. isPickable: boolean;
  108985. /**
  108986. * Gets the hosting scene
  108987. */
  108988. scene: Scene;
  108989. /**
  108990. * Specifies the rendering group id for this mesh (0 by default)
  108991. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108992. */
  108993. renderingGroupId: number;
  108994. /**
  108995. * Defines the list of sprites managed by the manager.
  108996. */
  108997. sprites: Array<Sprite>;
  108998. /**
  108999. * Gets or sets the spritesheet texture
  109000. */
  109001. texture: Texture;
  109002. /** Defines the default width of a cell in the spritesheet */
  109003. cellWidth: number;
  109004. /** Defines the default height of a cell in the spritesheet */
  109005. cellHeight: number;
  109006. /**
  109007. * Tests the intersection of a sprite with a specific ray.
  109008. * @param ray The ray we are sending to test the collision
  109009. * @param camera The camera space we are sending rays in
  109010. * @param predicate A predicate allowing excluding sprites from the list of object to test
  109011. * @param fastCheck defines if the first intersection will be used (and not the closest)
  109012. * @returns picking info or null.
  109013. */
  109014. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109015. /**
  109016. * Intersects the sprites with a ray
  109017. * @param ray defines the ray to intersect with
  109018. * @param camera defines the current active camera
  109019. * @param predicate defines a predicate used to select candidate sprites
  109020. * @returns null if no hit or a PickingInfo array
  109021. */
  109022. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109023. /**
  109024. * Renders the list of sprites on screen.
  109025. */
  109026. render(): void;
  109027. }
  109028. /**
  109029. * Class used to manage multiple sprites on the same spritesheet
  109030. * @see https://doc.babylonjs.com/babylon101/sprites
  109031. */
  109032. export class SpriteManager implements ISpriteManager {
  109033. /** defines the manager's name */
  109034. name: string;
  109035. /** Define the Url to load snippets */
  109036. static SnippetUrl: string;
  109037. /** Snippet ID if the manager was created from the snippet server */
  109038. snippetId: string;
  109039. /** Gets the list of sprites */
  109040. sprites: Sprite[];
  109041. /** Gets or sets the rendering group id (0 by default) */
  109042. renderingGroupId: number;
  109043. /** Gets or sets camera layer mask */
  109044. layerMask: number;
  109045. /** Gets or sets a boolean indicating if the sprites are pickable */
  109046. isPickable: boolean;
  109047. /**
  109048. * An event triggered when the manager is disposed.
  109049. */
  109050. onDisposeObservable: Observable<SpriteManager>;
  109051. /**
  109052. * Callback called when the manager is disposed
  109053. */
  109054. set onDispose(callback: () => void);
  109055. /**
  109056. * Gets or sets the unique id of the sprite
  109057. */
  109058. uniqueId: number;
  109059. /**
  109060. * Gets the array of sprites
  109061. */
  109062. get children(): Sprite[];
  109063. /**
  109064. * Gets the hosting scene
  109065. */
  109066. get scene(): Scene;
  109067. /**
  109068. * Gets the capacity of the manager
  109069. */
  109070. get capacity(): number;
  109071. /**
  109072. * Gets or sets the spritesheet texture
  109073. */
  109074. get texture(): Texture;
  109075. set texture(value: Texture);
  109076. /** Defines the default width of a cell in the spritesheet */
  109077. get cellWidth(): number;
  109078. set cellWidth(value: number);
  109079. /** Defines the default height of a cell in the spritesheet */
  109080. get cellHeight(): number;
  109081. set cellHeight(value: number);
  109082. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  109083. get fogEnabled(): boolean;
  109084. set fogEnabled(value: boolean);
  109085. /**
  109086. * Blend mode use to render the particle, it can be any of
  109087. * the static Constants.ALPHA_x properties provided in this class.
  109088. * Default value is Constants.ALPHA_COMBINE
  109089. */
  109090. get blendMode(): number;
  109091. set blendMode(blendMode: number);
  109092. /** Disables writing to the depth buffer when rendering the sprites.
  109093. * It can be handy to disable depth writing when using textures without alpha channel
  109094. * and setting some specific blend modes.
  109095. */
  109096. disableDepthWrite: boolean;
  109097. private _spriteRenderer;
  109098. /** Associative array from JSON sprite data file */
  109099. private _cellData;
  109100. /** Array of sprite names from JSON sprite data file */
  109101. private _spriteMap;
  109102. /** True when packed cell data from JSON file is ready*/
  109103. private _packedAndReady;
  109104. private _textureContent;
  109105. private _onDisposeObserver;
  109106. private _fromPacked;
  109107. private _scene;
  109108. /**
  109109. * Creates a new sprite manager
  109110. * @param name defines the manager's name
  109111. * @param imgUrl defines the sprite sheet url
  109112. * @param capacity defines the maximum allowed number of sprites
  109113. * @param cellSize defines the size of a sprite cell
  109114. * @param scene defines the hosting scene
  109115. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  109116. * @param samplingMode defines the smapling mode to use with spritesheet
  109117. * @param fromPacked set to false; do not alter
  109118. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  109119. */
  109120. constructor(
  109121. /** defines the manager's name */
  109122. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  109123. /**
  109124. * Returns the string "SpriteManager"
  109125. * @returns "SpriteManager"
  109126. */
  109127. getClassName(): string;
  109128. private _makePacked;
  109129. private _checkTextureAlpha;
  109130. /**
  109131. * Intersects the sprites with a ray
  109132. * @param ray defines the ray to intersect with
  109133. * @param camera defines the current active camera
  109134. * @param predicate defines a predicate used to select candidate sprites
  109135. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  109136. * @returns null if no hit or a PickingInfo
  109137. */
  109138. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109139. /**
  109140. * Intersects the sprites with a ray
  109141. * @param ray defines the ray to intersect with
  109142. * @param camera defines the current active camera
  109143. * @param predicate defines a predicate used to select candidate sprites
  109144. * @returns null if no hit or a PickingInfo array
  109145. */
  109146. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109147. /**
  109148. * Render all child sprites
  109149. */
  109150. render(): void;
  109151. private _customUpdate;
  109152. /**
  109153. * Release associated resources
  109154. */
  109155. dispose(): void;
  109156. /**
  109157. * Serializes the sprite manager to a JSON object
  109158. * @param serializeTexture defines if the texture must be serialized as well
  109159. * @returns the JSON object
  109160. */
  109161. serialize(serializeTexture?: boolean): any;
  109162. /**
  109163. * Parses a JSON object to create a new sprite manager.
  109164. * @param parsedManager The JSON object to parse
  109165. * @param scene The scene to create the sprite managerin
  109166. * @param rootUrl The root url to use to load external dependencies like texture
  109167. * @returns the new sprite manager
  109168. */
  109169. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  109170. /**
  109171. * Creates a sprite manager from a snippet saved in a remote file
  109172. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  109173. * @param url defines the url to load from
  109174. * @param scene defines the hosting scene
  109175. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109176. * @returns a promise that will resolve to the new sprite manager
  109177. */
  109178. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  109179. /**
  109180. * Creates a sprite manager from a snippet saved by the sprite editor
  109181. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  109182. * @param scene defines the hosting scene
  109183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109184. * @returns a promise that will resolve to the new sprite manager
  109185. */
  109186. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  109187. }
  109188. }
  109189. declare module BABYLON {
  109190. /**
  109191. * Class used to represent a sprite
  109192. * @see https://doc.babylonjs.com/babylon101/sprites
  109193. */
  109194. export class Sprite extends ThinSprite implements IAnimatable {
  109195. /** defines the name */
  109196. name: string;
  109197. /** Gets or sets the current world position */
  109198. position: Vector3;
  109199. /** Gets or sets the main color */
  109200. color: Color4;
  109201. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  109202. disposeWhenFinishedAnimating: boolean;
  109203. /** Gets the list of attached animations */
  109204. animations: Nullable<Array<Animation>>;
  109205. /** Gets or sets a boolean indicating if the sprite can be picked */
  109206. isPickable: boolean;
  109207. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  109208. useAlphaForPicking: boolean;
  109209. /**
  109210. * Gets or sets the associated action manager
  109211. */
  109212. actionManager: Nullable<ActionManager>;
  109213. /**
  109214. * An event triggered when the control has been disposed
  109215. */
  109216. onDisposeObservable: Observable<Sprite>;
  109217. private _manager;
  109218. private _onAnimationEnd;
  109219. /**
  109220. * Gets or sets the sprite size
  109221. */
  109222. get size(): number;
  109223. set size(value: number);
  109224. /**
  109225. * Gets or sets the unique id of the sprite
  109226. */
  109227. uniqueId: number;
  109228. /**
  109229. * Gets the manager of this sprite
  109230. */
  109231. get manager(): ISpriteManager;
  109232. /**
  109233. * Creates a new Sprite
  109234. * @param name defines the name
  109235. * @param manager defines the manager
  109236. */
  109237. constructor(
  109238. /** defines the name */
  109239. name: string, manager: ISpriteManager);
  109240. /**
  109241. * Returns the string "Sprite"
  109242. * @returns "Sprite"
  109243. */
  109244. getClassName(): string;
  109245. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  109246. get fromIndex(): number;
  109247. set fromIndex(value: number);
  109248. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  109249. get toIndex(): number;
  109250. set toIndex(value: number);
  109251. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  109252. get loopAnimation(): boolean;
  109253. set loopAnimation(value: boolean);
  109254. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  109255. get delay(): number;
  109256. set delay(value: number);
  109257. /**
  109258. * Starts an animation
  109259. * @param from defines the initial key
  109260. * @param to defines the end key
  109261. * @param loop defines if the animation must loop
  109262. * @param delay defines the start delay (in ms)
  109263. * @param onAnimationEnd defines a callback to call when animation ends
  109264. */
  109265. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  109266. private _endAnimation;
  109267. /** Release associated resources */
  109268. dispose(): void;
  109269. /**
  109270. * Serializes the sprite to a JSON object
  109271. * @returns the JSON object
  109272. */
  109273. serialize(): any;
  109274. /**
  109275. * Parses a JSON object to create a new sprite
  109276. * @param parsedSprite The JSON object to parse
  109277. * @param manager defines the hosting manager
  109278. * @returns the new sprite
  109279. */
  109280. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  109281. }
  109282. }
  109283. declare module BABYLON {
  109284. /**
  109285. * Information about the result of picking within a scene
  109286. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  109287. */
  109288. export class PickingInfo {
  109289. /** @hidden */
  109290. _pickingUnavailable: boolean;
  109291. /**
  109292. * If the pick collided with an object
  109293. */
  109294. hit: boolean;
  109295. /**
  109296. * Distance away where the pick collided
  109297. */
  109298. distance: number;
  109299. /**
  109300. * The location of pick collision
  109301. */
  109302. pickedPoint: Nullable<Vector3>;
  109303. /**
  109304. * The mesh corresponding the the pick collision
  109305. */
  109306. pickedMesh: Nullable<AbstractMesh>;
  109307. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  109308. bu: number;
  109309. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  109310. bv: number;
  109311. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  109312. faceId: number;
  109313. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  109314. subMeshFaceId: number;
  109315. /** Id of the the submesh that was picked */
  109316. subMeshId: number;
  109317. /** If a sprite was picked, this will be the sprite the pick collided with */
  109318. pickedSprite: Nullable<Sprite>;
  109319. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  109320. thinInstanceIndex: number;
  109321. /**
  109322. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  109323. */
  109324. originMesh: Nullable<AbstractMesh>;
  109325. /**
  109326. * The ray that was used to perform the picking.
  109327. */
  109328. ray: Nullable<Ray>;
  109329. /**
  109330. * Gets the normal correspodning to the face the pick collided with
  109331. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  109332. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  109333. * @returns The normal correspodning to the face the pick collided with
  109334. */
  109335. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  109336. /**
  109337. * Gets the texture coordinates of where the pick occured
  109338. * @returns the vector containing the coordnates of the texture
  109339. */
  109340. getTextureCoordinates(): Nullable<Vector2>;
  109341. }
  109342. }
  109343. declare module BABYLON {
  109344. /**
  109345. * Gather the list of pointer event types as constants.
  109346. */
  109347. export class PointerEventTypes {
  109348. /**
  109349. * 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.
  109350. */
  109351. static readonly POINTERDOWN: number;
  109352. /**
  109353. * The pointerup event is fired when a pointer is no longer active.
  109354. */
  109355. static readonly POINTERUP: number;
  109356. /**
  109357. * The pointermove event is fired when a pointer changes coordinates.
  109358. */
  109359. static readonly POINTERMOVE: number;
  109360. /**
  109361. * The pointerwheel event is fired when a mouse wheel has been rotated.
  109362. */
  109363. static readonly POINTERWHEEL: number;
  109364. /**
  109365. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  109366. */
  109367. static readonly POINTERPICK: number;
  109368. /**
  109369. * The pointertap event is fired when a the object has been touched and released without drag.
  109370. */
  109371. static readonly POINTERTAP: number;
  109372. /**
  109373. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  109374. */
  109375. static readonly POINTERDOUBLETAP: number;
  109376. }
  109377. /**
  109378. * Base class of pointer info types.
  109379. */
  109380. export class PointerInfoBase {
  109381. /**
  109382. * Defines the type of event (PointerEventTypes)
  109383. */
  109384. type: number;
  109385. /**
  109386. * Defines the related dom event
  109387. */
  109388. event: PointerEvent | MouseWheelEvent;
  109389. /**
  109390. * Instantiates the base class of pointers info.
  109391. * @param type Defines the type of event (PointerEventTypes)
  109392. * @param event Defines the related dom event
  109393. */
  109394. constructor(
  109395. /**
  109396. * Defines the type of event (PointerEventTypes)
  109397. */
  109398. type: number,
  109399. /**
  109400. * Defines the related dom event
  109401. */
  109402. event: PointerEvent | MouseWheelEvent);
  109403. }
  109404. /**
  109405. * This class is used to store pointer related info for the onPrePointerObservable event.
  109406. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  109407. */
  109408. export class PointerInfoPre extends PointerInfoBase {
  109409. /**
  109410. * Ray from a pointer if availible (eg. 6dof controller)
  109411. */
  109412. ray: Nullable<Ray>;
  109413. /**
  109414. * Defines the local position of the pointer on the canvas.
  109415. */
  109416. localPosition: Vector2;
  109417. /**
  109418. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  109419. */
  109420. skipOnPointerObservable: boolean;
  109421. /**
  109422. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  109423. * @param type Defines the type of event (PointerEventTypes)
  109424. * @param event Defines the related dom event
  109425. * @param localX Defines the local x coordinates of the pointer when the event occured
  109426. * @param localY Defines the local y coordinates of the pointer when the event occured
  109427. */
  109428. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  109429. }
  109430. /**
  109431. * This type contains all the data related to a pointer event in Babylon.js.
  109432. * 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.
  109433. */
  109434. export class PointerInfo extends PointerInfoBase {
  109435. /**
  109436. * Defines the picking info associated to the info (if any)\
  109437. */
  109438. pickInfo: Nullable<PickingInfo>;
  109439. /**
  109440. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  109441. * @param type Defines the type of event (PointerEventTypes)
  109442. * @param event Defines the related dom event
  109443. * @param pickInfo Defines the picking info associated to the info (if any)\
  109444. */
  109445. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  109446. /**
  109447. * Defines the picking info associated to the info (if any)\
  109448. */
  109449. pickInfo: Nullable<PickingInfo>);
  109450. }
  109451. /**
  109452. * Data relating to a touch event on the screen.
  109453. */
  109454. export interface PointerTouch {
  109455. /**
  109456. * X coordinate of touch.
  109457. */
  109458. x: number;
  109459. /**
  109460. * Y coordinate of touch.
  109461. */
  109462. y: number;
  109463. /**
  109464. * Id of touch. Unique for each finger.
  109465. */
  109466. pointerId: number;
  109467. /**
  109468. * Event type passed from DOM.
  109469. */
  109470. type: any;
  109471. }
  109472. }
  109473. declare module BABYLON {
  109474. /**
  109475. * Manage the mouse inputs to control the movement of a free camera.
  109476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109477. */
  109478. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  109479. /**
  109480. * Define if touch is enabled in the mouse input
  109481. */
  109482. touchEnabled: boolean;
  109483. /**
  109484. * Defines the camera the input is attached to.
  109485. */
  109486. camera: FreeCamera;
  109487. /**
  109488. * Defines the buttons associated with the input to handle camera move.
  109489. */
  109490. buttons: number[];
  109491. /**
  109492. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  109493. */
  109494. angularSensibility: number;
  109495. private _pointerInput;
  109496. private _onMouseMove;
  109497. private _observer;
  109498. private previousPosition;
  109499. /**
  109500. * Observable for when a pointer move event occurs containing the move offset
  109501. */
  109502. onPointerMovedObservable: Observable<{
  109503. offsetX: number;
  109504. offsetY: number;
  109505. }>;
  109506. /**
  109507. * @hidden
  109508. * If the camera should be rotated automatically based on pointer movement
  109509. */
  109510. _allowCameraRotation: boolean;
  109511. /**
  109512. * Manage the mouse inputs to control the movement of a free camera.
  109513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109514. * @param touchEnabled Defines if touch is enabled or not
  109515. */
  109516. constructor(
  109517. /**
  109518. * Define if touch is enabled in the mouse input
  109519. */
  109520. touchEnabled?: boolean);
  109521. /**
  109522. * Attach the input controls to a specific dom element to get the input from.
  109523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109524. */
  109525. attachControl(noPreventDefault?: boolean): void;
  109526. /**
  109527. * Called on JS contextmenu event.
  109528. * Override this method to provide functionality.
  109529. */
  109530. protected onContextMenu(evt: PointerEvent): void;
  109531. /**
  109532. * Detach the current controls from the specified dom element.
  109533. */
  109534. detachControl(): void;
  109535. /**
  109536. * Gets the class name of the current intput.
  109537. * @returns the class name
  109538. */
  109539. getClassName(): string;
  109540. /**
  109541. * Get the friendly name associated with the input class.
  109542. * @returns the input friendly name
  109543. */
  109544. getSimpleName(): string;
  109545. }
  109546. }
  109547. declare module BABYLON {
  109548. /**
  109549. * Base class for mouse wheel input..
  109550. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  109551. * for example usage.
  109552. */
  109553. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  109554. /**
  109555. * Defines the camera the input is attached to.
  109556. */
  109557. abstract camera: Camera;
  109558. /**
  109559. * How fast is the camera moves in relation to X axis mouseWheel events.
  109560. * Use negative value to reverse direction.
  109561. */
  109562. wheelPrecisionX: number;
  109563. /**
  109564. * How fast is the camera moves in relation to Y axis mouseWheel events.
  109565. * Use negative value to reverse direction.
  109566. */
  109567. wheelPrecisionY: number;
  109568. /**
  109569. * How fast is the camera moves in relation to Z axis mouseWheel events.
  109570. * Use negative value to reverse direction.
  109571. */
  109572. wheelPrecisionZ: number;
  109573. /**
  109574. * Observable for when a mouse wheel move event occurs.
  109575. */
  109576. onChangedObservable: Observable<{
  109577. wheelDeltaX: number;
  109578. wheelDeltaY: number;
  109579. wheelDeltaZ: number;
  109580. }>;
  109581. private _wheel;
  109582. private _observer;
  109583. /**
  109584. * Attach the input controls to a specific dom element to get the input from.
  109585. * @param noPreventDefault Defines whether event caught by the controls
  109586. * should call preventdefault().
  109587. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109588. */
  109589. attachControl(noPreventDefault?: boolean): void;
  109590. /**
  109591. * Detach the current controls from the specified dom element.
  109592. */
  109593. detachControl(): void;
  109594. /**
  109595. * Called for each rendered frame.
  109596. */
  109597. checkInputs(): void;
  109598. /**
  109599. * Gets the class name of the current intput.
  109600. * @returns the class name
  109601. */
  109602. getClassName(): string;
  109603. /**
  109604. * Get the friendly name associated with the input class.
  109605. * @returns the input friendly name
  109606. */
  109607. getSimpleName(): string;
  109608. /**
  109609. * Incremental value of multiple mouse wheel movements of the X axis.
  109610. * Should be zero-ed when read.
  109611. */
  109612. protected _wheelDeltaX: number;
  109613. /**
  109614. * Incremental value of multiple mouse wheel movements of the Y axis.
  109615. * Should be zero-ed when read.
  109616. */
  109617. protected _wheelDeltaY: number;
  109618. /**
  109619. * Incremental value of multiple mouse wheel movements of the Z axis.
  109620. * Should be zero-ed when read.
  109621. */
  109622. protected _wheelDeltaZ: number;
  109623. /**
  109624. * Firefox uses a different scheme to report scroll distances to other
  109625. * browsers. Rather than use complicated methods to calculate the exact
  109626. * multiple we need to apply, let's just cheat and use a constant.
  109627. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  109628. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  109629. */
  109630. private readonly _ffMultiplier;
  109631. /**
  109632. * Different event attributes for wheel data fall into a few set ranges.
  109633. * Some relevant but dated date here:
  109634. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  109635. */
  109636. private readonly _normalize;
  109637. }
  109638. }
  109639. declare module BABYLON {
  109640. /**
  109641. * Manage the mouse wheel inputs to control a free camera.
  109642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109643. */
  109644. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  109645. /**
  109646. * Defines the camera the input is attached to.
  109647. */
  109648. camera: FreeCamera;
  109649. /**
  109650. * Gets the class name of the current input.
  109651. * @returns the class name
  109652. */
  109653. getClassName(): string;
  109654. /**
  109655. * Set which movement axis (relative to camera's orientation) the mouse
  109656. * wheel's X axis controls.
  109657. * @param axis The axis to be moved. Set null to clear.
  109658. */
  109659. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  109660. /**
  109661. * Get the configured movement axis (relative to camera's orientation) the
  109662. * mouse wheel's X axis controls.
  109663. * @returns The configured axis or null if none.
  109664. */
  109665. get wheelXMoveRelative(): Nullable<Coordinate>;
  109666. /**
  109667. * Set which movement axis (relative to camera's orientation) the mouse
  109668. * wheel's Y axis controls.
  109669. * @param axis The axis to be moved. Set null to clear.
  109670. */
  109671. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  109672. /**
  109673. * Get the configured movement axis (relative to camera's orientation) the
  109674. * mouse wheel's Y axis controls.
  109675. * @returns The configured axis or null if none.
  109676. */
  109677. get wheelYMoveRelative(): Nullable<Coordinate>;
  109678. /**
  109679. * Set which movement axis (relative to camera's orientation) the mouse
  109680. * wheel's Z axis controls.
  109681. * @param axis The axis to be moved. Set null to clear.
  109682. */
  109683. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  109684. /**
  109685. * Get the configured movement axis (relative to camera's orientation) the
  109686. * mouse wheel's Z axis controls.
  109687. * @returns The configured axis or null if none.
  109688. */
  109689. get wheelZMoveRelative(): Nullable<Coordinate>;
  109690. /**
  109691. * Set which rotation axis (relative to camera's orientation) the mouse
  109692. * wheel's X axis controls.
  109693. * @param axis The axis to be moved. Set null to clear.
  109694. */
  109695. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  109696. /**
  109697. * Get the configured rotation axis (relative to camera's orientation) the
  109698. * mouse wheel's X axis controls.
  109699. * @returns The configured axis or null if none.
  109700. */
  109701. get wheelXRotateRelative(): Nullable<Coordinate>;
  109702. /**
  109703. * Set which rotation axis (relative to camera's orientation) the mouse
  109704. * wheel's Y axis controls.
  109705. * @param axis The axis to be moved. Set null to clear.
  109706. */
  109707. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  109708. /**
  109709. * Get the configured rotation axis (relative to camera's orientation) the
  109710. * mouse wheel's Y axis controls.
  109711. * @returns The configured axis or null if none.
  109712. */
  109713. get wheelYRotateRelative(): Nullable<Coordinate>;
  109714. /**
  109715. * Set which rotation axis (relative to camera's orientation) the mouse
  109716. * wheel's Z axis controls.
  109717. * @param axis The axis to be moved. Set null to clear.
  109718. */
  109719. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  109720. /**
  109721. * Get the configured rotation axis (relative to camera's orientation) the
  109722. * mouse wheel's Z axis controls.
  109723. * @returns The configured axis or null if none.
  109724. */
  109725. get wheelZRotateRelative(): Nullable<Coordinate>;
  109726. /**
  109727. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  109728. * controls.
  109729. * @param axis The axis to be moved. Set null to clear.
  109730. */
  109731. set wheelXMoveScene(axis: Nullable<Coordinate>);
  109732. /**
  109733. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109734. * X axis controls.
  109735. * @returns The configured axis or null if none.
  109736. */
  109737. get wheelXMoveScene(): Nullable<Coordinate>;
  109738. /**
  109739. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  109740. * controls.
  109741. * @param axis The axis to be moved. Set null to clear.
  109742. */
  109743. set wheelYMoveScene(axis: Nullable<Coordinate>);
  109744. /**
  109745. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109746. * Y axis controls.
  109747. * @returns The configured axis or null if none.
  109748. */
  109749. get wheelYMoveScene(): Nullable<Coordinate>;
  109750. /**
  109751. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  109752. * controls.
  109753. * @param axis The axis to be moved. Set null to clear.
  109754. */
  109755. set wheelZMoveScene(axis: Nullable<Coordinate>);
  109756. /**
  109757. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109758. * Z axis controls.
  109759. * @returns The configured axis or null if none.
  109760. */
  109761. get wheelZMoveScene(): Nullable<Coordinate>;
  109762. /**
  109763. * Called for each rendered frame.
  109764. */
  109765. checkInputs(): void;
  109766. private _moveRelative;
  109767. private _rotateRelative;
  109768. private _moveScene;
  109769. /**
  109770. * These are set to the desired default behaviour.
  109771. */
  109772. private _wheelXAction;
  109773. private _wheelXActionCoordinate;
  109774. private _wheelYAction;
  109775. private _wheelYActionCoordinate;
  109776. private _wheelZAction;
  109777. private _wheelZActionCoordinate;
  109778. /**
  109779. * Update the camera according to any configured properties for the 3
  109780. * mouse-wheel axis.
  109781. */
  109782. private _updateCamera;
  109783. /**
  109784. * Update one property of the camera.
  109785. */
  109786. private _updateCameraProperty;
  109787. }
  109788. }
  109789. declare module BABYLON {
  109790. /**
  109791. * Manage the touch inputs to control the movement of a free camera.
  109792. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109793. */
  109794. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  109795. /**
  109796. * Define if mouse events can be treated as touch events
  109797. */
  109798. allowMouse: boolean;
  109799. /**
  109800. * Defines the camera the input is attached to.
  109801. */
  109802. camera: FreeCamera;
  109803. /**
  109804. * Defines the touch sensibility for rotation.
  109805. * The higher the faster.
  109806. */
  109807. touchAngularSensibility: number;
  109808. /**
  109809. * Defines the touch sensibility for move.
  109810. * The higher the faster.
  109811. */
  109812. touchMoveSensibility: number;
  109813. private _offsetX;
  109814. private _offsetY;
  109815. private _pointerPressed;
  109816. private _pointerInput?;
  109817. private _observer;
  109818. private _onLostFocus;
  109819. /**
  109820. * Manage the touch inputs to control the movement of a free camera.
  109821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109822. * @param allowMouse Defines if mouse events can be treated as touch events
  109823. */
  109824. constructor(
  109825. /**
  109826. * Define if mouse events can be treated as touch events
  109827. */
  109828. allowMouse?: boolean);
  109829. /**
  109830. * Attach the input controls to a specific dom element to get the input from.
  109831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109832. */
  109833. attachControl(noPreventDefault?: boolean): void;
  109834. /**
  109835. * Detach the current controls from the specified dom element.
  109836. */
  109837. detachControl(): void;
  109838. /**
  109839. * Update the current camera state depending on the inputs that have been used this frame.
  109840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109841. */
  109842. checkInputs(): void;
  109843. /**
  109844. * Gets the class name of the current intput.
  109845. * @returns the class name
  109846. */
  109847. getClassName(): string;
  109848. /**
  109849. * Get the friendly name associated with the input class.
  109850. * @returns the input friendly name
  109851. */
  109852. getSimpleName(): string;
  109853. }
  109854. }
  109855. declare module BABYLON {
  109856. /**
  109857. * Default Inputs manager for the FreeCamera.
  109858. * It groups all the default supported inputs for ease of use.
  109859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109860. */
  109861. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  109862. /**
  109863. * @hidden
  109864. */
  109865. _mouseInput: Nullable<FreeCameraMouseInput>;
  109866. /**
  109867. * @hidden
  109868. */
  109869. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  109870. /**
  109871. * Instantiates a new FreeCameraInputsManager.
  109872. * @param camera Defines the camera the inputs belong to
  109873. */
  109874. constructor(camera: FreeCamera);
  109875. /**
  109876. * Add keyboard input support to the input manager.
  109877. * @returns the current input manager
  109878. */
  109879. addKeyboard(): FreeCameraInputsManager;
  109880. /**
  109881. * Add mouse input support to the input manager.
  109882. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  109883. * @returns the current input manager
  109884. */
  109885. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  109886. /**
  109887. * Removes the mouse input support from the manager
  109888. * @returns the current input manager
  109889. */
  109890. removeMouse(): FreeCameraInputsManager;
  109891. /**
  109892. * Add mouse wheel input support to the input manager.
  109893. * @returns the current input manager
  109894. */
  109895. addMouseWheel(): FreeCameraInputsManager;
  109896. /**
  109897. * Removes the mouse wheel input support from the manager
  109898. * @returns the current input manager
  109899. */
  109900. removeMouseWheel(): FreeCameraInputsManager;
  109901. /**
  109902. * Add touch input support to the input manager.
  109903. * @returns the current input manager
  109904. */
  109905. addTouch(): FreeCameraInputsManager;
  109906. /**
  109907. * Remove all attached input methods from a camera
  109908. */
  109909. clear(): void;
  109910. }
  109911. }
  109912. declare module BABYLON {
  109913. /**
  109914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  109916. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  109917. */
  109918. export class FreeCamera extends TargetCamera {
  109919. /**
  109920. * Define the collision ellipsoid of the camera.
  109921. * This is helpful to simulate a camera body like the player body around the camera
  109922. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109923. */
  109924. ellipsoid: Vector3;
  109925. /**
  109926. * Define an offset for the position of the ellipsoid around the camera.
  109927. * This can be helpful to determine the center of the body near the gravity center of the body
  109928. * instead of its head.
  109929. */
  109930. ellipsoidOffset: Vector3;
  109931. /**
  109932. * Enable or disable collisions of the camera with the rest of the scene objects.
  109933. */
  109934. checkCollisions: boolean;
  109935. /**
  109936. * Enable or disable gravity on the camera.
  109937. */
  109938. applyGravity: boolean;
  109939. /**
  109940. * Define the input manager associated to the camera.
  109941. */
  109942. inputs: FreeCameraInputsManager;
  109943. /**
  109944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  109945. * Higher values reduce sensitivity.
  109946. */
  109947. get angularSensibility(): number;
  109948. /**
  109949. * Sets the input sensibility for a mouse input. (default is 2000.0)
  109950. * Higher values reduce sensitivity.
  109951. */
  109952. set angularSensibility(value: number);
  109953. /**
  109954. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  109955. */
  109956. get keysUp(): number[];
  109957. set keysUp(value: number[]);
  109958. /**
  109959. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  109960. */
  109961. get keysUpward(): number[];
  109962. set keysUpward(value: number[]);
  109963. /**
  109964. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  109965. */
  109966. get keysDown(): number[];
  109967. set keysDown(value: number[]);
  109968. /**
  109969. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  109970. */
  109971. get keysDownward(): number[];
  109972. set keysDownward(value: number[]);
  109973. /**
  109974. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  109975. */
  109976. get keysLeft(): number[];
  109977. set keysLeft(value: number[]);
  109978. /**
  109979. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  109980. */
  109981. get keysRight(): number[];
  109982. set keysRight(value: number[]);
  109983. /**
  109984. * Event raised when the camera collide with a mesh in the scene.
  109985. */
  109986. onCollide: (collidedMesh: AbstractMesh) => void;
  109987. private _collider;
  109988. private _needMoveForGravity;
  109989. private _oldPosition;
  109990. private _diffPosition;
  109991. private _newPosition;
  109992. /** @hidden */
  109993. _localDirection: Vector3;
  109994. /** @hidden */
  109995. _transformedDirection: Vector3;
  109996. /**
  109997. * Instantiates a Free Camera.
  109998. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109999. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  110000. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  110001. * @param name Define the name of the camera in the scene
  110002. * @param position Define the start position of the camera in the scene
  110003. * @param scene Define the scene the camera belongs to
  110004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  110005. */
  110006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110007. /**
  110008. * Attach the input controls to a specific dom element to get the input from.
  110009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110010. */
  110011. attachControl(noPreventDefault?: boolean): void;
  110012. /**
  110013. * Attach the input controls to a specific dom element to get the input from.
  110014. * @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
  110015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110016. * BACK COMPAT SIGNATURE ONLY.
  110017. */
  110018. attachControl(ignored: any, noPreventDefault?: boolean): void;
  110019. /**
  110020. * Detach the current controls from the specified dom element.
  110021. */
  110022. detachControl(): void;
  110023. /**
  110024. * Detach the current controls from the specified dom element.
  110025. * @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
  110026. */
  110027. detachControl(ignored: any): void;
  110028. private _collisionMask;
  110029. /**
  110030. * Define a collision mask to limit the list of object the camera can collide with
  110031. */
  110032. get collisionMask(): number;
  110033. set collisionMask(mask: number);
  110034. /** @hidden */
  110035. _collideWithWorld(displacement: Vector3): void;
  110036. private _onCollisionPositionChange;
  110037. /** @hidden */
  110038. _checkInputs(): void;
  110039. /** @hidden */
  110040. _decideIfNeedsToMove(): boolean;
  110041. /** @hidden */
  110042. _updatePosition(): void;
  110043. /**
  110044. * Destroy the camera and release the current resources hold by it.
  110045. */
  110046. dispose(): void;
  110047. /**
  110048. * Gets the current object class name.
  110049. * @return the class name
  110050. */
  110051. getClassName(): string;
  110052. }
  110053. }
  110054. declare module BABYLON {
  110055. /**
  110056. * Represents a gamepad control stick position
  110057. */
  110058. export class StickValues {
  110059. /**
  110060. * The x component of the control stick
  110061. */
  110062. x: number;
  110063. /**
  110064. * The y component of the control stick
  110065. */
  110066. y: number;
  110067. /**
  110068. * Initializes the gamepad x and y control stick values
  110069. * @param x The x component of the gamepad control stick value
  110070. * @param y The y component of the gamepad control stick value
  110071. */
  110072. constructor(
  110073. /**
  110074. * The x component of the control stick
  110075. */
  110076. x: number,
  110077. /**
  110078. * The y component of the control stick
  110079. */
  110080. y: number);
  110081. }
  110082. /**
  110083. * An interface which manages callbacks for gamepad button changes
  110084. */
  110085. export interface GamepadButtonChanges {
  110086. /**
  110087. * Called when a gamepad has been changed
  110088. */
  110089. changed: boolean;
  110090. /**
  110091. * Called when a gamepad press event has been triggered
  110092. */
  110093. pressChanged: boolean;
  110094. /**
  110095. * Called when a touch event has been triggered
  110096. */
  110097. touchChanged: boolean;
  110098. /**
  110099. * Called when a value has changed
  110100. */
  110101. valueChanged: boolean;
  110102. }
  110103. /**
  110104. * Represents a gamepad
  110105. */
  110106. export class Gamepad {
  110107. /**
  110108. * The id of the gamepad
  110109. */
  110110. id: string;
  110111. /**
  110112. * The index of the gamepad
  110113. */
  110114. index: number;
  110115. /**
  110116. * The browser gamepad
  110117. */
  110118. browserGamepad: any;
  110119. /**
  110120. * Specifies what type of gamepad this represents
  110121. */
  110122. type: number;
  110123. private _leftStick;
  110124. private _rightStick;
  110125. /** @hidden */
  110126. _isConnected: boolean;
  110127. private _leftStickAxisX;
  110128. private _leftStickAxisY;
  110129. private _rightStickAxisX;
  110130. private _rightStickAxisY;
  110131. /**
  110132. * Triggered when the left control stick has been changed
  110133. */
  110134. private _onleftstickchanged;
  110135. /**
  110136. * Triggered when the right control stick has been changed
  110137. */
  110138. private _onrightstickchanged;
  110139. /**
  110140. * Represents a gamepad controller
  110141. */
  110142. static GAMEPAD: number;
  110143. /**
  110144. * Represents a generic controller
  110145. */
  110146. static GENERIC: number;
  110147. /**
  110148. * Represents an XBox controller
  110149. */
  110150. static XBOX: number;
  110151. /**
  110152. * Represents a pose-enabled controller
  110153. */
  110154. static POSE_ENABLED: number;
  110155. /**
  110156. * Represents an Dual Shock controller
  110157. */
  110158. static DUALSHOCK: number;
  110159. /**
  110160. * Specifies whether the left control stick should be Y-inverted
  110161. */
  110162. protected _invertLeftStickY: boolean;
  110163. /**
  110164. * Specifies if the gamepad has been connected
  110165. */
  110166. get isConnected(): boolean;
  110167. /**
  110168. * Initializes the gamepad
  110169. * @param id The id of the gamepad
  110170. * @param index The index of the gamepad
  110171. * @param browserGamepad The browser gamepad
  110172. * @param leftStickX The x component of the left joystick
  110173. * @param leftStickY The y component of the left joystick
  110174. * @param rightStickX The x component of the right joystick
  110175. * @param rightStickY The y component of the right joystick
  110176. */
  110177. constructor(
  110178. /**
  110179. * The id of the gamepad
  110180. */
  110181. id: string,
  110182. /**
  110183. * The index of the gamepad
  110184. */
  110185. index: number,
  110186. /**
  110187. * The browser gamepad
  110188. */
  110189. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  110190. /**
  110191. * Callback triggered when the left joystick has changed
  110192. * @param callback
  110193. */
  110194. onleftstickchanged(callback: (values: StickValues) => void): void;
  110195. /**
  110196. * Callback triggered when the right joystick has changed
  110197. * @param callback
  110198. */
  110199. onrightstickchanged(callback: (values: StickValues) => void): void;
  110200. /**
  110201. * Gets the left joystick
  110202. */
  110203. get leftStick(): StickValues;
  110204. /**
  110205. * Sets the left joystick values
  110206. */
  110207. set leftStick(newValues: StickValues);
  110208. /**
  110209. * Gets the right joystick
  110210. */
  110211. get rightStick(): StickValues;
  110212. /**
  110213. * Sets the right joystick value
  110214. */
  110215. set rightStick(newValues: StickValues);
  110216. /**
  110217. * Updates the gamepad joystick positions
  110218. */
  110219. update(): void;
  110220. /**
  110221. * Disposes the gamepad
  110222. */
  110223. dispose(): void;
  110224. }
  110225. /**
  110226. * Represents a generic gamepad
  110227. */
  110228. export class GenericPad extends Gamepad {
  110229. private _buttons;
  110230. private _onbuttondown;
  110231. private _onbuttonup;
  110232. /**
  110233. * Observable triggered when a button has been pressed
  110234. */
  110235. onButtonDownObservable: Observable<number>;
  110236. /**
  110237. * Observable triggered when a button has been released
  110238. */
  110239. onButtonUpObservable: Observable<number>;
  110240. /**
  110241. * Callback triggered when a button has been pressed
  110242. * @param callback Called when a button has been pressed
  110243. */
  110244. onbuttondown(callback: (buttonPressed: number) => void): void;
  110245. /**
  110246. * Callback triggered when a button has been released
  110247. * @param callback Called when a button has been released
  110248. */
  110249. onbuttonup(callback: (buttonReleased: number) => void): void;
  110250. /**
  110251. * Initializes the generic gamepad
  110252. * @param id The id of the generic gamepad
  110253. * @param index The index of the generic gamepad
  110254. * @param browserGamepad The browser gamepad
  110255. */
  110256. constructor(id: string, index: number, browserGamepad: any);
  110257. private _setButtonValue;
  110258. /**
  110259. * Updates the generic gamepad
  110260. */
  110261. update(): void;
  110262. /**
  110263. * Disposes the generic gamepad
  110264. */
  110265. dispose(): void;
  110266. }
  110267. }
  110268. declare module BABYLON {
  110269. /**
  110270. * Defines a runtime animation
  110271. */
  110272. export class RuntimeAnimation {
  110273. private _events;
  110274. /**
  110275. * The current frame of the runtime animation
  110276. */
  110277. private _currentFrame;
  110278. /**
  110279. * The animation used by the runtime animation
  110280. */
  110281. private _animation;
  110282. /**
  110283. * The target of the runtime animation
  110284. */
  110285. private _target;
  110286. /**
  110287. * The initiating animatable
  110288. */
  110289. private _host;
  110290. /**
  110291. * The original value of the runtime animation
  110292. */
  110293. private _originalValue;
  110294. /**
  110295. * The original blend value of the runtime animation
  110296. */
  110297. private _originalBlendValue;
  110298. /**
  110299. * The offsets cache of the runtime animation
  110300. */
  110301. private _offsetsCache;
  110302. /**
  110303. * The high limits cache of the runtime animation
  110304. */
  110305. private _highLimitsCache;
  110306. /**
  110307. * Specifies if the runtime animation has been stopped
  110308. */
  110309. private _stopped;
  110310. /**
  110311. * The blending factor of the runtime animation
  110312. */
  110313. private _blendingFactor;
  110314. /**
  110315. * The BabylonJS scene
  110316. */
  110317. private _scene;
  110318. /**
  110319. * The current value of the runtime animation
  110320. */
  110321. private _currentValue;
  110322. /** @hidden */
  110323. _animationState: _IAnimationState;
  110324. /**
  110325. * The active target of the runtime animation
  110326. */
  110327. private _activeTargets;
  110328. private _currentActiveTarget;
  110329. private _directTarget;
  110330. /**
  110331. * The target path of the runtime animation
  110332. */
  110333. private _targetPath;
  110334. /**
  110335. * The weight of the runtime animation
  110336. */
  110337. private _weight;
  110338. /**
  110339. * The ratio offset of the runtime animation
  110340. */
  110341. private _ratioOffset;
  110342. /**
  110343. * The previous delay of the runtime animation
  110344. */
  110345. private _previousDelay;
  110346. /**
  110347. * The previous ratio of the runtime animation
  110348. */
  110349. private _previousRatio;
  110350. private _enableBlending;
  110351. private _keys;
  110352. private _minFrame;
  110353. private _maxFrame;
  110354. private _minValue;
  110355. private _maxValue;
  110356. private _targetIsArray;
  110357. /**
  110358. * Gets the current frame of the runtime animation
  110359. */
  110360. get currentFrame(): number;
  110361. /**
  110362. * Gets the weight of the runtime animation
  110363. */
  110364. get weight(): number;
  110365. /**
  110366. * Gets the current value of the runtime animation
  110367. */
  110368. get currentValue(): any;
  110369. /**
  110370. * Gets the target path of the runtime animation
  110371. */
  110372. get targetPath(): string;
  110373. /**
  110374. * Gets the actual target of the runtime animation
  110375. */
  110376. get target(): any;
  110377. /**
  110378. * Gets the additive state of the runtime animation
  110379. */
  110380. get isAdditive(): boolean;
  110381. /** @hidden */
  110382. _onLoop: () => void;
  110383. /**
  110384. * Create a new RuntimeAnimation object
  110385. * @param target defines the target of the animation
  110386. * @param animation defines the source animation object
  110387. * @param scene defines the hosting scene
  110388. * @param host defines the initiating Animatable
  110389. */
  110390. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  110391. private _preparePath;
  110392. /**
  110393. * Gets the animation from the runtime animation
  110394. */
  110395. get animation(): Animation;
  110396. /**
  110397. * Resets the runtime animation to the beginning
  110398. * @param restoreOriginal defines whether to restore the target property to the original value
  110399. */
  110400. reset(restoreOriginal?: boolean): void;
  110401. /**
  110402. * Specifies if the runtime animation is stopped
  110403. * @returns Boolean specifying if the runtime animation is stopped
  110404. */
  110405. isStopped(): boolean;
  110406. /**
  110407. * Disposes of the runtime animation
  110408. */
  110409. dispose(): void;
  110410. /**
  110411. * Apply the interpolated value to the target
  110412. * @param currentValue defines the value computed by the animation
  110413. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  110414. */
  110415. setValue(currentValue: any, weight: number): void;
  110416. private _getOriginalValues;
  110417. private _setValue;
  110418. /**
  110419. * Gets the loop pmode of the runtime animation
  110420. * @returns Loop Mode
  110421. */
  110422. private _getCorrectLoopMode;
  110423. /**
  110424. * Move the current animation to a given frame
  110425. * @param frame defines the frame to move to
  110426. */
  110427. goToFrame(frame: number): void;
  110428. /**
  110429. * @hidden Internal use only
  110430. */
  110431. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  110432. /**
  110433. * Execute the current animation
  110434. * @param delay defines the delay to add to the current frame
  110435. * @param from defines the lower bound of the animation range
  110436. * @param to defines the upper bound of the animation range
  110437. * @param loop defines if the current animation must loop
  110438. * @param speedRatio defines the current speed ratio
  110439. * @param weight defines the weight of the animation (default is -1 so no weight)
  110440. * @param onLoop optional callback called when animation loops
  110441. * @returns a boolean indicating if the animation is running
  110442. */
  110443. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  110444. }
  110445. }
  110446. declare module BABYLON {
  110447. /**
  110448. * Class used to store an actual running animation
  110449. */
  110450. export class Animatable {
  110451. /** defines the target object */
  110452. target: any;
  110453. /** defines the starting frame number (default is 0) */
  110454. fromFrame: number;
  110455. /** defines the ending frame number (default is 100) */
  110456. toFrame: number;
  110457. /** defines if the animation must loop (default is false) */
  110458. loopAnimation: boolean;
  110459. /** defines a callback to call when animation ends if it is not looping */
  110460. onAnimationEnd?: (() => void) | null | undefined;
  110461. /** defines a callback to call when animation loops */
  110462. onAnimationLoop?: (() => void) | null | undefined;
  110463. /** defines whether the animation should be evaluated additively */
  110464. isAdditive: boolean;
  110465. private _localDelayOffset;
  110466. private _pausedDelay;
  110467. private _runtimeAnimations;
  110468. private _paused;
  110469. private _scene;
  110470. private _speedRatio;
  110471. private _weight;
  110472. private _syncRoot;
  110473. /**
  110474. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  110475. * This will only apply for non looping animation (default is true)
  110476. */
  110477. disposeOnEnd: boolean;
  110478. /**
  110479. * Gets a boolean indicating if the animation has started
  110480. */
  110481. animationStarted: boolean;
  110482. /**
  110483. * Observer raised when the animation ends
  110484. */
  110485. onAnimationEndObservable: Observable<Animatable>;
  110486. /**
  110487. * Observer raised when the animation loops
  110488. */
  110489. onAnimationLoopObservable: Observable<Animatable>;
  110490. /**
  110491. * Gets the root Animatable used to synchronize and normalize animations
  110492. */
  110493. get syncRoot(): Nullable<Animatable>;
  110494. /**
  110495. * Gets the current frame of the first RuntimeAnimation
  110496. * Used to synchronize Animatables
  110497. */
  110498. get masterFrame(): number;
  110499. /**
  110500. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  110501. */
  110502. get weight(): number;
  110503. set weight(value: number);
  110504. /**
  110505. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  110506. */
  110507. get speedRatio(): number;
  110508. set speedRatio(value: number);
  110509. /**
  110510. * Creates a new Animatable
  110511. * @param scene defines the hosting scene
  110512. * @param target defines the target object
  110513. * @param fromFrame defines the starting frame number (default is 0)
  110514. * @param toFrame defines the ending frame number (default is 100)
  110515. * @param loopAnimation defines if the animation must loop (default is false)
  110516. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  110517. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  110518. * @param animations defines a group of animation to add to the new Animatable
  110519. * @param onAnimationLoop defines a callback to call when animation loops
  110520. * @param isAdditive defines whether the animation should be evaluated additively
  110521. */
  110522. constructor(scene: Scene,
  110523. /** defines the target object */
  110524. target: any,
  110525. /** defines the starting frame number (default is 0) */
  110526. fromFrame?: number,
  110527. /** defines the ending frame number (default is 100) */
  110528. toFrame?: number,
  110529. /** defines if the animation must loop (default is false) */
  110530. loopAnimation?: boolean, speedRatio?: number,
  110531. /** defines a callback to call when animation ends if it is not looping */
  110532. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  110533. /** defines a callback to call when animation loops */
  110534. onAnimationLoop?: (() => void) | null | undefined,
  110535. /** defines whether the animation should be evaluated additively */
  110536. isAdditive?: boolean);
  110537. /**
  110538. * Synchronize and normalize current Animatable with a source Animatable
  110539. * This is useful when using animation weights and when animations are not of the same length
  110540. * @param root defines the root Animatable to synchronize with
  110541. * @returns the current Animatable
  110542. */
  110543. syncWith(root: Animatable): Animatable;
  110544. /**
  110545. * Gets the list of runtime animations
  110546. * @returns an array of RuntimeAnimation
  110547. */
  110548. getAnimations(): RuntimeAnimation[];
  110549. /**
  110550. * Adds more animations to the current animatable
  110551. * @param target defines the target of the animations
  110552. * @param animations defines the new animations to add
  110553. */
  110554. appendAnimations(target: any, animations: Animation[]): void;
  110555. /**
  110556. * Gets the source animation for a specific property
  110557. * @param property defines the propertyu to look for
  110558. * @returns null or the source animation for the given property
  110559. */
  110560. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  110561. /**
  110562. * Gets the runtime animation for a specific property
  110563. * @param property defines the propertyu to look for
  110564. * @returns null or the runtime animation for the given property
  110565. */
  110566. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  110567. /**
  110568. * Resets the animatable to its original state
  110569. */
  110570. reset(): void;
  110571. /**
  110572. * Allows the animatable to blend with current running animations
  110573. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110574. * @param blendingSpeed defines the blending speed to use
  110575. */
  110576. enableBlending(blendingSpeed: number): void;
  110577. /**
  110578. * Disable animation blending
  110579. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110580. */
  110581. disableBlending(): void;
  110582. /**
  110583. * Jump directly to a given frame
  110584. * @param frame defines the frame to jump to
  110585. */
  110586. goToFrame(frame: number): void;
  110587. /**
  110588. * Pause the animation
  110589. */
  110590. pause(): void;
  110591. /**
  110592. * Restart the animation
  110593. */
  110594. restart(): void;
  110595. private _raiseOnAnimationEnd;
  110596. /**
  110597. * Stop and delete the current animation
  110598. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  110599. * @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)
  110600. */
  110601. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  110602. /**
  110603. * Wait asynchronously for the animation to end
  110604. * @returns a promise which will be fullfilled when the animation ends
  110605. */
  110606. waitAsync(): Promise<Animatable>;
  110607. /** @hidden */
  110608. _animate(delay: number): boolean;
  110609. }
  110610. interface Scene {
  110611. /** @hidden */
  110612. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  110613. /** @hidden */
  110614. _processLateAnimationBindingsForMatrices(holder: {
  110615. totalWeight: number;
  110616. totalAdditiveWeight: number;
  110617. animations: RuntimeAnimation[];
  110618. additiveAnimations: RuntimeAnimation[];
  110619. originalValue: Matrix;
  110620. }): any;
  110621. /** @hidden */
  110622. _processLateAnimationBindingsForQuaternions(holder: {
  110623. totalWeight: number;
  110624. totalAdditiveWeight: number;
  110625. animations: RuntimeAnimation[];
  110626. additiveAnimations: RuntimeAnimation[];
  110627. originalValue: Quaternion;
  110628. }, refQuaternion: Quaternion): Quaternion;
  110629. /** @hidden */
  110630. _processLateAnimationBindings(): void;
  110631. /**
  110632. * Will start the animation sequence of a given target
  110633. * @param target defines the target
  110634. * @param from defines from which frame should animation start
  110635. * @param to defines until which frame should animation run.
  110636. * @param weight defines the weight to apply to the animation (1.0 by default)
  110637. * @param loop defines if the animation loops
  110638. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110639. * @param onAnimationEnd defines the function to be executed when the animation ends
  110640. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110641. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110642. * @param onAnimationLoop defines the callback to call when an animation loops
  110643. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110644. * @returns the animatable object created for this animation
  110645. */
  110646. 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;
  110647. /**
  110648. * Will start the animation sequence of a given target
  110649. * @param target defines the target
  110650. * @param from defines from which frame should animation start
  110651. * @param to defines until which frame should animation run.
  110652. * @param loop defines if the animation loops
  110653. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110654. * @param onAnimationEnd defines the function to be executed when the animation ends
  110655. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110656. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110657. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  110658. * @param onAnimationLoop defines the callback to call when an animation loops
  110659. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110660. * @returns the animatable object created for this animation
  110661. */
  110662. 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;
  110663. /**
  110664. * Will start the animation sequence of a given target and its hierarchy
  110665. * @param target defines the target
  110666. * @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.
  110667. * @param from defines from which frame should animation start
  110668. * @param to defines until which frame should animation run.
  110669. * @param loop defines if the animation loops
  110670. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110671. * @param onAnimationEnd defines the function to be executed when the animation ends
  110672. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110673. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110674. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110675. * @param onAnimationLoop defines the callback to call when an animation loops
  110676. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110677. * @returns the list of created animatables
  110678. */
  110679. 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[];
  110680. /**
  110681. * Begin a new animation on a given node
  110682. * @param target defines the target where the animation will take place
  110683. * @param animations defines the list of animations to start
  110684. * @param from defines the initial value
  110685. * @param to defines the final value
  110686. * @param loop defines if you want animation to loop (off by default)
  110687. * @param speedRatio defines the speed ratio to apply to all animations
  110688. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110689. * @param onAnimationLoop defines the callback to call when an animation loops
  110690. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110691. * @returns the list of created animatables
  110692. */
  110693. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110694. /**
  110695. * Begin a new animation on a given node and its hierarchy
  110696. * @param target defines the root node where the animation will take place
  110697. * @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.
  110698. * @param animations defines the list of animations to start
  110699. * @param from defines the initial value
  110700. * @param to defines the final value
  110701. * @param loop defines if you want animation to loop (off by default)
  110702. * @param speedRatio defines the speed ratio to apply to all animations
  110703. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110704. * @param onAnimationLoop defines the callback to call when an animation loops
  110705. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110706. * @returns the list of animatables created for all nodes
  110707. */
  110708. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  110709. /**
  110710. * Gets the animatable associated with a specific target
  110711. * @param target defines the target of the animatable
  110712. * @returns the required animatable if found
  110713. */
  110714. getAnimatableByTarget(target: any): Nullable<Animatable>;
  110715. /**
  110716. * Gets all animatables associated with a given target
  110717. * @param target defines the target to look animatables for
  110718. * @returns an array of Animatables
  110719. */
  110720. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  110721. /**
  110722. * Stops and removes all animations that have been applied to the scene
  110723. */
  110724. stopAllAnimations(): void;
  110725. /**
  110726. * Gets the current delta time used by animation engine
  110727. */
  110728. deltaTime: number;
  110729. }
  110730. interface Bone {
  110731. /**
  110732. * Copy an animation range from another bone
  110733. * @param source defines the source bone
  110734. * @param rangeName defines the range name to copy
  110735. * @param frameOffset defines the frame offset
  110736. * @param rescaleAsRequired defines if rescaling must be applied if required
  110737. * @param skelDimensionsRatio defines the scaling ratio
  110738. * @returns true if operation was successful
  110739. */
  110740. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  110741. }
  110742. }
  110743. declare module BABYLON {
  110744. /**
  110745. * Class used to override all child animations of a given target
  110746. */
  110747. export class AnimationPropertiesOverride {
  110748. /**
  110749. * Gets or sets a value indicating if animation blending must be used
  110750. */
  110751. enableBlending: boolean;
  110752. /**
  110753. * Gets or sets the blending speed to use when enableBlending is true
  110754. */
  110755. blendingSpeed: number;
  110756. /**
  110757. * Gets or sets the default loop mode to use
  110758. */
  110759. loopMode: number;
  110760. }
  110761. }
  110762. declare module BABYLON {
  110763. /**
  110764. * Class used to handle skinning animations
  110765. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110766. */
  110767. export class Skeleton implements IAnimatable {
  110768. /** defines the skeleton name */
  110769. name: string;
  110770. /** defines the skeleton Id */
  110771. id: string;
  110772. /**
  110773. * Defines the list of child bones
  110774. */
  110775. bones: Bone[];
  110776. /**
  110777. * Defines an estimate of the dimension of the skeleton at rest
  110778. */
  110779. dimensionsAtRest: Vector3;
  110780. /**
  110781. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  110782. */
  110783. needInitialSkinMatrix: boolean;
  110784. /**
  110785. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  110786. */
  110787. overrideMesh: Nullable<AbstractMesh>;
  110788. /**
  110789. * Gets the list of animations attached to this skeleton
  110790. */
  110791. animations: Array<Animation>;
  110792. private _scene;
  110793. private _isDirty;
  110794. private _transformMatrices;
  110795. private _transformMatrixTexture;
  110796. private _meshesWithPoseMatrix;
  110797. private _animatables;
  110798. private _identity;
  110799. private _synchronizedWithMesh;
  110800. private _ranges;
  110801. private _lastAbsoluteTransformsUpdateId;
  110802. private _canUseTextureForBones;
  110803. private _uniqueId;
  110804. /** @hidden */
  110805. _numBonesWithLinkedTransformNode: number;
  110806. /** @hidden */
  110807. _hasWaitingData: Nullable<boolean>;
  110808. /** @hidden */
  110809. _waitingOverrideMeshId: Nullable<string>;
  110810. /**
  110811. * Specifies if the skeleton should be serialized
  110812. */
  110813. doNotSerialize: boolean;
  110814. private _useTextureToStoreBoneMatrices;
  110815. /**
  110816. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  110817. * Please note that this option is not available if the hardware does not support it
  110818. */
  110819. get useTextureToStoreBoneMatrices(): boolean;
  110820. set useTextureToStoreBoneMatrices(value: boolean);
  110821. private _animationPropertiesOverride;
  110822. /**
  110823. * Gets or sets the animation properties override
  110824. */
  110825. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110826. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110827. /**
  110828. * List of inspectable custom properties (used by the Inspector)
  110829. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110830. */
  110831. inspectableCustomProperties: IInspectable[];
  110832. /**
  110833. * An observable triggered before computing the skeleton's matrices
  110834. */
  110835. onBeforeComputeObservable: Observable<Skeleton>;
  110836. /**
  110837. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  110838. */
  110839. get isUsingTextureForMatrices(): boolean;
  110840. /**
  110841. * Gets the unique ID of this skeleton
  110842. */
  110843. get uniqueId(): number;
  110844. /**
  110845. * Creates a new skeleton
  110846. * @param name defines the skeleton name
  110847. * @param id defines the skeleton Id
  110848. * @param scene defines the hosting scene
  110849. */
  110850. constructor(
  110851. /** defines the skeleton name */
  110852. name: string,
  110853. /** defines the skeleton Id */
  110854. id: string, scene: Scene);
  110855. /**
  110856. * Gets the current object class name.
  110857. * @return the class name
  110858. */
  110859. getClassName(): string;
  110860. /**
  110861. * Returns an array containing the root bones
  110862. * @returns an array containing the root bones
  110863. */
  110864. getChildren(): Array<Bone>;
  110865. /**
  110866. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  110867. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110868. * @returns a Float32Array containing matrices data
  110869. */
  110870. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  110871. /**
  110872. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  110873. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110874. * @returns a raw texture containing the data
  110875. */
  110876. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  110877. /**
  110878. * Gets the current hosting scene
  110879. * @returns a scene object
  110880. */
  110881. getScene(): Scene;
  110882. /**
  110883. * Gets a string representing the current skeleton data
  110884. * @param fullDetails defines a boolean indicating if we want a verbose version
  110885. * @returns a string representing the current skeleton data
  110886. */
  110887. toString(fullDetails?: boolean): string;
  110888. /**
  110889. * Get bone's index searching by name
  110890. * @param name defines bone's name to search for
  110891. * @return the indice of the bone. Returns -1 if not found
  110892. */
  110893. getBoneIndexByName(name: string): number;
  110894. /**
  110895. * Creater a new animation range
  110896. * @param name defines the name of the range
  110897. * @param from defines the start key
  110898. * @param to defines the end key
  110899. */
  110900. createAnimationRange(name: string, from: number, to: number): void;
  110901. /**
  110902. * Delete a specific animation range
  110903. * @param name defines the name of the range
  110904. * @param deleteFrames defines if frames must be removed as well
  110905. */
  110906. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110907. /**
  110908. * Gets a specific animation range
  110909. * @param name defines the name of the range to look for
  110910. * @returns the requested animation range or null if not found
  110911. */
  110912. getAnimationRange(name: string): Nullable<AnimationRange>;
  110913. /**
  110914. * Gets the list of all animation ranges defined on this skeleton
  110915. * @returns an array
  110916. */
  110917. getAnimationRanges(): Nullable<AnimationRange>[];
  110918. /**
  110919. * Copy animation range from a source skeleton.
  110920. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  110921. * @param source defines the source skeleton
  110922. * @param name defines the name of the range to copy
  110923. * @param rescaleAsRequired defines if rescaling must be applied if required
  110924. * @returns true if operation was successful
  110925. */
  110926. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  110927. /**
  110928. * Forces the skeleton to go to rest pose
  110929. */
  110930. returnToRest(): void;
  110931. private _getHighestAnimationFrame;
  110932. /**
  110933. * Begin a specific animation range
  110934. * @param name defines the name of the range to start
  110935. * @param loop defines if looping must be turned on (false by default)
  110936. * @param speedRatio defines the speed ratio to apply (1 by default)
  110937. * @param onAnimationEnd defines a callback which will be called when animation will end
  110938. * @returns a new animatable
  110939. */
  110940. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110941. /**
  110942. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  110943. * @param skeleton defines the Skeleton containing the animation range to convert
  110944. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110945. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  110946. * @returns the original skeleton
  110947. */
  110948. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  110949. /** @hidden */
  110950. _markAsDirty(): void;
  110951. /** @hidden */
  110952. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110953. /** @hidden */
  110954. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110955. private _computeTransformMatrices;
  110956. /**
  110957. * Build all resources required to render a skeleton
  110958. */
  110959. prepare(): void;
  110960. /**
  110961. * Gets the list of animatables currently running for this skeleton
  110962. * @returns an array of animatables
  110963. */
  110964. getAnimatables(): IAnimatable[];
  110965. /**
  110966. * Clone the current skeleton
  110967. * @param name defines the name of the new skeleton
  110968. * @param id defines the id of the new skeleton
  110969. * @returns the new skeleton
  110970. */
  110971. clone(name: string, id?: string): Skeleton;
  110972. /**
  110973. * Enable animation blending for this skeleton
  110974. * @param blendingSpeed defines the blending speed to apply
  110975. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110976. */
  110977. enableBlending(blendingSpeed?: number): void;
  110978. /**
  110979. * Releases all resources associated with the current skeleton
  110980. */
  110981. dispose(): void;
  110982. /**
  110983. * Serialize the skeleton in a JSON object
  110984. * @returns a JSON object
  110985. */
  110986. serialize(): any;
  110987. /**
  110988. * Creates a new skeleton from serialized data
  110989. * @param parsedSkeleton defines the serialized data
  110990. * @param scene defines the hosting scene
  110991. * @returns a new skeleton
  110992. */
  110993. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  110994. /**
  110995. * Compute all node absolute transforms
  110996. * @param forceUpdate defines if computation must be done even if cache is up to date
  110997. */
  110998. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  110999. /**
  111000. * Gets the root pose matrix
  111001. * @returns a matrix
  111002. */
  111003. getPoseMatrix(): Nullable<Matrix>;
  111004. /**
  111005. * Sorts bones per internal index
  111006. */
  111007. sortBones(): void;
  111008. private _sortBones;
  111009. /**
  111010. * Set the current local matrix as the restPose for all bones in the skeleton.
  111011. */
  111012. setCurrentPoseAsRest(): void;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. /**
  111017. * Class used to store bone information
  111018. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111019. */
  111020. export class Bone extends Node {
  111021. /**
  111022. * defines the bone name
  111023. */
  111024. name: string;
  111025. private static _tmpVecs;
  111026. private static _tmpQuat;
  111027. private static _tmpMats;
  111028. /**
  111029. * Gets the list of child bones
  111030. */
  111031. children: Bone[];
  111032. /** Gets the animations associated with this bone */
  111033. animations: Animation[];
  111034. /**
  111035. * Gets or sets bone length
  111036. */
  111037. length: number;
  111038. /**
  111039. * @hidden Internal only
  111040. * Set this value to map this bone to a different index in the transform matrices
  111041. * Set this value to -1 to exclude the bone from the transform matrices
  111042. */
  111043. _index: Nullable<number>;
  111044. private _skeleton;
  111045. private _localMatrix;
  111046. private _restPose;
  111047. private _bindPose;
  111048. private _baseMatrix;
  111049. private _absoluteTransform;
  111050. private _invertedAbsoluteTransform;
  111051. private _parent;
  111052. private _scalingDeterminant;
  111053. private _worldTransform;
  111054. private _localScaling;
  111055. private _localRotation;
  111056. private _localPosition;
  111057. private _needToDecompose;
  111058. private _needToCompose;
  111059. /** @hidden */
  111060. _linkedTransformNode: Nullable<TransformNode>;
  111061. /** @hidden */
  111062. _waitingTransformNodeId: Nullable<string>;
  111063. /** @hidden */
  111064. get _matrix(): Matrix;
  111065. /** @hidden */
  111066. set _matrix(value: Matrix);
  111067. /**
  111068. * Create a new bone
  111069. * @param name defines the bone name
  111070. * @param skeleton defines the parent skeleton
  111071. * @param parentBone defines the parent (can be null if the bone is the root)
  111072. * @param localMatrix defines the local matrix
  111073. * @param restPose defines the rest pose matrix
  111074. * @param baseMatrix defines the base matrix
  111075. * @param index defines index of the bone in the hiearchy
  111076. */
  111077. constructor(
  111078. /**
  111079. * defines the bone name
  111080. */
  111081. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  111082. /**
  111083. * Gets the current object class name.
  111084. * @return the class name
  111085. */
  111086. getClassName(): string;
  111087. /**
  111088. * Gets the parent skeleton
  111089. * @returns a skeleton
  111090. */
  111091. getSkeleton(): Skeleton;
  111092. /**
  111093. * Gets parent bone
  111094. * @returns a bone or null if the bone is the root of the bone hierarchy
  111095. */
  111096. getParent(): Nullable<Bone>;
  111097. /**
  111098. * Returns an array containing the root bones
  111099. * @returns an array containing the root bones
  111100. */
  111101. getChildren(): Array<Bone>;
  111102. /**
  111103. * Gets the node index in matrix array generated for rendering
  111104. * @returns the node index
  111105. */
  111106. getIndex(): number;
  111107. /**
  111108. * Sets the parent bone
  111109. * @param parent defines the parent (can be null if the bone is the root)
  111110. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  111111. */
  111112. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  111113. /**
  111114. * Gets the local matrix
  111115. * @returns a matrix
  111116. */
  111117. getLocalMatrix(): Matrix;
  111118. /**
  111119. * Gets the base matrix (initial matrix which remains unchanged)
  111120. * @returns a matrix
  111121. */
  111122. getBaseMatrix(): Matrix;
  111123. /**
  111124. * Gets the rest pose matrix
  111125. * @returns a matrix
  111126. */
  111127. getRestPose(): Matrix;
  111128. /**
  111129. * Sets the rest pose matrix
  111130. * @param matrix the local-space rest pose to set for this bone
  111131. */
  111132. setRestPose(matrix: Matrix): void;
  111133. /**
  111134. * Gets the bind pose matrix
  111135. * @returns the bind pose matrix
  111136. */
  111137. getBindPose(): Matrix;
  111138. /**
  111139. * Sets the bind pose matrix
  111140. * @param matrix the local-space bind pose to set for this bone
  111141. */
  111142. setBindPose(matrix: Matrix): void;
  111143. /**
  111144. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  111145. */
  111146. getWorldMatrix(): Matrix;
  111147. /**
  111148. * Sets the local matrix to rest pose matrix
  111149. */
  111150. returnToRest(): void;
  111151. /**
  111152. * Gets the inverse of the absolute transform matrix.
  111153. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  111154. * @returns a matrix
  111155. */
  111156. getInvertedAbsoluteTransform(): Matrix;
  111157. /**
  111158. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  111159. * @returns a matrix
  111160. */
  111161. getAbsoluteTransform(): Matrix;
  111162. /**
  111163. * Links with the given transform node.
  111164. * The local matrix of this bone is copied from the transform node every frame.
  111165. * @param transformNode defines the transform node to link to
  111166. */
  111167. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  111168. /**
  111169. * Gets the node used to drive the bone's transformation
  111170. * @returns a transform node or null
  111171. */
  111172. getTransformNode(): Nullable<TransformNode>;
  111173. /** Gets or sets current position (in local space) */
  111174. get position(): Vector3;
  111175. set position(newPosition: Vector3);
  111176. /** Gets or sets current rotation (in local space) */
  111177. get rotation(): Vector3;
  111178. set rotation(newRotation: Vector3);
  111179. /** Gets or sets current rotation quaternion (in local space) */
  111180. get rotationQuaternion(): Quaternion;
  111181. set rotationQuaternion(newRotation: Quaternion);
  111182. /** Gets or sets current scaling (in local space) */
  111183. get scaling(): Vector3;
  111184. set scaling(newScaling: Vector3);
  111185. /**
  111186. * Gets the animation properties override
  111187. */
  111188. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111189. private _decompose;
  111190. private _compose;
  111191. /**
  111192. * Update the base and local matrices
  111193. * @param matrix defines the new base or local matrix
  111194. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  111195. * @param updateLocalMatrix defines if the local matrix should be updated
  111196. */
  111197. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  111198. /** @hidden */
  111199. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  111200. /**
  111201. * Flag the bone as dirty (Forcing it to update everything)
  111202. */
  111203. markAsDirty(): void;
  111204. /** @hidden */
  111205. _markAsDirtyAndCompose(): void;
  111206. private _markAsDirtyAndDecompose;
  111207. /**
  111208. * Translate the bone in local or world space
  111209. * @param vec The amount to translate the bone
  111210. * @param space The space that the translation is in
  111211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111212. */
  111213. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111214. /**
  111215. * Set the postion of the bone in local or world space
  111216. * @param position The position to set the bone
  111217. * @param space The space that the position is in
  111218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111219. */
  111220. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111221. /**
  111222. * Set the absolute position of the bone (world space)
  111223. * @param position The position to set the bone
  111224. * @param mesh The mesh that this bone is attached to
  111225. */
  111226. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  111227. /**
  111228. * Scale the bone on the x, y and z axes (in local space)
  111229. * @param x The amount to scale the bone on the x axis
  111230. * @param y The amount to scale the bone on the y axis
  111231. * @param z The amount to scale the bone on the z axis
  111232. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  111233. */
  111234. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  111235. /**
  111236. * Set the bone scaling in local space
  111237. * @param scale defines the scaling vector
  111238. */
  111239. setScale(scale: Vector3): void;
  111240. /**
  111241. * Gets the current scaling in local space
  111242. * @returns the current scaling vector
  111243. */
  111244. getScale(): Vector3;
  111245. /**
  111246. * Gets the current scaling in local space and stores it in a target vector
  111247. * @param result defines the target vector
  111248. */
  111249. getScaleToRef(result: Vector3): void;
  111250. /**
  111251. * Set the yaw, pitch, and roll of the bone in local or world space
  111252. * @param yaw The rotation of the bone on the y axis
  111253. * @param pitch The rotation of the bone on the x axis
  111254. * @param roll The rotation of the bone on the z axis
  111255. * @param space The space that the axes of rotation are in
  111256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111257. */
  111258. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  111259. /**
  111260. * Add a rotation to the bone on an axis in local or world space
  111261. * @param axis The axis to rotate the bone on
  111262. * @param amount The amount to rotate the bone
  111263. * @param space The space that the axis is in
  111264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111265. */
  111266. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  111267. /**
  111268. * Set the rotation of the bone to a particular axis angle in local or world space
  111269. * @param axis The axis to rotate the bone on
  111270. * @param angle The angle that the bone should be rotated to
  111271. * @param space The space that the axis is in
  111272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111273. */
  111274. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  111275. /**
  111276. * Set the euler rotation of the bone in local or world space
  111277. * @param rotation The euler rotation that the bone should be set to
  111278. * @param space The space that the rotation is in
  111279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111280. */
  111281. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111282. /**
  111283. * Set the quaternion rotation of the bone in local or world space
  111284. * @param quat The quaternion rotation that the bone should be set to
  111285. * @param space The space that the rotation is in
  111286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111287. */
  111288. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  111289. /**
  111290. * Set the rotation matrix of the bone in local or world space
  111291. * @param rotMat The rotation matrix that the bone should be set to
  111292. * @param space The space that the rotation is in
  111293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111294. */
  111295. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  111296. private _rotateWithMatrix;
  111297. private _getNegativeRotationToRef;
  111298. /**
  111299. * Get the position of the bone in local or world space
  111300. * @param space The space that the returned position is in
  111301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111302. * @returns The position of the bone
  111303. */
  111304. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  111305. /**
  111306. * Copy the position of the bone to a vector3 in local or world space
  111307. * @param space The space that the returned position is in
  111308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111309. * @param result The vector3 to copy the position to
  111310. */
  111311. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  111312. /**
  111313. * Get the absolute position of the bone (world space)
  111314. * @param mesh The mesh that this bone is attached to
  111315. * @returns The absolute position of the bone
  111316. */
  111317. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  111318. /**
  111319. * Copy the absolute position of the bone (world space) to the result param
  111320. * @param mesh The mesh that this bone is attached to
  111321. * @param result The vector3 to copy the absolute position to
  111322. */
  111323. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  111324. /**
  111325. * Compute the absolute transforms of this bone and its children
  111326. */
  111327. computeAbsoluteTransforms(): void;
  111328. /**
  111329. * Get the world direction from an axis that is in the local space of the bone
  111330. * @param localAxis The local direction that is used to compute the world direction
  111331. * @param mesh The mesh that this bone is attached to
  111332. * @returns The world direction
  111333. */
  111334. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111335. /**
  111336. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  111337. * @param localAxis The local direction that is used to compute the world direction
  111338. * @param mesh The mesh that this bone is attached to
  111339. * @param result The vector3 that the world direction will be copied to
  111340. */
  111341. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111342. /**
  111343. * Get the euler rotation of the bone in local or world space
  111344. * @param space The space that the rotation should be in
  111345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111346. * @returns The euler rotation
  111347. */
  111348. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  111349. /**
  111350. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  111351. * @param space The space that the rotation should be in
  111352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111353. * @param result The vector3 that the rotation should be copied to
  111354. */
  111355. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111356. /**
  111357. * Get the quaternion rotation of the bone in either local or world space
  111358. * @param space The space that the rotation should be in
  111359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111360. * @returns The quaternion rotation
  111361. */
  111362. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  111363. /**
  111364. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  111365. * @param space The space that the rotation should be in
  111366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111367. * @param result The quaternion that the rotation should be copied to
  111368. */
  111369. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  111370. /**
  111371. * Get the rotation matrix of the bone in local or world space
  111372. * @param space The space that the rotation should be in
  111373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111374. * @returns The rotation matrix
  111375. */
  111376. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  111377. /**
  111378. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  111379. * @param space The space that the rotation should be in
  111380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111381. * @param result The quaternion that the rotation should be copied to
  111382. */
  111383. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  111384. /**
  111385. * Get the world position of a point that is in the local space of the bone
  111386. * @param position The local position
  111387. * @param mesh The mesh that this bone is attached to
  111388. * @returns The world position
  111389. */
  111390. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111391. /**
  111392. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  111393. * @param position The local position
  111394. * @param mesh The mesh that this bone is attached to
  111395. * @param result The vector3 that the world position should be copied to
  111396. */
  111397. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111398. /**
  111399. * Get the local position of a point that is in world space
  111400. * @param position The world position
  111401. * @param mesh The mesh that this bone is attached to
  111402. * @returns The local position
  111403. */
  111404. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111405. /**
  111406. * Get the local position of a point that is in world space and copy it to the result param
  111407. * @param position The world position
  111408. * @param mesh The mesh that this bone is attached to
  111409. * @param result The vector3 that the local position should be copied to
  111410. */
  111411. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111412. /**
  111413. * Set the current local matrix as the restPose for this bone.
  111414. */
  111415. setCurrentPoseAsRest(): void;
  111416. }
  111417. }
  111418. declare module BABYLON {
  111419. /**
  111420. * 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.
  111421. * @see https://doc.babylonjs.com/how_to/transformnode
  111422. */
  111423. export class TransformNode extends Node {
  111424. /**
  111425. * Object will not rotate to face the camera
  111426. */
  111427. static BILLBOARDMODE_NONE: number;
  111428. /**
  111429. * Object will rotate to face the camera but only on the x axis
  111430. */
  111431. static BILLBOARDMODE_X: number;
  111432. /**
  111433. * Object will rotate to face the camera but only on the y axis
  111434. */
  111435. static BILLBOARDMODE_Y: number;
  111436. /**
  111437. * Object will rotate to face the camera but only on the z axis
  111438. */
  111439. static BILLBOARDMODE_Z: number;
  111440. /**
  111441. * Object will rotate to face the camera
  111442. */
  111443. static BILLBOARDMODE_ALL: number;
  111444. /**
  111445. * Object will rotate to face the camera's position instead of orientation
  111446. */
  111447. static BILLBOARDMODE_USE_POSITION: number;
  111448. private static _TmpRotation;
  111449. private static _TmpScaling;
  111450. private static _TmpTranslation;
  111451. private _forward;
  111452. private _forwardInverted;
  111453. private _up;
  111454. private _right;
  111455. private _rightInverted;
  111456. private _position;
  111457. private _rotation;
  111458. private _rotationQuaternion;
  111459. protected _scaling: Vector3;
  111460. protected _isDirty: boolean;
  111461. private _transformToBoneReferal;
  111462. private _isAbsoluteSynced;
  111463. private _billboardMode;
  111464. /**
  111465. * Gets or sets the billboard mode. Default is 0.
  111466. *
  111467. * | Value | Type | Description |
  111468. * | --- | --- | --- |
  111469. * | 0 | BILLBOARDMODE_NONE | |
  111470. * | 1 | BILLBOARDMODE_X | |
  111471. * | 2 | BILLBOARDMODE_Y | |
  111472. * | 4 | BILLBOARDMODE_Z | |
  111473. * | 7 | BILLBOARDMODE_ALL | |
  111474. *
  111475. */
  111476. get billboardMode(): number;
  111477. set billboardMode(value: number);
  111478. private _preserveParentRotationForBillboard;
  111479. /**
  111480. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  111481. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  111482. */
  111483. get preserveParentRotationForBillboard(): boolean;
  111484. set preserveParentRotationForBillboard(value: boolean);
  111485. /**
  111486. * 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
  111487. */
  111488. scalingDeterminant: number;
  111489. private _infiniteDistance;
  111490. /**
  111491. * Gets or sets the distance of the object to max, often used by skybox
  111492. */
  111493. get infiniteDistance(): boolean;
  111494. set infiniteDistance(value: boolean);
  111495. /**
  111496. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  111497. * By default the system will update normals to compensate
  111498. */
  111499. ignoreNonUniformScaling: boolean;
  111500. /**
  111501. * 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
  111502. */
  111503. reIntegrateRotationIntoRotationQuaternion: boolean;
  111504. /** @hidden */
  111505. _poseMatrix: Nullable<Matrix>;
  111506. /** @hidden */
  111507. _localMatrix: Matrix;
  111508. private _usePivotMatrix;
  111509. private _absolutePosition;
  111510. private _absoluteScaling;
  111511. private _absoluteRotationQuaternion;
  111512. private _pivotMatrix;
  111513. private _pivotMatrixInverse;
  111514. /** @hidden */
  111515. _postMultiplyPivotMatrix: boolean;
  111516. protected _isWorldMatrixFrozen: boolean;
  111517. /** @hidden */
  111518. _indexInSceneTransformNodesArray: number;
  111519. /**
  111520. * An event triggered after the world matrix is updated
  111521. */
  111522. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  111523. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  111524. /**
  111525. * Gets a string identifying the name of the class
  111526. * @returns "TransformNode" string
  111527. */
  111528. getClassName(): string;
  111529. /**
  111530. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  111531. */
  111532. get position(): Vector3;
  111533. set position(newPosition: Vector3);
  111534. /**
  111535. * 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)).
  111536. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  111537. */
  111538. get rotation(): Vector3;
  111539. set rotation(newRotation: Vector3);
  111540. /**
  111541. * 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)).
  111542. */
  111543. get scaling(): Vector3;
  111544. set scaling(newScaling: Vector3);
  111545. /**
  111546. * 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).
  111547. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  111548. */
  111549. get rotationQuaternion(): Nullable<Quaternion>;
  111550. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  111551. /**
  111552. * The forward direction of that transform in world space.
  111553. */
  111554. get forward(): Vector3;
  111555. /**
  111556. * The up direction of that transform in world space.
  111557. */
  111558. get up(): Vector3;
  111559. /**
  111560. * The right direction of that transform in world space.
  111561. */
  111562. get right(): Vector3;
  111563. /**
  111564. * Copies the parameter passed Matrix into the mesh Pose matrix.
  111565. * @param matrix the matrix to copy the pose from
  111566. * @returns this TransformNode.
  111567. */
  111568. updatePoseMatrix(matrix: Matrix): TransformNode;
  111569. /**
  111570. * Returns the mesh Pose matrix.
  111571. * @returns the pose matrix
  111572. */
  111573. getPoseMatrix(): Matrix;
  111574. /** @hidden */
  111575. _isSynchronized(): boolean;
  111576. /** @hidden */
  111577. _initCache(): void;
  111578. /**
  111579. * Flag the transform node as dirty (Forcing it to update everything)
  111580. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  111581. * @returns this transform node
  111582. */
  111583. markAsDirty(property: string): TransformNode;
  111584. /**
  111585. * Returns the current mesh absolute position.
  111586. * Returns a Vector3.
  111587. */
  111588. get absolutePosition(): Vector3;
  111589. /**
  111590. * Returns the current mesh absolute scaling.
  111591. * Returns a Vector3.
  111592. */
  111593. get absoluteScaling(): Vector3;
  111594. /**
  111595. * Returns the current mesh absolute rotation.
  111596. * Returns a Quaternion.
  111597. */
  111598. get absoluteRotationQuaternion(): Quaternion;
  111599. /**
  111600. * Sets a new matrix to apply before all other transformation
  111601. * @param matrix defines the transform matrix
  111602. * @returns the current TransformNode
  111603. */
  111604. setPreTransformMatrix(matrix: Matrix): TransformNode;
  111605. /**
  111606. * Sets a new pivot matrix to the current node
  111607. * @param matrix defines the new pivot matrix to use
  111608. * @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
  111609. * @returns the current TransformNode
  111610. */
  111611. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  111612. /**
  111613. * Returns the mesh pivot matrix.
  111614. * Default : Identity.
  111615. * @returns the matrix
  111616. */
  111617. getPivotMatrix(): Matrix;
  111618. /**
  111619. * Instantiate (when possible) or clone that node with its hierarchy
  111620. * @param newParent defines the new parent to use for the instance (or clone)
  111621. * @param options defines options to configure how copy is done
  111622. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  111623. * @returns an instance (or a clone) of the current node with its hiearchy
  111624. */
  111625. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  111626. doNotInstantiate: boolean;
  111627. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  111628. /**
  111629. * Prevents the World matrix to be computed any longer
  111630. * @param newWorldMatrix defines an optional matrix to use as world matrix
  111631. * @returns the TransformNode.
  111632. */
  111633. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  111634. /**
  111635. * Allows back the World matrix computation.
  111636. * @returns the TransformNode.
  111637. */
  111638. unfreezeWorldMatrix(): this;
  111639. /**
  111640. * True if the World matrix has been frozen.
  111641. */
  111642. get isWorldMatrixFrozen(): boolean;
  111643. /**
  111644. * Retuns the mesh absolute position in the World.
  111645. * @returns a Vector3.
  111646. */
  111647. getAbsolutePosition(): Vector3;
  111648. /**
  111649. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  111650. * @param absolutePosition the absolute position to set
  111651. * @returns the TransformNode.
  111652. */
  111653. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  111654. /**
  111655. * Sets the mesh position in its local space.
  111656. * @param vector3 the position to set in localspace
  111657. * @returns the TransformNode.
  111658. */
  111659. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  111660. /**
  111661. * Returns the mesh position in the local space from the current World matrix values.
  111662. * @returns a new Vector3.
  111663. */
  111664. getPositionExpressedInLocalSpace(): Vector3;
  111665. /**
  111666. * Translates the mesh along the passed Vector3 in its local space.
  111667. * @param vector3 the distance to translate in localspace
  111668. * @returns the TransformNode.
  111669. */
  111670. locallyTranslate(vector3: Vector3): TransformNode;
  111671. private static _lookAtVectorCache;
  111672. /**
  111673. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  111674. * @param targetPoint the position (must be in same space as current mesh) to look at
  111675. * @param yawCor optional yaw (y-axis) correction in radians
  111676. * @param pitchCor optional pitch (x-axis) correction in radians
  111677. * @param rollCor optional roll (z-axis) correction in radians
  111678. * @param space the choosen space of the target
  111679. * @returns the TransformNode.
  111680. */
  111681. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  111682. /**
  111683. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111684. * This Vector3 is expressed in the World space.
  111685. * @param localAxis axis to rotate
  111686. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111687. */
  111688. getDirection(localAxis: Vector3): Vector3;
  111689. /**
  111690. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  111691. * localAxis is expressed in the mesh local space.
  111692. * result is computed in the Wordl space from the mesh World matrix.
  111693. * @param localAxis axis to rotate
  111694. * @param result the resulting transformnode
  111695. * @returns this TransformNode.
  111696. */
  111697. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  111698. /**
  111699. * Sets this transform node rotation to the given local axis.
  111700. * @param localAxis the axis in local space
  111701. * @param yawCor optional yaw (y-axis) correction in radians
  111702. * @param pitchCor optional pitch (x-axis) correction in radians
  111703. * @param rollCor optional roll (z-axis) correction in radians
  111704. * @returns this TransformNode
  111705. */
  111706. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  111707. /**
  111708. * Sets a new pivot point to the current node
  111709. * @param point defines the new pivot point to use
  111710. * @param space defines if the point is in world or local space (local by default)
  111711. * @returns the current TransformNode
  111712. */
  111713. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  111714. /**
  111715. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  111716. * @returns the pivot point
  111717. */
  111718. getPivotPoint(): Vector3;
  111719. /**
  111720. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  111721. * @param result the vector3 to store the result
  111722. * @returns this TransformNode.
  111723. */
  111724. getPivotPointToRef(result: Vector3): TransformNode;
  111725. /**
  111726. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  111727. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  111728. */
  111729. getAbsolutePivotPoint(): Vector3;
  111730. /**
  111731. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  111732. * @param result vector3 to store the result
  111733. * @returns this TransformNode.
  111734. */
  111735. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  111736. /**
  111737. * Defines the passed node as the parent of the current node.
  111738. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  111739. * @see https://doc.babylonjs.com/how_to/parenting
  111740. * @param node the node ot set as the parent
  111741. * @returns this TransformNode.
  111742. */
  111743. setParent(node: Nullable<Node>): TransformNode;
  111744. private _nonUniformScaling;
  111745. /**
  111746. * True if the scaling property of this object is non uniform eg. (1,2,1)
  111747. */
  111748. get nonUniformScaling(): boolean;
  111749. /** @hidden */
  111750. _updateNonUniformScalingState(value: boolean): boolean;
  111751. /**
  111752. * Attach the current TransformNode to another TransformNode associated with a bone
  111753. * @param bone Bone affecting the TransformNode
  111754. * @param affectedTransformNode TransformNode associated with the bone
  111755. * @returns this object
  111756. */
  111757. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  111758. /**
  111759. * Detach the transform node if its associated with a bone
  111760. * @returns this object
  111761. */
  111762. detachFromBone(): TransformNode;
  111763. private static _rotationAxisCache;
  111764. /**
  111765. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  111766. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111767. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111768. * The passed axis is also normalized.
  111769. * @param axis the axis to rotate around
  111770. * @param amount the amount to rotate in radians
  111771. * @param space Space to rotate in (Default: local)
  111772. * @returns the TransformNode.
  111773. */
  111774. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  111775. /**
  111776. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  111777. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111778. * The passed axis is also normalized. .
  111779. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  111780. * @param point the point to rotate around
  111781. * @param axis the axis to rotate around
  111782. * @param amount the amount to rotate in radians
  111783. * @returns the TransformNode
  111784. */
  111785. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  111786. /**
  111787. * Translates the mesh along the axis vector for the passed distance in the given space.
  111788. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111789. * @param axis the axis to translate in
  111790. * @param distance the distance to translate
  111791. * @param space Space to rotate in (Default: local)
  111792. * @returns the TransformNode.
  111793. */
  111794. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  111795. /**
  111796. * Adds a rotation step to the mesh current rotation.
  111797. * x, y, z are Euler angles expressed in radians.
  111798. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  111799. * This means this rotation is made in the mesh local space only.
  111800. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  111801. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  111802. * ```javascript
  111803. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  111804. * ```
  111805. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  111806. * 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.
  111807. * @param x Rotation to add
  111808. * @param y Rotation to add
  111809. * @param z Rotation to add
  111810. * @returns the TransformNode.
  111811. */
  111812. addRotation(x: number, y: number, z: number): TransformNode;
  111813. /**
  111814. * @hidden
  111815. */
  111816. protected _getEffectiveParent(): Nullable<Node>;
  111817. /**
  111818. * Computes the world matrix of the node
  111819. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111820. * @returns the world matrix
  111821. */
  111822. computeWorldMatrix(force?: boolean): Matrix;
  111823. /**
  111824. * Resets this nodeTransform's local matrix to Matrix.Identity().
  111825. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  111826. */
  111827. resetLocalMatrix(independentOfChildren?: boolean): void;
  111828. protected _afterComputeWorldMatrix(): void;
  111829. /**
  111830. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  111831. * @param func callback function to add
  111832. *
  111833. * @returns the TransformNode.
  111834. */
  111835. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111836. /**
  111837. * Removes a registered callback function.
  111838. * @param func callback function to remove
  111839. * @returns the TransformNode.
  111840. */
  111841. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111842. /**
  111843. * Gets the position of the current mesh in camera space
  111844. * @param camera defines the camera to use
  111845. * @returns a position
  111846. */
  111847. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  111848. /**
  111849. * Returns the distance from the mesh to the active camera
  111850. * @param camera defines the camera to use
  111851. * @returns the distance
  111852. */
  111853. getDistanceToCamera(camera?: Nullable<Camera>): number;
  111854. /**
  111855. * Clone the current transform node
  111856. * @param name Name of the new clone
  111857. * @param newParent New parent for the clone
  111858. * @param doNotCloneChildren Do not clone children hierarchy
  111859. * @returns the new transform node
  111860. */
  111861. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  111862. /**
  111863. * Serializes the objects information.
  111864. * @param currentSerializationObject defines the object to serialize in
  111865. * @returns the serialized object
  111866. */
  111867. serialize(currentSerializationObject?: any): any;
  111868. /**
  111869. * Returns a new TransformNode object parsed from the source provided.
  111870. * @param parsedTransformNode is the source.
  111871. * @param scene the scne the object belongs to
  111872. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  111873. * @returns a new TransformNode object parsed from the source provided.
  111874. */
  111875. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  111876. /**
  111877. * Get all child-transformNodes of this node
  111878. * @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
  111879. * @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
  111880. * @returns an array of TransformNode
  111881. */
  111882. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  111883. /**
  111884. * Releases resources associated with this transform node.
  111885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111887. */
  111888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111889. /**
  111890. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111891. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111892. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111893. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111894. * @returns the current mesh
  111895. */
  111896. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  111897. private _syncAbsoluteScalingAndRotation;
  111898. }
  111899. }
  111900. declare module BABYLON {
  111901. /**
  111902. * Defines the types of pose enabled controllers that are supported
  111903. */
  111904. export enum PoseEnabledControllerType {
  111905. /**
  111906. * HTC Vive
  111907. */
  111908. VIVE = 0,
  111909. /**
  111910. * Oculus Rift
  111911. */
  111912. OCULUS = 1,
  111913. /**
  111914. * Windows mixed reality
  111915. */
  111916. WINDOWS = 2,
  111917. /**
  111918. * Samsung gear VR
  111919. */
  111920. GEAR_VR = 3,
  111921. /**
  111922. * Google Daydream
  111923. */
  111924. DAYDREAM = 4,
  111925. /**
  111926. * Generic
  111927. */
  111928. GENERIC = 5
  111929. }
  111930. /**
  111931. * Defines the MutableGamepadButton interface for the state of a gamepad button
  111932. */
  111933. export interface MutableGamepadButton {
  111934. /**
  111935. * Value of the button/trigger
  111936. */
  111937. value: number;
  111938. /**
  111939. * If the button/trigger is currently touched
  111940. */
  111941. touched: boolean;
  111942. /**
  111943. * If the button/trigger is currently pressed
  111944. */
  111945. pressed: boolean;
  111946. }
  111947. /**
  111948. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  111949. * @hidden
  111950. */
  111951. export interface ExtendedGamepadButton extends GamepadButton {
  111952. /**
  111953. * If the button/trigger is currently pressed
  111954. */
  111955. readonly pressed: boolean;
  111956. /**
  111957. * If the button/trigger is currently touched
  111958. */
  111959. readonly touched: boolean;
  111960. /**
  111961. * Value of the button/trigger
  111962. */
  111963. readonly value: number;
  111964. }
  111965. /** @hidden */
  111966. export interface _GamePadFactory {
  111967. /**
  111968. * Returns whether or not the current gamepad can be created for this type of controller.
  111969. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111970. * @returns true if it can be created, otherwise false
  111971. */
  111972. canCreate(gamepadInfo: any): boolean;
  111973. /**
  111974. * Creates a new instance of the Gamepad.
  111975. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111976. * @returns the new gamepad instance
  111977. */
  111978. create(gamepadInfo: any): Gamepad;
  111979. }
  111980. /**
  111981. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111982. */
  111983. export class PoseEnabledControllerHelper {
  111984. /** @hidden */
  111985. static _ControllerFactories: _GamePadFactory[];
  111986. /** @hidden */
  111987. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  111988. /**
  111989. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111990. * @param vrGamepad the gamepad to initialized
  111991. * @returns a vr controller of the type the gamepad identified as
  111992. */
  111993. static InitiateController(vrGamepad: any): Gamepad;
  111994. }
  111995. /**
  111996. * Defines the PoseEnabledController object that contains state of a vr capable controller
  111997. */
  111998. export class PoseEnabledController extends Gamepad implements PoseControlled {
  111999. /**
  112000. * If the controller is used in a webXR session
  112001. */
  112002. isXR: boolean;
  112003. private _deviceRoomPosition;
  112004. private _deviceRoomRotationQuaternion;
  112005. /**
  112006. * The device position in babylon space
  112007. */
  112008. devicePosition: Vector3;
  112009. /**
  112010. * The device rotation in babylon space
  112011. */
  112012. deviceRotationQuaternion: Quaternion;
  112013. /**
  112014. * The scale factor of the device in babylon space
  112015. */
  112016. deviceScaleFactor: number;
  112017. /**
  112018. * (Likely devicePosition should be used instead) The device position in its room space
  112019. */
  112020. position: Vector3;
  112021. /**
  112022. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  112023. */
  112024. rotationQuaternion: Quaternion;
  112025. /**
  112026. * The type of controller (Eg. Windows mixed reality)
  112027. */
  112028. controllerType: PoseEnabledControllerType;
  112029. protected _calculatedPosition: Vector3;
  112030. private _calculatedRotation;
  112031. /**
  112032. * The raw pose from the device
  112033. */
  112034. rawPose: DevicePose;
  112035. private _trackPosition;
  112036. private _maxRotationDistFromHeadset;
  112037. private _draggedRoomRotation;
  112038. /**
  112039. * @hidden
  112040. */
  112041. _disableTrackPosition(fixedPosition: Vector3): void;
  112042. /**
  112043. * Internal, the mesh attached to the controller
  112044. * @hidden
  112045. */
  112046. _mesh: Nullable<AbstractMesh>;
  112047. private _poseControlledCamera;
  112048. private _leftHandSystemQuaternion;
  112049. /**
  112050. * Internal, matrix used to convert room space to babylon space
  112051. * @hidden
  112052. */
  112053. _deviceToWorld: Matrix;
  112054. /**
  112055. * Node to be used when casting a ray from the controller
  112056. * @hidden
  112057. */
  112058. _pointingPoseNode: Nullable<TransformNode>;
  112059. /**
  112060. * Name of the child mesh that can be used to cast a ray from the controller
  112061. */
  112062. static readonly POINTING_POSE: string;
  112063. /**
  112064. * Creates a new PoseEnabledController from a gamepad
  112065. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  112066. */
  112067. constructor(browserGamepad: any);
  112068. private _workingMatrix;
  112069. /**
  112070. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  112071. */
  112072. update(): void;
  112073. /**
  112074. * Updates only the pose device and mesh without doing any button event checking
  112075. */
  112076. protected _updatePoseAndMesh(): void;
  112077. /**
  112078. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  112079. * @param poseData raw pose fromthe device
  112080. */
  112081. updateFromDevice(poseData: DevicePose): void;
  112082. /**
  112083. * @hidden
  112084. */
  112085. _meshAttachedObservable: Observable<AbstractMesh>;
  112086. /**
  112087. * Attaches a mesh to the controller
  112088. * @param mesh the mesh to be attached
  112089. */
  112090. attachToMesh(mesh: AbstractMesh): void;
  112091. /**
  112092. * Attaches the controllers mesh to a camera
  112093. * @param camera the camera the mesh should be attached to
  112094. */
  112095. attachToPoseControlledCamera(camera: TargetCamera): void;
  112096. /**
  112097. * Disposes of the controller
  112098. */
  112099. dispose(): void;
  112100. /**
  112101. * The mesh that is attached to the controller
  112102. */
  112103. get mesh(): Nullable<AbstractMesh>;
  112104. /**
  112105. * Gets the ray of the controller in the direction the controller is pointing
  112106. * @param length the length the resulting ray should be
  112107. * @returns a ray in the direction the controller is pointing
  112108. */
  112109. getForwardRay(length?: number): Ray;
  112110. }
  112111. }
  112112. declare module BABYLON {
  112113. /**
  112114. * Defines the WebVRController object that represents controllers tracked in 3D space
  112115. */
  112116. export abstract class WebVRController extends PoseEnabledController {
  112117. /**
  112118. * Internal, the default controller model for the controller
  112119. */
  112120. protected _defaultModel: Nullable<AbstractMesh>;
  112121. /**
  112122. * Fired when the trigger state has changed
  112123. */
  112124. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112125. /**
  112126. * Fired when the main button state has changed
  112127. */
  112128. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112129. /**
  112130. * Fired when the secondary button state has changed
  112131. */
  112132. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112133. /**
  112134. * Fired when the pad state has changed
  112135. */
  112136. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  112137. /**
  112138. * Fired when controllers stick values have changed
  112139. */
  112140. onPadValuesChangedObservable: Observable<StickValues>;
  112141. /**
  112142. * Array of button availible on the controller
  112143. */
  112144. protected _buttons: Array<MutableGamepadButton>;
  112145. private _onButtonStateChange;
  112146. /**
  112147. * Fired when a controller button's state has changed
  112148. * @param callback the callback containing the button that was modified
  112149. */
  112150. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  112151. /**
  112152. * X and Y axis corresponding to the controllers joystick
  112153. */
  112154. pad: StickValues;
  112155. /**
  112156. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  112157. */
  112158. hand: string;
  112159. /**
  112160. * The default controller model for the controller
  112161. */
  112162. get defaultModel(): Nullable<AbstractMesh>;
  112163. /**
  112164. * Creates a new WebVRController from a gamepad
  112165. * @param vrGamepad the gamepad that the WebVRController should be created from
  112166. */
  112167. constructor(vrGamepad: any);
  112168. /**
  112169. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  112170. */
  112171. update(): void;
  112172. /**
  112173. * Function to be called when a button is modified
  112174. */
  112175. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112176. /**
  112177. * Loads a mesh and attaches it to the controller
  112178. * @param scene the scene the mesh should be added to
  112179. * @param meshLoaded callback for when the mesh has been loaded
  112180. */
  112181. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112182. private _setButtonValue;
  112183. private _changes;
  112184. private _checkChanges;
  112185. /**
  112186. * Disposes of th webVRCOntroller
  112187. */
  112188. dispose(): void;
  112189. }
  112190. }
  112191. declare module BABYLON {
  112192. /**
  112193. * The HemisphericLight simulates the ambient environment light,
  112194. * so the passed direction is the light reflection direction, not the incoming direction.
  112195. */
  112196. export class HemisphericLight extends Light {
  112197. /**
  112198. * The groundColor is the light in the opposite direction to the one specified during creation.
  112199. * 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.
  112200. */
  112201. groundColor: Color3;
  112202. /**
  112203. * The light reflection direction, not the incoming direction.
  112204. */
  112205. direction: Vector3;
  112206. /**
  112207. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  112208. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  112209. * The HemisphericLight can't cast shadows.
  112210. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112211. * @param name The friendly name of the light
  112212. * @param direction The direction of the light reflection
  112213. * @param scene The scene the light belongs to
  112214. */
  112215. constructor(name: string, direction: Vector3, scene: Scene);
  112216. protected _buildUniformLayout(): void;
  112217. /**
  112218. * Returns the string "HemisphericLight".
  112219. * @return The class name
  112220. */
  112221. getClassName(): string;
  112222. /**
  112223. * Sets the HemisphericLight direction towards the passed target (Vector3).
  112224. * Returns the updated direction.
  112225. * @param target The target the direction should point to
  112226. * @return The computed direction
  112227. */
  112228. setDirectionToTarget(target: Vector3): Vector3;
  112229. /**
  112230. * Returns the shadow generator associated to the light.
  112231. * @returns Always null for hemispheric lights because it does not support shadows.
  112232. */
  112233. getShadowGenerator(): Nullable<IShadowGenerator>;
  112234. /**
  112235. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  112236. * @param effect The effect to update
  112237. * @param lightIndex The index of the light in the effect to update
  112238. * @returns The hemispheric light
  112239. */
  112240. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  112241. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112242. /**
  112243. * Computes the world matrix of the node
  112244. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112245. * @param useWasUpdatedFlag defines a reserved property
  112246. * @returns the world matrix
  112247. */
  112248. computeWorldMatrix(): Matrix;
  112249. /**
  112250. * Returns the integer 3.
  112251. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112252. */
  112253. getTypeID(): number;
  112254. /**
  112255. * Prepares the list of defines specific to the light type.
  112256. * @param defines the list of defines
  112257. * @param lightIndex defines the index of the light for the effect
  112258. */
  112259. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /** @hidden */
  112264. export var vrMultiviewToSingleviewPixelShader: {
  112265. name: string;
  112266. shader: string;
  112267. };
  112268. }
  112269. declare module BABYLON {
  112270. /**
  112271. * Renders to multiple views with a single draw call
  112272. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  112273. */
  112274. export class MultiviewRenderTarget extends RenderTargetTexture {
  112275. /**
  112276. * Creates a multiview render target
  112277. * @param scene scene used with the render target
  112278. * @param size the size of the render target (used for each view)
  112279. */
  112280. constructor(scene: Scene, size?: number | {
  112281. width: number;
  112282. height: number;
  112283. } | {
  112284. ratio: number;
  112285. });
  112286. /**
  112287. * @hidden
  112288. * @param faceIndex the face index, if its a cube texture
  112289. */
  112290. _bindFrameBuffer(faceIndex?: number): void;
  112291. /**
  112292. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  112293. * @returns the view count
  112294. */
  112295. getViewCount(): number;
  112296. }
  112297. }
  112298. declare module BABYLON {
  112299. interface Engine {
  112300. /**
  112301. * Creates a new multiview render target
  112302. * @param width defines the width of the texture
  112303. * @param height defines the height of the texture
  112304. * @returns the created multiview texture
  112305. */
  112306. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  112307. /**
  112308. * Binds a multiview framebuffer to be drawn to
  112309. * @param multiviewTexture texture to bind
  112310. */
  112311. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  112312. }
  112313. interface Camera {
  112314. /**
  112315. * @hidden
  112316. * 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)
  112317. */
  112318. _useMultiviewToSingleView: boolean;
  112319. /**
  112320. * @hidden
  112321. * 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)
  112322. */
  112323. _multiviewTexture: Nullable<RenderTargetTexture>;
  112324. /**
  112325. * @hidden
  112326. * ensures the multiview texture of the camera exists and has the specified width/height
  112327. * @param width height to set on the multiview texture
  112328. * @param height width to set on the multiview texture
  112329. */
  112330. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  112331. }
  112332. interface Scene {
  112333. /** @hidden */
  112334. _transformMatrixR: Matrix;
  112335. /** @hidden */
  112336. _multiviewSceneUbo: Nullable<UniformBuffer>;
  112337. /** @hidden */
  112338. _createMultiviewUbo(): void;
  112339. /** @hidden */
  112340. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  112341. /** @hidden */
  112342. _renderMultiviewToSingleView(camera: Camera): void;
  112343. }
  112344. }
  112345. declare module BABYLON {
  112346. /**
  112347. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  112348. * This will not be used for webXR as it supports displaying texture arrays directly
  112349. */
  112350. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  112351. /**
  112352. * Gets a string identifying the name of the class
  112353. * @returns "VRMultiviewToSingleviewPostProcess" string
  112354. */
  112355. getClassName(): string;
  112356. /**
  112357. * Initializes a VRMultiviewToSingleview
  112358. * @param name name of the post process
  112359. * @param camera camera to be applied to
  112360. * @param scaleFactor scaling factor to the size of the output texture
  112361. */
  112362. constructor(name: string, camera: Camera, scaleFactor: number);
  112363. }
  112364. }
  112365. declare module BABYLON {
  112366. /**
  112367. * Interface used to define additional presentation attributes
  112368. */
  112369. export interface IVRPresentationAttributes {
  112370. /**
  112371. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  112372. */
  112373. highRefreshRate: boolean;
  112374. /**
  112375. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  112376. */
  112377. foveationLevel: number;
  112378. }
  112379. interface Engine {
  112380. /** @hidden */
  112381. _vrDisplay: any;
  112382. /** @hidden */
  112383. _vrSupported: boolean;
  112384. /** @hidden */
  112385. _oldSize: Size;
  112386. /** @hidden */
  112387. _oldHardwareScaleFactor: number;
  112388. /** @hidden */
  112389. _vrExclusivePointerMode: boolean;
  112390. /** @hidden */
  112391. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  112392. /** @hidden */
  112393. _onVRDisplayPointerRestricted: () => void;
  112394. /** @hidden */
  112395. _onVRDisplayPointerUnrestricted: () => void;
  112396. /** @hidden */
  112397. _onVrDisplayConnect: Nullable<(display: any) => void>;
  112398. /** @hidden */
  112399. _onVrDisplayDisconnect: Nullable<() => void>;
  112400. /** @hidden */
  112401. _onVrDisplayPresentChange: Nullable<() => void>;
  112402. /**
  112403. * Observable signaled when VR display mode changes
  112404. */
  112405. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  112406. /**
  112407. * Observable signaled when VR request present is complete
  112408. */
  112409. onVRRequestPresentComplete: Observable<boolean>;
  112410. /**
  112411. * Observable signaled when VR request present starts
  112412. */
  112413. onVRRequestPresentStart: Observable<Engine>;
  112414. /**
  112415. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  112416. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  112417. */
  112418. isInVRExclusivePointerMode: boolean;
  112419. /**
  112420. * Gets a boolean indicating if a webVR device was detected
  112421. * @returns true if a webVR device was detected
  112422. */
  112423. isVRDevicePresent(): boolean;
  112424. /**
  112425. * Gets the current webVR device
  112426. * @returns the current webVR device (or null)
  112427. */
  112428. getVRDevice(): any;
  112429. /**
  112430. * Initializes a webVR display and starts listening to display change events
  112431. * The onVRDisplayChangedObservable will be notified upon these changes
  112432. * @returns A promise containing a VRDisplay and if vr is supported
  112433. */
  112434. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  112435. /** @hidden */
  112436. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  112437. /**
  112438. * Gets or sets the presentation attributes used to configure VR rendering
  112439. */
  112440. vrPresentationAttributes?: IVRPresentationAttributes;
  112441. /**
  112442. * Call this function to switch to webVR mode
  112443. * Will do nothing if webVR is not supported or if there is no webVR device
  112444. * @param options the webvr options provided to the camera. mainly used for multiview
  112445. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112446. */
  112447. enableVR(options: WebVROptions): void;
  112448. /** @hidden */
  112449. _onVRFullScreenTriggered(): void;
  112450. }
  112451. }
  112452. declare module BABYLON {
  112453. /**
  112454. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  112455. * IMPORTANT!! The data is right-hand data.
  112456. * @export
  112457. * @interface DevicePose
  112458. */
  112459. export interface DevicePose {
  112460. /**
  112461. * The position of the device, values in array are [x,y,z].
  112462. */
  112463. readonly position: Nullable<Float32Array>;
  112464. /**
  112465. * The linearVelocity of the device, values in array are [x,y,z].
  112466. */
  112467. readonly linearVelocity: Nullable<Float32Array>;
  112468. /**
  112469. * The linearAcceleration of the device, values in array are [x,y,z].
  112470. */
  112471. readonly linearAcceleration: Nullable<Float32Array>;
  112472. /**
  112473. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  112474. */
  112475. readonly orientation: Nullable<Float32Array>;
  112476. /**
  112477. * The angularVelocity of the device, values in array are [x,y,z].
  112478. */
  112479. readonly angularVelocity: Nullable<Float32Array>;
  112480. /**
  112481. * The angularAcceleration of the device, values in array are [x,y,z].
  112482. */
  112483. readonly angularAcceleration: Nullable<Float32Array>;
  112484. }
  112485. /**
  112486. * Interface representing a pose controlled object in Babylon.
  112487. * A pose controlled object has both regular pose values as well as pose values
  112488. * from an external device such as a VR head mounted display
  112489. */
  112490. export interface PoseControlled {
  112491. /**
  112492. * The position of the object in babylon space.
  112493. */
  112494. position: Vector3;
  112495. /**
  112496. * The rotation quaternion of the object in babylon space.
  112497. */
  112498. rotationQuaternion: Quaternion;
  112499. /**
  112500. * The position of the device in babylon space.
  112501. */
  112502. devicePosition?: Vector3;
  112503. /**
  112504. * The rotation quaternion of the device in babylon space.
  112505. */
  112506. deviceRotationQuaternion: Quaternion;
  112507. /**
  112508. * The raw pose coming from the device.
  112509. */
  112510. rawPose: Nullable<DevicePose>;
  112511. /**
  112512. * The scale of the device to be used when translating from device space to babylon space.
  112513. */
  112514. deviceScaleFactor: number;
  112515. /**
  112516. * Updates the poseControlled values based on the input device pose.
  112517. * @param poseData the pose data to update the object with
  112518. */
  112519. updateFromDevice(poseData: DevicePose): void;
  112520. }
  112521. /**
  112522. * Set of options to customize the webVRCamera
  112523. */
  112524. export interface WebVROptions {
  112525. /**
  112526. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  112527. */
  112528. trackPosition?: boolean;
  112529. /**
  112530. * Sets the scale of the vrDevice in babylon space. (default: 1)
  112531. */
  112532. positionScale?: number;
  112533. /**
  112534. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  112535. */
  112536. displayName?: string;
  112537. /**
  112538. * Should the native controller meshes be initialized. (default: true)
  112539. */
  112540. controllerMeshes?: boolean;
  112541. /**
  112542. * Creating a default HemiLight only on controllers. (default: true)
  112543. */
  112544. defaultLightingOnControllers?: boolean;
  112545. /**
  112546. * If you don't want to use the default VR button of the helper. (default: false)
  112547. */
  112548. useCustomVRButton?: boolean;
  112549. /**
  112550. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  112551. */
  112552. customVRButton?: HTMLButtonElement;
  112553. /**
  112554. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  112555. */
  112556. rayLength?: number;
  112557. /**
  112558. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  112559. */
  112560. defaultHeight?: number;
  112561. /**
  112562. * If multiview should be used if availible (default: false)
  112563. */
  112564. useMultiview?: boolean;
  112565. }
  112566. /**
  112567. * This represents a WebVR camera.
  112568. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  112569. * @example https://doc.babylonjs.com/how_to/webvr_camera
  112570. */
  112571. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  112572. private webVROptions;
  112573. /**
  112574. * @hidden
  112575. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  112576. */
  112577. _vrDevice: any;
  112578. /**
  112579. * The rawPose of the vrDevice.
  112580. */
  112581. rawPose: Nullable<DevicePose>;
  112582. private _onVREnabled;
  112583. private _specsVersion;
  112584. private _attached;
  112585. private _frameData;
  112586. protected _descendants: Array<Node>;
  112587. private _deviceRoomPosition;
  112588. /** @hidden */
  112589. _deviceRoomRotationQuaternion: Quaternion;
  112590. private _standingMatrix;
  112591. /**
  112592. * Represents device position in babylon space.
  112593. */
  112594. devicePosition: Vector3;
  112595. /**
  112596. * Represents device rotation in babylon space.
  112597. */
  112598. deviceRotationQuaternion: Quaternion;
  112599. /**
  112600. * The scale of the device to be used when translating from device space to babylon space.
  112601. */
  112602. deviceScaleFactor: number;
  112603. private _deviceToWorld;
  112604. private _worldToDevice;
  112605. /**
  112606. * References to the webVR controllers for the vrDevice.
  112607. */
  112608. controllers: Array<WebVRController>;
  112609. /**
  112610. * Emits an event when a controller is attached.
  112611. */
  112612. onControllersAttachedObservable: Observable<WebVRController[]>;
  112613. /**
  112614. * Emits an event when a controller's mesh has been loaded;
  112615. */
  112616. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112617. /**
  112618. * Emits an event when the HMD's pose has been updated.
  112619. */
  112620. onPoseUpdatedFromDeviceObservable: Observable<any>;
  112621. private _poseSet;
  112622. /**
  112623. * If the rig cameras be used as parent instead of this camera.
  112624. */
  112625. rigParenting: boolean;
  112626. private _lightOnControllers;
  112627. private _defaultHeight?;
  112628. /**
  112629. * Instantiates a WebVRFreeCamera.
  112630. * @param name The name of the WebVRFreeCamera
  112631. * @param position The starting anchor position for the camera
  112632. * @param scene The scene the camera belongs to
  112633. * @param webVROptions a set of customizable options for the webVRCamera
  112634. */
  112635. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  112636. /**
  112637. * Gets the device distance from the ground in meters.
  112638. * @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.
  112639. */
  112640. deviceDistanceToRoomGround(): number;
  112641. /**
  112642. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112643. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  112644. */
  112645. useStandingMatrix(callback?: (bool: boolean) => void): void;
  112646. /**
  112647. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112648. * @returns A promise with a boolean set to if the standing matrix is supported.
  112649. */
  112650. useStandingMatrixAsync(): Promise<boolean>;
  112651. /**
  112652. * Disposes the camera
  112653. */
  112654. dispose(): void;
  112655. /**
  112656. * Gets a vrController by name.
  112657. * @param name The name of the controller to retreive
  112658. * @returns the controller matching the name specified or null if not found
  112659. */
  112660. getControllerByName(name: string): Nullable<WebVRController>;
  112661. private _leftController;
  112662. /**
  112663. * The controller corresponding to the users left hand.
  112664. */
  112665. get leftController(): Nullable<WebVRController>;
  112666. private _rightController;
  112667. /**
  112668. * The controller corresponding to the users right hand.
  112669. */
  112670. get rightController(): Nullable<WebVRController>;
  112671. /**
  112672. * Casts a ray forward from the vrCamera's gaze.
  112673. * @param length Length of the ray (default: 100)
  112674. * @returns the ray corresponding to the gaze
  112675. */
  112676. getForwardRay(length?: number): Ray;
  112677. /**
  112678. * @hidden
  112679. * Updates the camera based on device's frame data
  112680. */
  112681. _checkInputs(): void;
  112682. /**
  112683. * Updates the poseControlled values based on the input device pose.
  112684. * @param poseData Pose coming from the device
  112685. */
  112686. updateFromDevice(poseData: DevicePose): void;
  112687. private _detachIfAttached;
  112688. /**
  112689. * WebVR's attach control will start broadcasting frames to the device.
  112690. * Note that in certain browsers (chrome for example) this function must be called
  112691. * within a user-interaction callback. Example:
  112692. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  112693. *
  112694. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  112695. */
  112696. attachControl(noPreventDefault?: boolean): void;
  112697. /**
  112698. * Detach the current controls from the specified dom element.
  112699. */
  112700. detachControl(): void;
  112701. /**
  112702. * @returns the name of this class
  112703. */
  112704. getClassName(): string;
  112705. /**
  112706. * Calls resetPose on the vrDisplay
  112707. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  112708. */
  112709. resetToCurrentRotation(): void;
  112710. /**
  112711. * @hidden
  112712. * Updates the rig cameras (left and right eye)
  112713. */
  112714. _updateRigCameras(): void;
  112715. private _workingVector;
  112716. private _oneVector;
  112717. private _workingMatrix;
  112718. private updateCacheCalled;
  112719. private _correctPositionIfNotTrackPosition;
  112720. /**
  112721. * @hidden
  112722. * Updates the cached values of the camera
  112723. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  112724. */
  112725. _updateCache(ignoreParentClass?: boolean): void;
  112726. /**
  112727. * @hidden
  112728. * Get current device position in babylon world
  112729. */
  112730. _computeDevicePosition(): void;
  112731. /**
  112732. * Updates the current device position and rotation in the babylon world
  112733. */
  112734. update(): void;
  112735. /**
  112736. * @hidden
  112737. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  112738. * @returns an identity matrix
  112739. */
  112740. _getViewMatrix(): Matrix;
  112741. private _tmpMatrix;
  112742. /**
  112743. * This function is called by the two RIG cameras.
  112744. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  112745. * @hidden
  112746. */
  112747. _getWebVRViewMatrix(): Matrix;
  112748. /** @hidden */
  112749. _getWebVRProjectionMatrix(): Matrix;
  112750. private _onGamepadConnectedObserver;
  112751. private _onGamepadDisconnectedObserver;
  112752. private _updateCacheWhenTrackingDisabledObserver;
  112753. /**
  112754. * Initializes the controllers and their meshes
  112755. */
  112756. initControllers(): void;
  112757. }
  112758. }
  112759. declare module BABYLON {
  112760. /**
  112761. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  112762. *
  112763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  112764. *
  112765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  112766. */
  112767. export class MaterialHelper {
  112768. /**
  112769. * Bind the current view position to an effect.
  112770. * @param effect The effect to be bound
  112771. * @param scene The scene the eyes position is used from
  112772. * @param variableName name of the shader variable that will hold the eye position
  112773. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  112774. * @return the computed eye position
  112775. */
  112776. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  112777. /**
  112778. * Helps preparing the defines values about the UVs in used in the effect.
  112779. * UVs are shared as much as we can accross channels in the shaders.
  112780. * @param texture The texture we are preparing the UVs for
  112781. * @param defines The defines to update
  112782. * @param key The channel key "diffuse", "specular"... used in the shader
  112783. */
  112784. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  112785. /**
  112786. * Binds a texture matrix value to its corrsponding uniform
  112787. * @param texture The texture to bind the matrix for
  112788. * @param uniformBuffer The uniform buffer receivin the data
  112789. * @param key The channel key "diffuse", "specular"... used in the shader
  112790. */
  112791. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  112792. /**
  112793. * Gets the current status of the fog (should it be enabled?)
  112794. * @param mesh defines the mesh to evaluate for fog support
  112795. * @param scene defines the hosting scene
  112796. * @returns true if fog must be enabled
  112797. */
  112798. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  112799. /**
  112800. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  112801. * @param mesh defines the current mesh
  112802. * @param scene defines the current scene
  112803. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  112804. * @param pointsCloud defines if point cloud rendering has to be turned on
  112805. * @param fogEnabled defines if fog has to be turned on
  112806. * @param alphaTest defines if alpha testing has to be turned on
  112807. * @param defines defines the current list of defines
  112808. */
  112809. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  112810. /**
  112811. * Helper used to prepare the list of defines associated with frame values for shader compilation
  112812. * @param scene defines the current scene
  112813. * @param engine defines the current engine
  112814. * @param defines specifies the list of active defines
  112815. * @param useInstances defines if instances have to be turned on
  112816. * @param useClipPlane defines if clip plane have to be turned on
  112817. * @param useInstances defines if instances have to be turned on
  112818. * @param useThinInstances defines if thin instances have to be turned on
  112819. */
  112820. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  112821. /**
  112822. * Prepares the defines for bones
  112823. * @param mesh The mesh containing the geometry data we will draw
  112824. * @param defines The defines to update
  112825. */
  112826. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  112827. /**
  112828. * Prepares the defines for morph targets
  112829. * @param mesh The mesh containing the geometry data we will draw
  112830. * @param defines The defines to update
  112831. */
  112832. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  112833. /**
  112834. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  112835. * @param mesh The mesh containing the geometry data we will draw
  112836. * @param defines The defines to update
  112837. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  112838. * @param useBones Precise whether bones should be used or not (override mesh info)
  112839. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  112840. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  112841. * @returns false if defines are considered not dirty and have not been checked
  112842. */
  112843. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  112844. /**
  112845. * Prepares the defines related to multiview
  112846. * @param scene The scene we are intending to draw
  112847. * @param defines The defines to update
  112848. */
  112849. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  112850. /**
  112851. * Prepares the defines related to the prepass
  112852. * @param scene The scene we are intending to draw
  112853. * @param defines The defines to update
  112854. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  112855. */
  112856. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  112857. /**
  112858. * Prepares the defines related to the light information passed in parameter
  112859. * @param scene The scene we are intending to draw
  112860. * @param mesh The mesh the effect is compiling for
  112861. * @param light The light the effect is compiling for
  112862. * @param lightIndex The index of the light
  112863. * @param defines The defines to update
  112864. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112865. * @param state Defines the current state regarding what is needed (normals, etc...)
  112866. */
  112867. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  112868. needNormals: boolean;
  112869. needRebuild: boolean;
  112870. shadowEnabled: boolean;
  112871. specularEnabled: boolean;
  112872. lightmapMode: boolean;
  112873. }): void;
  112874. /**
  112875. * Prepares the defines related to the light information passed in parameter
  112876. * @param scene The scene we are intending to draw
  112877. * @param mesh The mesh the effect is compiling for
  112878. * @param defines The defines to update
  112879. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112880. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  112881. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  112882. * @returns true if normals will be required for the rest of the effect
  112883. */
  112884. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  112885. /**
  112886. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  112887. * @param lightIndex defines the light index
  112888. * @param uniformsList The uniform list
  112889. * @param samplersList The sampler list
  112890. * @param projectedLightTexture defines if projected texture must be used
  112891. * @param uniformBuffersList defines an optional list of uniform buffers
  112892. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  112893. */
  112894. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  112895. /**
  112896. * Prepares the uniforms and samplers list to be used in the effect
  112897. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  112898. * @param samplersList The sampler list
  112899. * @param defines The defines helping in the list generation
  112900. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  112901. */
  112902. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  112903. /**
  112904. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  112905. * @param defines The defines to update while falling back
  112906. * @param fallbacks The authorized effect fallbacks
  112907. * @param maxSimultaneousLights The maximum number of lights allowed
  112908. * @param rank the current rank of the Effect
  112909. * @returns The newly affected rank
  112910. */
  112911. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  112912. private static _TmpMorphInfluencers;
  112913. /**
  112914. * Prepares the list of attributes required for morph targets according to the effect defines.
  112915. * @param attribs The current list of supported attribs
  112916. * @param mesh The mesh to prepare the morph targets attributes for
  112917. * @param influencers The number of influencers
  112918. */
  112919. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  112920. /**
  112921. * Prepares the list of attributes required for morph targets according to the effect defines.
  112922. * @param attribs The current list of supported attribs
  112923. * @param mesh The mesh to prepare the morph targets attributes for
  112924. * @param defines The current Defines of the effect
  112925. */
  112926. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  112927. /**
  112928. * Prepares the list of attributes required for bones according to the effect defines.
  112929. * @param attribs The current list of supported attribs
  112930. * @param mesh The mesh to prepare the bones attributes for
  112931. * @param defines The current Defines of the effect
  112932. * @param fallbacks The current efffect fallback strategy
  112933. */
  112934. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  112935. /**
  112936. * Check and prepare the list of attributes required for instances according to the effect defines.
  112937. * @param attribs The current list of supported attribs
  112938. * @param defines The current MaterialDefines of the effect
  112939. */
  112940. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  112941. /**
  112942. * Add the list of attributes required for instances to the attribs array.
  112943. * @param attribs The current list of supported attribs
  112944. */
  112945. static PushAttributesForInstances(attribs: string[]): void;
  112946. /**
  112947. * Binds the light information to the effect.
  112948. * @param light The light containing the generator
  112949. * @param effect The effect we are binding the data to
  112950. * @param lightIndex The light index in the effect used to render
  112951. */
  112952. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  112953. /**
  112954. * Binds the lights information from the scene to the effect for the given mesh.
  112955. * @param light Light to bind
  112956. * @param lightIndex Light index
  112957. * @param scene The scene where the light belongs to
  112958. * @param effect The effect we are binding the data to
  112959. * @param useSpecular Defines if specular is supported
  112960. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112961. */
  112962. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  112963. /**
  112964. * Binds the lights information from the scene to the effect for the given mesh.
  112965. * @param scene The scene the lights belongs to
  112966. * @param mesh The mesh we are binding the information to render
  112967. * @param effect The effect we are binding the data to
  112968. * @param defines The generated defines for the effect
  112969. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  112970. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112971. */
  112972. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  112973. private static _tempFogColor;
  112974. /**
  112975. * Binds the fog information from the scene to the effect for the given mesh.
  112976. * @param scene The scene the lights belongs to
  112977. * @param mesh The mesh we are binding the information to render
  112978. * @param effect The effect we are binding the data to
  112979. * @param linearSpace Defines if the fog effect is applied in linear space
  112980. */
  112981. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  112982. /**
  112983. * Binds the bones information from the mesh to the effect.
  112984. * @param mesh The mesh we are binding the information to render
  112985. * @param effect The effect we are binding the data to
  112986. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  112987. */
  112988. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  112989. private static _CopyBonesTransformationMatrices;
  112990. /**
  112991. * Binds the morph targets information from the mesh to the effect.
  112992. * @param abstractMesh The mesh we are binding the information to render
  112993. * @param effect The effect we are binding the data to
  112994. */
  112995. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  112996. /**
  112997. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  112998. * @param defines The generated defines used in the effect
  112999. * @param effect The effect we are binding the data to
  113000. * @param scene The scene we are willing to render with logarithmic scale for
  113001. */
  113002. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  113003. /**
  113004. * Binds the clip plane information from the scene to the effect.
  113005. * @param scene The scene the clip plane information are extracted from
  113006. * @param effect The effect we are binding the data to
  113007. */
  113008. static BindClipPlane(effect: Effect, scene: Scene): void;
  113009. }
  113010. }
  113011. declare module BABYLON {
  113012. /** @hidden */
  113013. export var bayerDitherFunctions: {
  113014. name: string;
  113015. shader: string;
  113016. };
  113017. }
  113018. declare module BABYLON {
  113019. /** @hidden */
  113020. export var shadowMapFragmentDeclaration: {
  113021. name: string;
  113022. shader: string;
  113023. };
  113024. }
  113025. declare module BABYLON {
  113026. /** @hidden */
  113027. export var shadowMapFragment: {
  113028. name: string;
  113029. shader: string;
  113030. };
  113031. }
  113032. declare module BABYLON {
  113033. /** @hidden */
  113034. export var shadowMapPixelShader: {
  113035. name: string;
  113036. shader: string;
  113037. };
  113038. }
  113039. declare module BABYLON {
  113040. /** @hidden */
  113041. export var shadowMapVertexDeclaration: {
  113042. name: string;
  113043. shader: string;
  113044. };
  113045. }
  113046. declare module BABYLON {
  113047. /** @hidden */
  113048. export var shadowMapVertexNormalBias: {
  113049. name: string;
  113050. shader: string;
  113051. };
  113052. }
  113053. declare module BABYLON {
  113054. /** @hidden */
  113055. export var shadowMapVertexMetric: {
  113056. name: string;
  113057. shader: string;
  113058. };
  113059. }
  113060. declare module BABYLON {
  113061. /** @hidden */
  113062. export var shadowMapVertexShader: {
  113063. name: string;
  113064. shader: string;
  113065. };
  113066. }
  113067. declare module BABYLON {
  113068. /** @hidden */
  113069. export var depthBoxBlurPixelShader: {
  113070. name: string;
  113071. shader: string;
  113072. };
  113073. }
  113074. declare module BABYLON {
  113075. /** @hidden */
  113076. export var shadowMapFragmentSoftTransparentShadow: {
  113077. name: string;
  113078. shader: string;
  113079. };
  113080. }
  113081. declare module BABYLON {
  113082. /**
  113083. * Creates an instance based on a source mesh.
  113084. */
  113085. export class InstancedMesh extends AbstractMesh {
  113086. private _sourceMesh;
  113087. private _currentLOD;
  113088. /** @hidden */
  113089. _indexInSourceMeshInstanceArray: number;
  113090. constructor(name: string, source: Mesh);
  113091. /**
  113092. * Returns the string "InstancedMesh".
  113093. */
  113094. getClassName(): string;
  113095. /** Gets the list of lights affecting that mesh */
  113096. get lightSources(): Light[];
  113097. _resyncLightSources(): void;
  113098. _resyncLightSource(light: Light): void;
  113099. _removeLightSource(light: Light, dispose: boolean): void;
  113100. /**
  113101. * If the source mesh receives shadows
  113102. */
  113103. get receiveShadows(): boolean;
  113104. /**
  113105. * The material of the source mesh
  113106. */
  113107. get material(): Nullable<Material>;
  113108. /**
  113109. * Visibility of the source mesh
  113110. */
  113111. get visibility(): number;
  113112. /**
  113113. * Skeleton of the source mesh
  113114. */
  113115. get skeleton(): Nullable<Skeleton>;
  113116. /**
  113117. * Rendering ground id of the source mesh
  113118. */
  113119. get renderingGroupId(): number;
  113120. set renderingGroupId(value: number);
  113121. /**
  113122. * Returns the total number of vertices (integer).
  113123. */
  113124. getTotalVertices(): number;
  113125. /**
  113126. * Returns a positive integer : the total number of indices in this mesh geometry.
  113127. * @returns the numner of indices or zero if the mesh has no geometry.
  113128. */
  113129. getTotalIndices(): number;
  113130. /**
  113131. * The source mesh of the instance
  113132. */
  113133. get sourceMesh(): Mesh;
  113134. /**
  113135. * Creates a new InstancedMesh object from the mesh model.
  113136. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113137. * @param name defines the name of the new instance
  113138. * @returns a new InstancedMesh
  113139. */
  113140. createInstance(name: string): InstancedMesh;
  113141. /**
  113142. * Is this node ready to be used/rendered
  113143. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113144. * @return {boolean} is it ready
  113145. */
  113146. isReady(completeCheck?: boolean): boolean;
  113147. /**
  113148. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113149. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  113150. * @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.
  113151. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  113152. */
  113153. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  113154. /**
  113155. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113156. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113157. * The `data` are either a numeric array either a Float32Array.
  113158. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  113159. * 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).
  113160. * Note that a new underlying VertexBuffer object is created each call.
  113161. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113162. *
  113163. * Possible `kind` values :
  113164. * - VertexBuffer.PositionKind
  113165. * - VertexBuffer.UVKind
  113166. * - VertexBuffer.UV2Kind
  113167. * - VertexBuffer.UV3Kind
  113168. * - VertexBuffer.UV4Kind
  113169. * - VertexBuffer.UV5Kind
  113170. * - VertexBuffer.UV6Kind
  113171. * - VertexBuffer.ColorKind
  113172. * - VertexBuffer.MatricesIndicesKind
  113173. * - VertexBuffer.MatricesIndicesExtraKind
  113174. * - VertexBuffer.MatricesWeightsKind
  113175. * - VertexBuffer.MatricesWeightsExtraKind
  113176. *
  113177. * Returns the Mesh.
  113178. */
  113179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113180. /**
  113181. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  113182. * If the mesh has no geometry, it is simply returned as it is.
  113183. * The `data` are either a numeric array either a Float32Array.
  113184. * No new underlying VertexBuffer object is created.
  113185. * 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.
  113186. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  113187. *
  113188. * Possible `kind` values :
  113189. * - VertexBuffer.PositionKind
  113190. * - VertexBuffer.UVKind
  113191. * - VertexBuffer.UV2Kind
  113192. * - VertexBuffer.UV3Kind
  113193. * - VertexBuffer.UV4Kind
  113194. * - VertexBuffer.UV5Kind
  113195. * - VertexBuffer.UV6Kind
  113196. * - VertexBuffer.ColorKind
  113197. * - VertexBuffer.MatricesIndicesKind
  113198. * - VertexBuffer.MatricesIndicesExtraKind
  113199. * - VertexBuffer.MatricesWeightsKind
  113200. * - VertexBuffer.MatricesWeightsExtraKind
  113201. *
  113202. * Returns the Mesh.
  113203. */
  113204. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  113205. /**
  113206. * Sets the mesh indices.
  113207. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  113208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  113209. * This method creates a new index buffer each call.
  113210. * Returns the Mesh.
  113211. */
  113212. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  113213. /**
  113214. * Boolean : True if the mesh owns the requested kind of data.
  113215. */
  113216. isVerticesDataPresent(kind: string): boolean;
  113217. /**
  113218. * Returns an array of indices (IndicesArray).
  113219. */
  113220. getIndices(): Nullable<IndicesArray>;
  113221. get _positions(): Nullable<Vector3[]>;
  113222. /**
  113223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113224. * This means the mesh underlying bounding box and sphere are recomputed.
  113225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113226. * @returns the current mesh
  113227. */
  113228. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  113229. /** @hidden */
  113230. _preActivate(): InstancedMesh;
  113231. /** @hidden */
  113232. _activate(renderId: number, intermediateRendering: boolean): boolean;
  113233. /** @hidden */
  113234. _postActivate(): void;
  113235. getWorldMatrix(): Matrix;
  113236. get isAnInstance(): boolean;
  113237. /**
  113238. * Returns the current associated LOD AbstractMesh.
  113239. */
  113240. getLOD(camera: Camera): AbstractMesh;
  113241. /** @hidden */
  113242. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113243. /** @hidden */
  113244. _syncSubMeshes(): InstancedMesh;
  113245. /** @hidden */
  113246. _generatePointsArray(): boolean;
  113247. /** @hidden */
  113248. _updateBoundingInfo(): AbstractMesh;
  113249. /**
  113250. * Creates a new InstancedMesh from the current mesh.
  113251. * - name (string) : the cloned mesh name
  113252. * - newParent (optional Node) : the optional Node to parent the clone to.
  113253. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  113254. *
  113255. * Returns the clone.
  113256. */
  113257. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  113258. /**
  113259. * Disposes the InstancedMesh.
  113260. * Returns nothing.
  113261. */
  113262. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113263. }
  113264. interface Mesh {
  113265. /**
  113266. * Register a custom buffer that will be instanced
  113267. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  113268. * @param kind defines the buffer kind
  113269. * @param stride defines the stride in floats
  113270. */
  113271. registerInstancedBuffer(kind: string, stride: number): void;
  113272. /**
  113273. * true to use the edge renderer for all instances of this mesh
  113274. */
  113275. edgesShareWithInstances: boolean;
  113276. /** @hidden */
  113277. _userInstancedBuffersStorage: {
  113278. data: {
  113279. [key: string]: Float32Array;
  113280. };
  113281. sizes: {
  113282. [key: string]: number;
  113283. };
  113284. vertexBuffers: {
  113285. [key: string]: Nullable<VertexBuffer>;
  113286. };
  113287. strides: {
  113288. [key: string]: number;
  113289. };
  113290. };
  113291. }
  113292. interface AbstractMesh {
  113293. /**
  113294. * Object used to store instanced buffers defined by user
  113295. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  113296. */
  113297. instancedBuffers: {
  113298. [key: string]: any;
  113299. };
  113300. }
  113301. }
  113302. declare module BABYLON {
  113303. /**
  113304. * Defines the options associated with the creation of a shader material.
  113305. */
  113306. export interface IShaderMaterialOptions {
  113307. /**
  113308. * Does the material work in alpha blend mode
  113309. */
  113310. needAlphaBlending: boolean;
  113311. /**
  113312. * Does the material work in alpha test mode
  113313. */
  113314. needAlphaTesting: boolean;
  113315. /**
  113316. * The list of attribute names used in the shader
  113317. */
  113318. attributes: string[];
  113319. /**
  113320. * The list of unifrom names used in the shader
  113321. */
  113322. uniforms: string[];
  113323. /**
  113324. * The list of UBO names used in the shader
  113325. */
  113326. uniformBuffers: string[];
  113327. /**
  113328. * The list of sampler names used in the shader
  113329. */
  113330. samplers: string[];
  113331. /**
  113332. * The list of defines used in the shader
  113333. */
  113334. defines: string[];
  113335. }
  113336. /**
  113337. * 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.
  113338. *
  113339. * This returned material effects how the mesh will look based on the code in the shaders.
  113340. *
  113341. * @see https://doc.babylonjs.com/how_to/shader_material
  113342. */
  113343. export class ShaderMaterial extends Material {
  113344. private _shaderPath;
  113345. private _options;
  113346. private _textures;
  113347. private _textureArrays;
  113348. private _floats;
  113349. private _ints;
  113350. private _floatsArrays;
  113351. private _colors3;
  113352. private _colors3Arrays;
  113353. private _colors4;
  113354. private _colors4Arrays;
  113355. private _vectors2;
  113356. private _vectors3;
  113357. private _vectors4;
  113358. private _matrices;
  113359. private _matrixArrays;
  113360. private _matrices3x3;
  113361. private _matrices2x2;
  113362. private _vectors2Arrays;
  113363. private _vectors3Arrays;
  113364. private _vectors4Arrays;
  113365. private _cachedWorldViewMatrix;
  113366. private _cachedWorldViewProjectionMatrix;
  113367. private _renderId;
  113368. private _multiview;
  113369. private _cachedDefines;
  113370. /** Define the Url to load snippets */
  113371. static SnippetUrl: string;
  113372. /** Snippet ID if the material was created from the snippet server */
  113373. snippetId: string;
  113374. /**
  113375. * Instantiate a new shader material.
  113376. * 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.
  113377. * This returned material effects how the mesh will look based on the code in the shaders.
  113378. * @see https://doc.babylonjs.com/how_to/shader_material
  113379. * @param name Define the name of the material in the scene
  113380. * @param scene Define the scene the material belongs to
  113381. * @param shaderPath Defines the route to the shader code in one of three ways:
  113382. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  113383. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  113384. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  113385. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  113386. * @param options Define the options used to create the shader
  113387. */
  113388. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  113389. /**
  113390. * Gets the shader path used to define the shader code
  113391. * It can be modified to trigger a new compilation
  113392. */
  113393. get shaderPath(): any;
  113394. /**
  113395. * Sets the shader path used to define the shader code
  113396. * It can be modified to trigger a new compilation
  113397. */
  113398. set shaderPath(shaderPath: any);
  113399. /**
  113400. * Gets the options used to compile the shader.
  113401. * They can be modified to trigger a new compilation
  113402. */
  113403. get options(): IShaderMaterialOptions;
  113404. /**
  113405. * Gets the current class name of the material e.g. "ShaderMaterial"
  113406. * Mainly use in serialization.
  113407. * @returns the class name
  113408. */
  113409. getClassName(): string;
  113410. /**
  113411. * Specifies if the material will require alpha blending
  113412. * @returns a boolean specifying if alpha blending is needed
  113413. */
  113414. needAlphaBlending(): boolean;
  113415. /**
  113416. * Specifies if this material should be rendered in alpha test mode
  113417. * @returns a boolean specifying if an alpha test is needed.
  113418. */
  113419. needAlphaTesting(): boolean;
  113420. private _checkUniform;
  113421. /**
  113422. * Set a texture in the shader.
  113423. * @param name Define the name of the uniform samplers as defined in the shader
  113424. * @param texture Define the texture to bind to this sampler
  113425. * @return the material itself allowing "fluent" like uniform updates
  113426. */
  113427. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  113428. /**
  113429. * Set a texture array in the shader.
  113430. * @param name Define the name of the uniform sampler array as defined in the shader
  113431. * @param textures Define the list of textures to bind to this sampler
  113432. * @return the material itself allowing "fluent" like uniform updates
  113433. */
  113434. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  113435. /**
  113436. * Set a float in the shader.
  113437. * @param name Define the name of the uniform as defined in the shader
  113438. * @param value Define the value to give to the uniform
  113439. * @return the material itself allowing "fluent" like uniform updates
  113440. */
  113441. setFloat(name: string, value: number): ShaderMaterial;
  113442. /**
  113443. * Set a int in the shader.
  113444. * @param name Define the name of the uniform as defined in the shader
  113445. * @param value Define the value to give to the uniform
  113446. * @return the material itself allowing "fluent" like uniform updates
  113447. */
  113448. setInt(name: string, value: number): ShaderMaterial;
  113449. /**
  113450. * Set an array of floats in the shader.
  113451. * @param name Define the name of the uniform as defined in the shader
  113452. * @param value Define the value to give to the uniform
  113453. * @return the material itself allowing "fluent" like uniform updates
  113454. */
  113455. setFloats(name: string, value: number[]): ShaderMaterial;
  113456. /**
  113457. * Set a vec3 in the shader from a Color3.
  113458. * @param name Define the name of the uniform as defined in the shader
  113459. * @param value Define the value to give to the uniform
  113460. * @return the material itself allowing "fluent" like uniform updates
  113461. */
  113462. setColor3(name: string, value: Color3): ShaderMaterial;
  113463. /**
  113464. * Set a vec3 array in the shader from a Color3 array.
  113465. * @param name Define the name of the uniform as defined in the shader
  113466. * @param value Define the value to give to the uniform
  113467. * @return the material itself allowing "fluent" like uniform updates
  113468. */
  113469. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  113470. /**
  113471. * Set a vec4 in the shader from a Color4.
  113472. * @param name Define the name of the uniform as defined in the shader
  113473. * @param value Define the value to give to the uniform
  113474. * @return the material itself allowing "fluent" like uniform updates
  113475. */
  113476. setColor4(name: string, value: Color4): ShaderMaterial;
  113477. /**
  113478. * Set a vec4 array in the shader from a Color4 array.
  113479. * @param name Define the name of the uniform as defined in the shader
  113480. * @param value Define the value to give to the uniform
  113481. * @return the material itself allowing "fluent" like uniform updates
  113482. */
  113483. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  113484. /**
  113485. * Set a vec2 in the shader from a Vector2.
  113486. * @param name Define the name of the uniform as defined in the shader
  113487. * @param value Define the value to give to the uniform
  113488. * @return the material itself allowing "fluent" like uniform updates
  113489. */
  113490. setVector2(name: string, value: Vector2): ShaderMaterial;
  113491. /**
  113492. * Set a vec3 in the shader from a Vector3.
  113493. * @param name Define the name of the uniform as defined in the shader
  113494. * @param value Define the value to give to the uniform
  113495. * @return the material itself allowing "fluent" like uniform updates
  113496. */
  113497. setVector3(name: string, value: Vector3): ShaderMaterial;
  113498. /**
  113499. * Set a vec4 in the shader from a Vector4.
  113500. * @param name Define the name of the uniform as defined in the shader
  113501. * @param value Define the value to give to the uniform
  113502. * @return the material itself allowing "fluent" like uniform updates
  113503. */
  113504. setVector4(name: string, value: Vector4): ShaderMaterial;
  113505. /**
  113506. * Set a mat4 in the shader from a Matrix.
  113507. * @param name Define the name of the uniform as defined in the shader
  113508. * @param value Define the value to give to the uniform
  113509. * @return the material itself allowing "fluent" like uniform updates
  113510. */
  113511. setMatrix(name: string, value: Matrix): ShaderMaterial;
  113512. /**
  113513. * Set a float32Array in the shader from a matrix array.
  113514. * @param name Define the name of the uniform as defined in the shader
  113515. * @param value Define the value to give to the uniform
  113516. * @return the material itself allowing "fluent" like uniform updates
  113517. */
  113518. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  113519. /**
  113520. * Set a mat3 in the shader from a Float32Array.
  113521. * @param name Define the name of the uniform as defined in the shader
  113522. * @param value Define the value to give to the uniform
  113523. * @return the material itself allowing "fluent" like uniform updates
  113524. */
  113525. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113526. /**
  113527. * Set a mat2 in the shader from a Float32Array.
  113528. * @param name Define the name of the uniform as defined in the shader
  113529. * @param value Define the value to give to the uniform
  113530. * @return the material itself allowing "fluent" like uniform updates
  113531. */
  113532. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113533. /**
  113534. * Set a vec2 array in the shader from a number array.
  113535. * @param name Define the name of the uniform as defined in the shader
  113536. * @param value Define the value to give to the uniform
  113537. * @return the material itself allowing "fluent" like uniform updates
  113538. */
  113539. setArray2(name: string, value: number[]): ShaderMaterial;
  113540. /**
  113541. * Set a vec3 array in the shader from a number array.
  113542. * @param name Define the name of the uniform as defined in the shader
  113543. * @param value Define the value to give to the uniform
  113544. * @return the material itself allowing "fluent" like uniform updates
  113545. */
  113546. setArray3(name: string, value: number[]): ShaderMaterial;
  113547. /**
  113548. * Set a vec4 array in the shader from a number array.
  113549. * @param name Define the name of the uniform as defined in the shader
  113550. * @param value Define the value to give to the uniform
  113551. * @return the material itself allowing "fluent" like uniform updates
  113552. */
  113553. setArray4(name: string, value: number[]): ShaderMaterial;
  113554. private _checkCache;
  113555. /**
  113556. * Specifies that the submesh is ready to be used
  113557. * @param mesh defines the mesh to check
  113558. * @param subMesh defines which submesh to check
  113559. * @param useInstances specifies that instances should be used
  113560. * @returns a boolean indicating that the submesh is ready or not
  113561. */
  113562. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113563. /**
  113564. * Checks if the material is ready to render the requested mesh
  113565. * @param mesh Define the mesh to render
  113566. * @param useInstances Define whether or not the material is used with instances
  113567. * @returns true if ready, otherwise false
  113568. */
  113569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  113570. /**
  113571. * Binds the world matrix to the material
  113572. * @param world defines the world transformation matrix
  113573. * @param effectOverride - If provided, use this effect instead of internal effect
  113574. */
  113575. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  113576. /**
  113577. * Binds the submesh to this material by preparing the effect and shader to draw
  113578. * @param world defines the world transformation matrix
  113579. * @param mesh defines the mesh containing the submesh
  113580. * @param subMesh defines the submesh to bind the material to
  113581. */
  113582. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113583. /**
  113584. * Binds the material to the mesh
  113585. * @param world defines the world transformation matrix
  113586. * @param mesh defines the mesh to bind the material to
  113587. * @param effectOverride - If provided, use this effect instead of internal effect
  113588. */
  113589. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  113590. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  113591. /**
  113592. * Gets the active textures from the material
  113593. * @returns an array of textures
  113594. */
  113595. getActiveTextures(): BaseTexture[];
  113596. /**
  113597. * Specifies if the material uses a texture
  113598. * @param texture defines the texture to check against the material
  113599. * @returns a boolean specifying if the material uses the texture
  113600. */
  113601. hasTexture(texture: BaseTexture): boolean;
  113602. /**
  113603. * Makes a duplicate of the material, and gives it a new name
  113604. * @param name defines the new name for the duplicated material
  113605. * @returns the cloned material
  113606. */
  113607. clone(name: string): ShaderMaterial;
  113608. /**
  113609. * Disposes the material
  113610. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113611. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113612. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113613. */
  113614. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113615. /**
  113616. * Serializes this material in a JSON representation
  113617. * @returns the serialized material object
  113618. */
  113619. serialize(): any;
  113620. /**
  113621. * Creates a shader material from parsed shader material data
  113622. * @param source defines the JSON represnetation of the material
  113623. * @param scene defines the hosting scene
  113624. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113625. * @returns a new material
  113626. */
  113627. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  113628. /**
  113629. * Creates a new ShaderMaterial from a snippet saved in a remote file
  113630. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  113631. * @param url defines the url to load from
  113632. * @param scene defines the hosting scene
  113633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113634. * @returns a promise that will resolve to the new ShaderMaterial
  113635. */
  113636. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113637. /**
  113638. * Creates a ShaderMaterial from a snippet saved by the Inspector
  113639. * @param snippetId defines the snippet to load
  113640. * @param scene defines the hosting scene
  113641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113642. * @returns a promise that will resolve to the new ShaderMaterial
  113643. */
  113644. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113645. }
  113646. }
  113647. declare module BABYLON {
  113648. /** @hidden */
  113649. export var colorPixelShader: {
  113650. name: string;
  113651. shader: string;
  113652. };
  113653. }
  113654. declare module BABYLON {
  113655. /** @hidden */
  113656. export var colorVertexShader: {
  113657. name: string;
  113658. shader: string;
  113659. };
  113660. }
  113661. declare module BABYLON {
  113662. /**
  113663. * Line mesh
  113664. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  113665. */
  113666. export class LinesMesh extends Mesh {
  113667. /**
  113668. * If vertex color should be applied to the mesh
  113669. */
  113670. readonly useVertexColor?: boolean | undefined;
  113671. /**
  113672. * If vertex alpha should be applied to the mesh
  113673. */
  113674. readonly useVertexAlpha?: boolean | undefined;
  113675. /**
  113676. * Color of the line (Default: White)
  113677. */
  113678. color: Color3;
  113679. /**
  113680. * Alpha of the line (Default: 1)
  113681. */
  113682. alpha: number;
  113683. /**
  113684. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113685. * This margin is expressed in world space coordinates, so its value may vary.
  113686. * Default value is 0.1
  113687. */
  113688. intersectionThreshold: number;
  113689. private _colorShader;
  113690. private color4;
  113691. /**
  113692. * Creates a new LinesMesh
  113693. * @param name defines the name
  113694. * @param scene defines the hosting scene
  113695. * @param parent defines the parent mesh if any
  113696. * @param source defines the optional source LinesMesh used to clone data from
  113697. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113698. * When false, achieved by calling a clone(), also passing False.
  113699. * This will make creation of children, recursive.
  113700. * @param useVertexColor defines if this LinesMesh supports vertex color
  113701. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  113702. */
  113703. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  113704. /**
  113705. * If vertex color should be applied to the mesh
  113706. */
  113707. useVertexColor?: boolean | undefined,
  113708. /**
  113709. * If vertex alpha should be applied to the mesh
  113710. */
  113711. useVertexAlpha?: boolean | undefined);
  113712. private _addClipPlaneDefine;
  113713. private _removeClipPlaneDefine;
  113714. isReady(): boolean;
  113715. /**
  113716. * Returns the string "LineMesh"
  113717. */
  113718. getClassName(): string;
  113719. /**
  113720. * @hidden
  113721. */
  113722. get material(): Material;
  113723. /**
  113724. * @hidden
  113725. */
  113726. set material(value: Material);
  113727. /**
  113728. * @hidden
  113729. */
  113730. get checkCollisions(): boolean;
  113731. set checkCollisions(value: boolean);
  113732. /** @hidden */
  113733. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113734. /** @hidden */
  113735. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113736. /**
  113737. * Disposes of the line mesh
  113738. * @param doNotRecurse If children should be disposed
  113739. */
  113740. dispose(doNotRecurse?: boolean): void;
  113741. /**
  113742. * Returns a new LineMesh object cloned from the current one.
  113743. */
  113744. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  113745. /**
  113746. * Creates a new InstancedLinesMesh object from the mesh model.
  113747. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113748. * @param name defines the name of the new instance
  113749. * @returns a new InstancedLinesMesh
  113750. */
  113751. createInstance(name: string): InstancedLinesMesh;
  113752. }
  113753. /**
  113754. * Creates an instance based on a source LinesMesh
  113755. */
  113756. export class InstancedLinesMesh extends InstancedMesh {
  113757. /**
  113758. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113759. * This margin is expressed in world space coordinates, so its value may vary.
  113760. * Initilized with the intersectionThreshold value of the source LinesMesh
  113761. */
  113762. intersectionThreshold: number;
  113763. constructor(name: string, source: LinesMesh);
  113764. /**
  113765. * Returns the string "InstancedLinesMesh".
  113766. */
  113767. getClassName(): string;
  113768. }
  113769. }
  113770. declare module BABYLON {
  113771. /** @hidden */
  113772. export var linePixelShader: {
  113773. name: string;
  113774. shader: string;
  113775. };
  113776. }
  113777. declare module BABYLON {
  113778. /** @hidden */
  113779. export var lineVertexShader: {
  113780. name: string;
  113781. shader: string;
  113782. };
  113783. }
  113784. declare module BABYLON {
  113785. interface Scene {
  113786. /** @hidden */
  113787. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  113788. }
  113789. interface AbstractMesh {
  113790. /**
  113791. * Gets the edgesRenderer associated with the mesh
  113792. */
  113793. edgesRenderer: Nullable<EdgesRenderer>;
  113794. }
  113795. interface LinesMesh {
  113796. /**
  113797. * Enables the edge rendering mode on the mesh.
  113798. * This mode makes the mesh edges visible
  113799. * @param epsilon defines the maximal distance between two angles to detect a face
  113800. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113801. * @returns the currentAbstractMesh
  113802. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113803. */
  113804. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113805. }
  113806. interface InstancedLinesMesh {
  113807. /**
  113808. * Enables the edge rendering mode on the mesh.
  113809. * This mode makes the mesh edges visible
  113810. * @param epsilon defines the maximal distance between two angles to detect a face
  113811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113812. * @returns the current InstancedLinesMesh
  113813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113814. */
  113815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  113816. }
  113817. /**
  113818. * Defines the minimum contract an Edges renderer should follow.
  113819. */
  113820. export interface IEdgesRenderer extends IDisposable {
  113821. /**
  113822. * Gets or sets a boolean indicating if the edgesRenderer is active
  113823. */
  113824. isEnabled: boolean;
  113825. /**
  113826. * Renders the edges of the attached mesh,
  113827. */
  113828. render(): void;
  113829. /**
  113830. * Checks wether or not the edges renderer is ready to render.
  113831. * @return true if ready, otherwise false.
  113832. */
  113833. isReady(): boolean;
  113834. /**
  113835. * List of instances to render in case the source mesh has instances
  113836. */
  113837. customInstances: SmartArray<Matrix>;
  113838. }
  113839. /**
  113840. * Defines the additional options of the edges renderer
  113841. */
  113842. export interface IEdgesRendererOptions {
  113843. /**
  113844. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  113845. * If not defined, the default value is true
  113846. */
  113847. useAlternateEdgeFinder?: boolean;
  113848. /**
  113849. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  113850. * If not defined, the default value is true.
  113851. * 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)
  113852. * This option is used only if useAlternateEdgeFinder = true
  113853. */
  113854. useFastVertexMerger?: boolean;
  113855. /**
  113856. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  113857. * The default value is 1e-6
  113858. * This option is used only if useAlternateEdgeFinder = true
  113859. */
  113860. epsilonVertexMerge?: number;
  113861. /**
  113862. * 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
  113863. * 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.
  113864. * This option is used only if useAlternateEdgeFinder = true
  113865. */
  113866. applyTessellation?: boolean;
  113867. /**
  113868. * 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
  113869. * The default value is 1e-6
  113870. * This option is used only if useAlternateEdgeFinder = true
  113871. */
  113872. epsilonVertexAligned?: number;
  113873. }
  113874. /**
  113875. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  113876. */
  113877. export class EdgesRenderer implements IEdgesRenderer {
  113878. /**
  113879. * Define the size of the edges with an orthographic camera
  113880. */
  113881. edgesWidthScalerForOrthographic: number;
  113882. /**
  113883. * Define the size of the edges with a perspective camera
  113884. */
  113885. edgesWidthScalerForPerspective: number;
  113886. protected _source: AbstractMesh;
  113887. protected _linesPositions: number[];
  113888. protected _linesNormals: number[];
  113889. protected _linesIndices: number[];
  113890. protected _epsilon: number;
  113891. protected _indicesCount: number;
  113892. protected _lineShader: ShaderMaterial;
  113893. protected _ib: DataBuffer;
  113894. protected _buffers: {
  113895. [key: string]: Nullable<VertexBuffer>;
  113896. };
  113897. protected _buffersForInstances: {
  113898. [key: string]: Nullable<VertexBuffer>;
  113899. };
  113900. protected _checkVerticesInsteadOfIndices: boolean;
  113901. protected _options: Nullable<IEdgesRendererOptions>;
  113902. private _meshRebuildObserver;
  113903. private _meshDisposeObserver;
  113904. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  113905. isEnabled: boolean;
  113906. /** Gets the vertices generated by the edge renderer */
  113907. get linesPositions(): Immutable<Array<number>>;
  113908. /** Gets the normals generated by the edge renderer */
  113909. get linesNormals(): Immutable<Array<number>>;
  113910. /** Gets the indices generated by the edge renderer */
  113911. get linesIndices(): Immutable<Array<number>>;
  113912. /**
  113913. * List of instances to render in case the source mesh has instances
  113914. */
  113915. customInstances: SmartArray<Matrix>;
  113916. private static GetShader;
  113917. /**
  113918. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  113919. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  113920. * @param source Mesh used to create edges
  113921. * @param epsilon sum of angles in adjacency to check for edge
  113922. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  113923. * @param generateEdgesLines - should generate Lines or only prepare resources.
  113924. * @param options The options to apply when generating the edges
  113925. */
  113926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  113927. protected _prepareRessources(): void;
  113928. /** @hidden */
  113929. _rebuild(): void;
  113930. /**
  113931. * Releases the required resources for the edges renderer
  113932. */
  113933. dispose(): void;
  113934. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  113935. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  113936. /**
  113937. * Checks if the pair of p0 and p1 is en edge
  113938. * @param faceIndex
  113939. * @param edge
  113940. * @param faceNormals
  113941. * @param p0
  113942. * @param p1
  113943. * @private
  113944. */
  113945. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  113946. /**
  113947. * push line into the position, normal and index buffer
  113948. * @protected
  113949. */
  113950. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  113951. /**
  113952. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  113953. */
  113954. private _tessellateTriangle;
  113955. private _generateEdgesLinesAlternate;
  113956. /**
  113957. * Generates lines edges from adjacencjes
  113958. * @private
  113959. */
  113960. _generateEdgesLines(): void;
  113961. /**
  113962. * Checks wether or not the edges renderer is ready to render.
  113963. * @return true if ready, otherwise false.
  113964. */
  113965. isReady(): boolean;
  113966. /**
  113967. * Renders the edges of the attached mesh,
  113968. */
  113969. render(): void;
  113970. }
  113971. /**
  113972. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  113973. */
  113974. export class LineEdgesRenderer extends EdgesRenderer {
  113975. /**
  113976. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  113977. * @param source LineMesh used to generate edges
  113978. * @param epsilon not important (specified angle for edge detection)
  113979. * @param checkVerticesInsteadOfIndices not important for LineMesh
  113980. */
  113981. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  113982. /**
  113983. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  113984. */
  113985. _generateEdgesLines(): void;
  113986. }
  113987. }
  113988. declare module BABYLON {
  113989. /**
  113990. * This represents the object necessary to create a rendering group.
  113991. * This is exclusively used and created by the rendering manager.
  113992. * To modify the behavior, you use the available helpers in your scene or meshes.
  113993. * @hidden
  113994. */
  113995. export class RenderingGroup {
  113996. index: number;
  113997. private static _zeroVector;
  113998. private _scene;
  113999. private _opaqueSubMeshes;
  114000. private _transparentSubMeshes;
  114001. private _alphaTestSubMeshes;
  114002. private _depthOnlySubMeshes;
  114003. private _particleSystems;
  114004. private _spriteManagers;
  114005. private _opaqueSortCompareFn;
  114006. private _alphaTestSortCompareFn;
  114007. private _transparentSortCompareFn;
  114008. private _renderOpaque;
  114009. private _renderAlphaTest;
  114010. private _renderTransparent;
  114011. /** @hidden */
  114012. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  114013. onBeforeTransparentRendering: () => void;
  114014. /**
  114015. * Set the opaque sort comparison function.
  114016. * If null the sub meshes will be render in the order they were created
  114017. */
  114018. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114019. /**
  114020. * Set the alpha test sort comparison function.
  114021. * If null the sub meshes will be render in the order they were created
  114022. */
  114023. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114024. /**
  114025. * Set the transparent sort comparison function.
  114026. * If null the sub meshes will be render in the order they were created
  114027. */
  114028. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114029. /**
  114030. * Creates a new rendering group.
  114031. * @param index The rendering group index
  114032. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  114033. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  114034. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  114035. */
  114036. 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>);
  114037. /**
  114038. * Render all the sub meshes contained in the group.
  114039. * @param customRenderFunction Used to override the default render behaviour of the group.
  114040. * @returns true if rendered some submeshes.
  114041. */
  114042. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  114043. /**
  114044. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  114045. * @param subMeshes The submeshes to render
  114046. */
  114047. private renderOpaqueSorted;
  114048. /**
  114049. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  114050. * @param subMeshes The submeshes to render
  114051. */
  114052. private renderAlphaTestSorted;
  114053. /**
  114054. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  114055. * @param subMeshes The submeshes to render
  114056. */
  114057. private renderTransparentSorted;
  114058. /**
  114059. * Renders the submeshes in a specified order.
  114060. * @param subMeshes The submeshes to sort before render
  114061. * @param sortCompareFn The comparison function use to sort
  114062. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  114063. * @param transparent Specifies to activate blending if true
  114064. */
  114065. private static renderSorted;
  114066. /**
  114067. * Renders the submeshes in the order they were dispatched (no sort applied).
  114068. * @param subMeshes The submeshes to render
  114069. */
  114070. private static renderUnsorted;
  114071. /**
  114072. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114073. * are rendered back to front if in the same alpha index.
  114074. *
  114075. * @param a The first submesh
  114076. * @param b The second submesh
  114077. * @returns The result of the comparison
  114078. */
  114079. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  114080. /**
  114081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114082. * are rendered back to front.
  114083. *
  114084. * @param a The first submesh
  114085. * @param b The second submesh
  114086. * @returns The result of the comparison
  114087. */
  114088. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  114089. /**
  114090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114091. * are rendered front to back (prevent overdraw).
  114092. *
  114093. * @param a The first submesh
  114094. * @param b The second submesh
  114095. * @returns The result of the comparison
  114096. */
  114097. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  114098. /**
  114099. * Resets the different lists of submeshes to prepare a new frame.
  114100. */
  114101. prepare(): void;
  114102. dispose(): void;
  114103. /**
  114104. * Inserts the submesh in its correct queue depending on its material.
  114105. * @param subMesh The submesh to dispatch
  114106. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  114107. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  114108. */
  114109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  114110. dispatchSprites(spriteManager: ISpriteManager): void;
  114111. dispatchParticles(particleSystem: IParticleSystem): void;
  114112. private _renderParticles;
  114113. private _renderSprites;
  114114. }
  114115. }
  114116. declare module BABYLON {
  114117. /**
  114118. * Interface describing the different options available in the rendering manager
  114119. * regarding Auto Clear between groups.
  114120. */
  114121. export interface IRenderingManagerAutoClearSetup {
  114122. /**
  114123. * Defines whether or not autoclear is enable.
  114124. */
  114125. autoClear: boolean;
  114126. /**
  114127. * Defines whether or not to autoclear the depth buffer.
  114128. */
  114129. depth: boolean;
  114130. /**
  114131. * Defines whether or not to autoclear the stencil buffer.
  114132. */
  114133. stencil: boolean;
  114134. }
  114135. /**
  114136. * This class is used by the onRenderingGroupObservable
  114137. */
  114138. export class RenderingGroupInfo {
  114139. /**
  114140. * The Scene that being rendered
  114141. */
  114142. scene: Scene;
  114143. /**
  114144. * The camera currently used for the rendering pass
  114145. */
  114146. camera: Nullable<Camera>;
  114147. /**
  114148. * The ID of the renderingGroup being processed
  114149. */
  114150. renderingGroupId: number;
  114151. }
  114152. /**
  114153. * This is the manager responsible of all the rendering for meshes sprites and particles.
  114154. * It is enable to manage the different groups as well as the different necessary sort functions.
  114155. * This should not be used directly aside of the few static configurations
  114156. */
  114157. export class RenderingManager {
  114158. /**
  114159. * The max id used for rendering groups (not included)
  114160. */
  114161. static MAX_RENDERINGGROUPS: number;
  114162. /**
  114163. * The min id used for rendering groups (included)
  114164. */
  114165. static MIN_RENDERINGGROUPS: number;
  114166. /**
  114167. * Used to globally prevent autoclearing scenes.
  114168. */
  114169. static AUTOCLEAR: boolean;
  114170. /**
  114171. * @hidden
  114172. */
  114173. _useSceneAutoClearSetup: boolean;
  114174. private _scene;
  114175. private _renderingGroups;
  114176. private _depthStencilBufferAlreadyCleaned;
  114177. private _autoClearDepthStencil;
  114178. private _customOpaqueSortCompareFn;
  114179. private _customAlphaTestSortCompareFn;
  114180. private _customTransparentSortCompareFn;
  114181. private _renderingGroupInfo;
  114182. /**
  114183. * Instantiates a new rendering group for a particular scene
  114184. * @param scene Defines the scene the groups belongs to
  114185. */
  114186. constructor(scene: Scene);
  114187. private _clearDepthStencilBuffer;
  114188. /**
  114189. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  114190. * @hidden
  114191. */
  114192. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  114193. /**
  114194. * Resets the different information of the group to prepare a new frame
  114195. * @hidden
  114196. */
  114197. reset(): void;
  114198. /**
  114199. * Dispose and release the group and its associated resources.
  114200. * @hidden
  114201. */
  114202. dispose(): void;
  114203. /**
  114204. * Clear the info related to rendering groups preventing retention points during dispose.
  114205. */
  114206. freeRenderingGroups(): void;
  114207. private _prepareRenderingGroup;
  114208. /**
  114209. * Add a sprite manager to the rendering manager in order to render it this frame.
  114210. * @param spriteManager Define the sprite manager to render
  114211. */
  114212. dispatchSprites(spriteManager: ISpriteManager): void;
  114213. /**
  114214. * Add a particle system to the rendering manager in order to render it this frame.
  114215. * @param particleSystem Define the particle system to render
  114216. */
  114217. dispatchParticles(particleSystem: IParticleSystem): void;
  114218. /**
  114219. * Add a submesh to the manager in order to render it this frame
  114220. * @param subMesh The submesh to dispatch
  114221. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  114222. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  114223. */
  114224. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  114225. /**
  114226. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  114227. * This allowed control for front to back rendering or reversly depending of the special needs.
  114228. *
  114229. * @param renderingGroupId The rendering group id corresponding to its index
  114230. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  114231. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  114232. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  114233. */
  114234. 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;
  114235. /**
  114236. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  114237. *
  114238. * @param renderingGroupId The rendering group id corresponding to its index
  114239. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114240. * @param depth Automatically clears depth between groups if true and autoClear is true.
  114241. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  114242. */
  114243. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  114244. /**
  114245. * Gets the current auto clear configuration for one rendering group of the rendering
  114246. * manager.
  114247. * @param index the rendering group index to get the information for
  114248. * @returns The auto clear setup for the requested rendering group
  114249. */
  114250. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  114251. }
  114252. }
  114253. declare module BABYLON {
  114254. /**
  114255. * Defines the options associated with the creation of a custom shader for a shadow generator.
  114256. */
  114257. export interface ICustomShaderOptions {
  114258. /**
  114259. * Gets or sets the custom shader name to use
  114260. */
  114261. shaderName: string;
  114262. /**
  114263. * The list of attribute names used in the shader
  114264. */
  114265. attributes?: string[];
  114266. /**
  114267. * The list of unifrom names used in the shader
  114268. */
  114269. uniforms?: string[];
  114270. /**
  114271. * The list of sampler names used in the shader
  114272. */
  114273. samplers?: string[];
  114274. /**
  114275. * The list of defines used in the shader
  114276. */
  114277. defines?: string[];
  114278. }
  114279. /**
  114280. * Interface to implement to create a shadow generator compatible with BJS.
  114281. */
  114282. export interface IShadowGenerator {
  114283. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114284. id: string;
  114285. /**
  114286. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114287. * @returns The render target texture if present otherwise, null
  114288. */
  114289. getShadowMap(): Nullable<RenderTargetTexture>;
  114290. /**
  114291. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114292. * @param subMesh The submesh we want to render in the shadow map
  114293. * @param useInstances Defines wether will draw in the map using instances
  114294. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114295. * @returns true if ready otherwise, false
  114296. */
  114297. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114298. /**
  114299. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114300. * @param defines Defines of the material we want to update
  114301. * @param lightIndex Index of the light in the enabled light list of the material
  114302. */
  114303. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  114304. /**
  114305. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  114306. * defined in the generator but impacting the effect).
  114307. * It implies the unifroms available on the materials are the standard BJS ones.
  114308. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  114309. * @param effect The effect we are binfing the information for
  114310. */
  114311. bindShadowLight(lightIndex: string, effect: Effect): void;
  114312. /**
  114313. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  114314. * (eq to shadow prjection matrix * light transform matrix)
  114315. * @returns The transform matrix used to create the shadow map
  114316. */
  114317. getTransformMatrix(): Matrix;
  114318. /**
  114319. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  114320. * Cube and 2D textures for instance.
  114321. */
  114322. recreateShadowMap(): void;
  114323. /**
  114324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114325. * @param onCompiled Callback triggered at the and of the effects compilation
  114326. * @param options Sets of optional options forcing the compilation with different modes
  114327. */
  114328. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114329. useInstances: boolean;
  114330. }>): void;
  114331. /**
  114332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114333. * @param options Sets of optional options forcing the compilation with different modes
  114334. * @returns A promise that resolves when the compilation completes
  114335. */
  114336. forceCompilationAsync(options?: Partial<{
  114337. useInstances: boolean;
  114338. }>): Promise<void>;
  114339. /**
  114340. * Serializes the shadow generator setup to a json object.
  114341. * @returns The serialized JSON object
  114342. */
  114343. serialize(): any;
  114344. /**
  114345. * Disposes the Shadow map and related Textures and effects.
  114346. */
  114347. dispose(): void;
  114348. }
  114349. /**
  114350. * Default implementation IShadowGenerator.
  114351. * This is the main object responsible of generating shadows in the framework.
  114352. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  114353. */
  114354. export class ShadowGenerator implements IShadowGenerator {
  114355. private static _Counter;
  114356. /**
  114357. * Name of the shadow generator class
  114358. */
  114359. static CLASSNAME: string;
  114360. /**
  114361. * Shadow generator mode None: no filtering applied.
  114362. */
  114363. static readonly FILTER_NONE: number;
  114364. /**
  114365. * Shadow generator mode ESM: Exponential Shadow Mapping.
  114366. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114367. */
  114368. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  114369. /**
  114370. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  114371. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  114372. */
  114373. static readonly FILTER_POISSONSAMPLING: number;
  114374. /**
  114375. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  114376. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114377. */
  114378. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  114379. /**
  114380. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  114381. * edge artifacts on steep falloff.
  114382. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114383. */
  114384. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  114385. /**
  114386. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  114387. * edge artifacts on steep falloff.
  114388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114389. */
  114390. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  114391. /**
  114392. * Shadow generator mode PCF: Percentage Closer Filtering
  114393. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  114394. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  114395. */
  114396. static readonly FILTER_PCF: number;
  114397. /**
  114398. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  114399. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  114400. * Contact Hardening
  114401. */
  114402. static readonly FILTER_PCSS: number;
  114403. /**
  114404. * Reserved for PCF and PCSS
  114405. * Highest Quality.
  114406. *
  114407. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  114408. *
  114409. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  114410. */
  114411. static readonly QUALITY_HIGH: number;
  114412. /**
  114413. * Reserved for PCF and PCSS
  114414. * Good tradeoff for quality/perf cross devices
  114415. *
  114416. * Execute PCF on a 3*3 kernel.
  114417. *
  114418. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  114419. */
  114420. static readonly QUALITY_MEDIUM: number;
  114421. /**
  114422. * Reserved for PCF and PCSS
  114423. * The lowest quality but the fastest.
  114424. *
  114425. * Execute PCF on a 1*1 kernel.
  114426. *
  114427. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  114428. */
  114429. static readonly QUALITY_LOW: number;
  114430. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114431. id: string;
  114432. /** Gets or sets the custom shader name to use */
  114433. customShaderOptions: ICustomShaderOptions;
  114434. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  114435. customAllowRendering: (subMesh: SubMesh) => boolean;
  114436. /**
  114437. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  114438. */
  114439. onBeforeShadowMapRenderObservable: Observable<Effect>;
  114440. /**
  114441. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  114442. */
  114443. onAfterShadowMapRenderObservable: Observable<Effect>;
  114444. /**
  114445. * Observable triggered before a mesh is rendered in the shadow map.
  114446. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  114447. */
  114448. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  114449. /**
  114450. * Observable triggered after a mesh is rendered in the shadow map.
  114451. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  114452. */
  114453. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  114454. protected _bias: number;
  114455. /**
  114456. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  114457. */
  114458. get bias(): number;
  114459. /**
  114460. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  114461. */
  114462. set bias(bias: number);
  114463. protected _normalBias: number;
  114464. /**
  114465. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114466. */
  114467. get normalBias(): number;
  114468. /**
  114469. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114470. */
  114471. set normalBias(normalBias: number);
  114472. protected _blurBoxOffset: number;
  114473. /**
  114474. * Gets the blur box offset: offset applied during the blur pass.
  114475. * Only useful if useKernelBlur = false
  114476. */
  114477. get blurBoxOffset(): number;
  114478. /**
  114479. * Sets the blur box offset: offset applied during the blur pass.
  114480. * Only useful if useKernelBlur = false
  114481. */
  114482. set blurBoxOffset(value: number);
  114483. protected _blurScale: number;
  114484. /**
  114485. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  114486. * 2 means half of the size.
  114487. */
  114488. get blurScale(): number;
  114489. /**
  114490. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  114491. * 2 means half of the size.
  114492. */
  114493. set blurScale(value: number);
  114494. protected _blurKernel: number;
  114495. /**
  114496. * Gets the blur kernel: kernel size of the blur pass.
  114497. * Only useful if useKernelBlur = true
  114498. */
  114499. get blurKernel(): number;
  114500. /**
  114501. * Sets the blur kernel: kernel size of the blur pass.
  114502. * Only useful if useKernelBlur = true
  114503. */
  114504. set blurKernel(value: number);
  114505. protected _useKernelBlur: boolean;
  114506. /**
  114507. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  114508. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114509. */
  114510. get useKernelBlur(): boolean;
  114511. /**
  114512. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  114513. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114514. */
  114515. set useKernelBlur(value: boolean);
  114516. protected _depthScale: number;
  114517. /**
  114518. * Gets the depth scale used in ESM mode.
  114519. */
  114520. get depthScale(): number;
  114521. /**
  114522. * Sets the depth scale used in ESM mode.
  114523. * This can override the scale stored on the light.
  114524. */
  114525. set depthScale(value: number);
  114526. protected _validateFilter(filter: number): number;
  114527. protected _filter: number;
  114528. /**
  114529. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  114530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114531. */
  114532. get filter(): number;
  114533. /**
  114534. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  114535. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114536. */
  114537. set filter(value: number);
  114538. /**
  114539. * Gets if the current filter is set to Poisson Sampling.
  114540. */
  114541. get usePoissonSampling(): boolean;
  114542. /**
  114543. * Sets the current filter to Poisson Sampling.
  114544. */
  114545. set usePoissonSampling(value: boolean);
  114546. /**
  114547. * Gets if the current filter is set to ESM.
  114548. */
  114549. get useExponentialShadowMap(): boolean;
  114550. /**
  114551. * Sets the current filter is to ESM.
  114552. */
  114553. set useExponentialShadowMap(value: boolean);
  114554. /**
  114555. * Gets if the current filter is set to filtered ESM.
  114556. */
  114557. get useBlurExponentialShadowMap(): boolean;
  114558. /**
  114559. * Gets if the current filter is set to filtered ESM.
  114560. */
  114561. set useBlurExponentialShadowMap(value: boolean);
  114562. /**
  114563. * Gets if the current filter is set to "close ESM" (using the inverse of the
  114564. * exponential to prevent steep falloff artifacts).
  114565. */
  114566. get useCloseExponentialShadowMap(): boolean;
  114567. /**
  114568. * Sets the current filter to "close ESM" (using the inverse of the
  114569. * exponential to prevent steep falloff artifacts).
  114570. */
  114571. set useCloseExponentialShadowMap(value: boolean);
  114572. /**
  114573. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  114574. * exponential to prevent steep falloff artifacts).
  114575. */
  114576. get useBlurCloseExponentialShadowMap(): boolean;
  114577. /**
  114578. * Sets the current filter to filtered "close ESM" (using the inverse of the
  114579. * exponential to prevent steep falloff artifacts).
  114580. */
  114581. set useBlurCloseExponentialShadowMap(value: boolean);
  114582. /**
  114583. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  114584. */
  114585. get usePercentageCloserFiltering(): boolean;
  114586. /**
  114587. * Sets the current filter to "PCF" (percentage closer filtering).
  114588. */
  114589. set usePercentageCloserFiltering(value: boolean);
  114590. protected _filteringQuality: number;
  114591. /**
  114592. * Gets the PCF or PCSS Quality.
  114593. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114594. */
  114595. get filteringQuality(): number;
  114596. /**
  114597. * Sets the PCF or PCSS Quality.
  114598. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114599. */
  114600. set filteringQuality(filteringQuality: number);
  114601. /**
  114602. * Gets if the current filter is set to "PCSS" (contact hardening).
  114603. */
  114604. get useContactHardeningShadow(): boolean;
  114605. /**
  114606. * Sets the current filter to "PCSS" (contact hardening).
  114607. */
  114608. set useContactHardeningShadow(value: boolean);
  114609. protected _contactHardeningLightSizeUVRatio: number;
  114610. /**
  114611. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114612. * Using a ratio helps keeping shape stability independently of the map size.
  114613. *
  114614. * It does not account for the light projection as it was having too much
  114615. * instability during the light setup or during light position changes.
  114616. *
  114617. * Only valid if useContactHardeningShadow is true.
  114618. */
  114619. get contactHardeningLightSizeUVRatio(): number;
  114620. /**
  114621. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114622. * Using a ratio helps keeping shape stability independently of the map size.
  114623. *
  114624. * It does not account for the light projection as it was having too much
  114625. * instability during the light setup or during light position changes.
  114626. *
  114627. * Only valid if useContactHardeningShadow is true.
  114628. */
  114629. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  114630. protected _darkness: number;
  114631. /** Gets or sets the actual darkness of a shadow */
  114632. get darkness(): number;
  114633. set darkness(value: number);
  114634. /**
  114635. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  114636. * 0 means strongest and 1 would means no shadow.
  114637. * @returns the darkness.
  114638. */
  114639. getDarkness(): number;
  114640. /**
  114641. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  114642. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  114643. * @returns the shadow generator allowing fluent coding.
  114644. */
  114645. setDarkness(darkness: number): ShadowGenerator;
  114646. protected _transparencyShadow: boolean;
  114647. /** Gets or sets the ability to have transparent shadow */
  114648. get transparencyShadow(): boolean;
  114649. set transparencyShadow(value: boolean);
  114650. /**
  114651. * Sets the ability to have transparent shadow (boolean).
  114652. * @param transparent True if transparent else False
  114653. * @returns the shadow generator allowing fluent coding
  114654. */
  114655. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  114656. /**
  114657. * Enables or disables shadows with varying strength based on the transparency
  114658. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  114659. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  114660. * mesh.visibility * alphaTexture.a
  114661. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  114662. */
  114663. enableSoftTransparentShadow: boolean;
  114664. protected _shadowMap: Nullable<RenderTargetTexture>;
  114665. protected _shadowMap2: Nullable<RenderTargetTexture>;
  114666. /**
  114667. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114668. * @returns The render target texture if present otherwise, null
  114669. */
  114670. getShadowMap(): Nullable<RenderTargetTexture>;
  114671. /**
  114672. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  114673. * @returns The render target texture if the shadow map is present otherwise, null
  114674. */
  114675. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  114676. /**
  114677. * Gets the class name of that object
  114678. * @returns "ShadowGenerator"
  114679. */
  114680. getClassName(): string;
  114681. /**
  114682. * Helper function to add a mesh and its descendants to the list of shadow casters.
  114683. * @param mesh Mesh to add
  114684. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  114685. * @returns the Shadow Generator itself
  114686. */
  114687. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114688. /**
  114689. * Helper function to remove a mesh and its descendants from the list of shadow casters
  114690. * @param mesh Mesh to remove
  114691. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  114692. * @returns the Shadow Generator itself
  114693. */
  114694. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114695. /**
  114696. * Controls the extent to which the shadows fade out at the edge of the frustum
  114697. */
  114698. frustumEdgeFalloff: number;
  114699. protected _light: IShadowLight;
  114700. /**
  114701. * Returns the associated light object.
  114702. * @returns the light generating the shadow
  114703. */
  114704. getLight(): IShadowLight;
  114705. /**
  114706. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  114707. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  114708. * It might on the other hand introduce peter panning.
  114709. */
  114710. forceBackFacesOnly: boolean;
  114711. protected _scene: Scene;
  114712. protected _lightDirection: Vector3;
  114713. protected _viewMatrix: Matrix;
  114714. protected _projectionMatrix: Matrix;
  114715. protected _transformMatrix: Matrix;
  114716. protected _cachedPosition: Vector3;
  114717. protected _cachedDirection: Vector3;
  114718. protected _cachedDefines: string;
  114719. protected _currentRenderID: number;
  114720. protected _boxBlurPostprocess: Nullable<PostProcess>;
  114721. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  114722. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  114723. protected _blurPostProcesses: PostProcess[];
  114724. protected _mapSize: number;
  114725. protected _currentFaceIndex: number;
  114726. protected _currentFaceIndexCache: number;
  114727. protected _textureType: number;
  114728. protected _defaultTextureMatrix: Matrix;
  114729. protected _storedUniqueId: Nullable<number>;
  114730. protected _nameForCustomEffect: string;
  114731. /** @hidden */
  114732. static _SceneComponentInitialization: (scene: Scene) => void;
  114733. /**
  114734. * Gets or sets the size of the texture what stores the shadows
  114735. */
  114736. get mapSize(): number;
  114737. set mapSize(size: number);
  114738. /**
  114739. * Creates a ShadowGenerator object.
  114740. * A ShadowGenerator is the required tool to use the shadows.
  114741. * Each light casting shadows needs to use its own ShadowGenerator.
  114742. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  114743. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  114744. * @param light The light object generating the shadows.
  114745. * @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.
  114746. */
  114747. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  114748. protected _initializeGenerator(): void;
  114749. protected _createTargetRenderTexture(): void;
  114750. protected _initializeShadowMap(): void;
  114751. protected _initializeBlurRTTAndPostProcesses(): void;
  114752. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  114753. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  114754. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  114755. protected _applyFilterValues(): void;
  114756. /**
  114757. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114758. * @param onCompiled Callback triggered at the and of the effects compilation
  114759. * @param options Sets of optional options forcing the compilation with different modes
  114760. */
  114761. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114762. useInstances: boolean;
  114763. }>): void;
  114764. /**
  114765. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114766. * @param options Sets of optional options forcing the compilation with different modes
  114767. * @returns A promise that resolves when the compilation completes
  114768. */
  114769. forceCompilationAsync(options?: Partial<{
  114770. useInstances: boolean;
  114771. }>): Promise<void>;
  114772. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  114773. private _prepareShadowDefines;
  114774. /**
  114775. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114776. * @param subMesh The submesh we want to render in the shadow map
  114777. * @param useInstances Defines wether will draw in the map using instances
  114778. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114779. * @returns true if ready otherwise, false
  114780. */
  114781. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114782. /**
  114783. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114784. * @param defines Defines of the material we want to update
  114785. * @param lightIndex Index of the light in the enabled light list of the material
  114786. */
  114787. prepareDefines(defines: any, lightIndex: number): void;
  114788. /**
  114789. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  114790. * defined in the generator but impacting the effect).
  114791. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  114792. * @param effect The effect we are binfing the information for
  114793. */
  114794. bindShadowLight(lightIndex: string, effect: Effect): void;
  114795. /**
  114796. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  114797. * (eq to shadow prjection matrix * light transform matrix)
  114798. * @returns The transform matrix used to create the shadow map
  114799. */
  114800. getTransformMatrix(): Matrix;
  114801. /**
  114802. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  114803. * Cube and 2D textures for instance.
  114804. */
  114805. recreateShadowMap(): void;
  114806. protected _disposeBlurPostProcesses(): void;
  114807. protected _disposeRTTandPostProcesses(): void;
  114808. /**
  114809. * Disposes the ShadowGenerator.
  114810. * Returns nothing.
  114811. */
  114812. dispose(): void;
  114813. /**
  114814. * Serializes the shadow generator setup to a json object.
  114815. * @returns The serialized JSON object
  114816. */
  114817. serialize(): any;
  114818. /**
  114819. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  114820. * @param parsedShadowGenerator The JSON object to parse
  114821. * @param scene The scene to create the shadow map for
  114822. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  114823. * @returns The parsed shadow generator
  114824. */
  114825. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  114826. }
  114827. }
  114828. declare module BABYLON {
  114829. /**
  114830. * Options to be used when creating a shadow depth material
  114831. */
  114832. export interface IIOptionShadowDepthMaterial {
  114833. /** Variables in the vertex shader code that need to have their names remapped.
  114834. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  114835. * "var_name" should be either: worldPos or vNormalW
  114836. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  114837. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  114838. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  114839. */
  114840. remappedVariables?: string[];
  114841. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  114842. standalone?: boolean;
  114843. }
  114844. /**
  114845. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  114846. */
  114847. export class ShadowDepthWrapper {
  114848. private _scene;
  114849. private _options?;
  114850. private _baseMaterial;
  114851. private _onEffectCreatedObserver;
  114852. private _subMeshToEffect;
  114853. private _subMeshToDepthEffect;
  114854. private _meshes;
  114855. /** @hidden */
  114856. _matriceNames: any;
  114857. /** Gets the standalone status of the wrapper */
  114858. get standalone(): boolean;
  114859. /** Gets the base material the wrapper is built upon */
  114860. get baseMaterial(): Material;
  114861. /**
  114862. * Instantiate a new shadow depth wrapper.
  114863. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  114864. * generate the shadow depth map. For more information, please refer to the documentation:
  114865. * https://doc.babylonjs.com/babylon101/shadows
  114866. * @param baseMaterial Material to wrap
  114867. * @param scene Define the scene the material belongs to
  114868. * @param options Options used to create the wrapper
  114869. */
  114870. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  114871. /**
  114872. * Gets the effect to use to generate the depth map
  114873. * @param subMesh subMesh to get the effect for
  114874. * @param shadowGenerator shadow generator to get the effect for
  114875. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  114876. */
  114877. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  114878. /**
  114879. * Specifies that the submesh is ready to be used for depth rendering
  114880. * @param subMesh submesh to check
  114881. * @param defines the list of defines to take into account when checking the effect
  114882. * @param shadowGenerator combined with subMesh, it defines the effect to check
  114883. * @param useInstances specifies that instances should be used
  114884. * @returns a boolean indicating that the submesh is ready or not
  114885. */
  114886. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  114887. /**
  114888. * Disposes the resources
  114889. */
  114890. dispose(): void;
  114891. private _makeEffect;
  114892. }
  114893. }
  114894. declare module BABYLON {
  114895. /**
  114896. * Options for compiling materials.
  114897. */
  114898. export interface IMaterialCompilationOptions {
  114899. /**
  114900. * Defines whether clip planes are enabled.
  114901. */
  114902. clipPlane: boolean;
  114903. /**
  114904. * Defines whether instances are enabled.
  114905. */
  114906. useInstances: boolean;
  114907. }
  114908. /**
  114909. * Options passed when calling customShaderNameResolve
  114910. */
  114911. export interface ICustomShaderNameResolveOptions {
  114912. /**
  114913. * 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
  114914. */
  114915. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114916. }
  114917. /**
  114918. * Base class for the main features of a material in Babylon.js
  114919. */
  114920. export class Material implements IAnimatable {
  114921. /**
  114922. * Returns the triangle fill mode
  114923. */
  114924. static readonly TriangleFillMode: number;
  114925. /**
  114926. * Returns the wireframe mode
  114927. */
  114928. static readonly WireFrameFillMode: number;
  114929. /**
  114930. * Returns the point fill mode
  114931. */
  114932. static readonly PointFillMode: number;
  114933. /**
  114934. * Returns the point list draw mode
  114935. */
  114936. static readonly PointListDrawMode: number;
  114937. /**
  114938. * Returns the line list draw mode
  114939. */
  114940. static readonly LineListDrawMode: number;
  114941. /**
  114942. * Returns the line loop draw mode
  114943. */
  114944. static readonly LineLoopDrawMode: number;
  114945. /**
  114946. * Returns the line strip draw mode
  114947. */
  114948. static readonly LineStripDrawMode: number;
  114949. /**
  114950. * Returns the triangle strip draw mode
  114951. */
  114952. static readonly TriangleStripDrawMode: number;
  114953. /**
  114954. * Returns the triangle fan draw mode
  114955. */
  114956. static readonly TriangleFanDrawMode: number;
  114957. /**
  114958. * Stores the clock-wise side orientation
  114959. */
  114960. static readonly ClockWiseSideOrientation: number;
  114961. /**
  114962. * Stores the counter clock-wise side orientation
  114963. */
  114964. static readonly CounterClockWiseSideOrientation: number;
  114965. /**
  114966. * The dirty texture flag value
  114967. */
  114968. static readonly TextureDirtyFlag: number;
  114969. /**
  114970. * The dirty light flag value
  114971. */
  114972. static readonly LightDirtyFlag: number;
  114973. /**
  114974. * The dirty fresnel flag value
  114975. */
  114976. static readonly FresnelDirtyFlag: number;
  114977. /**
  114978. * The dirty attribute flag value
  114979. */
  114980. static readonly AttributesDirtyFlag: number;
  114981. /**
  114982. * The dirty misc flag value
  114983. */
  114984. static readonly MiscDirtyFlag: number;
  114985. /**
  114986. * The dirty prepass flag value
  114987. */
  114988. static readonly PrePassDirtyFlag: number;
  114989. /**
  114990. * The all dirty flag value
  114991. */
  114992. static readonly AllDirtyFlag: number;
  114993. /**
  114994. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114995. */
  114996. static readonly MATERIAL_OPAQUE: number;
  114997. /**
  114998. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114999. */
  115000. static readonly MATERIAL_ALPHATEST: number;
  115001. /**
  115002. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115003. */
  115004. static readonly MATERIAL_ALPHABLEND: number;
  115005. /**
  115006. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115007. * They are also discarded below the alpha cutoff threshold to improve performances.
  115008. */
  115009. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  115010. /**
  115011. * The Whiteout method is used to blend normals.
  115012. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115013. */
  115014. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  115015. /**
  115016. * The Reoriented Normal Mapping method is used to blend normals.
  115017. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115018. */
  115019. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  115020. /**
  115021. * Custom callback helping to override the default shader used in the material.
  115022. */
  115023. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  115024. /**
  115025. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  115026. */
  115027. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  115028. /**
  115029. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  115030. * This means that the material can keep using a previous shader while a new one is being compiled.
  115031. * This is mostly used when shader parallel compilation is supported (true by default)
  115032. */
  115033. allowShaderHotSwapping: boolean;
  115034. /**
  115035. * The ID of the material
  115036. */
  115037. id: string;
  115038. /**
  115039. * Gets or sets the unique id of the material
  115040. */
  115041. uniqueId: number;
  115042. /**
  115043. * The name of the material
  115044. */
  115045. name: string;
  115046. /**
  115047. * Gets or sets user defined metadata
  115048. */
  115049. metadata: any;
  115050. /**
  115051. * For internal use only. Please do not use.
  115052. */
  115053. reservedDataStore: any;
  115054. /**
  115055. * Specifies if the ready state should be checked on each call
  115056. */
  115057. checkReadyOnEveryCall: boolean;
  115058. /**
  115059. * Specifies if the ready state should be checked once
  115060. */
  115061. checkReadyOnlyOnce: boolean;
  115062. /**
  115063. * The state of the material
  115064. */
  115065. state: string;
  115066. /**
  115067. * If the material can be rendered to several textures with MRT extension
  115068. */
  115069. get canRenderToMRT(): boolean;
  115070. /**
  115071. * The alpha value of the material
  115072. */
  115073. protected _alpha: number;
  115074. /**
  115075. * List of inspectable custom properties (used by the Inspector)
  115076. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  115077. */
  115078. inspectableCustomProperties: IInspectable[];
  115079. /**
  115080. * Sets the alpha value of the material
  115081. */
  115082. set alpha(value: number);
  115083. /**
  115084. * Gets the alpha value of the material
  115085. */
  115086. get alpha(): number;
  115087. /**
  115088. * Specifies if back face culling is enabled
  115089. */
  115090. protected _backFaceCulling: boolean;
  115091. /**
  115092. * Sets the back-face culling state
  115093. */
  115094. set backFaceCulling(value: boolean);
  115095. /**
  115096. * Gets the back-face culling state
  115097. */
  115098. get backFaceCulling(): boolean;
  115099. /**
  115100. * Stores the value for side orientation
  115101. */
  115102. sideOrientation: number;
  115103. /**
  115104. * Callback triggered when the material is compiled
  115105. */
  115106. onCompiled: Nullable<(effect: Effect) => void>;
  115107. /**
  115108. * Callback triggered when an error occurs
  115109. */
  115110. onError: Nullable<(effect: Effect, errors: string) => void>;
  115111. /**
  115112. * Callback triggered to get the render target textures
  115113. */
  115114. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  115115. /**
  115116. * Gets a boolean indicating that current material needs to register RTT
  115117. */
  115118. get hasRenderTargetTextures(): boolean;
  115119. /**
  115120. * Specifies if the material should be serialized
  115121. */
  115122. doNotSerialize: boolean;
  115123. /**
  115124. * @hidden
  115125. */
  115126. _storeEffectOnSubMeshes: boolean;
  115127. /**
  115128. * Stores the animations for the material
  115129. */
  115130. animations: Nullable<Array<Animation>>;
  115131. /**
  115132. * An event triggered when the material is disposed
  115133. */
  115134. onDisposeObservable: Observable<Material>;
  115135. /**
  115136. * An observer which watches for dispose events
  115137. */
  115138. private _onDisposeObserver;
  115139. private _onUnBindObservable;
  115140. /**
  115141. * Called during a dispose event
  115142. */
  115143. set onDispose(callback: () => void);
  115144. private _onBindObservable;
  115145. /**
  115146. * An event triggered when the material is bound
  115147. */
  115148. get onBindObservable(): Observable<AbstractMesh>;
  115149. /**
  115150. * An observer which watches for bind events
  115151. */
  115152. private _onBindObserver;
  115153. /**
  115154. * Called during a bind event
  115155. */
  115156. set onBind(callback: (Mesh: AbstractMesh) => void);
  115157. /**
  115158. * An event triggered when the material is unbound
  115159. */
  115160. get onUnBindObservable(): Observable<Material>;
  115161. protected _onEffectCreatedObservable: Nullable<Observable<{
  115162. effect: Effect;
  115163. subMesh: Nullable<SubMesh>;
  115164. }>>;
  115165. /**
  115166. * An event triggered when the effect is (re)created
  115167. */
  115168. get onEffectCreatedObservable(): Observable<{
  115169. effect: Effect;
  115170. subMesh: Nullable<SubMesh>;
  115171. }>;
  115172. /**
  115173. * Stores the value of the alpha mode
  115174. */
  115175. private _alphaMode;
  115176. /**
  115177. * Sets the value of the alpha mode.
  115178. *
  115179. * | Value | Type | Description |
  115180. * | --- | --- | --- |
  115181. * | 0 | ALPHA_DISABLE | |
  115182. * | 1 | ALPHA_ADD | |
  115183. * | 2 | ALPHA_COMBINE | |
  115184. * | 3 | ALPHA_SUBTRACT | |
  115185. * | 4 | ALPHA_MULTIPLY | |
  115186. * | 5 | ALPHA_MAXIMIZED | |
  115187. * | 6 | ALPHA_ONEONE | |
  115188. * | 7 | ALPHA_PREMULTIPLIED | |
  115189. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  115190. * | 9 | ALPHA_INTERPOLATE | |
  115191. * | 10 | ALPHA_SCREENMODE | |
  115192. *
  115193. */
  115194. set alphaMode(value: number);
  115195. /**
  115196. * Gets the value of the alpha mode
  115197. */
  115198. get alphaMode(): number;
  115199. /**
  115200. * Stores the state of the need depth pre-pass value
  115201. */
  115202. private _needDepthPrePass;
  115203. /**
  115204. * Sets the need depth pre-pass value
  115205. */
  115206. set needDepthPrePass(value: boolean);
  115207. /**
  115208. * Gets the depth pre-pass value
  115209. */
  115210. get needDepthPrePass(): boolean;
  115211. /**
  115212. * Specifies if depth writing should be disabled
  115213. */
  115214. disableDepthWrite: boolean;
  115215. /**
  115216. * Specifies if color writing should be disabled
  115217. */
  115218. disableColorWrite: boolean;
  115219. /**
  115220. * Specifies if depth writing should be forced
  115221. */
  115222. forceDepthWrite: boolean;
  115223. /**
  115224. * Specifies the depth function that should be used. 0 means the default engine function
  115225. */
  115226. depthFunction: number;
  115227. /**
  115228. * Specifies if there should be a separate pass for culling
  115229. */
  115230. separateCullingPass: boolean;
  115231. /**
  115232. * Stores the state specifing if fog should be enabled
  115233. */
  115234. private _fogEnabled;
  115235. /**
  115236. * Sets the state for enabling fog
  115237. */
  115238. set fogEnabled(value: boolean);
  115239. /**
  115240. * Gets the value of the fog enabled state
  115241. */
  115242. get fogEnabled(): boolean;
  115243. /**
  115244. * Stores the size of points
  115245. */
  115246. pointSize: number;
  115247. /**
  115248. * Stores the z offset value
  115249. */
  115250. zOffset: number;
  115251. get wireframe(): boolean;
  115252. /**
  115253. * Sets the state of wireframe mode
  115254. */
  115255. set wireframe(value: boolean);
  115256. /**
  115257. * Gets the value specifying if point clouds are enabled
  115258. */
  115259. get pointsCloud(): boolean;
  115260. /**
  115261. * Sets the state of point cloud mode
  115262. */
  115263. set pointsCloud(value: boolean);
  115264. /**
  115265. * Gets the material fill mode
  115266. */
  115267. get fillMode(): number;
  115268. /**
  115269. * Sets the material fill mode
  115270. */
  115271. set fillMode(value: number);
  115272. /**
  115273. * @hidden
  115274. * Stores the effects for the material
  115275. */
  115276. _effect: Nullable<Effect>;
  115277. /**
  115278. * Specifies if uniform buffers should be used
  115279. */
  115280. private _useUBO;
  115281. /**
  115282. * Stores a reference to the scene
  115283. */
  115284. private _scene;
  115285. private _needToBindSceneUbo;
  115286. /**
  115287. * Stores the fill mode state
  115288. */
  115289. private _fillMode;
  115290. /**
  115291. * Specifies if the depth write state should be cached
  115292. */
  115293. private _cachedDepthWriteState;
  115294. /**
  115295. * Specifies if the color write state should be cached
  115296. */
  115297. private _cachedColorWriteState;
  115298. /**
  115299. * Specifies if the depth function state should be cached
  115300. */
  115301. private _cachedDepthFunctionState;
  115302. /**
  115303. * Stores the uniform buffer
  115304. */
  115305. protected _uniformBuffer: UniformBuffer;
  115306. /** @hidden */
  115307. _indexInSceneMaterialArray: number;
  115308. /** @hidden */
  115309. meshMap: Nullable<{
  115310. [id: string]: AbstractMesh | undefined;
  115311. }>;
  115312. /**
  115313. * Creates a material instance
  115314. * @param name defines the name of the material
  115315. * @param scene defines the scene to reference
  115316. * @param doNotAdd specifies if the material should be added to the scene
  115317. */
  115318. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  115319. /**
  115320. * Returns a string representation of the current material
  115321. * @param fullDetails defines a boolean indicating which levels of logging is desired
  115322. * @returns a string with material information
  115323. */
  115324. toString(fullDetails?: boolean): string;
  115325. /**
  115326. * Gets the class name of the material
  115327. * @returns a string with the class name of the material
  115328. */
  115329. getClassName(): string;
  115330. /**
  115331. * Specifies if updates for the material been locked
  115332. */
  115333. get isFrozen(): boolean;
  115334. /**
  115335. * Locks updates for the material
  115336. */
  115337. freeze(): void;
  115338. /**
  115339. * Unlocks updates for the material
  115340. */
  115341. unfreeze(): void;
  115342. /**
  115343. * Specifies if the material is ready to be used
  115344. * @param mesh defines the mesh to check
  115345. * @param useInstances specifies if instances should be used
  115346. * @returns a boolean indicating if the material is ready to be used
  115347. */
  115348. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  115349. /**
  115350. * Specifies that the submesh is ready to be used
  115351. * @param mesh defines the mesh to check
  115352. * @param subMesh defines which submesh to check
  115353. * @param useInstances specifies that instances should be used
  115354. * @returns a boolean indicating that the submesh is ready or not
  115355. */
  115356. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115357. /**
  115358. * Returns the material effect
  115359. * @returns the effect associated with the material
  115360. */
  115361. getEffect(): Nullable<Effect>;
  115362. /**
  115363. * Returns the current scene
  115364. * @returns a Scene
  115365. */
  115366. getScene(): Scene;
  115367. /**
  115368. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115369. */
  115370. protected _forceAlphaTest: boolean;
  115371. /**
  115372. * The transparency mode of the material.
  115373. */
  115374. protected _transparencyMode: Nullable<number>;
  115375. /**
  115376. * Gets the current transparency mode.
  115377. */
  115378. get transparencyMode(): Nullable<number>;
  115379. /**
  115380. * Sets the transparency mode of the material.
  115381. *
  115382. * | Value | Type | Description |
  115383. * | ----- | ----------------------------------- | ----------- |
  115384. * | 0 | OPAQUE | |
  115385. * | 1 | ALPHATEST | |
  115386. * | 2 | ALPHABLEND | |
  115387. * | 3 | ALPHATESTANDBLEND | |
  115388. *
  115389. */
  115390. set transparencyMode(value: Nullable<number>);
  115391. /**
  115392. * Returns true if alpha blending should be disabled.
  115393. */
  115394. protected get _disableAlphaBlending(): boolean;
  115395. /**
  115396. * Specifies whether or not this material should be rendered in alpha blend mode.
  115397. * @returns a boolean specifying if alpha blending is needed
  115398. */
  115399. needAlphaBlending(): boolean;
  115400. /**
  115401. * Specifies if the mesh will require alpha blending
  115402. * @param mesh defines the mesh to check
  115403. * @returns a boolean specifying if alpha blending is needed for the mesh
  115404. */
  115405. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115406. /**
  115407. * Specifies whether or not this material should be rendered in alpha test mode.
  115408. * @returns a boolean specifying if an alpha test is needed.
  115409. */
  115410. needAlphaTesting(): boolean;
  115411. /**
  115412. * Specifies if material alpha testing should be turned on for the mesh
  115413. * @param mesh defines the mesh to check
  115414. */
  115415. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  115416. /**
  115417. * Gets the texture used for the alpha test
  115418. * @returns the texture to use for alpha testing
  115419. */
  115420. getAlphaTestTexture(): Nullable<BaseTexture>;
  115421. /**
  115422. * Marks the material to indicate that it needs to be re-calculated
  115423. */
  115424. markDirty(): void;
  115425. /** @hidden */
  115426. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  115427. /**
  115428. * Binds the material to the mesh
  115429. * @param world defines the world transformation matrix
  115430. * @param mesh defines the mesh to bind the material to
  115431. */
  115432. bind(world: Matrix, mesh?: Mesh): void;
  115433. /**
  115434. * Binds the submesh to the material
  115435. * @param world defines the world transformation matrix
  115436. * @param mesh defines the mesh containing the submesh
  115437. * @param subMesh defines the submesh to bind the material to
  115438. */
  115439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115440. /**
  115441. * Binds the world matrix to the material
  115442. * @param world defines the world transformation matrix
  115443. */
  115444. bindOnlyWorldMatrix(world: Matrix): void;
  115445. /**
  115446. * Update the scene ubo before it can be used in rendering processing
  115447. * @param scene the scene to retrieve the ubo from
  115448. * @returns the scene UniformBuffer
  115449. */
  115450. finalizeSceneUbo(scene: Scene): UniformBuffer;
  115451. /**
  115452. * Binds the scene's uniform buffer to the effect.
  115453. * @param effect defines the effect to bind to the scene uniform buffer
  115454. * @param sceneUbo defines the uniform buffer storing scene data
  115455. */
  115456. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  115457. /**
  115458. * Binds the view matrix to the effect
  115459. * @param effect defines the effect to bind the view matrix to
  115460. */
  115461. bindView(effect: Effect): void;
  115462. /**
  115463. * Binds the view projection and projection matrices to the effect
  115464. * @param effect defines the effect to bind the view projection and projection matrices to
  115465. */
  115466. bindViewProjection(effect: Effect): void;
  115467. /**
  115468. * Binds the view matrix to the effect
  115469. * @param effect defines the effect to bind the view matrix to
  115470. * @param variableName name of the shader variable that will hold the eye position
  115471. */
  115472. bindEyePosition(effect: Effect, variableName?: string): void;
  115473. /**
  115474. * Processes to execute after binding the material to a mesh
  115475. * @param mesh defines the rendered mesh
  115476. */
  115477. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  115478. /**
  115479. * Unbinds the material from the mesh
  115480. */
  115481. unbind(): void;
  115482. /**
  115483. * Gets the active textures from the material
  115484. * @returns an array of textures
  115485. */
  115486. getActiveTextures(): BaseTexture[];
  115487. /**
  115488. * Specifies if the material uses a texture
  115489. * @param texture defines the texture to check against the material
  115490. * @returns a boolean specifying if the material uses the texture
  115491. */
  115492. hasTexture(texture: BaseTexture): boolean;
  115493. /**
  115494. * Makes a duplicate of the material, and gives it a new name
  115495. * @param name defines the new name for the duplicated material
  115496. * @returns the cloned material
  115497. */
  115498. clone(name: string): Nullable<Material>;
  115499. /**
  115500. * Gets the meshes bound to the material
  115501. * @returns an array of meshes bound to the material
  115502. */
  115503. getBindedMeshes(): AbstractMesh[];
  115504. /**
  115505. * Force shader compilation
  115506. * @param mesh defines the mesh associated with this material
  115507. * @param onCompiled defines a function to execute once the material is compiled
  115508. * @param options defines the options to configure the compilation
  115509. * @param onError defines a function to execute if the material fails compiling
  115510. */
  115511. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  115512. /**
  115513. * Force shader compilation
  115514. * @param mesh defines the mesh that will use this material
  115515. * @param options defines additional options for compiling the shaders
  115516. * @returns a promise that resolves when the compilation completes
  115517. */
  115518. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  115519. private static readonly _AllDirtyCallBack;
  115520. private static readonly _ImageProcessingDirtyCallBack;
  115521. private static readonly _TextureDirtyCallBack;
  115522. private static readonly _FresnelDirtyCallBack;
  115523. private static readonly _MiscDirtyCallBack;
  115524. private static readonly _PrePassDirtyCallBack;
  115525. private static readonly _LightsDirtyCallBack;
  115526. private static readonly _AttributeDirtyCallBack;
  115527. private static _FresnelAndMiscDirtyCallBack;
  115528. private static _TextureAndMiscDirtyCallBack;
  115529. private static readonly _DirtyCallbackArray;
  115530. private static readonly _RunDirtyCallBacks;
  115531. /**
  115532. * Marks a define in the material to indicate that it needs to be re-computed
  115533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  115534. */
  115535. markAsDirty(flag: number): void;
  115536. /**
  115537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  115538. * @param func defines a function which checks material defines against the submeshes
  115539. */
  115540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  115541. /**
  115542. * Indicates that the scene should check if the rendering now needs a prepass
  115543. */
  115544. protected _markScenePrePassDirty(): void;
  115545. /**
  115546. * Indicates that we need to re-calculated for all submeshes
  115547. */
  115548. protected _markAllSubMeshesAsAllDirty(): void;
  115549. /**
  115550. * Indicates that image processing needs to be re-calculated for all submeshes
  115551. */
  115552. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  115553. /**
  115554. * Indicates that textures need to be re-calculated for all submeshes
  115555. */
  115556. protected _markAllSubMeshesAsTexturesDirty(): void;
  115557. /**
  115558. * Indicates that fresnel needs to be re-calculated for all submeshes
  115559. */
  115560. protected _markAllSubMeshesAsFresnelDirty(): void;
  115561. /**
  115562. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  115563. */
  115564. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  115565. /**
  115566. * Indicates that lights need to be re-calculated for all submeshes
  115567. */
  115568. protected _markAllSubMeshesAsLightsDirty(): void;
  115569. /**
  115570. * Indicates that attributes need to be re-calculated for all submeshes
  115571. */
  115572. protected _markAllSubMeshesAsAttributesDirty(): void;
  115573. /**
  115574. * Indicates that misc needs to be re-calculated for all submeshes
  115575. */
  115576. protected _markAllSubMeshesAsMiscDirty(): void;
  115577. /**
  115578. * Indicates that prepass needs to be re-calculated for all submeshes
  115579. */
  115580. protected _markAllSubMeshesAsPrePassDirty(): void;
  115581. /**
  115582. * Indicates that textures and misc need to be re-calculated for all submeshes
  115583. */
  115584. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  115585. /**
  115586. * Sets the required values to the prepass renderer.
  115587. * @param prePassRenderer defines the prepass renderer to setup.
  115588. * @returns true if the pre pass is needed.
  115589. */
  115590. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  115591. /**
  115592. * Disposes the material
  115593. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115594. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115595. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115596. */
  115597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115598. /** @hidden */
  115599. private releaseVertexArrayObject;
  115600. /**
  115601. * Serializes this material
  115602. * @returns the serialized material object
  115603. */
  115604. serialize(): any;
  115605. /**
  115606. * Creates a material from parsed material data
  115607. * @param parsedMaterial defines parsed material data
  115608. * @param scene defines the hosting scene
  115609. * @param rootUrl defines the root URL to use to load textures
  115610. * @returns a new material
  115611. */
  115612. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  115613. }
  115614. }
  115615. declare module BABYLON {
  115616. /**
  115617. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115618. * separate meshes. This can be use to improve performances.
  115619. * @see https://doc.babylonjs.com/how_to/multi_materials
  115620. */
  115621. export class MultiMaterial extends Material {
  115622. private _subMaterials;
  115623. /**
  115624. * Gets or Sets the list of Materials used within the multi material.
  115625. * They need to be ordered according to the submeshes order in the associated mesh
  115626. */
  115627. get subMaterials(): Nullable<Material>[];
  115628. set subMaterials(value: Nullable<Material>[]);
  115629. /**
  115630. * Function used to align with Node.getChildren()
  115631. * @returns the list of Materials used within the multi material
  115632. */
  115633. getChildren(): Nullable<Material>[];
  115634. /**
  115635. * Instantiates a new Multi Material
  115636. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115637. * separate meshes. This can be use to improve performances.
  115638. * @see https://doc.babylonjs.com/how_to/multi_materials
  115639. * @param name Define the name in the scene
  115640. * @param scene Define the scene the material belongs to
  115641. */
  115642. constructor(name: string, scene: Scene);
  115643. private _hookArray;
  115644. /**
  115645. * Get one of the submaterial by its index in the submaterials array
  115646. * @param index The index to look the sub material at
  115647. * @returns The Material if the index has been defined
  115648. */
  115649. getSubMaterial(index: number): Nullable<Material>;
  115650. /**
  115651. * Get the list of active textures for the whole sub materials list.
  115652. * @returns All the textures that will be used during the rendering
  115653. */
  115654. getActiveTextures(): BaseTexture[];
  115655. /**
  115656. * Specifies if any sub-materials of this multi-material use a given texture.
  115657. * @param texture Defines the texture to check against this multi-material's sub-materials.
  115658. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  115659. */
  115660. hasTexture(texture: BaseTexture): boolean;
  115661. /**
  115662. * Gets the current class name of the material e.g. "MultiMaterial"
  115663. * Mainly use in serialization.
  115664. * @returns the class name
  115665. */
  115666. getClassName(): string;
  115667. /**
  115668. * Checks if the material is ready to render the requested sub mesh
  115669. * @param mesh Define the mesh the submesh belongs to
  115670. * @param subMesh Define the sub mesh to look readyness for
  115671. * @param useInstances Define whether or not the material is used with instances
  115672. * @returns true if ready, otherwise false
  115673. */
  115674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115675. /**
  115676. * Clones the current material and its related sub materials
  115677. * @param name Define the name of the newly cloned material
  115678. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  115679. * @returns the cloned material
  115680. */
  115681. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  115682. /**
  115683. * Serializes the materials into a JSON representation.
  115684. * @returns the JSON representation
  115685. */
  115686. serialize(): any;
  115687. /**
  115688. * Dispose the material and release its associated resources
  115689. * @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)
  115690. * @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)
  115691. * @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)
  115692. */
  115693. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  115694. /**
  115695. * Creates a MultiMaterial from parsed MultiMaterial data.
  115696. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  115697. * @param scene defines the hosting scene
  115698. * @returns a new MultiMaterial
  115699. */
  115700. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  115701. }
  115702. }
  115703. declare module BABYLON {
  115704. /** @hidden */
  115705. export interface ICustomEffect {
  115706. effect: Effect;
  115707. defines: string;
  115708. }
  115709. /**
  115710. * Defines a subdivision inside a mesh
  115711. */
  115712. export class SubMesh implements ICullable {
  115713. /** the material index to use */
  115714. materialIndex: number;
  115715. /** vertex index start */
  115716. verticesStart: number;
  115717. /** vertices count */
  115718. verticesCount: number;
  115719. /** index start */
  115720. indexStart: number;
  115721. /** indices count */
  115722. indexCount: number;
  115723. /** @hidden */
  115724. _materialDefines: Nullable<MaterialDefines>;
  115725. /** @hidden */
  115726. _materialEffect: Nullable<Effect>;
  115727. /** @hidden */
  115728. _effectOverride: Nullable<Effect>;
  115729. private _customEffects;
  115730. /**
  115731. * Gets material defines used by the effect associated to the sub mesh
  115732. */
  115733. get materialDefines(): Nullable<MaterialDefines>;
  115734. /**
  115735. * Sets material defines used by the effect associated to the sub mesh
  115736. */
  115737. set materialDefines(defines: Nullable<MaterialDefines>);
  115738. /** @hidden */
  115739. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  115740. /** @hidden */
  115741. _removeCustomEffect(name: string): void;
  115742. /**
  115743. * Gets associated effect
  115744. */
  115745. get effect(): Nullable<Effect>;
  115746. /**
  115747. * Sets associated effect (effect used to render this submesh)
  115748. * @param effect defines the effect to associate with
  115749. * @param defines defines the set of defines used to compile this effect
  115750. */
  115751. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  115752. /** @hidden */
  115753. _linesIndexCount: number;
  115754. private _mesh;
  115755. private _renderingMesh;
  115756. private _boundingInfo;
  115757. private _linesIndexBuffer;
  115758. /** @hidden */
  115759. _lastColliderWorldVertices: Nullable<Vector3[]>;
  115760. /** @hidden */
  115761. _trianglePlanes: Plane[];
  115762. /** @hidden */
  115763. _lastColliderTransformMatrix: Nullable<Matrix>;
  115764. /** @hidden */
  115765. _renderId: number;
  115766. /** @hidden */
  115767. _alphaIndex: number;
  115768. /** @hidden */
  115769. _distanceToCamera: number;
  115770. /** @hidden */
  115771. _id: number;
  115772. private _currentMaterial;
  115773. /**
  115774. * Add a new submesh to a mesh
  115775. * @param materialIndex defines the material index to use
  115776. * @param verticesStart defines vertex index start
  115777. * @param verticesCount defines vertices count
  115778. * @param indexStart defines index start
  115779. * @param indexCount defines indices count
  115780. * @param mesh defines the parent mesh
  115781. * @param renderingMesh defines an optional rendering mesh
  115782. * @param createBoundingBox defines if bounding box should be created for this submesh
  115783. * @returns the new submesh
  115784. */
  115785. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  115786. /**
  115787. * Creates a new submesh
  115788. * @param materialIndex defines the material index to use
  115789. * @param verticesStart defines vertex index start
  115790. * @param verticesCount defines vertices count
  115791. * @param indexStart defines index start
  115792. * @param indexCount defines indices count
  115793. * @param mesh defines the parent mesh
  115794. * @param renderingMesh defines an optional rendering mesh
  115795. * @param createBoundingBox defines if bounding box should be created for this submesh
  115796. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  115797. */
  115798. constructor(
  115799. /** the material index to use */
  115800. materialIndex: number,
  115801. /** vertex index start */
  115802. verticesStart: number,
  115803. /** vertices count */
  115804. verticesCount: number,
  115805. /** index start */
  115806. indexStart: number,
  115807. /** indices count */
  115808. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  115809. /**
  115810. * Returns true if this submesh covers the entire parent mesh
  115811. * @ignorenaming
  115812. */
  115813. get IsGlobal(): boolean;
  115814. /**
  115815. * Returns the submesh BoudingInfo object
  115816. * @returns current bounding info (or mesh's one if the submesh is global)
  115817. */
  115818. getBoundingInfo(): BoundingInfo;
  115819. /**
  115820. * Sets the submesh BoundingInfo
  115821. * @param boundingInfo defines the new bounding info to use
  115822. * @returns the SubMesh
  115823. */
  115824. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  115825. /**
  115826. * Returns the mesh of the current submesh
  115827. * @return the parent mesh
  115828. */
  115829. getMesh(): AbstractMesh;
  115830. /**
  115831. * Returns the rendering mesh of the submesh
  115832. * @returns the rendering mesh (could be different from parent mesh)
  115833. */
  115834. getRenderingMesh(): Mesh;
  115835. /**
  115836. * Returns the replacement mesh of the submesh
  115837. * @returns the replacement mesh (could be different from parent mesh)
  115838. */
  115839. getReplacementMesh(): Nullable<AbstractMesh>;
  115840. /**
  115841. * Returns the effective mesh of the submesh
  115842. * @returns the effective mesh (could be different from parent mesh)
  115843. */
  115844. getEffectiveMesh(): AbstractMesh;
  115845. /**
  115846. * Returns the submesh material
  115847. * @returns null or the current material
  115848. */
  115849. getMaterial(): Nullable<Material>;
  115850. private _IsMultiMaterial;
  115851. /**
  115852. * Sets a new updated BoundingInfo object to the submesh
  115853. * @param data defines an optional position array to use to determine the bounding info
  115854. * @returns the SubMesh
  115855. */
  115856. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  115857. /** @hidden */
  115858. _checkCollision(collider: Collider): boolean;
  115859. /**
  115860. * Updates the submesh BoundingInfo
  115861. * @param world defines the world matrix to use to update the bounding info
  115862. * @returns the submesh
  115863. */
  115864. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  115865. /**
  115866. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  115867. * @param frustumPlanes defines the frustum planes
  115868. * @returns true if the submesh is intersecting with the frustum
  115869. */
  115870. isInFrustum(frustumPlanes: Plane[]): boolean;
  115871. /**
  115872. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  115873. * @param frustumPlanes defines the frustum planes
  115874. * @returns true if the submesh is inside the frustum
  115875. */
  115876. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  115877. /**
  115878. * Renders the submesh
  115879. * @param enableAlphaMode defines if alpha needs to be used
  115880. * @returns the submesh
  115881. */
  115882. render(enableAlphaMode: boolean): SubMesh;
  115883. /**
  115884. * @hidden
  115885. */
  115886. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  115887. /**
  115888. * Checks if the submesh intersects with a ray
  115889. * @param ray defines the ray to test
  115890. * @returns true is the passed ray intersects the submesh bounding box
  115891. */
  115892. canIntersects(ray: Ray): boolean;
  115893. /**
  115894. * Intersects current submesh with a ray
  115895. * @param ray defines the ray to test
  115896. * @param positions defines mesh's positions array
  115897. * @param indices defines mesh's indices array
  115898. * @param fastCheck defines if the first intersection will be used (and not the closest)
  115899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  115900. * @returns intersection info or null if no intersection
  115901. */
  115902. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  115903. /** @hidden */
  115904. private _intersectLines;
  115905. /** @hidden */
  115906. private _intersectUnIndexedLines;
  115907. /** @hidden */
  115908. private _intersectTriangles;
  115909. /** @hidden */
  115910. private _intersectUnIndexedTriangles;
  115911. /** @hidden */
  115912. _rebuild(): void;
  115913. /**
  115914. * Creates a new submesh from the passed mesh
  115915. * @param newMesh defines the new hosting mesh
  115916. * @param newRenderingMesh defines an optional rendering mesh
  115917. * @returns the new submesh
  115918. */
  115919. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  115920. /**
  115921. * Release associated resources
  115922. */
  115923. dispose(): void;
  115924. /**
  115925. * Gets the class name
  115926. * @returns the string "SubMesh".
  115927. */
  115928. getClassName(): string;
  115929. /**
  115930. * Creates a new submesh from indices data
  115931. * @param materialIndex the index of the main mesh material
  115932. * @param startIndex the index where to start the copy in the mesh indices array
  115933. * @param indexCount the number of indices to copy then from the startIndex
  115934. * @param mesh the main mesh to create the submesh from
  115935. * @param renderingMesh the optional rendering mesh
  115936. * @returns a new submesh
  115937. */
  115938. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  115939. }
  115940. }
  115941. declare module BABYLON {
  115942. /**
  115943. * Class used to represent data loading progression
  115944. */
  115945. export class SceneLoaderFlags {
  115946. private static _ForceFullSceneLoadingForIncremental;
  115947. private static _ShowLoadingScreen;
  115948. private static _CleanBoneMatrixWeights;
  115949. private static _loggingLevel;
  115950. /**
  115951. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115952. */
  115953. static get ForceFullSceneLoadingForIncremental(): boolean;
  115954. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115955. /**
  115956. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115957. */
  115958. static get ShowLoadingScreen(): boolean;
  115959. static set ShowLoadingScreen(value: boolean);
  115960. /**
  115961. * Defines the current logging level (while loading the scene)
  115962. * @ignorenaming
  115963. */
  115964. static get loggingLevel(): number;
  115965. static set loggingLevel(value: number);
  115966. /**
  115967. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115968. */
  115969. static get CleanBoneMatrixWeights(): boolean;
  115970. static set CleanBoneMatrixWeights(value: boolean);
  115971. }
  115972. }
  115973. declare module BABYLON {
  115974. /**
  115975. * Class used to store geometry data (vertex buffers + index buffer)
  115976. */
  115977. export class Geometry implements IGetSetVerticesData {
  115978. /**
  115979. * Gets or sets the ID of the geometry
  115980. */
  115981. id: string;
  115982. /**
  115983. * Gets or sets the unique ID of the geometry
  115984. */
  115985. uniqueId: number;
  115986. /**
  115987. * Gets the delay loading state of the geometry (none by default which means not delayed)
  115988. */
  115989. delayLoadState: number;
  115990. /**
  115991. * Gets the file containing the data to load when running in delay load state
  115992. */
  115993. delayLoadingFile: Nullable<string>;
  115994. /**
  115995. * Callback called when the geometry is updated
  115996. */
  115997. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  115998. private _scene;
  115999. private _engine;
  116000. private _meshes;
  116001. private _totalVertices;
  116002. /** @hidden */
  116003. _indices: IndicesArray;
  116004. /** @hidden */
  116005. _vertexBuffers: {
  116006. [key: string]: VertexBuffer;
  116007. };
  116008. private _isDisposed;
  116009. private _extend;
  116010. private _boundingBias;
  116011. /** @hidden */
  116012. _delayInfo: Array<string>;
  116013. private _indexBuffer;
  116014. private _indexBufferIsUpdatable;
  116015. /** @hidden */
  116016. _boundingInfo: Nullable<BoundingInfo>;
  116017. /** @hidden */
  116018. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  116019. /** @hidden */
  116020. _softwareSkinningFrameId: number;
  116021. private _vertexArrayObjects;
  116022. private _updatable;
  116023. /** @hidden */
  116024. _positions: Nullable<Vector3[]>;
  116025. private _positionsCache;
  116026. /**
  116027. * 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
  116028. */
  116029. get boundingBias(): Vector2;
  116030. /**
  116031. * 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
  116032. */
  116033. set boundingBias(value: Vector2);
  116034. /**
  116035. * Static function used to attach a new empty geometry to a mesh
  116036. * @param mesh defines the mesh to attach the geometry to
  116037. * @returns the new Geometry
  116038. */
  116039. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  116040. /** Get the list of meshes using this geometry */
  116041. get meshes(): Mesh[];
  116042. /**
  116043. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  116044. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  116045. */
  116046. useBoundingInfoFromGeometry: boolean;
  116047. /**
  116048. * Creates a new geometry
  116049. * @param id defines the unique ID
  116050. * @param scene defines the hosting scene
  116051. * @param vertexData defines the VertexData used to get geometry data
  116052. * @param updatable defines if geometry must be updatable (false by default)
  116053. * @param mesh defines the mesh that will be associated with the geometry
  116054. */
  116055. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  116056. /**
  116057. * Gets the current extend of the geometry
  116058. */
  116059. get extend(): {
  116060. minimum: Vector3;
  116061. maximum: Vector3;
  116062. };
  116063. /**
  116064. * Gets the hosting scene
  116065. * @returns the hosting Scene
  116066. */
  116067. getScene(): Scene;
  116068. /**
  116069. * Gets the hosting engine
  116070. * @returns the hosting Engine
  116071. */
  116072. getEngine(): Engine;
  116073. /**
  116074. * Defines if the geometry is ready to use
  116075. * @returns true if the geometry is ready to be used
  116076. */
  116077. isReady(): boolean;
  116078. /**
  116079. * Gets a value indicating that the geometry should not be serialized
  116080. */
  116081. get doNotSerialize(): boolean;
  116082. /** @hidden */
  116083. _rebuild(): void;
  116084. /**
  116085. * Affects all geometry data in one call
  116086. * @param vertexData defines the geometry data
  116087. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  116088. */
  116089. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  116090. /**
  116091. * Set specific vertex data
  116092. * @param kind defines the data kind (Position, normal, etc...)
  116093. * @param data defines the vertex data to use
  116094. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  116095. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  116096. */
  116097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  116098. /**
  116099. * Removes a specific vertex data
  116100. * @param kind defines the data kind (Position, normal, etc...)
  116101. */
  116102. removeVerticesData(kind: string): void;
  116103. /**
  116104. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  116105. * @param buffer defines the vertex buffer to use
  116106. * @param totalVertices defines the total number of vertices for position kind (could be null)
  116107. */
  116108. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  116109. /**
  116110. * Update a specific vertex buffer
  116111. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  116112. * It will do nothing if the buffer is not updatable
  116113. * @param kind defines the data kind (Position, normal, etc...)
  116114. * @param data defines the data to use
  116115. * @param offset defines the offset in the target buffer where to store the data
  116116. * @param useBytes set to true if the offset is in bytes
  116117. */
  116118. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  116119. /**
  116120. * Update a specific vertex buffer
  116121. * This function will create a new buffer if the current one is not updatable
  116122. * @param kind defines the data kind (Position, normal, etc...)
  116123. * @param data defines the data to use
  116124. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  116125. */
  116126. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  116127. private _updateBoundingInfo;
  116128. /** @hidden */
  116129. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  116130. /**
  116131. * Gets total number of vertices
  116132. * @returns the total number of vertices
  116133. */
  116134. getTotalVertices(): number;
  116135. /**
  116136. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  116137. * @param kind defines the data kind (Position, normal, etc...)
  116138. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  116139. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  116140. * @returns a float array containing vertex data
  116141. */
  116142. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  116143. /**
  116144. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  116145. * @param kind defines the data kind (Position, normal, etc...)
  116146. * @returns true if the vertex buffer with the specified kind is updatable
  116147. */
  116148. isVertexBufferUpdatable(kind: string): boolean;
  116149. /**
  116150. * Gets a specific vertex buffer
  116151. * @param kind defines the data kind (Position, normal, etc...)
  116152. * @returns a VertexBuffer
  116153. */
  116154. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  116155. /**
  116156. * Returns all vertex buffers
  116157. * @return an object holding all vertex buffers indexed by kind
  116158. */
  116159. getVertexBuffers(): Nullable<{
  116160. [key: string]: VertexBuffer;
  116161. }>;
  116162. /**
  116163. * Gets a boolean indicating if specific vertex buffer is present
  116164. * @param kind defines the data kind (Position, normal, etc...)
  116165. * @returns true if data is present
  116166. */
  116167. isVerticesDataPresent(kind: string): boolean;
  116168. /**
  116169. * Gets a list of all attached data kinds (Position, normal, etc...)
  116170. * @returns a list of string containing all kinds
  116171. */
  116172. getVerticesDataKinds(): string[];
  116173. /**
  116174. * Update index buffer
  116175. * @param indices defines the indices to store in the index buffer
  116176. * @param offset defines the offset in the target buffer where to store the data
  116177. * @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)
  116178. */
  116179. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  116180. /**
  116181. * Creates a new index buffer
  116182. * @param indices defines the indices to store in the index buffer
  116183. * @param totalVertices defines the total number of vertices (could be null)
  116184. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  116185. */
  116186. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  116187. /**
  116188. * Return the total number of indices
  116189. * @returns the total number of indices
  116190. */
  116191. getTotalIndices(): number;
  116192. /**
  116193. * Gets the index buffer array
  116194. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  116195. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  116196. * @returns the index buffer array
  116197. */
  116198. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  116199. /**
  116200. * Gets the index buffer
  116201. * @return the index buffer
  116202. */
  116203. getIndexBuffer(): Nullable<DataBuffer>;
  116204. /** @hidden */
  116205. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  116206. /**
  116207. * Release the associated resources for a specific mesh
  116208. * @param mesh defines the source mesh
  116209. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  116210. */
  116211. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  116212. /**
  116213. * Apply current geometry to a given mesh
  116214. * @param mesh defines the mesh to apply geometry to
  116215. */
  116216. applyToMesh(mesh: Mesh): void;
  116217. private _updateExtend;
  116218. private _applyToMesh;
  116219. private notifyUpdate;
  116220. /**
  116221. * Load the geometry if it was flagged as delay loaded
  116222. * @param scene defines the hosting scene
  116223. * @param onLoaded defines a callback called when the geometry is loaded
  116224. */
  116225. load(scene: Scene, onLoaded?: () => void): void;
  116226. private _queueLoad;
  116227. /**
  116228. * Invert the geometry to move from a right handed system to a left handed one.
  116229. */
  116230. toLeftHanded(): void;
  116231. /** @hidden */
  116232. _resetPointsArrayCache(): void;
  116233. /** @hidden */
  116234. _generatePointsArray(): boolean;
  116235. /**
  116236. * Gets a value indicating if the geometry is disposed
  116237. * @returns true if the geometry was disposed
  116238. */
  116239. isDisposed(): boolean;
  116240. private _disposeVertexArrayObjects;
  116241. /**
  116242. * Free all associated resources
  116243. */
  116244. dispose(): void;
  116245. /**
  116246. * Clone the current geometry into a new geometry
  116247. * @param id defines the unique ID of the new geometry
  116248. * @returns a new geometry object
  116249. */
  116250. copy(id: string): Geometry;
  116251. /**
  116252. * Serialize the current geometry info (and not the vertices data) into a JSON object
  116253. * @return a JSON representation of the current geometry data (without the vertices data)
  116254. */
  116255. serialize(): any;
  116256. private toNumberArray;
  116257. /**
  116258. * Serialize all vertices data into a JSON oject
  116259. * @returns a JSON representation of the current geometry data
  116260. */
  116261. serializeVerticeData(): any;
  116262. /**
  116263. * Extracts a clone of a mesh geometry
  116264. * @param mesh defines the source mesh
  116265. * @param id defines the unique ID of the new geometry object
  116266. * @returns the new geometry object
  116267. */
  116268. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  116269. /**
  116270. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  116271. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116272. * Be aware Math.random() could cause collisions, but:
  116273. * "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"
  116274. * @returns a string containing a new GUID
  116275. */
  116276. static RandomId(): string;
  116277. /** @hidden */
  116278. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  116279. private static _CleanMatricesWeights;
  116280. /**
  116281. * Create a new geometry from persisted data (Using .babylon file format)
  116282. * @param parsedVertexData defines the persisted data
  116283. * @param scene defines the hosting scene
  116284. * @param rootUrl defines the root url to use to load assets (like delayed data)
  116285. * @returns the new geometry object
  116286. */
  116287. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  116288. }
  116289. }
  116290. declare module BABYLON {
  116291. /**
  116292. * Defines a target to use with MorphTargetManager
  116293. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116294. */
  116295. export class MorphTarget implements IAnimatable {
  116296. /** defines the name of the target */
  116297. name: string;
  116298. /**
  116299. * Gets or sets the list of animations
  116300. */
  116301. animations: Animation[];
  116302. private _scene;
  116303. private _positions;
  116304. private _normals;
  116305. private _tangents;
  116306. private _uvs;
  116307. private _influence;
  116308. private _uniqueId;
  116309. /**
  116310. * Observable raised when the influence changes
  116311. */
  116312. onInfluenceChanged: Observable<boolean>;
  116313. /** @hidden */
  116314. _onDataLayoutChanged: Observable<void>;
  116315. /**
  116316. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  116317. */
  116318. get influence(): number;
  116319. set influence(influence: number);
  116320. /**
  116321. * Gets or sets the id of the morph Target
  116322. */
  116323. id: string;
  116324. private _animationPropertiesOverride;
  116325. /**
  116326. * Gets or sets the animation properties override
  116327. */
  116328. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116329. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116330. /**
  116331. * Creates a new MorphTarget
  116332. * @param name defines the name of the target
  116333. * @param influence defines the influence to use
  116334. * @param scene defines the scene the morphtarget belongs to
  116335. */
  116336. constructor(
  116337. /** defines the name of the target */
  116338. name: string, influence?: number, scene?: Nullable<Scene>);
  116339. /**
  116340. * Gets the unique ID of this manager
  116341. */
  116342. get uniqueId(): number;
  116343. /**
  116344. * Gets a boolean defining if the target contains position data
  116345. */
  116346. get hasPositions(): boolean;
  116347. /**
  116348. * Gets a boolean defining if the target contains normal data
  116349. */
  116350. get hasNormals(): boolean;
  116351. /**
  116352. * Gets a boolean defining if the target contains tangent data
  116353. */
  116354. get hasTangents(): boolean;
  116355. /**
  116356. * Gets a boolean defining if the target contains texture coordinates data
  116357. */
  116358. get hasUVs(): boolean;
  116359. /**
  116360. * Affects position data to this target
  116361. * @param data defines the position data to use
  116362. */
  116363. setPositions(data: Nullable<FloatArray>): void;
  116364. /**
  116365. * Gets the position data stored in this target
  116366. * @returns a FloatArray containing the position data (or null if not present)
  116367. */
  116368. getPositions(): Nullable<FloatArray>;
  116369. /**
  116370. * Affects normal data to this target
  116371. * @param data defines the normal data to use
  116372. */
  116373. setNormals(data: Nullable<FloatArray>): void;
  116374. /**
  116375. * Gets the normal data stored in this target
  116376. * @returns a FloatArray containing the normal data (or null if not present)
  116377. */
  116378. getNormals(): Nullable<FloatArray>;
  116379. /**
  116380. * Affects tangent data to this target
  116381. * @param data defines the tangent data to use
  116382. */
  116383. setTangents(data: Nullable<FloatArray>): void;
  116384. /**
  116385. * Gets the tangent data stored in this target
  116386. * @returns a FloatArray containing the tangent data (or null if not present)
  116387. */
  116388. getTangents(): Nullable<FloatArray>;
  116389. /**
  116390. * Affects texture coordinates data to this target
  116391. * @param data defines the texture coordinates data to use
  116392. */
  116393. setUVs(data: Nullable<FloatArray>): void;
  116394. /**
  116395. * Gets the texture coordinates data stored in this target
  116396. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  116397. */
  116398. getUVs(): Nullable<FloatArray>;
  116399. /**
  116400. * Clone the current target
  116401. * @returns a new MorphTarget
  116402. */
  116403. clone(): MorphTarget;
  116404. /**
  116405. * Serializes the current target into a Serialization object
  116406. * @returns the serialized object
  116407. */
  116408. serialize(): any;
  116409. /**
  116410. * Returns the string "MorphTarget"
  116411. * @returns "MorphTarget"
  116412. */
  116413. getClassName(): string;
  116414. /**
  116415. * Creates a new target from serialized data
  116416. * @param serializationObject defines the serialized data to use
  116417. * @returns a new MorphTarget
  116418. */
  116419. static Parse(serializationObject: any): MorphTarget;
  116420. /**
  116421. * Creates a MorphTarget from mesh data
  116422. * @param mesh defines the source mesh
  116423. * @param name defines the name to use for the new target
  116424. * @param influence defines the influence to attach to the target
  116425. * @returns a new MorphTarget
  116426. */
  116427. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  116428. }
  116429. }
  116430. declare module BABYLON {
  116431. /**
  116432. * This class is used to deform meshes using morphing between different targets
  116433. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116434. */
  116435. export class MorphTargetManager {
  116436. private _targets;
  116437. private _targetInfluenceChangedObservers;
  116438. private _targetDataLayoutChangedObservers;
  116439. private _activeTargets;
  116440. private _scene;
  116441. private _influences;
  116442. private _supportsNormals;
  116443. private _supportsTangents;
  116444. private _supportsUVs;
  116445. private _vertexCount;
  116446. private _uniqueId;
  116447. private _tempInfluences;
  116448. /**
  116449. * Gets or sets a boolean indicating if normals must be morphed
  116450. */
  116451. enableNormalMorphing: boolean;
  116452. /**
  116453. * Gets or sets a boolean indicating if tangents must be morphed
  116454. */
  116455. enableTangentMorphing: boolean;
  116456. /**
  116457. * Gets or sets a boolean indicating if UV must be morphed
  116458. */
  116459. enableUVMorphing: boolean;
  116460. /**
  116461. * Creates a new MorphTargetManager
  116462. * @param scene defines the current scene
  116463. */
  116464. constructor(scene?: Nullable<Scene>);
  116465. /**
  116466. * Gets the unique ID of this manager
  116467. */
  116468. get uniqueId(): number;
  116469. /**
  116470. * Gets the number of vertices handled by this manager
  116471. */
  116472. get vertexCount(): number;
  116473. /**
  116474. * Gets a boolean indicating if this manager supports morphing of normals
  116475. */
  116476. get supportsNormals(): boolean;
  116477. /**
  116478. * Gets a boolean indicating if this manager supports morphing of tangents
  116479. */
  116480. get supportsTangents(): boolean;
  116481. /**
  116482. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  116483. */
  116484. get supportsUVs(): boolean;
  116485. /**
  116486. * Gets the number of targets stored in this manager
  116487. */
  116488. get numTargets(): number;
  116489. /**
  116490. * Gets the number of influencers (ie. the number of targets with influences > 0)
  116491. */
  116492. get numInfluencers(): number;
  116493. /**
  116494. * Gets the list of influences (one per target)
  116495. */
  116496. get influences(): Float32Array;
  116497. /**
  116498. * Gets the active target at specified index. An active target is a target with an influence > 0
  116499. * @param index defines the index to check
  116500. * @returns the requested target
  116501. */
  116502. getActiveTarget(index: number): MorphTarget;
  116503. /**
  116504. * Gets the target at specified index
  116505. * @param index defines the index to check
  116506. * @returns the requested target
  116507. */
  116508. getTarget(index: number): MorphTarget;
  116509. /**
  116510. * Add a new target to this manager
  116511. * @param target defines the target to add
  116512. */
  116513. addTarget(target: MorphTarget): void;
  116514. /**
  116515. * Removes a target from the manager
  116516. * @param target defines the target to remove
  116517. */
  116518. removeTarget(target: MorphTarget): void;
  116519. /**
  116520. * Clone the current manager
  116521. * @returns a new MorphTargetManager
  116522. */
  116523. clone(): MorphTargetManager;
  116524. /**
  116525. * Serializes the current manager into a Serialization object
  116526. * @returns the serialized object
  116527. */
  116528. serialize(): any;
  116529. private _syncActiveTargets;
  116530. /**
  116531. * Syncrhonize the targets with all the meshes using this morph target manager
  116532. */
  116533. synchronize(): void;
  116534. /**
  116535. * Creates a new MorphTargetManager from serialized data
  116536. * @param serializationObject defines the serialized data
  116537. * @param scene defines the hosting scene
  116538. * @returns the new MorphTargetManager
  116539. */
  116540. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  116541. }
  116542. }
  116543. declare module BABYLON {
  116544. /**
  116545. * Class used to represent a specific level of detail of a mesh
  116546. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  116547. */
  116548. export class MeshLODLevel {
  116549. /** Defines the distance where this level should start being displayed */
  116550. distance: number;
  116551. /** Defines the mesh to use to render this level */
  116552. mesh: Nullable<Mesh>;
  116553. /**
  116554. * Creates a new LOD level
  116555. * @param distance defines the distance where this level should star being displayed
  116556. * @param mesh defines the mesh to use to render this level
  116557. */
  116558. constructor(
  116559. /** Defines the distance where this level should start being displayed */
  116560. distance: number,
  116561. /** Defines the mesh to use to render this level */
  116562. mesh: Nullable<Mesh>);
  116563. }
  116564. }
  116565. declare module BABYLON {
  116566. /**
  116567. * Helper class used to generate a canvas to manipulate images
  116568. */
  116569. export class CanvasGenerator {
  116570. /**
  116571. * Create a new canvas (or offscreen canvas depending on the context)
  116572. * @param width defines the expected width
  116573. * @param height defines the expected height
  116574. * @return a new canvas or offscreen canvas
  116575. */
  116576. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  116577. }
  116578. }
  116579. declare module BABYLON {
  116580. /**
  116581. * Mesh representing the gorund
  116582. */
  116583. export class GroundMesh extends Mesh {
  116584. /** If octree should be generated */
  116585. generateOctree: boolean;
  116586. private _heightQuads;
  116587. /** @hidden */
  116588. _subdivisionsX: number;
  116589. /** @hidden */
  116590. _subdivisionsY: number;
  116591. /** @hidden */
  116592. _width: number;
  116593. /** @hidden */
  116594. _height: number;
  116595. /** @hidden */
  116596. _minX: number;
  116597. /** @hidden */
  116598. _maxX: number;
  116599. /** @hidden */
  116600. _minZ: number;
  116601. /** @hidden */
  116602. _maxZ: number;
  116603. constructor(name: string, scene: Scene);
  116604. /**
  116605. * "GroundMesh"
  116606. * @returns "GroundMesh"
  116607. */
  116608. getClassName(): string;
  116609. /**
  116610. * The minimum of x and y subdivisions
  116611. */
  116612. get subdivisions(): number;
  116613. /**
  116614. * X subdivisions
  116615. */
  116616. get subdivisionsX(): number;
  116617. /**
  116618. * Y subdivisions
  116619. */
  116620. get subdivisionsY(): number;
  116621. /**
  116622. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  116623. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116624. * @param chunksCount the number of subdivisions for x and y
  116625. * @param octreeBlocksSize (Default: 32)
  116626. */
  116627. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  116628. /**
  116629. * Returns a height (y) value in the Worl system :
  116630. * the ground altitude at the coordinates (x, z) expressed in the World system.
  116631. * @param x x coordinate
  116632. * @param z z coordinate
  116633. * @returns the ground y position if (x, z) are outside the ground surface.
  116634. */
  116635. getHeightAtCoordinates(x: number, z: number): number;
  116636. /**
  116637. * Returns a normalized vector (Vector3) orthogonal to the ground
  116638. * at the ground coordinates (x, z) expressed in the World system.
  116639. * @param x x coordinate
  116640. * @param z z coordinate
  116641. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  116642. */
  116643. getNormalAtCoordinates(x: number, z: number): Vector3;
  116644. /**
  116645. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  116646. * at the ground coordinates (x, z) expressed in the World system.
  116647. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  116648. * @param x x coordinate
  116649. * @param z z coordinate
  116650. * @param ref vector to store the result
  116651. * @returns the GroundMesh.
  116652. */
  116653. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  116654. /**
  116655. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  116656. * if the ground has been updated.
  116657. * This can be used in the render loop.
  116658. * @returns the GroundMesh.
  116659. */
  116660. updateCoordinateHeights(): GroundMesh;
  116661. private _getFacetAt;
  116662. private _initHeightQuads;
  116663. private _computeHeightQuads;
  116664. /**
  116665. * Serializes this ground mesh
  116666. * @param serializationObject object to write serialization to
  116667. */
  116668. serialize(serializationObject: any): void;
  116669. /**
  116670. * Parses a serialized ground mesh
  116671. * @param parsedMesh the serialized mesh
  116672. * @param scene the scene to create the ground mesh in
  116673. * @returns the created ground mesh
  116674. */
  116675. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  116676. }
  116677. }
  116678. declare module BABYLON {
  116679. /**
  116680. * Interface for Physics-Joint data
  116681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116682. */
  116683. export interface PhysicsJointData {
  116684. /**
  116685. * The main pivot of the joint
  116686. */
  116687. mainPivot?: Vector3;
  116688. /**
  116689. * The connected pivot of the joint
  116690. */
  116691. connectedPivot?: Vector3;
  116692. /**
  116693. * The main axis of the joint
  116694. */
  116695. mainAxis?: Vector3;
  116696. /**
  116697. * The connected axis of the joint
  116698. */
  116699. connectedAxis?: Vector3;
  116700. /**
  116701. * The collision of the joint
  116702. */
  116703. collision?: boolean;
  116704. /**
  116705. * Native Oimo/Cannon/Energy data
  116706. */
  116707. nativeParams?: any;
  116708. }
  116709. /**
  116710. * This is a holder class for the physics joint created by the physics plugin
  116711. * It holds a set of functions to control the underlying joint
  116712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116713. */
  116714. export class PhysicsJoint {
  116715. /**
  116716. * The type of the physics joint
  116717. */
  116718. type: number;
  116719. /**
  116720. * The data for the physics joint
  116721. */
  116722. jointData: PhysicsJointData;
  116723. private _physicsJoint;
  116724. protected _physicsPlugin: IPhysicsEnginePlugin;
  116725. /**
  116726. * Initializes the physics joint
  116727. * @param type The type of the physics joint
  116728. * @param jointData The data for the physics joint
  116729. */
  116730. constructor(
  116731. /**
  116732. * The type of the physics joint
  116733. */
  116734. type: number,
  116735. /**
  116736. * The data for the physics joint
  116737. */
  116738. jointData: PhysicsJointData);
  116739. /**
  116740. * Gets the physics joint
  116741. */
  116742. get physicsJoint(): any;
  116743. /**
  116744. * Sets the physics joint
  116745. */
  116746. set physicsJoint(newJoint: any);
  116747. /**
  116748. * Sets the physics plugin
  116749. */
  116750. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  116751. /**
  116752. * Execute a function that is physics-plugin specific.
  116753. * @param {Function} func the function that will be executed.
  116754. * It accepts two parameters: the physics world and the physics joint
  116755. */
  116756. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  116757. /**
  116758. * Distance-Joint type
  116759. */
  116760. static DistanceJoint: number;
  116761. /**
  116762. * Hinge-Joint type
  116763. */
  116764. static HingeJoint: number;
  116765. /**
  116766. * Ball-and-Socket joint type
  116767. */
  116768. static BallAndSocketJoint: number;
  116769. /**
  116770. * Wheel-Joint type
  116771. */
  116772. static WheelJoint: number;
  116773. /**
  116774. * Slider-Joint type
  116775. */
  116776. static SliderJoint: number;
  116777. /**
  116778. * Prismatic-Joint type
  116779. */
  116780. static PrismaticJoint: number;
  116781. /**
  116782. * Universal-Joint type
  116783. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  116784. */
  116785. static UniversalJoint: number;
  116786. /**
  116787. * Hinge-Joint 2 type
  116788. */
  116789. static Hinge2Joint: number;
  116790. /**
  116791. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  116792. */
  116793. static PointToPointJoint: number;
  116794. /**
  116795. * Spring-Joint type
  116796. */
  116797. static SpringJoint: number;
  116798. /**
  116799. * Lock-Joint type
  116800. */
  116801. static LockJoint: number;
  116802. }
  116803. /**
  116804. * A class representing a physics distance joint
  116805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116806. */
  116807. export class DistanceJoint extends PhysicsJoint {
  116808. /**
  116809. *
  116810. * @param jointData The data for the Distance-Joint
  116811. */
  116812. constructor(jointData: DistanceJointData);
  116813. /**
  116814. * Update the predefined distance.
  116815. * @param maxDistance The maximum preferred distance
  116816. * @param minDistance The minimum preferred distance
  116817. */
  116818. updateDistance(maxDistance: number, minDistance?: number): void;
  116819. }
  116820. /**
  116821. * Represents a Motor-Enabled Joint
  116822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116823. */
  116824. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  116825. /**
  116826. * Initializes the Motor-Enabled Joint
  116827. * @param type The type of the joint
  116828. * @param jointData The physica joint data for the joint
  116829. */
  116830. constructor(type: number, jointData: PhysicsJointData);
  116831. /**
  116832. * Set the motor values.
  116833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116834. * @param force the force to apply
  116835. * @param maxForce max force for this motor.
  116836. */
  116837. setMotor(force?: number, maxForce?: number): void;
  116838. /**
  116839. * Set the motor's limits.
  116840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116841. * @param upperLimit The upper limit of the motor
  116842. * @param lowerLimit The lower limit of the motor
  116843. */
  116844. setLimit(upperLimit: number, lowerLimit?: number): void;
  116845. }
  116846. /**
  116847. * This class represents a single physics Hinge-Joint
  116848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116849. */
  116850. export class HingeJoint extends MotorEnabledJoint {
  116851. /**
  116852. * Initializes the Hinge-Joint
  116853. * @param jointData The joint data for the Hinge-Joint
  116854. */
  116855. constructor(jointData: PhysicsJointData);
  116856. /**
  116857. * Set the motor values.
  116858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116859. * @param {number} force the force to apply
  116860. * @param {number} maxForce max force for this motor.
  116861. */
  116862. setMotor(force?: number, maxForce?: number): void;
  116863. /**
  116864. * Set the motor's limits.
  116865. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116866. * @param upperLimit The upper limit of the motor
  116867. * @param lowerLimit The lower limit of the motor
  116868. */
  116869. setLimit(upperLimit: number, lowerLimit?: number): void;
  116870. }
  116871. /**
  116872. * This class represents a dual hinge physics joint (same as wheel joint)
  116873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116874. */
  116875. export class Hinge2Joint extends MotorEnabledJoint {
  116876. /**
  116877. * Initializes the Hinge2-Joint
  116878. * @param jointData The joint data for the Hinge2-Joint
  116879. */
  116880. constructor(jointData: PhysicsJointData);
  116881. /**
  116882. * Set the motor values.
  116883. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116884. * @param {number} targetSpeed the speed the motor is to reach
  116885. * @param {number} maxForce max force for this motor.
  116886. * @param {motorIndex} the motor's index, 0 or 1.
  116887. */
  116888. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  116889. /**
  116890. * Set the motor limits.
  116891. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116892. * @param {number} upperLimit the upper limit
  116893. * @param {number} lowerLimit lower limit
  116894. * @param {motorIndex} the motor's index, 0 or 1.
  116895. */
  116896. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116897. }
  116898. /**
  116899. * Interface for a motor enabled joint
  116900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116901. */
  116902. export interface IMotorEnabledJoint {
  116903. /**
  116904. * Physics joint
  116905. */
  116906. physicsJoint: any;
  116907. /**
  116908. * Sets the motor of the motor-enabled joint
  116909. * @param force The force of the motor
  116910. * @param maxForce The maximum force of the motor
  116911. * @param motorIndex The index of the motor
  116912. */
  116913. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  116914. /**
  116915. * Sets the limit of the motor
  116916. * @param upperLimit The upper limit of the motor
  116917. * @param lowerLimit The lower limit of the motor
  116918. * @param motorIndex The index of the motor
  116919. */
  116920. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116921. }
  116922. /**
  116923. * Joint data for a Distance-Joint
  116924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116925. */
  116926. export interface DistanceJointData extends PhysicsJointData {
  116927. /**
  116928. * Max distance the 2 joint objects can be apart
  116929. */
  116930. maxDistance: number;
  116931. }
  116932. /**
  116933. * Joint data from a spring joint
  116934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116935. */
  116936. export interface SpringJointData extends PhysicsJointData {
  116937. /**
  116938. * Length of the spring
  116939. */
  116940. length: number;
  116941. /**
  116942. * Stiffness of the spring
  116943. */
  116944. stiffness: number;
  116945. /**
  116946. * Damping of the spring
  116947. */
  116948. damping: number;
  116949. /** this callback will be called when applying the force to the impostors. */
  116950. forceApplicationCallback: () => void;
  116951. }
  116952. }
  116953. declare module BABYLON {
  116954. /**
  116955. * Holds the data for the raycast result
  116956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116957. */
  116958. export class PhysicsRaycastResult {
  116959. private _hasHit;
  116960. private _hitDistance;
  116961. private _hitNormalWorld;
  116962. private _hitPointWorld;
  116963. private _rayFromWorld;
  116964. private _rayToWorld;
  116965. /**
  116966. * Gets if there was a hit
  116967. */
  116968. get hasHit(): boolean;
  116969. /**
  116970. * Gets the distance from the hit
  116971. */
  116972. get hitDistance(): number;
  116973. /**
  116974. * Gets the hit normal/direction in the world
  116975. */
  116976. get hitNormalWorld(): Vector3;
  116977. /**
  116978. * Gets the hit point in the world
  116979. */
  116980. get hitPointWorld(): Vector3;
  116981. /**
  116982. * Gets the ray "start point" of the ray in the world
  116983. */
  116984. get rayFromWorld(): Vector3;
  116985. /**
  116986. * Gets the ray "end point" of the ray in the world
  116987. */
  116988. get rayToWorld(): Vector3;
  116989. /**
  116990. * Sets the hit data (normal & point in world space)
  116991. * @param hitNormalWorld defines the normal in world space
  116992. * @param hitPointWorld defines the point in world space
  116993. */
  116994. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  116995. /**
  116996. * Sets the distance from the start point to the hit point
  116997. * @param distance
  116998. */
  116999. setHitDistance(distance: number): void;
  117000. /**
  117001. * Calculates the distance manually
  117002. */
  117003. calculateHitDistance(): void;
  117004. /**
  117005. * Resets all the values to default
  117006. * @param from The from point on world space
  117007. * @param to The to point on world space
  117008. */
  117009. reset(from?: Vector3, to?: Vector3): void;
  117010. }
  117011. /**
  117012. * Interface for the size containing width and height
  117013. */
  117014. interface IXYZ {
  117015. /**
  117016. * X
  117017. */
  117018. x: number;
  117019. /**
  117020. * Y
  117021. */
  117022. y: number;
  117023. /**
  117024. * Z
  117025. */
  117026. z: number;
  117027. }
  117028. }
  117029. declare module BABYLON {
  117030. /**
  117031. * Interface used to describe a physics joint
  117032. */
  117033. export interface PhysicsImpostorJoint {
  117034. /** Defines the main impostor to which the joint is linked */
  117035. mainImpostor: PhysicsImpostor;
  117036. /** Defines the impostor that is connected to the main impostor using this joint */
  117037. connectedImpostor: PhysicsImpostor;
  117038. /** Defines the joint itself */
  117039. joint: PhysicsJoint;
  117040. }
  117041. /** @hidden */
  117042. export interface IPhysicsEnginePlugin {
  117043. world: any;
  117044. name: string;
  117045. setGravity(gravity: Vector3): void;
  117046. setTimeStep(timeStep: number): void;
  117047. getTimeStep(): number;
  117048. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117051. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117052. removePhysicsBody(impostor: PhysicsImpostor): void;
  117053. generateJoint(joint: PhysicsImpostorJoint): void;
  117054. removeJoint(joint: PhysicsImpostorJoint): void;
  117055. isSupported(): boolean;
  117056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117063. getBodyMass(impostor: PhysicsImpostor): number;
  117064. getBodyFriction(impostor: PhysicsImpostor): number;
  117065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117066. getBodyRestitution(impostor: PhysicsImpostor): number;
  117067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117068. getBodyPressure?(impostor: PhysicsImpostor): number;
  117069. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  117070. getBodyStiffness?(impostor: PhysicsImpostor): number;
  117071. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  117072. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  117073. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  117074. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  117075. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  117076. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117077. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117078. sleepBody(impostor: PhysicsImpostor): void;
  117079. wakeUpBody(impostor: PhysicsImpostor): void;
  117080. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117081. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117082. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  117083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117084. getRadius(impostor: PhysicsImpostor): number;
  117085. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117086. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117087. dispose(): void;
  117088. }
  117089. /**
  117090. * Interface used to define a physics engine
  117091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117092. */
  117093. export interface IPhysicsEngine {
  117094. /**
  117095. * Gets the gravity vector used by the simulation
  117096. */
  117097. gravity: Vector3;
  117098. /**
  117099. * Sets the gravity vector used by the simulation
  117100. * @param gravity defines the gravity vector to use
  117101. */
  117102. setGravity(gravity: Vector3): void;
  117103. /**
  117104. * Set the time step of the physics engine.
  117105. * Default is 1/60.
  117106. * To slow it down, enter 1/600 for example.
  117107. * To speed it up, 1/30
  117108. * @param newTimeStep the new timestep to apply to this world.
  117109. */
  117110. setTimeStep(newTimeStep: number): void;
  117111. /**
  117112. * Get the time step of the physics engine.
  117113. * @returns the current time step
  117114. */
  117115. getTimeStep(): number;
  117116. /**
  117117. * Set the sub time step of the physics engine.
  117118. * Default is 0 meaning there is no sub steps
  117119. * To increase physics resolution precision, set a small value (like 1 ms)
  117120. * @param subTimeStep defines the new sub timestep used for physics resolution.
  117121. */
  117122. setSubTimeStep(subTimeStep: number): void;
  117123. /**
  117124. * Get the sub time step of the physics engine.
  117125. * @returns the current sub time step
  117126. */
  117127. getSubTimeStep(): number;
  117128. /**
  117129. * Release all resources
  117130. */
  117131. dispose(): void;
  117132. /**
  117133. * Gets the name of the current physics plugin
  117134. * @returns the name of the plugin
  117135. */
  117136. getPhysicsPluginName(): string;
  117137. /**
  117138. * Adding a new impostor for the impostor tracking.
  117139. * This will be done by the impostor itself.
  117140. * @param impostor the impostor to add
  117141. */
  117142. addImpostor(impostor: PhysicsImpostor): void;
  117143. /**
  117144. * Remove an impostor from the engine.
  117145. * This impostor and its mesh will not longer be updated by the physics engine.
  117146. * @param impostor the impostor to remove
  117147. */
  117148. removeImpostor(impostor: PhysicsImpostor): void;
  117149. /**
  117150. * Add a joint to the physics engine
  117151. * @param mainImpostor defines the main impostor to which the joint is added.
  117152. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117153. * @param joint defines the joint that will connect both impostors.
  117154. */
  117155. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117156. /**
  117157. * Removes a joint from the simulation
  117158. * @param mainImpostor defines the impostor used with the joint
  117159. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117160. * @param joint defines the joint to remove
  117161. */
  117162. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117163. /**
  117164. * Gets the current plugin used to run the simulation
  117165. * @returns current plugin
  117166. */
  117167. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117168. /**
  117169. * Gets the list of physic impostors
  117170. * @returns an array of PhysicsImpostor
  117171. */
  117172. getImpostors(): Array<PhysicsImpostor>;
  117173. /**
  117174. * Gets the impostor for a physics enabled object
  117175. * @param object defines the object impersonated by the impostor
  117176. * @returns the PhysicsImpostor or null if not found
  117177. */
  117178. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117179. /**
  117180. * Gets the impostor for a physics body object
  117181. * @param body defines physics body used by the impostor
  117182. * @returns the PhysicsImpostor or null if not found
  117183. */
  117184. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117185. /**
  117186. * Does a raycast in the physics world
  117187. * @param from when should the ray start?
  117188. * @param to when should the ray end?
  117189. * @returns PhysicsRaycastResult
  117190. */
  117191. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117192. /**
  117193. * Called by the scene. No need to call it.
  117194. * @param delta defines the timespam between frames
  117195. */
  117196. _step(delta: number): void;
  117197. }
  117198. }
  117199. declare module BABYLON {
  117200. /**
  117201. * The interface for the physics imposter parameters
  117202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117203. */
  117204. export interface PhysicsImpostorParameters {
  117205. /**
  117206. * The mass of the physics imposter
  117207. */
  117208. mass: number;
  117209. /**
  117210. * The friction of the physics imposter
  117211. */
  117212. friction?: number;
  117213. /**
  117214. * The coefficient of restitution of the physics imposter
  117215. */
  117216. restitution?: number;
  117217. /**
  117218. * The native options of the physics imposter
  117219. */
  117220. nativeOptions?: any;
  117221. /**
  117222. * Specifies if the parent should be ignored
  117223. */
  117224. ignoreParent?: boolean;
  117225. /**
  117226. * Specifies if bi-directional transformations should be disabled
  117227. */
  117228. disableBidirectionalTransformation?: boolean;
  117229. /**
  117230. * The pressure inside the physics imposter, soft object only
  117231. */
  117232. pressure?: number;
  117233. /**
  117234. * The stiffness the physics imposter, soft object only
  117235. */
  117236. stiffness?: number;
  117237. /**
  117238. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  117239. */
  117240. velocityIterations?: number;
  117241. /**
  117242. * The number of iterations used in maintaining consistent vertex positions, soft object only
  117243. */
  117244. positionIterations?: number;
  117245. /**
  117246. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  117247. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  117248. * Add to fix multiple points
  117249. */
  117250. fixedPoints?: number;
  117251. /**
  117252. * The collision margin around a soft object
  117253. */
  117254. margin?: number;
  117255. /**
  117256. * The collision margin around a soft object
  117257. */
  117258. damping?: number;
  117259. /**
  117260. * The path for a rope based on an extrusion
  117261. */
  117262. path?: any;
  117263. /**
  117264. * The shape of an extrusion used for a rope based on an extrusion
  117265. */
  117266. shape?: any;
  117267. }
  117268. /**
  117269. * Interface for a physics-enabled object
  117270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117271. */
  117272. export interface IPhysicsEnabledObject {
  117273. /**
  117274. * The position of the physics-enabled object
  117275. */
  117276. position: Vector3;
  117277. /**
  117278. * The rotation of the physics-enabled object
  117279. */
  117280. rotationQuaternion: Nullable<Quaternion>;
  117281. /**
  117282. * The scale of the physics-enabled object
  117283. */
  117284. scaling: Vector3;
  117285. /**
  117286. * The rotation of the physics-enabled object
  117287. */
  117288. rotation?: Vector3;
  117289. /**
  117290. * The parent of the physics-enabled object
  117291. */
  117292. parent?: any;
  117293. /**
  117294. * The bounding info of the physics-enabled object
  117295. * @returns The bounding info of the physics-enabled object
  117296. */
  117297. getBoundingInfo(): BoundingInfo;
  117298. /**
  117299. * Computes the world matrix
  117300. * @param force Specifies if the world matrix should be computed by force
  117301. * @returns A world matrix
  117302. */
  117303. computeWorldMatrix(force: boolean): Matrix;
  117304. /**
  117305. * Gets the world matrix
  117306. * @returns A world matrix
  117307. */
  117308. getWorldMatrix?(): Matrix;
  117309. /**
  117310. * Gets the child meshes
  117311. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  117312. * @returns An array of abstract meshes
  117313. */
  117314. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  117315. /**
  117316. * Gets the vertex data
  117317. * @param kind The type of vertex data
  117318. * @returns A nullable array of numbers, or a float32 array
  117319. */
  117320. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  117321. /**
  117322. * Gets the indices from the mesh
  117323. * @returns A nullable array of index arrays
  117324. */
  117325. getIndices?(): Nullable<IndicesArray>;
  117326. /**
  117327. * Gets the scene from the mesh
  117328. * @returns the indices array or null
  117329. */
  117330. getScene?(): Scene;
  117331. /**
  117332. * Gets the absolute position from the mesh
  117333. * @returns the absolute position
  117334. */
  117335. getAbsolutePosition(): Vector3;
  117336. /**
  117337. * Gets the absolute pivot point from the mesh
  117338. * @returns the absolute pivot point
  117339. */
  117340. getAbsolutePivotPoint(): Vector3;
  117341. /**
  117342. * Rotates the mesh
  117343. * @param axis The axis of rotation
  117344. * @param amount The amount of rotation
  117345. * @param space The space of the rotation
  117346. * @returns The rotation transform node
  117347. */
  117348. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  117349. /**
  117350. * Translates the mesh
  117351. * @param axis The axis of translation
  117352. * @param distance The distance of translation
  117353. * @param space The space of the translation
  117354. * @returns The transform node
  117355. */
  117356. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  117357. /**
  117358. * Sets the absolute position of the mesh
  117359. * @param absolutePosition The absolute position of the mesh
  117360. * @returns The transform node
  117361. */
  117362. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  117363. /**
  117364. * Gets the class name of the mesh
  117365. * @returns The class name
  117366. */
  117367. getClassName(): string;
  117368. }
  117369. /**
  117370. * Represents a physics imposter
  117371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117372. */
  117373. export class PhysicsImpostor {
  117374. /**
  117375. * The physics-enabled object used as the physics imposter
  117376. */
  117377. object: IPhysicsEnabledObject;
  117378. /**
  117379. * The type of the physics imposter
  117380. */
  117381. type: number;
  117382. private _options;
  117383. private _scene?;
  117384. /**
  117385. * The default object size of the imposter
  117386. */
  117387. static DEFAULT_OBJECT_SIZE: Vector3;
  117388. /**
  117389. * The identity quaternion of the imposter
  117390. */
  117391. static IDENTITY_QUATERNION: Quaternion;
  117392. /** @hidden */
  117393. _pluginData: any;
  117394. private _physicsEngine;
  117395. private _physicsBody;
  117396. private _bodyUpdateRequired;
  117397. private _onBeforePhysicsStepCallbacks;
  117398. private _onAfterPhysicsStepCallbacks;
  117399. /** @hidden */
  117400. _onPhysicsCollideCallbacks: Array<{
  117401. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  117402. otherImpostors: Array<PhysicsImpostor>;
  117403. }>;
  117404. private _deltaPosition;
  117405. private _deltaRotation;
  117406. private _deltaRotationConjugated;
  117407. /** @hidden */
  117408. _isFromLine: boolean;
  117409. private _parent;
  117410. private _isDisposed;
  117411. private static _tmpVecs;
  117412. private static _tmpQuat;
  117413. /**
  117414. * Specifies if the physics imposter is disposed
  117415. */
  117416. get isDisposed(): boolean;
  117417. /**
  117418. * Gets the mass of the physics imposter
  117419. */
  117420. get mass(): number;
  117421. set mass(value: number);
  117422. /**
  117423. * Gets the coefficient of friction
  117424. */
  117425. get friction(): number;
  117426. /**
  117427. * Sets the coefficient of friction
  117428. */
  117429. set friction(value: number);
  117430. /**
  117431. * Gets the coefficient of restitution
  117432. */
  117433. get restitution(): number;
  117434. /**
  117435. * Sets the coefficient of restitution
  117436. */
  117437. set restitution(value: number);
  117438. /**
  117439. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117440. */
  117441. get pressure(): number;
  117442. /**
  117443. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117444. */
  117445. set pressure(value: number);
  117446. /**
  117447. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117448. */
  117449. get stiffness(): number;
  117450. /**
  117451. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117452. */
  117453. set stiffness(value: number);
  117454. /**
  117455. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117456. */
  117457. get velocityIterations(): number;
  117458. /**
  117459. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117460. */
  117461. set velocityIterations(value: number);
  117462. /**
  117463. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117464. */
  117465. get positionIterations(): number;
  117466. /**
  117467. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117468. */
  117469. set positionIterations(value: number);
  117470. /**
  117471. * The unique id of the physics imposter
  117472. * set by the physics engine when adding this impostor to the array
  117473. */
  117474. uniqueId: number;
  117475. /**
  117476. * @hidden
  117477. */
  117478. soft: boolean;
  117479. /**
  117480. * @hidden
  117481. */
  117482. segments: number;
  117483. private _joints;
  117484. /**
  117485. * Initializes the physics imposter
  117486. * @param object The physics-enabled object used as the physics imposter
  117487. * @param type The type of the physics imposter
  117488. * @param _options The options for the physics imposter
  117489. * @param _scene The Babylon scene
  117490. */
  117491. constructor(
  117492. /**
  117493. * The physics-enabled object used as the physics imposter
  117494. */
  117495. object: IPhysicsEnabledObject,
  117496. /**
  117497. * The type of the physics imposter
  117498. */
  117499. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  117500. /**
  117501. * This function will completly initialize this impostor.
  117502. * It will create a new body - but only if this mesh has no parent.
  117503. * If it has, this impostor will not be used other than to define the impostor
  117504. * of the child mesh.
  117505. * @hidden
  117506. */
  117507. _init(): void;
  117508. private _getPhysicsParent;
  117509. /**
  117510. * Should a new body be generated.
  117511. * @returns boolean specifying if body initialization is required
  117512. */
  117513. isBodyInitRequired(): boolean;
  117514. /**
  117515. * Sets the updated scaling
  117516. * @param updated Specifies if the scaling is updated
  117517. */
  117518. setScalingUpdated(): void;
  117519. /**
  117520. * Force a regeneration of this or the parent's impostor's body.
  117521. * Use under cautious - This will remove all joints already implemented.
  117522. */
  117523. forceUpdate(): void;
  117524. /**
  117525. * Gets the body that holds this impostor. Either its own, or its parent.
  117526. */
  117527. get physicsBody(): any;
  117528. /**
  117529. * Get the parent of the physics imposter
  117530. * @returns Physics imposter or null
  117531. */
  117532. get parent(): Nullable<PhysicsImpostor>;
  117533. /**
  117534. * Sets the parent of the physics imposter
  117535. */
  117536. set parent(value: Nullable<PhysicsImpostor>);
  117537. /**
  117538. * Set the physics body. Used mainly by the physics engine/plugin
  117539. */
  117540. set physicsBody(physicsBody: any);
  117541. /**
  117542. * Resets the update flags
  117543. */
  117544. resetUpdateFlags(): void;
  117545. /**
  117546. * Gets the object extend size
  117547. * @returns the object extend size
  117548. */
  117549. getObjectExtendSize(): Vector3;
  117550. /**
  117551. * Gets the object center
  117552. * @returns The object center
  117553. */
  117554. getObjectCenter(): Vector3;
  117555. /**
  117556. * Get a specific parameter from the options parameters
  117557. * @param paramName The object parameter name
  117558. * @returns The object parameter
  117559. */
  117560. getParam(paramName: string): any;
  117561. /**
  117562. * Sets a specific parameter in the options given to the physics plugin
  117563. * @param paramName The parameter name
  117564. * @param value The value of the parameter
  117565. */
  117566. setParam(paramName: string, value: number): void;
  117567. /**
  117568. * Specifically change the body's mass option. Won't recreate the physics body object
  117569. * @param mass The mass of the physics imposter
  117570. */
  117571. setMass(mass: number): void;
  117572. /**
  117573. * Gets the linear velocity
  117574. * @returns linear velocity or null
  117575. */
  117576. getLinearVelocity(): Nullable<Vector3>;
  117577. /**
  117578. * Sets the linear velocity
  117579. * @param velocity linear velocity or null
  117580. */
  117581. setLinearVelocity(velocity: Nullable<Vector3>): void;
  117582. /**
  117583. * Gets the angular velocity
  117584. * @returns angular velocity or null
  117585. */
  117586. getAngularVelocity(): Nullable<Vector3>;
  117587. /**
  117588. * Sets the angular velocity
  117589. * @param velocity The velocity or null
  117590. */
  117591. setAngularVelocity(velocity: Nullable<Vector3>): void;
  117592. /**
  117593. * Execute a function with the physics plugin native code
  117594. * Provide a function the will have two variables - the world object and the physics body object
  117595. * @param func The function to execute with the physics plugin native code
  117596. */
  117597. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  117598. /**
  117599. * Register a function that will be executed before the physics world is stepping forward
  117600. * @param func The function to execute before the physics world is stepped forward
  117601. */
  117602. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117603. /**
  117604. * Unregister a function that will be executed before the physics world is stepping forward
  117605. * @param func The function to execute before the physics world is stepped forward
  117606. */
  117607. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117608. /**
  117609. * Register a function that will be executed after the physics step
  117610. * @param func The function to execute after physics step
  117611. */
  117612. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117613. /**
  117614. * Unregisters a function that will be executed after the physics step
  117615. * @param func The function to execute after physics step
  117616. */
  117617. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117618. /**
  117619. * register a function that will be executed when this impostor collides against a different body
  117620. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117621. * @param func Callback that is executed on collision
  117622. */
  117623. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  117624. /**
  117625. * Unregisters the physics imposter on contact
  117626. * @param collideAgainst The physics object to collide against
  117627. * @param func Callback to execute on collision
  117628. */
  117629. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  117630. private _tmpQuat;
  117631. private _tmpQuat2;
  117632. /**
  117633. * Get the parent rotation
  117634. * @returns The parent rotation
  117635. */
  117636. getParentsRotation(): Quaternion;
  117637. /**
  117638. * this function is executed by the physics engine.
  117639. */
  117640. beforeStep: () => void;
  117641. /**
  117642. * this function is executed by the physics engine
  117643. */
  117644. afterStep: () => void;
  117645. /**
  117646. * Legacy collision detection event support
  117647. */
  117648. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  117649. /**
  117650. * event and body object due to cannon's event-based architecture.
  117651. */
  117652. onCollide: (e: {
  117653. body: any;
  117654. point: Nullable<Vector3>;
  117655. }) => void;
  117656. /**
  117657. * Apply a force
  117658. * @param force The force to apply
  117659. * @param contactPoint The contact point for the force
  117660. * @returns The physics imposter
  117661. */
  117662. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117663. /**
  117664. * Apply an impulse
  117665. * @param force The impulse force
  117666. * @param contactPoint The contact point for the impulse force
  117667. * @returns The physics imposter
  117668. */
  117669. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117670. /**
  117671. * A help function to create a joint
  117672. * @param otherImpostor A physics imposter used to create a joint
  117673. * @param jointType The type of joint
  117674. * @param jointData The data for the joint
  117675. * @returns The physics imposter
  117676. */
  117677. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  117678. /**
  117679. * Add a joint to this impostor with a different impostor
  117680. * @param otherImpostor A physics imposter used to add a joint
  117681. * @param joint The joint to add
  117682. * @returns The physics imposter
  117683. */
  117684. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  117685. /**
  117686. * Add an anchor to a cloth impostor
  117687. * @param otherImpostor rigid impostor to anchor to
  117688. * @param width ratio across width from 0 to 1
  117689. * @param height ratio up height from 0 to 1
  117690. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117691. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  117692. * @returns impostor the soft imposter
  117693. */
  117694. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117695. /**
  117696. * Add a hook to a rope impostor
  117697. * @param otherImpostor rigid impostor to anchor to
  117698. * @param length ratio across rope from 0 to 1
  117699. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  117700. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117701. * @returns impostor the rope imposter
  117702. */
  117703. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117704. /**
  117705. * Will keep this body still, in a sleep mode.
  117706. * @returns the physics imposter
  117707. */
  117708. sleep(): PhysicsImpostor;
  117709. /**
  117710. * Wake the body up.
  117711. * @returns The physics imposter
  117712. */
  117713. wakeUp(): PhysicsImpostor;
  117714. /**
  117715. * Clones the physics imposter
  117716. * @param newObject The physics imposter clones to this physics-enabled object
  117717. * @returns A nullable physics imposter
  117718. */
  117719. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117720. /**
  117721. * Disposes the physics imposter
  117722. */
  117723. dispose(): void;
  117724. /**
  117725. * Sets the delta position
  117726. * @param position The delta position amount
  117727. */
  117728. setDeltaPosition(position: Vector3): void;
  117729. /**
  117730. * Sets the delta rotation
  117731. * @param rotation The delta rotation amount
  117732. */
  117733. setDeltaRotation(rotation: Quaternion): void;
  117734. /**
  117735. * Gets the box size of the physics imposter and stores the result in the input parameter
  117736. * @param result Stores the box size
  117737. * @returns The physics imposter
  117738. */
  117739. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  117740. /**
  117741. * Gets the radius of the physics imposter
  117742. * @returns Radius of the physics imposter
  117743. */
  117744. getRadius(): number;
  117745. /**
  117746. * Sync a bone with this impostor
  117747. * @param bone The bone to sync to the impostor.
  117748. * @param boneMesh The mesh that the bone is influencing.
  117749. * @param jointPivot The pivot of the joint / bone in local space.
  117750. * @param distToJoint Optional distance from the impostor to the joint.
  117751. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117752. */
  117753. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  117754. /**
  117755. * Sync impostor to a bone
  117756. * @param bone The bone that the impostor will be synced to.
  117757. * @param boneMesh The mesh that the bone is influencing.
  117758. * @param jointPivot The pivot of the joint / bone in local space.
  117759. * @param distToJoint Optional distance from the impostor to the joint.
  117760. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117761. * @param boneAxis Optional vector3 axis the bone is aligned with
  117762. */
  117763. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  117764. /**
  117765. * No-Imposter type
  117766. */
  117767. static NoImpostor: number;
  117768. /**
  117769. * Sphere-Imposter type
  117770. */
  117771. static SphereImpostor: number;
  117772. /**
  117773. * Box-Imposter type
  117774. */
  117775. static BoxImpostor: number;
  117776. /**
  117777. * Plane-Imposter type
  117778. */
  117779. static PlaneImpostor: number;
  117780. /**
  117781. * Mesh-imposter type
  117782. */
  117783. static MeshImpostor: number;
  117784. /**
  117785. * Capsule-Impostor type (Ammo.js plugin only)
  117786. */
  117787. static CapsuleImpostor: number;
  117788. /**
  117789. * Cylinder-Imposter type
  117790. */
  117791. static CylinderImpostor: number;
  117792. /**
  117793. * Particle-Imposter type
  117794. */
  117795. static ParticleImpostor: number;
  117796. /**
  117797. * Heightmap-Imposter type
  117798. */
  117799. static HeightmapImpostor: number;
  117800. /**
  117801. * ConvexHull-Impostor type (Ammo.js plugin only)
  117802. */
  117803. static ConvexHullImpostor: number;
  117804. /**
  117805. * Custom-Imposter type (Ammo.js plugin only)
  117806. */
  117807. static CustomImpostor: number;
  117808. /**
  117809. * Rope-Imposter type
  117810. */
  117811. static RopeImpostor: number;
  117812. /**
  117813. * Cloth-Imposter type
  117814. */
  117815. static ClothImpostor: number;
  117816. /**
  117817. * Softbody-Imposter type
  117818. */
  117819. static SoftbodyImpostor: number;
  117820. }
  117821. }
  117822. declare module BABYLON {
  117823. /**
  117824. * @hidden
  117825. **/
  117826. export class _CreationDataStorage {
  117827. closePath?: boolean;
  117828. closeArray?: boolean;
  117829. idx: number[];
  117830. dashSize: number;
  117831. gapSize: number;
  117832. path3D: Path3D;
  117833. pathArray: Vector3[][];
  117834. arc: number;
  117835. radius: number;
  117836. cap: number;
  117837. tessellation: number;
  117838. }
  117839. /**
  117840. * @hidden
  117841. **/
  117842. class _InstanceDataStorage {
  117843. visibleInstances: any;
  117844. batchCache: _InstancesBatch;
  117845. instancesBufferSize: number;
  117846. instancesBuffer: Nullable<Buffer>;
  117847. instancesData: Float32Array;
  117848. overridenInstanceCount: number;
  117849. isFrozen: boolean;
  117850. previousBatch: Nullable<_InstancesBatch>;
  117851. hardwareInstancedRendering: boolean;
  117852. sideOrientation: number;
  117853. manualUpdate: boolean;
  117854. previousRenderId: number;
  117855. }
  117856. /**
  117857. * @hidden
  117858. **/
  117859. export class _InstancesBatch {
  117860. mustReturn: boolean;
  117861. visibleInstances: Nullable<InstancedMesh[]>[];
  117862. renderSelf: boolean[];
  117863. hardwareInstancedRendering: boolean[];
  117864. }
  117865. /**
  117866. * @hidden
  117867. **/
  117868. class _ThinInstanceDataStorage {
  117869. instancesCount: number;
  117870. matrixBuffer: Nullable<Buffer>;
  117871. matrixBufferSize: number;
  117872. matrixData: Nullable<Float32Array>;
  117873. boundingVectors: Array<Vector3>;
  117874. worldMatrices: Nullable<Matrix[]>;
  117875. }
  117876. /**
  117877. * Class used to represent renderable models
  117878. */
  117879. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  117880. /**
  117881. * Mesh side orientation : usually the external or front surface
  117882. */
  117883. static readonly FRONTSIDE: number;
  117884. /**
  117885. * Mesh side orientation : usually the internal or back surface
  117886. */
  117887. static readonly BACKSIDE: number;
  117888. /**
  117889. * Mesh side orientation : both internal and external or front and back surfaces
  117890. */
  117891. static readonly DOUBLESIDE: number;
  117892. /**
  117893. * Mesh side orientation : by default, `FRONTSIDE`
  117894. */
  117895. static readonly DEFAULTSIDE: number;
  117896. /**
  117897. * Mesh cap setting : no cap
  117898. */
  117899. static readonly NO_CAP: number;
  117900. /**
  117901. * Mesh cap setting : one cap at the beginning of the mesh
  117902. */
  117903. static readonly CAP_START: number;
  117904. /**
  117905. * Mesh cap setting : one cap at the end of the mesh
  117906. */
  117907. static readonly CAP_END: number;
  117908. /**
  117909. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  117910. */
  117911. static readonly CAP_ALL: number;
  117912. /**
  117913. * Mesh pattern setting : no flip or rotate
  117914. */
  117915. static readonly NO_FLIP: number;
  117916. /**
  117917. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  117918. */
  117919. static readonly FLIP_TILE: number;
  117920. /**
  117921. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  117922. */
  117923. static readonly ROTATE_TILE: number;
  117924. /**
  117925. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  117926. */
  117927. static readonly FLIP_ROW: number;
  117928. /**
  117929. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  117930. */
  117931. static readonly ROTATE_ROW: number;
  117932. /**
  117933. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  117934. */
  117935. static readonly FLIP_N_ROTATE_TILE: number;
  117936. /**
  117937. * Mesh pattern setting : rotate pattern and rotate
  117938. */
  117939. static readonly FLIP_N_ROTATE_ROW: number;
  117940. /**
  117941. * Mesh tile positioning : part tiles same on left/right or top/bottom
  117942. */
  117943. static readonly CENTER: number;
  117944. /**
  117945. * Mesh tile positioning : part tiles on left
  117946. */
  117947. static readonly LEFT: number;
  117948. /**
  117949. * Mesh tile positioning : part tiles on right
  117950. */
  117951. static readonly RIGHT: number;
  117952. /**
  117953. * Mesh tile positioning : part tiles on top
  117954. */
  117955. static readonly TOP: number;
  117956. /**
  117957. * Mesh tile positioning : part tiles on bottom
  117958. */
  117959. static readonly BOTTOM: number;
  117960. /**
  117961. * Gets the default side orientation.
  117962. * @param orientation the orientation to value to attempt to get
  117963. * @returns the default orientation
  117964. * @hidden
  117965. */
  117966. static _GetDefaultSideOrientation(orientation?: number): number;
  117967. private _internalMeshDataInfo;
  117968. get computeBonesUsingShaders(): boolean;
  117969. set computeBonesUsingShaders(value: boolean);
  117970. /**
  117971. * An event triggered before rendering the mesh
  117972. */
  117973. get onBeforeRenderObservable(): Observable<Mesh>;
  117974. /**
  117975. * An event triggered before binding the mesh
  117976. */
  117977. get onBeforeBindObservable(): Observable<Mesh>;
  117978. /**
  117979. * An event triggered after rendering the mesh
  117980. */
  117981. get onAfterRenderObservable(): Observable<Mesh>;
  117982. /**
  117983. * An event triggered before drawing the mesh
  117984. */
  117985. get onBeforeDrawObservable(): Observable<Mesh>;
  117986. private _onBeforeDrawObserver;
  117987. /**
  117988. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  117989. */
  117990. set onBeforeDraw(callback: () => void);
  117991. get hasInstances(): boolean;
  117992. get hasThinInstances(): boolean;
  117993. /**
  117994. * Gets the delay loading state of the mesh (when delay loading is turned on)
  117995. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  117996. */
  117997. delayLoadState: number;
  117998. /**
  117999. * Gets the list of instances created from this mesh
  118000. * it is not supposed to be modified manually.
  118001. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  118002. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118003. */
  118004. instances: InstancedMesh[];
  118005. /**
  118006. * Gets the file containing delay loading data for this mesh
  118007. */
  118008. delayLoadingFile: string;
  118009. /** @hidden */
  118010. _binaryInfo: any;
  118011. /**
  118012. * User defined function used to change how LOD level selection is done
  118013. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118014. */
  118015. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  118016. /**
  118017. * Gets or sets the morph target manager
  118018. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  118019. */
  118020. get morphTargetManager(): Nullable<MorphTargetManager>;
  118021. set morphTargetManager(value: Nullable<MorphTargetManager>);
  118022. /** @hidden */
  118023. _creationDataStorage: Nullable<_CreationDataStorage>;
  118024. /** @hidden */
  118025. _geometry: Nullable<Geometry>;
  118026. /** @hidden */
  118027. _delayInfo: Array<string>;
  118028. /** @hidden */
  118029. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  118030. /** @hidden */
  118031. _instanceDataStorage: _InstanceDataStorage;
  118032. /** @hidden */
  118033. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  118034. private _effectiveMaterial;
  118035. /** @hidden */
  118036. _shouldGenerateFlatShading: boolean;
  118037. /** @hidden */
  118038. _originalBuilderSideOrientation: number;
  118039. /**
  118040. * Use this property to change the original side orientation defined at construction time
  118041. */
  118042. overrideMaterialSideOrientation: Nullable<number>;
  118043. /**
  118044. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  118045. * Note this will reduce performance when set to true.
  118046. */
  118047. ignoreCameraMaxZ: boolean;
  118048. /**
  118049. * Gets the source mesh (the one used to clone this one from)
  118050. */
  118051. get source(): Nullable<Mesh>;
  118052. /**
  118053. * Gets the list of clones of this mesh
  118054. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  118055. * Note that useClonedMeshMap=true is the default setting
  118056. */
  118057. get cloneMeshMap(): Nullable<{
  118058. [id: string]: Mesh | undefined;
  118059. }>;
  118060. /**
  118061. * Gets or sets a boolean indicating that this mesh does not use index buffer
  118062. */
  118063. get isUnIndexed(): boolean;
  118064. set isUnIndexed(value: boolean);
  118065. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  118066. get worldMatrixInstancedBuffer(): Float32Array;
  118067. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  118068. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  118069. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  118070. /**
  118071. * @constructor
  118072. * @param name The value used by scene.getMeshByName() to do a lookup.
  118073. * @param scene The scene to add this mesh to.
  118074. * @param parent The parent of this mesh, if it has one
  118075. * @param source An optional Mesh from which geometry is shared, cloned.
  118076. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  118077. * When false, achieved by calling a clone(), also passing False.
  118078. * This will make creation of children, recursive.
  118079. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  118080. */
  118081. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  118082. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  118083. doNotInstantiate: boolean;
  118084. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  118085. /**
  118086. * Gets the class name
  118087. * @returns the string "Mesh".
  118088. */
  118089. getClassName(): string;
  118090. /** @hidden */
  118091. get _isMesh(): boolean;
  118092. /**
  118093. * Returns a description of this mesh
  118094. * @param fullDetails define if full details about this mesh must be used
  118095. * @returns a descriptive string representing this mesh
  118096. */
  118097. toString(fullDetails?: boolean): string;
  118098. /** @hidden */
  118099. _unBindEffect(): void;
  118100. /**
  118101. * Gets a boolean indicating if this mesh has LOD
  118102. */
  118103. get hasLODLevels(): boolean;
  118104. /**
  118105. * Gets the list of MeshLODLevel associated with the current mesh
  118106. * @returns an array of MeshLODLevel
  118107. */
  118108. getLODLevels(): MeshLODLevel[];
  118109. private _sortLODLevels;
  118110. /**
  118111. * Add a mesh as LOD level triggered at the given distance.
  118112. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118113. * @param distance The distance from the center of the object to show this level
  118114. * @param mesh The mesh to be added as LOD level (can be null)
  118115. * @return This mesh (for chaining)
  118116. */
  118117. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  118118. /**
  118119. * Returns the LOD level mesh at the passed distance or null if not found.
  118120. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118121. * @param distance The distance from the center of the object to show this level
  118122. * @returns a Mesh or `null`
  118123. */
  118124. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  118125. /**
  118126. * Remove a mesh from the LOD array
  118127. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118128. * @param mesh defines the mesh to be removed
  118129. * @return This mesh (for chaining)
  118130. */
  118131. removeLODLevel(mesh: Mesh): Mesh;
  118132. /**
  118133. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  118134. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118135. * @param camera defines the camera to use to compute distance
  118136. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  118137. * @return This mesh (for chaining)
  118138. */
  118139. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  118140. /**
  118141. * Gets the mesh internal Geometry object
  118142. */
  118143. get geometry(): Nullable<Geometry>;
  118144. /**
  118145. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  118146. * @returns the total number of vertices
  118147. */
  118148. getTotalVertices(): number;
  118149. /**
  118150. * Returns the content of an associated vertex buffer
  118151. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118152. * - VertexBuffer.PositionKind
  118153. * - VertexBuffer.UVKind
  118154. * - VertexBuffer.UV2Kind
  118155. * - VertexBuffer.UV3Kind
  118156. * - VertexBuffer.UV4Kind
  118157. * - VertexBuffer.UV5Kind
  118158. * - VertexBuffer.UV6Kind
  118159. * - VertexBuffer.ColorKind
  118160. * - VertexBuffer.MatricesIndicesKind
  118161. * - VertexBuffer.MatricesIndicesExtraKind
  118162. * - VertexBuffer.MatricesWeightsKind
  118163. * - VertexBuffer.MatricesWeightsExtraKind
  118164. * @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
  118165. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  118166. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  118167. */
  118168. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  118169. /**
  118170. * Returns the mesh VertexBuffer object from the requested `kind`
  118171. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118172. * - VertexBuffer.PositionKind
  118173. * - VertexBuffer.NormalKind
  118174. * - VertexBuffer.UVKind
  118175. * - VertexBuffer.UV2Kind
  118176. * - VertexBuffer.UV3Kind
  118177. * - VertexBuffer.UV4Kind
  118178. * - VertexBuffer.UV5Kind
  118179. * - VertexBuffer.UV6Kind
  118180. * - VertexBuffer.ColorKind
  118181. * - VertexBuffer.MatricesIndicesKind
  118182. * - VertexBuffer.MatricesIndicesExtraKind
  118183. * - VertexBuffer.MatricesWeightsKind
  118184. * - VertexBuffer.MatricesWeightsExtraKind
  118185. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  118186. */
  118187. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  118188. /**
  118189. * Tests if a specific vertex buffer is associated with this mesh
  118190. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  118191. * - VertexBuffer.PositionKind
  118192. * - VertexBuffer.NormalKind
  118193. * - VertexBuffer.UVKind
  118194. * - VertexBuffer.UV2Kind
  118195. * - VertexBuffer.UV3Kind
  118196. * - VertexBuffer.UV4Kind
  118197. * - VertexBuffer.UV5Kind
  118198. * - VertexBuffer.UV6Kind
  118199. * - VertexBuffer.ColorKind
  118200. * - VertexBuffer.MatricesIndicesKind
  118201. * - VertexBuffer.MatricesIndicesExtraKind
  118202. * - VertexBuffer.MatricesWeightsKind
  118203. * - VertexBuffer.MatricesWeightsExtraKind
  118204. * @returns a boolean
  118205. */
  118206. isVerticesDataPresent(kind: string): boolean;
  118207. /**
  118208. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  118209. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  118210. * - VertexBuffer.PositionKind
  118211. * - VertexBuffer.UVKind
  118212. * - VertexBuffer.UV2Kind
  118213. * - VertexBuffer.UV3Kind
  118214. * - VertexBuffer.UV4Kind
  118215. * - VertexBuffer.UV5Kind
  118216. * - VertexBuffer.UV6Kind
  118217. * - VertexBuffer.ColorKind
  118218. * - VertexBuffer.MatricesIndicesKind
  118219. * - VertexBuffer.MatricesIndicesExtraKind
  118220. * - VertexBuffer.MatricesWeightsKind
  118221. * - VertexBuffer.MatricesWeightsExtraKind
  118222. * @returns a boolean
  118223. */
  118224. isVertexBufferUpdatable(kind: string): boolean;
  118225. /**
  118226. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  118227. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118228. * - VertexBuffer.PositionKind
  118229. * - VertexBuffer.NormalKind
  118230. * - VertexBuffer.UVKind
  118231. * - VertexBuffer.UV2Kind
  118232. * - VertexBuffer.UV3Kind
  118233. * - VertexBuffer.UV4Kind
  118234. * - VertexBuffer.UV5Kind
  118235. * - VertexBuffer.UV6Kind
  118236. * - VertexBuffer.ColorKind
  118237. * - VertexBuffer.MatricesIndicesKind
  118238. * - VertexBuffer.MatricesIndicesExtraKind
  118239. * - VertexBuffer.MatricesWeightsKind
  118240. * - VertexBuffer.MatricesWeightsExtraKind
  118241. * @returns an array of strings
  118242. */
  118243. getVerticesDataKinds(): string[];
  118244. /**
  118245. * Returns a positive integer : the total number of indices in this mesh geometry.
  118246. * @returns the numner of indices or zero if the mesh has no geometry.
  118247. */
  118248. getTotalIndices(): number;
  118249. /**
  118250. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  118251. * @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.
  118252. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118253. * @returns the indices array or an empty array if the mesh has no geometry
  118254. */
  118255. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  118256. get isBlocked(): boolean;
  118257. /**
  118258. * Determine if the current mesh is ready to be rendered
  118259. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  118260. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  118261. * @returns true if all associated assets are ready (material, textures, shaders)
  118262. */
  118263. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  118264. /**
  118265. * 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.
  118266. */
  118267. get areNormalsFrozen(): boolean;
  118268. /**
  118269. * 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.
  118270. * @returns the current mesh
  118271. */
  118272. freezeNormals(): Mesh;
  118273. /**
  118274. * 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
  118275. * @returns the current mesh
  118276. */
  118277. unfreezeNormals(): Mesh;
  118278. /**
  118279. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  118280. */
  118281. set overridenInstanceCount(count: number);
  118282. /** @hidden */
  118283. _preActivate(): Mesh;
  118284. /** @hidden */
  118285. _preActivateForIntermediateRendering(renderId: number): Mesh;
  118286. /** @hidden */
  118287. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  118288. protected _afterComputeWorldMatrix(): void;
  118289. /** @hidden */
  118290. _postActivate(): void;
  118291. /**
  118292. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  118293. * This means the mesh underlying bounding box and sphere are recomputed.
  118294. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  118295. * @returns the current mesh
  118296. */
  118297. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  118298. /** @hidden */
  118299. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  118300. /**
  118301. * This function will subdivide the mesh into multiple submeshes
  118302. * @param count defines the expected number of submeshes
  118303. */
  118304. subdivide(count: number): void;
  118305. /**
  118306. * Copy a FloatArray into a specific associated vertex buffer
  118307. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118308. * - VertexBuffer.PositionKind
  118309. * - VertexBuffer.UVKind
  118310. * - VertexBuffer.UV2Kind
  118311. * - VertexBuffer.UV3Kind
  118312. * - VertexBuffer.UV4Kind
  118313. * - VertexBuffer.UV5Kind
  118314. * - VertexBuffer.UV6Kind
  118315. * - VertexBuffer.ColorKind
  118316. * - VertexBuffer.MatricesIndicesKind
  118317. * - VertexBuffer.MatricesIndicesExtraKind
  118318. * - VertexBuffer.MatricesWeightsKind
  118319. * - VertexBuffer.MatricesWeightsExtraKind
  118320. * @param data defines the data source
  118321. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  118322. * @param stride defines the data stride size (can be null)
  118323. * @returns the current mesh
  118324. */
  118325. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  118326. /**
  118327. * Delete a vertex buffer associated with this mesh
  118328. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  118329. * - VertexBuffer.PositionKind
  118330. * - VertexBuffer.UVKind
  118331. * - VertexBuffer.UV2Kind
  118332. * - VertexBuffer.UV3Kind
  118333. * - VertexBuffer.UV4Kind
  118334. * - VertexBuffer.UV5Kind
  118335. * - VertexBuffer.UV6Kind
  118336. * - VertexBuffer.ColorKind
  118337. * - VertexBuffer.MatricesIndicesKind
  118338. * - VertexBuffer.MatricesIndicesExtraKind
  118339. * - VertexBuffer.MatricesWeightsKind
  118340. * - VertexBuffer.MatricesWeightsExtraKind
  118341. */
  118342. removeVerticesData(kind: string): void;
  118343. /**
  118344. * Flags an associated vertex buffer as updatable
  118345. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  118346. * - VertexBuffer.PositionKind
  118347. * - VertexBuffer.UVKind
  118348. * - VertexBuffer.UV2Kind
  118349. * - VertexBuffer.UV3Kind
  118350. * - VertexBuffer.UV4Kind
  118351. * - VertexBuffer.UV5Kind
  118352. * - VertexBuffer.UV6Kind
  118353. * - VertexBuffer.ColorKind
  118354. * - VertexBuffer.MatricesIndicesKind
  118355. * - VertexBuffer.MatricesIndicesExtraKind
  118356. * - VertexBuffer.MatricesWeightsKind
  118357. * - VertexBuffer.MatricesWeightsExtraKind
  118358. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  118359. */
  118360. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  118361. /**
  118362. * Sets the mesh global Vertex Buffer
  118363. * @param buffer defines the buffer to use
  118364. * @returns the current mesh
  118365. */
  118366. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  118367. /**
  118368. * Update a specific associated vertex buffer
  118369. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118370. * - VertexBuffer.PositionKind
  118371. * - VertexBuffer.UVKind
  118372. * - VertexBuffer.UV2Kind
  118373. * - VertexBuffer.UV3Kind
  118374. * - VertexBuffer.UV4Kind
  118375. * - VertexBuffer.UV5Kind
  118376. * - VertexBuffer.UV6Kind
  118377. * - VertexBuffer.ColorKind
  118378. * - VertexBuffer.MatricesIndicesKind
  118379. * - VertexBuffer.MatricesIndicesExtraKind
  118380. * - VertexBuffer.MatricesWeightsKind
  118381. * - VertexBuffer.MatricesWeightsExtraKind
  118382. * @param data defines the data source
  118383. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  118384. * @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)
  118385. * @returns the current mesh
  118386. */
  118387. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  118388. /**
  118389. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  118390. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  118391. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  118392. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  118393. * @returns the current mesh
  118394. */
  118395. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  118396. /**
  118397. * Creates a un-shared specific occurence of the geometry for the mesh.
  118398. * @returns the current mesh
  118399. */
  118400. makeGeometryUnique(): Mesh;
  118401. /**
  118402. * Set the index buffer of this mesh
  118403. * @param indices defines the source data
  118404. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  118405. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  118406. * @returns the current mesh
  118407. */
  118408. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  118409. /**
  118410. * Update the current index buffer
  118411. * @param indices defines the source data
  118412. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  118413. * @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)
  118414. * @returns the current mesh
  118415. */
  118416. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  118417. /**
  118418. * Invert the geometry to move from a right handed system to a left handed one.
  118419. * @returns the current mesh
  118420. */
  118421. toLeftHanded(): Mesh;
  118422. /** @hidden */
  118423. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  118424. /** @hidden */
  118425. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  118426. /**
  118427. * Registers for this mesh a javascript function called just before the rendering process
  118428. * @param func defines the function to call before rendering this mesh
  118429. * @returns the current mesh
  118430. */
  118431. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118432. /**
  118433. * Disposes a previously registered javascript function called before the rendering
  118434. * @param func defines the function to remove
  118435. * @returns the current mesh
  118436. */
  118437. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118438. /**
  118439. * Registers for this mesh a javascript function called just after the rendering is complete
  118440. * @param func defines the function to call after rendering this mesh
  118441. * @returns the current mesh
  118442. */
  118443. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118444. /**
  118445. * Disposes a previously registered javascript function called after the rendering.
  118446. * @param func defines the function to remove
  118447. * @returns the current mesh
  118448. */
  118449. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118450. /** @hidden */
  118451. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  118452. /** @hidden */
  118453. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  118454. /** @hidden */
  118455. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  118456. /** @hidden */
  118457. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  118458. /** @hidden */
  118459. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  118460. /** @hidden */
  118461. _rebuild(): void;
  118462. /** @hidden */
  118463. _freeze(): void;
  118464. /** @hidden */
  118465. _unFreeze(): void;
  118466. /**
  118467. * 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
  118468. * @param subMesh defines the subMesh to render
  118469. * @param enableAlphaMode defines if alpha mode can be changed
  118470. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  118471. * @returns the current mesh
  118472. */
  118473. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  118474. private _onBeforeDraw;
  118475. /**
  118476. * Renormalize the mesh and patch it up if there are no weights
  118477. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  118478. * However in the case of zero weights then we set just a single influence to 1.
  118479. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  118480. */
  118481. cleanMatrixWeights(): void;
  118482. private normalizeSkinFourWeights;
  118483. private normalizeSkinWeightsAndExtra;
  118484. /**
  118485. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  118486. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  118487. * the user know there was an issue with importing the mesh
  118488. * @returns a validation object with skinned, valid and report string
  118489. */
  118490. validateSkinning(): {
  118491. skinned: boolean;
  118492. valid: boolean;
  118493. report: string;
  118494. };
  118495. /** @hidden */
  118496. _checkDelayState(): Mesh;
  118497. private _queueLoad;
  118498. /**
  118499. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  118500. * A mesh is in the frustum if its bounding box intersects the frustum
  118501. * @param frustumPlanes defines the frustum to test
  118502. * @returns true if the mesh is in the frustum planes
  118503. */
  118504. isInFrustum(frustumPlanes: Plane[]): boolean;
  118505. /**
  118506. * Sets the mesh material by the material or multiMaterial `id` property
  118507. * @param id is a string identifying the material or the multiMaterial
  118508. * @returns the current mesh
  118509. */
  118510. setMaterialByID(id: string): Mesh;
  118511. /**
  118512. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  118513. * @returns an array of IAnimatable
  118514. */
  118515. getAnimatables(): IAnimatable[];
  118516. /**
  118517. * Modifies the mesh geometry according to the passed transformation matrix.
  118518. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  118519. * The mesh normals are modified using the same transformation.
  118520. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118521. * @param transform defines the transform matrix to use
  118522. * @see https://doc.babylonjs.com/resources/baking_transformations
  118523. * @returns the current mesh
  118524. */
  118525. bakeTransformIntoVertices(transform: Matrix): Mesh;
  118526. /**
  118527. * Modifies the mesh geometry according to its own current World Matrix.
  118528. * The mesh World Matrix is then reset.
  118529. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  118530. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118531. * @see https://doc.babylonjs.com/resources/baking_transformations
  118532. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  118533. * @returns the current mesh
  118534. */
  118535. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  118536. /** @hidden */
  118537. get _positions(): Nullable<Vector3[]>;
  118538. /** @hidden */
  118539. _resetPointsArrayCache(): Mesh;
  118540. /** @hidden */
  118541. _generatePointsArray(): boolean;
  118542. /**
  118543. * Returns a new Mesh object generated from the current mesh properties.
  118544. * This method must not get confused with createInstance()
  118545. * @param name is a string, the name given to the new mesh
  118546. * @param newParent can be any Node object (default `null`)
  118547. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  118548. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  118549. * @returns a new mesh
  118550. */
  118551. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  118552. /**
  118553. * Releases resources associated with this mesh.
  118554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118556. */
  118557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118558. /** @hidden */
  118559. _disposeInstanceSpecificData(): void;
  118560. /** @hidden */
  118561. _disposeThinInstanceSpecificData(): void;
  118562. /**
  118563. * Modifies the mesh geometry according to a displacement map.
  118564. * 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.
  118565. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118566. * @param url is a string, the URL from the image file is to be downloaded.
  118567. * @param minHeight is the lower limit of the displacement.
  118568. * @param maxHeight is the upper limit of the displacement.
  118569. * @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.
  118570. * @param uvOffset is an optional vector2 used to offset UV.
  118571. * @param uvScale is an optional vector2 used to scale UV.
  118572. * @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.
  118573. * @returns the Mesh.
  118574. */
  118575. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118576. /**
  118577. * Modifies the mesh geometry according to a displacementMap buffer.
  118578. * 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.
  118579. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118580. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  118581. * @param heightMapWidth is the width of the buffer image.
  118582. * @param heightMapHeight is the height of the buffer image.
  118583. * @param minHeight is the lower limit of the displacement.
  118584. * @param maxHeight is the upper limit of the displacement.
  118585. * @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.
  118586. * @param uvOffset is an optional vector2 used to offset UV.
  118587. * @param uvScale is an optional vector2 used to scale UV.
  118588. * @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.
  118589. * @returns the Mesh.
  118590. */
  118591. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118592. /**
  118593. * Modify the mesh to get a flat shading rendering.
  118594. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  118595. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  118596. * @returns current mesh
  118597. */
  118598. convertToFlatShadedMesh(): Mesh;
  118599. /**
  118600. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  118601. * In other words, more vertices, no more indices and a single bigger VBO.
  118602. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  118603. * @returns current mesh
  118604. */
  118605. convertToUnIndexedMesh(): Mesh;
  118606. /**
  118607. * Inverses facet orientations.
  118608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118609. * @param flipNormals will also inverts the normals
  118610. * @returns current mesh
  118611. */
  118612. flipFaces(flipNormals?: boolean): Mesh;
  118613. /**
  118614. * Increase the number of facets and hence vertices in a mesh
  118615. * Vertex normals are interpolated from existing vertex normals
  118616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118617. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  118618. */
  118619. increaseVertices(numberPerEdge: number): void;
  118620. /**
  118621. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  118622. * This will undo any application of covertToFlatShadedMesh
  118623. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118624. */
  118625. forceSharedVertices(): void;
  118626. /** @hidden */
  118627. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  118628. /** @hidden */
  118629. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  118630. /**
  118631. * Creates a new InstancedMesh object from the mesh model.
  118632. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118633. * @param name defines the name of the new instance
  118634. * @returns a new InstancedMesh
  118635. */
  118636. createInstance(name: string): InstancedMesh;
  118637. /**
  118638. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  118639. * After this call, all the mesh instances have the same submeshes than the current mesh.
  118640. * @returns the current mesh
  118641. */
  118642. synchronizeInstances(): Mesh;
  118643. /**
  118644. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  118645. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  118646. * This should be used together with the simplification to avoid disappearing triangles.
  118647. * @param successCallback an optional success callback to be called after the optimization finished.
  118648. * @returns the current mesh
  118649. */
  118650. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  118651. /**
  118652. * Serialize current mesh
  118653. * @param serializationObject defines the object which will receive the serialization data
  118654. */
  118655. serialize(serializationObject: any): void;
  118656. /** @hidden */
  118657. _syncGeometryWithMorphTargetManager(): void;
  118658. /** @hidden */
  118659. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  118660. /**
  118661. * Returns a new Mesh object parsed from the source provided.
  118662. * @param parsedMesh is the source
  118663. * @param scene defines the hosting scene
  118664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  118665. * @returns a new Mesh
  118666. */
  118667. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  118668. /**
  118669. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  118670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118671. * @param name defines the name of the mesh to create
  118672. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  118673. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  118674. * @param closePath creates a seam between the first and the last points of each path of the path array
  118675. * @param offset is taken in account only if the `pathArray` is containing a single path
  118676. * @param scene defines the hosting scene
  118677. * @param updatable defines if the mesh must be flagged as updatable
  118678. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118679. * @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)
  118680. * @returns a new Mesh
  118681. */
  118682. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118683. /**
  118684. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  118685. * @param name defines the name of the mesh to create
  118686. * @param radius sets the radius size (float) of the polygon (default 0.5)
  118687. * @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
  118688. * @param scene defines the hosting scene
  118689. * @param updatable defines if the mesh must be flagged as updatable
  118690. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118691. * @returns a new Mesh
  118692. */
  118693. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118694. /**
  118695. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  118696. * @param name defines the name of the mesh to create
  118697. * @param size sets the size (float) of each box side (default 1)
  118698. * @param scene defines the hosting scene
  118699. * @param updatable defines if the mesh must be flagged as updatable
  118700. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118701. * @returns a new Mesh
  118702. */
  118703. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118704. /**
  118705. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  118706. * @param name defines the name of the mesh to create
  118707. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118708. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118709. * @param scene defines the hosting scene
  118710. * @param updatable defines if the mesh must be flagged as updatable
  118711. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118712. * @returns a new Mesh
  118713. */
  118714. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118715. /**
  118716. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  118717. * @param name defines the name of the mesh to create
  118718. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118719. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118720. * @param scene defines the hosting scene
  118721. * @returns a new Mesh
  118722. */
  118723. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  118724. /**
  118725. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  118726. * @param name defines the name of the mesh to create
  118727. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  118728. * @param diameterTop set the top cap diameter (floats, default 1)
  118729. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  118730. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  118731. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  118732. * @param scene defines the hosting scene
  118733. * @param updatable defines if the mesh must be flagged as updatable
  118734. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118735. * @returns a new Mesh
  118736. */
  118737. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  118738. /**
  118739. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  118740. * @param name defines the name of the mesh to create
  118741. * @param diameter sets the diameter size (float) of the torus (default 1)
  118742. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  118743. * @param tessellation sets the number of torus sides (postive integer, default 16)
  118744. * @param scene defines the hosting scene
  118745. * @param updatable defines if the mesh must be flagged as updatable
  118746. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118747. * @returns a new Mesh
  118748. */
  118749. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118750. /**
  118751. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  118752. * @param name defines the name of the mesh to create
  118753. * @param radius sets the global radius size (float) of the torus knot (default 2)
  118754. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  118755. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  118756. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  118757. * @param p the number of windings on X axis (positive integers, default 2)
  118758. * @param q the number of windings on Y axis (positive integers, default 3)
  118759. * @param scene defines the hosting scene
  118760. * @param updatable defines if the mesh must be flagged as updatable
  118761. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118762. * @returns a new Mesh
  118763. */
  118764. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118765. /**
  118766. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  118767. * @param name defines the name of the mesh to create
  118768. * @param points is an array successive Vector3
  118769. * @param scene defines the hosting scene
  118770. * @param updatable defines if the mesh must be flagged as updatable
  118771. * @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).
  118772. * @returns a new Mesh
  118773. */
  118774. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  118775. /**
  118776. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  118777. * @param name defines the name of the mesh to create
  118778. * @param points is an array successive Vector3
  118779. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  118780. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118781. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  118782. * @param scene defines the hosting scene
  118783. * @param updatable defines if the mesh must be flagged as updatable
  118784. * @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)
  118785. * @returns a new Mesh
  118786. */
  118787. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  118788. /**
  118789. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  118790. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  118791. * 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.
  118792. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118793. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118794. * Remember you can only change the shape positions, not their number when updating a polygon.
  118795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118796. * @param name defines the name of the mesh to create
  118797. * @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
  118798. * @param scene defines the hosting scene
  118799. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118800. * @param updatable defines if the mesh must be flagged as updatable
  118801. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118802. * @param earcutInjection can be used to inject your own earcut reference
  118803. * @returns a new Mesh
  118804. */
  118805. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118806. /**
  118807. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  118808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  118809. * @param name defines the name of the mesh to create
  118810. * @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
  118811. * @param depth defines the height of extrusion
  118812. * @param scene defines the hosting scene
  118813. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118814. * @param updatable defines if the mesh must be flagged as updatable
  118815. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118816. * @param earcutInjection can be used to inject your own earcut reference
  118817. * @returns a new Mesh
  118818. */
  118819. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118820. /**
  118821. * Creates an extruded shape mesh.
  118822. * 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
  118823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118825. * @param name defines the name of the mesh to create
  118826. * @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
  118827. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118828. * @param scale is the value to scale the shape
  118829. * @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
  118830. * @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
  118831. * @param scene defines the hosting scene
  118832. * @param updatable defines if the mesh must be flagged as updatable
  118833. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118834. * @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)
  118835. * @returns a new Mesh
  118836. */
  118837. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118838. /**
  118839. * Creates an custom extruded shape mesh.
  118840. * The custom extrusion is a parametric shape.
  118841. * It has no predefined shape. Its final shape will depend on the input parameters.
  118842. * Please consider using the same method from the MeshBuilder class instead
  118843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118844. * @param name defines the name of the mesh to create
  118845. * @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
  118846. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118847. * @param scaleFunction is a custom Javascript function called on each path point
  118848. * @param rotationFunction is a custom Javascript function called on each path point
  118849. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118850. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  118851. * @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
  118852. * @param scene defines the hosting scene
  118853. * @param updatable defines if the mesh must be flagged as updatable
  118854. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118855. * @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)
  118856. * @returns a new Mesh
  118857. */
  118858. 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;
  118859. /**
  118860. * Creates lathe mesh.
  118861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  118862. * Please consider using the same method from the MeshBuilder class instead
  118863. * @param name defines the name of the mesh to create
  118864. * @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
  118865. * @param radius is the radius value of the lathe
  118866. * @param tessellation is the side number of the lathe.
  118867. * @param scene defines the hosting scene
  118868. * @param updatable defines if the mesh must be flagged as updatable
  118869. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118870. * @returns a new Mesh
  118871. */
  118872. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118873. /**
  118874. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  118875. * @param name defines the name of the mesh to create
  118876. * @param size sets the size (float) of both sides of the plane at once (default 1)
  118877. * @param scene defines the hosting scene
  118878. * @param updatable defines if the mesh must be flagged as updatable
  118879. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118880. * @returns a new Mesh
  118881. */
  118882. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118883. /**
  118884. * Creates a ground mesh.
  118885. * Please consider using the same method from the MeshBuilder class instead
  118886. * @param name defines the name of the mesh to create
  118887. * @param width set the width of the ground
  118888. * @param height set the height of the ground
  118889. * @param subdivisions sets the number of subdivisions per side
  118890. * @param scene defines the hosting scene
  118891. * @param updatable defines if the mesh must be flagged as updatable
  118892. * @returns a new Mesh
  118893. */
  118894. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  118895. /**
  118896. * Creates a tiled ground mesh.
  118897. * Please consider using the same method from the MeshBuilder class instead
  118898. * @param name defines the name of the mesh to create
  118899. * @param xmin set the ground minimum X coordinate
  118900. * @param zmin set the ground minimum Y coordinate
  118901. * @param xmax set the ground maximum X coordinate
  118902. * @param zmax set the ground maximum Z coordinate
  118903. * @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
  118904. * @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
  118905. * @param scene defines the hosting scene
  118906. * @param updatable defines if the mesh must be flagged as updatable
  118907. * @returns a new Mesh
  118908. */
  118909. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  118910. w: number;
  118911. h: number;
  118912. }, precision: {
  118913. w: number;
  118914. h: number;
  118915. }, scene: Scene, updatable?: boolean): Mesh;
  118916. /**
  118917. * Creates a ground mesh from a height map.
  118918. * Please consider using the same method from the MeshBuilder class instead
  118919. * @see https://doc.babylonjs.com/babylon101/height_map
  118920. * @param name defines the name of the mesh to create
  118921. * @param url sets the URL of the height map image resource
  118922. * @param width set the ground width size
  118923. * @param height set the ground height size
  118924. * @param subdivisions sets the number of subdivision per side
  118925. * @param minHeight is the minimum altitude on the ground
  118926. * @param maxHeight is the maximum altitude on the ground
  118927. * @param scene defines the hosting scene
  118928. * @param updatable defines if the mesh must be flagged as updatable
  118929. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  118930. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118931. * @returns a new Mesh
  118932. */
  118933. 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;
  118934. /**
  118935. * Creates a tube mesh.
  118936. * The tube is a parametric shape.
  118937. * It has no predefined shape. Its final shape will depend on the input parameters.
  118938. * Please consider using the same method from the MeshBuilder class instead
  118939. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118940. * @param name defines the name of the mesh to create
  118941. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  118942. * @param radius sets the tube radius size
  118943. * @param tessellation is the number of sides on the tubular surface
  118944. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  118945. * @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
  118946. * @param scene defines the hosting scene
  118947. * @param updatable defines if the mesh must be flagged as updatable
  118948. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118949. * @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)
  118950. * @returns a new Mesh
  118951. */
  118952. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  118953. (i: number, distance: number): number;
  118954. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118955. /**
  118956. * Creates a polyhedron mesh.
  118957. * Please consider using the same method from the MeshBuilder class instead.
  118958. * * 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
  118959. * * The parameter `size` (positive float, default 1) sets the polygon size
  118960. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118961. * * 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`
  118962. * * 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
  118963. * * 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)`)
  118964. * * 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
  118965. * * 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
  118966. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118969. * @param name defines the name of the mesh to create
  118970. * @param options defines the options used to create the mesh
  118971. * @param scene defines the hosting scene
  118972. * @returns a new Mesh
  118973. */
  118974. static CreatePolyhedron(name: string, options: {
  118975. type?: number;
  118976. size?: number;
  118977. sizeX?: number;
  118978. sizeY?: number;
  118979. sizeZ?: number;
  118980. custom?: any;
  118981. faceUV?: Vector4[];
  118982. faceColors?: Color4[];
  118983. updatable?: boolean;
  118984. sideOrientation?: number;
  118985. }, scene: Scene): Mesh;
  118986. /**
  118987. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118988. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118989. * * 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`)
  118990. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118991. * * 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
  118992. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118995. * @param name defines the name of the mesh
  118996. * @param options defines the options used to create the mesh
  118997. * @param scene defines the hosting scene
  118998. * @returns a new Mesh
  118999. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119000. */
  119001. static CreateIcoSphere(name: string, options: {
  119002. radius?: number;
  119003. flat?: boolean;
  119004. subdivisions?: number;
  119005. sideOrientation?: number;
  119006. updatable?: boolean;
  119007. }, scene: Scene): Mesh;
  119008. /**
  119009. * Creates a decal mesh.
  119010. * Please consider using the same method from the MeshBuilder class instead.
  119011. * A decal is a mesh usually applied as a model onto the surface of another mesh
  119012. * @param name defines the name of the mesh
  119013. * @param sourceMesh defines the mesh receiving the decal
  119014. * @param position sets the position of the decal in world coordinates
  119015. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  119016. * @param size sets the decal scaling
  119017. * @param angle sets the angle to rotate the decal
  119018. * @returns a new Mesh
  119019. */
  119020. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  119021. /** Creates a Capsule Mesh
  119022. * @param name defines the name of the mesh.
  119023. * @param options the constructors options used to shape the mesh.
  119024. * @param scene defines the scene the mesh is scoped to.
  119025. * @returns the capsule mesh
  119026. * @see https://doc.babylonjs.com/how_to/capsule_shape
  119027. */
  119028. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  119029. /**
  119030. * Prepare internal position array for software CPU skinning
  119031. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  119032. */
  119033. setPositionsForCPUSkinning(): Float32Array;
  119034. /**
  119035. * Prepare internal normal array for software CPU skinning
  119036. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  119037. */
  119038. setNormalsForCPUSkinning(): Float32Array;
  119039. /**
  119040. * Updates the vertex buffer by applying transformation from the bones
  119041. * @param skeleton defines the skeleton to apply to current mesh
  119042. * @returns the current mesh
  119043. */
  119044. applySkeleton(skeleton: Skeleton): Mesh;
  119045. /**
  119046. * 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
  119047. * @param meshes defines the list of meshes to scan
  119048. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  119049. */
  119050. static MinMax(meshes: AbstractMesh[]): {
  119051. min: Vector3;
  119052. max: Vector3;
  119053. };
  119054. /**
  119055. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  119056. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  119057. * @returns a vector3
  119058. */
  119059. static Center(meshesOrMinMaxVector: {
  119060. min: Vector3;
  119061. max: Vector3;
  119062. } | AbstractMesh[]): Vector3;
  119063. /**
  119064. * Merge the array of meshes into a single mesh for performance reasons.
  119065. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  119066. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  119067. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  119068. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  119069. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  119070. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  119071. * @returns a new mesh
  119072. */
  119073. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  119074. /** @hidden */
  119075. addInstance(instance: InstancedMesh): void;
  119076. /** @hidden */
  119077. removeInstance(instance: InstancedMesh): void;
  119078. }
  119079. }
  119080. declare module BABYLON {
  119081. /**
  119082. * The options Interface for creating a Capsule Mesh
  119083. */
  119084. export interface ICreateCapsuleOptions {
  119085. /** The Orientation of the capsule. Default : Vector3.Up() */
  119086. orientation?: Vector3;
  119087. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  119088. subdivisions: number;
  119089. /** Number of cylindrical segments on the capsule. */
  119090. tessellation: number;
  119091. /** Height or Length of the capsule. */
  119092. height: number;
  119093. /** Radius of the capsule. */
  119094. radius: number;
  119095. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  119096. capSubdivisions: number;
  119097. /** Overwrite for the top radius. */
  119098. radiusTop?: number;
  119099. /** Overwrite for the bottom radius. */
  119100. radiusBottom?: number;
  119101. /** Overwrite for the top capSubdivisions. */
  119102. topCapSubdivisions?: number;
  119103. /** Overwrite for the bottom capSubdivisions. */
  119104. bottomCapSubdivisions?: number;
  119105. }
  119106. /**
  119107. * Class containing static functions to help procedurally build meshes
  119108. */
  119109. export class CapsuleBuilder {
  119110. /**
  119111. * Creates a capsule or a pill mesh
  119112. * @param name defines the name of the mesh
  119113. * @param options The constructors options.
  119114. * @param scene The scene the mesh is scoped to.
  119115. * @returns Capsule Mesh
  119116. */
  119117. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  119118. }
  119119. }
  119120. declare module BABYLON {
  119121. /**
  119122. * Define an interface for all classes that will get and set the data on vertices
  119123. */
  119124. export interface IGetSetVerticesData {
  119125. /**
  119126. * Gets a boolean indicating if specific vertex data is present
  119127. * @param kind defines the vertex data kind to use
  119128. * @returns true is data kind is present
  119129. */
  119130. isVerticesDataPresent(kind: string): boolean;
  119131. /**
  119132. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  119133. * @param kind defines the data kind (Position, normal, etc...)
  119134. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  119135. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  119136. * @returns a float array containing vertex data
  119137. */
  119138. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  119139. /**
  119140. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  119141. * @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.
  119142. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  119143. * @returns the indices array or an empty array if the mesh has no geometry
  119144. */
  119145. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  119146. /**
  119147. * Set specific vertex data
  119148. * @param kind defines the data kind (Position, normal, etc...)
  119149. * @param data defines the vertex data to use
  119150. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  119151. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  119152. */
  119153. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  119154. /**
  119155. * Update a specific associated vertex buffer
  119156. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  119157. * - VertexBuffer.PositionKind
  119158. * - VertexBuffer.UVKind
  119159. * - VertexBuffer.UV2Kind
  119160. * - VertexBuffer.UV3Kind
  119161. * - VertexBuffer.UV4Kind
  119162. * - VertexBuffer.UV5Kind
  119163. * - VertexBuffer.UV6Kind
  119164. * - VertexBuffer.ColorKind
  119165. * - VertexBuffer.MatricesIndicesKind
  119166. * - VertexBuffer.MatricesIndicesExtraKind
  119167. * - VertexBuffer.MatricesWeightsKind
  119168. * - VertexBuffer.MatricesWeightsExtraKind
  119169. * @param data defines the data source
  119170. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  119171. * @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)
  119172. */
  119173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  119174. /**
  119175. * Creates a new index buffer
  119176. * @param indices defines the indices to store in the index buffer
  119177. * @param totalVertices defines the total number of vertices (could be null)
  119178. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  119179. */
  119180. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  119181. }
  119182. /**
  119183. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  119184. */
  119185. export class VertexData {
  119186. /**
  119187. * Mesh side orientation : usually the external or front surface
  119188. */
  119189. static readonly FRONTSIDE: number;
  119190. /**
  119191. * Mesh side orientation : usually the internal or back surface
  119192. */
  119193. static readonly BACKSIDE: number;
  119194. /**
  119195. * Mesh side orientation : both internal and external or front and back surfaces
  119196. */
  119197. static readonly DOUBLESIDE: number;
  119198. /**
  119199. * Mesh side orientation : by default, `FRONTSIDE`
  119200. */
  119201. static readonly DEFAULTSIDE: number;
  119202. /**
  119203. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  119204. */
  119205. positions: Nullable<FloatArray>;
  119206. /**
  119207. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  119208. */
  119209. normals: Nullable<FloatArray>;
  119210. /**
  119211. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  119212. */
  119213. tangents: Nullable<FloatArray>;
  119214. /**
  119215. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119216. */
  119217. uvs: Nullable<FloatArray>;
  119218. /**
  119219. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119220. */
  119221. uvs2: Nullable<FloatArray>;
  119222. /**
  119223. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119224. */
  119225. uvs3: Nullable<FloatArray>;
  119226. /**
  119227. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119228. */
  119229. uvs4: Nullable<FloatArray>;
  119230. /**
  119231. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119232. */
  119233. uvs5: Nullable<FloatArray>;
  119234. /**
  119235. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119236. */
  119237. uvs6: Nullable<FloatArray>;
  119238. /**
  119239. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  119240. */
  119241. colors: Nullable<FloatArray>;
  119242. /**
  119243. * 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).
  119244. */
  119245. matricesIndices: Nullable<FloatArray>;
  119246. /**
  119247. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  119248. */
  119249. matricesWeights: Nullable<FloatArray>;
  119250. /**
  119251. * An array extending the number of possible indices
  119252. */
  119253. matricesIndicesExtra: Nullable<FloatArray>;
  119254. /**
  119255. * An array extending the number of possible weights when the number of indices is extended
  119256. */
  119257. matricesWeightsExtra: Nullable<FloatArray>;
  119258. /**
  119259. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  119260. */
  119261. indices: Nullable<IndicesArray>;
  119262. /**
  119263. * Uses the passed data array to set the set the values for the specified kind of data
  119264. * @param data a linear array of floating numbers
  119265. * @param kind the type of data that is being set, eg positions, colors etc
  119266. */
  119267. set(data: FloatArray, kind: string): void;
  119268. /**
  119269. * Associates the vertexData to the passed Mesh.
  119270. * Sets it as updatable or not (default `false`)
  119271. * @param mesh the mesh the vertexData is applied to
  119272. * @param updatable when used and having the value true allows new data to update the vertexData
  119273. * @returns the VertexData
  119274. */
  119275. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  119276. /**
  119277. * Associates the vertexData to the passed Geometry.
  119278. * Sets it as updatable or not (default `false`)
  119279. * @param geometry the geometry the vertexData is applied to
  119280. * @param updatable when used and having the value true allows new data to update the vertexData
  119281. * @returns VertexData
  119282. */
  119283. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  119284. /**
  119285. * Updates the associated mesh
  119286. * @param mesh the mesh to be updated
  119287. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  119288. * @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
  119289. * @returns VertexData
  119290. */
  119291. updateMesh(mesh: Mesh): VertexData;
  119292. /**
  119293. * Updates the associated geometry
  119294. * @param geometry the geometry to be updated
  119295. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  119296. * @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
  119297. * @returns VertexData.
  119298. */
  119299. updateGeometry(geometry: Geometry): VertexData;
  119300. private _applyTo;
  119301. private _update;
  119302. /**
  119303. * Transforms each position and each normal of the vertexData according to the passed Matrix
  119304. * @param matrix the transforming matrix
  119305. * @returns the VertexData
  119306. */
  119307. transform(matrix: Matrix): VertexData;
  119308. /**
  119309. * Merges the passed VertexData into the current one
  119310. * @param other the VertexData to be merged into the current one
  119311. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  119312. * @returns the modified VertexData
  119313. */
  119314. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  119315. private _mergeElement;
  119316. private _validate;
  119317. /**
  119318. * Serializes the VertexData
  119319. * @returns a serialized object
  119320. */
  119321. serialize(): any;
  119322. /**
  119323. * Extracts the vertexData from a mesh
  119324. * @param mesh the mesh from which to extract the VertexData
  119325. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  119326. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  119327. * @returns the object VertexData associated to the passed mesh
  119328. */
  119329. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  119330. /**
  119331. * Extracts the vertexData from the geometry
  119332. * @param geometry the geometry from which to extract the VertexData
  119333. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  119334. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  119335. * @returns the object VertexData associated to the passed mesh
  119336. */
  119337. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  119338. private static _ExtractFrom;
  119339. /**
  119340. * Creates the VertexData for a Ribbon
  119341. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  119342. * * pathArray array of paths, each of which an array of successive Vector3
  119343. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  119344. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  119345. * * 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
  119346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119347. * * 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)
  119348. * * 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)
  119349. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  119350. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  119351. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  119352. * @returns the VertexData of the ribbon
  119353. */
  119354. static CreateRibbon(options: {
  119355. pathArray: Vector3[][];
  119356. closeArray?: boolean;
  119357. closePath?: boolean;
  119358. offset?: number;
  119359. sideOrientation?: number;
  119360. frontUVs?: Vector4;
  119361. backUVs?: Vector4;
  119362. invertUV?: boolean;
  119363. uvs?: Vector2[];
  119364. colors?: Color4[];
  119365. }): VertexData;
  119366. /**
  119367. * Creates the VertexData for a box
  119368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119369. * * size sets the width, height and depth of the box to the value of size, optional default 1
  119370. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  119371. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  119372. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  119373. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  119374. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  119375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119376. * * 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)
  119377. * * 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)
  119378. * @returns the VertexData of the box
  119379. */
  119380. static CreateBox(options: {
  119381. size?: number;
  119382. width?: number;
  119383. height?: number;
  119384. depth?: number;
  119385. faceUV?: Vector4[];
  119386. faceColors?: Color4[];
  119387. sideOrientation?: number;
  119388. frontUVs?: Vector4;
  119389. backUVs?: Vector4;
  119390. }): VertexData;
  119391. /**
  119392. * Creates the VertexData for a tiled box
  119393. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119394. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119395. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  119396. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  119397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119398. * @returns the VertexData of the box
  119399. */
  119400. static CreateTiledBox(options: {
  119401. pattern?: number;
  119402. width?: number;
  119403. height?: number;
  119404. depth?: number;
  119405. tileSize?: number;
  119406. tileWidth?: number;
  119407. tileHeight?: number;
  119408. alignHorizontal?: number;
  119409. alignVertical?: number;
  119410. faceUV?: Vector4[];
  119411. faceColors?: Color4[];
  119412. sideOrientation?: number;
  119413. }): VertexData;
  119414. /**
  119415. * Creates the VertexData for a tiled plane
  119416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119417. * * pattern a limited pattern arrangement depending on the number
  119418. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  119419. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  119420. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  119421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119422. * * 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)
  119423. * * 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)
  119424. * @returns the VertexData of the tiled plane
  119425. */
  119426. static CreateTiledPlane(options: {
  119427. pattern?: number;
  119428. tileSize?: number;
  119429. tileWidth?: number;
  119430. tileHeight?: number;
  119431. size?: number;
  119432. width?: number;
  119433. height?: number;
  119434. alignHorizontal?: number;
  119435. alignVertical?: number;
  119436. sideOrientation?: number;
  119437. frontUVs?: Vector4;
  119438. backUVs?: Vector4;
  119439. }): VertexData;
  119440. /**
  119441. * Creates the VertexData for an ellipsoid, defaults to a sphere
  119442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119443. * * segments sets the number of horizontal strips optional, default 32
  119444. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  119445. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  119446. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  119447. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  119448. * * 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
  119449. * * 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
  119450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119451. * * 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)
  119452. * * 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)
  119453. * @returns the VertexData of the ellipsoid
  119454. */
  119455. static CreateSphere(options: {
  119456. segments?: number;
  119457. diameter?: number;
  119458. diameterX?: number;
  119459. diameterY?: number;
  119460. diameterZ?: number;
  119461. arc?: number;
  119462. slice?: number;
  119463. sideOrientation?: number;
  119464. frontUVs?: Vector4;
  119465. backUVs?: Vector4;
  119466. }): VertexData;
  119467. /**
  119468. * Creates the VertexData for a cylinder, cone or prism
  119469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119470. * * height sets the height (y direction) of the cylinder, optional, default 2
  119471. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  119472. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  119473. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  119474. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119475. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  119476. * * 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
  119477. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119478. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119479. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  119480. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  119481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119482. * * 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)
  119483. * * 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)
  119484. * @returns the VertexData of the cylinder, cone or prism
  119485. */
  119486. static CreateCylinder(options: {
  119487. height?: number;
  119488. diameterTop?: number;
  119489. diameterBottom?: number;
  119490. diameter?: number;
  119491. tessellation?: number;
  119492. subdivisions?: number;
  119493. arc?: number;
  119494. faceColors?: Color4[];
  119495. faceUV?: Vector4[];
  119496. hasRings?: boolean;
  119497. enclose?: boolean;
  119498. sideOrientation?: number;
  119499. frontUVs?: Vector4;
  119500. backUVs?: Vector4;
  119501. }): VertexData;
  119502. /**
  119503. * Creates the VertexData for a torus
  119504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119505. * * diameter the diameter of the torus, optional default 1
  119506. * * thickness the diameter of the tube forming the torus, optional default 0.5
  119507. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119509. * * 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)
  119510. * * 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)
  119511. * @returns the VertexData of the torus
  119512. */
  119513. static CreateTorus(options: {
  119514. diameter?: number;
  119515. thickness?: number;
  119516. tessellation?: number;
  119517. sideOrientation?: number;
  119518. frontUVs?: Vector4;
  119519. backUVs?: Vector4;
  119520. }): VertexData;
  119521. /**
  119522. * Creates the VertexData of the LineSystem
  119523. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  119524. * - lines an array of lines, each line being an array of successive Vector3
  119525. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  119526. * @returns the VertexData of the LineSystem
  119527. */
  119528. static CreateLineSystem(options: {
  119529. lines: Vector3[][];
  119530. colors?: Nullable<Color4[][]>;
  119531. }): VertexData;
  119532. /**
  119533. * Create the VertexData for a DashedLines
  119534. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  119535. * - points an array successive Vector3
  119536. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  119537. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  119538. * - dashNb the intended total number of dashes, optional, default 200
  119539. * @returns the VertexData for the DashedLines
  119540. */
  119541. static CreateDashedLines(options: {
  119542. points: Vector3[];
  119543. dashSize?: number;
  119544. gapSize?: number;
  119545. dashNb?: number;
  119546. }): VertexData;
  119547. /**
  119548. * Creates the VertexData for a Ground
  119549. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119550. * - width the width (x direction) of the ground, optional, default 1
  119551. * - height the height (z direction) of the ground, optional, default 1
  119552. * - subdivisions the number of subdivisions per side, optional, default 1
  119553. * @returns the VertexData of the Ground
  119554. */
  119555. static CreateGround(options: {
  119556. width?: number;
  119557. height?: number;
  119558. subdivisions?: number;
  119559. subdivisionsX?: number;
  119560. subdivisionsY?: number;
  119561. }): VertexData;
  119562. /**
  119563. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  119564. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119565. * * xmin the ground minimum X coordinate, optional, default -1
  119566. * * zmin the ground minimum Z coordinate, optional, default -1
  119567. * * xmax the ground maximum X coordinate, optional, default 1
  119568. * * zmax the ground maximum Z coordinate, optional, default 1
  119569. * * 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}
  119570. * * 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}
  119571. * @returns the VertexData of the TiledGround
  119572. */
  119573. static CreateTiledGround(options: {
  119574. xmin: number;
  119575. zmin: number;
  119576. xmax: number;
  119577. zmax: number;
  119578. subdivisions?: {
  119579. w: number;
  119580. h: number;
  119581. };
  119582. precision?: {
  119583. w: number;
  119584. h: number;
  119585. };
  119586. }): VertexData;
  119587. /**
  119588. * Creates the VertexData of the Ground designed from a heightmap
  119589. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  119590. * * width the width (x direction) of the ground
  119591. * * height the height (z direction) of the ground
  119592. * * subdivisions the number of subdivisions per side
  119593. * * minHeight the minimum altitude on the ground, optional, default 0
  119594. * * maxHeight the maximum altitude on the ground, optional default 1
  119595. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  119596. * * buffer the array holding the image color data
  119597. * * bufferWidth the width of image
  119598. * * bufferHeight the height of image
  119599. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  119600. * @returns the VertexData of the Ground designed from a heightmap
  119601. */
  119602. static CreateGroundFromHeightMap(options: {
  119603. width: number;
  119604. height: number;
  119605. subdivisions: number;
  119606. minHeight: number;
  119607. maxHeight: number;
  119608. colorFilter: Color3;
  119609. buffer: Uint8Array;
  119610. bufferWidth: number;
  119611. bufferHeight: number;
  119612. alphaFilter: number;
  119613. }): VertexData;
  119614. /**
  119615. * Creates the VertexData for a Plane
  119616. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  119617. * * size sets the width and height of the plane to the value of size, optional default 1
  119618. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  119619. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  119620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119621. * * 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)
  119622. * * 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)
  119623. * @returns the VertexData of the box
  119624. */
  119625. static CreatePlane(options: {
  119626. size?: number;
  119627. width?: number;
  119628. height?: number;
  119629. sideOrientation?: number;
  119630. frontUVs?: Vector4;
  119631. backUVs?: Vector4;
  119632. }): VertexData;
  119633. /**
  119634. * Creates the VertexData of the Disc or regular Polygon
  119635. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  119636. * * radius the radius of the disc, optional default 0.5
  119637. * * tessellation the number of polygon sides, optional, default 64
  119638. * * 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
  119639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119640. * * 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)
  119641. * * 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)
  119642. * @returns the VertexData of the box
  119643. */
  119644. static CreateDisc(options: {
  119645. radius?: number;
  119646. tessellation?: number;
  119647. arc?: number;
  119648. sideOrientation?: number;
  119649. frontUVs?: Vector4;
  119650. backUVs?: Vector4;
  119651. }): VertexData;
  119652. /**
  119653. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  119654. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  119655. * @param polygon a mesh built from polygonTriangulation.build()
  119656. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119657. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119658. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119659. * @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)
  119660. * @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)
  119661. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  119662. * @returns the VertexData of the Polygon
  119663. */
  119664. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  119665. /**
  119666. * Creates the VertexData of the IcoSphere
  119667. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  119668. * * radius the radius of the IcoSphere, optional default 1
  119669. * * radiusX allows stretching in the x direction, optional, default radius
  119670. * * radiusY allows stretching in the y direction, optional, default radius
  119671. * * radiusZ allows stretching in the z direction, optional, default radius
  119672. * * flat when true creates a flat shaded mesh, optional, default true
  119673. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119675. * * 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)
  119676. * * 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)
  119677. * @returns the VertexData of the IcoSphere
  119678. */
  119679. static CreateIcoSphere(options: {
  119680. radius?: number;
  119681. radiusX?: number;
  119682. radiusY?: number;
  119683. radiusZ?: number;
  119684. flat?: boolean;
  119685. subdivisions?: number;
  119686. sideOrientation?: number;
  119687. frontUVs?: Vector4;
  119688. backUVs?: Vector4;
  119689. }): VertexData;
  119690. /**
  119691. * Creates the VertexData for a Polyhedron
  119692. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  119693. * * type provided types are:
  119694. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  119695. * * 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)
  119696. * * size the size of the IcoSphere, optional default 1
  119697. * * sizeX allows stretching in the x direction, optional, default size
  119698. * * sizeY allows stretching in the y direction, optional, default size
  119699. * * sizeZ allows stretching in the z direction, optional, default size
  119700. * * 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
  119701. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119702. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119703. * * flat when true creates a flat shaded mesh, optional, default true
  119704. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119706. * * 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)
  119707. * * 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)
  119708. * @returns the VertexData of the Polyhedron
  119709. */
  119710. static CreatePolyhedron(options: {
  119711. type?: number;
  119712. size?: number;
  119713. sizeX?: number;
  119714. sizeY?: number;
  119715. sizeZ?: number;
  119716. custom?: any;
  119717. faceUV?: Vector4[];
  119718. faceColors?: Color4[];
  119719. flat?: boolean;
  119720. sideOrientation?: number;
  119721. frontUVs?: Vector4;
  119722. backUVs?: Vector4;
  119723. }): VertexData;
  119724. /**
  119725. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  119726. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  119727. * @returns the VertexData of the Capsule
  119728. */
  119729. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  119730. /**
  119731. * Creates the VertexData for a TorusKnot
  119732. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  119733. * * radius the radius of the torus knot, optional, default 2
  119734. * * tube the thickness of the tube, optional, default 0.5
  119735. * * radialSegments the number of sides on each tube segments, optional, default 32
  119736. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  119737. * * p the number of windings around the z axis, optional, default 2
  119738. * * q the number of windings around the x axis, optional, default 3
  119739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119740. * * 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)
  119741. * * 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)
  119742. * @returns the VertexData of the Torus Knot
  119743. */
  119744. static CreateTorusKnot(options: {
  119745. radius?: number;
  119746. tube?: number;
  119747. radialSegments?: number;
  119748. tubularSegments?: number;
  119749. p?: number;
  119750. q?: number;
  119751. sideOrientation?: number;
  119752. frontUVs?: Vector4;
  119753. backUVs?: Vector4;
  119754. }): VertexData;
  119755. /**
  119756. * Compute normals for given positions and indices
  119757. * @param positions an array of vertex positions, [...., x, y, z, ......]
  119758. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  119759. * @param normals an array of vertex normals, [...., x, y, z, ......]
  119760. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  119761. * * facetNormals : optional array of facet normals (vector3)
  119762. * * facetPositions : optional array of facet positions (vector3)
  119763. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  119764. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  119765. * * bInfo : optional bounding info, required for facetPartitioning computation
  119766. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  119767. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  119768. * * useRightHandedSystem: optional boolean to for right handed system computation
  119769. * * depthSort : optional boolean to enable the facet depth sort computation
  119770. * * distanceTo : optional Vector3 to compute the facet depth from this location
  119771. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  119772. */
  119773. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  119774. facetNormals?: any;
  119775. facetPositions?: any;
  119776. facetPartitioning?: any;
  119777. ratio?: number;
  119778. bInfo?: any;
  119779. bbSize?: Vector3;
  119780. subDiv?: any;
  119781. useRightHandedSystem?: boolean;
  119782. depthSort?: boolean;
  119783. distanceTo?: Vector3;
  119784. depthSortedFacets?: any;
  119785. }): void;
  119786. /** @hidden */
  119787. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  119788. /**
  119789. * Applies VertexData created from the imported parameters to the geometry
  119790. * @param parsedVertexData the parsed data from an imported file
  119791. * @param geometry the geometry to apply the VertexData to
  119792. */
  119793. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  119794. }
  119795. }
  119796. declare module BABYLON {
  119797. /**
  119798. * Class containing static functions to help procedurally build meshes
  119799. */
  119800. export class DiscBuilder {
  119801. /**
  119802. * Creates a plane polygonal mesh. By default, this is a disc
  119803. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119804. * * 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
  119805. * * 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
  119806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119809. * @param name defines the name of the mesh
  119810. * @param options defines the options used to create the mesh
  119811. * @param scene defines the hosting scene
  119812. * @returns the plane polygonal mesh
  119813. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119814. */
  119815. static CreateDisc(name: string, options: {
  119816. radius?: number;
  119817. tessellation?: number;
  119818. arc?: number;
  119819. updatable?: boolean;
  119820. sideOrientation?: number;
  119821. frontUVs?: Vector4;
  119822. backUVs?: Vector4;
  119823. }, scene?: Nullable<Scene>): Mesh;
  119824. }
  119825. }
  119826. declare module BABYLON {
  119827. /**
  119828. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  119829. *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.
  119830. * The SPS is also a particle system. It provides some methods to manage the particles.
  119831. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  119832. *
  119833. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  119834. */
  119835. export class SolidParticleSystem implements IDisposable {
  119836. /**
  119837. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  119838. * Example : var p = SPS.particles[i];
  119839. */
  119840. particles: SolidParticle[];
  119841. /**
  119842. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  119843. */
  119844. nbParticles: number;
  119845. /**
  119846. * If the particles must ever face the camera (default false). Useful for planar particles.
  119847. */
  119848. billboard: boolean;
  119849. /**
  119850. * Recompute normals when adding a shape
  119851. */
  119852. recomputeNormals: boolean;
  119853. /**
  119854. * This a counter ofr your own usage. It's not set by any SPS functions.
  119855. */
  119856. counter: number;
  119857. /**
  119858. * The SPS name. This name is also given to the underlying mesh.
  119859. */
  119860. name: string;
  119861. /**
  119862. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  119863. */
  119864. mesh: Mesh;
  119865. /**
  119866. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  119867. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  119868. */
  119869. vars: any;
  119870. /**
  119871. * This array is populated when the SPS is set as 'pickable'.
  119872. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  119873. * Each element of this array is an object `{idx: int, faceId: int}`.
  119874. * `idx` is the picked particle index in the `SPS.particles` array
  119875. * `faceId` is the picked face index counted within this particle.
  119876. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  119877. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  119878. * Use the method SPS.pickedParticle(pickingInfo) instead.
  119879. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119880. */
  119881. pickedParticles: {
  119882. idx: number;
  119883. faceId: number;
  119884. }[];
  119885. /**
  119886. * This array is populated when the SPS is set as 'pickable'
  119887. * Each key of this array is a submesh index.
  119888. * Each element of this array is a second array defined like this :
  119889. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  119890. * Each element of this second array is an object `{idx: int, faceId: int}`.
  119891. * `idx` is the picked particle index in the `SPS.particles` array
  119892. * `faceId` is the picked face index counted within this particle.
  119893. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  119894. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119895. */
  119896. pickedBySubMesh: {
  119897. idx: number;
  119898. faceId: number;
  119899. }[][];
  119900. /**
  119901. * This array is populated when `enableDepthSort` is set to true.
  119902. * Each element of this array is an instance of the class DepthSortedParticle.
  119903. */
  119904. depthSortedParticles: DepthSortedParticle[];
  119905. /**
  119906. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  119907. * @hidden
  119908. */
  119909. _bSphereOnly: boolean;
  119910. /**
  119911. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  119912. * @hidden
  119913. */
  119914. _bSphereRadiusFactor: number;
  119915. private _scene;
  119916. private _positions;
  119917. private _indices;
  119918. private _normals;
  119919. private _colors;
  119920. private _uvs;
  119921. private _indices32;
  119922. private _positions32;
  119923. private _normals32;
  119924. private _fixedNormal32;
  119925. private _colors32;
  119926. private _uvs32;
  119927. private _index;
  119928. private _updatable;
  119929. private _pickable;
  119930. private _isVisibilityBoxLocked;
  119931. private _alwaysVisible;
  119932. private _depthSort;
  119933. private _expandable;
  119934. private _shapeCounter;
  119935. private _copy;
  119936. private _color;
  119937. private _computeParticleColor;
  119938. private _computeParticleTexture;
  119939. private _computeParticleRotation;
  119940. private _computeParticleVertex;
  119941. private _computeBoundingBox;
  119942. private _depthSortParticles;
  119943. private _camera;
  119944. private _mustUnrotateFixedNormals;
  119945. private _particlesIntersect;
  119946. private _needs32Bits;
  119947. private _isNotBuilt;
  119948. private _lastParticleId;
  119949. private _idxOfId;
  119950. private _multimaterialEnabled;
  119951. private _useModelMaterial;
  119952. private _indicesByMaterial;
  119953. private _materialIndexes;
  119954. private _depthSortFunction;
  119955. private _materialSortFunction;
  119956. private _materials;
  119957. private _multimaterial;
  119958. private _materialIndexesById;
  119959. private _defaultMaterial;
  119960. private _autoUpdateSubMeshes;
  119961. private _tmpVertex;
  119962. /**
  119963. * Creates a SPS (Solid Particle System) object.
  119964. * @param name (String) is the SPS name, this will be the underlying mesh name.
  119965. * @param scene (Scene) is the scene in which the SPS is added.
  119966. * @param options defines the options of the sps e.g.
  119967. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  119968. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  119969. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  119970. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  119971. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  119972. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  119973. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  119974. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  119975. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  119976. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  119977. */
  119978. constructor(name: string, scene: Scene, options?: {
  119979. updatable?: boolean;
  119980. isPickable?: boolean;
  119981. enableDepthSort?: boolean;
  119982. particleIntersection?: boolean;
  119983. boundingSphereOnly?: boolean;
  119984. bSphereRadiusFactor?: number;
  119985. expandable?: boolean;
  119986. useModelMaterial?: boolean;
  119987. enableMultiMaterial?: boolean;
  119988. });
  119989. /**
  119990. * Builds the SPS underlying mesh. Returns a standard Mesh.
  119991. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  119992. * @returns the created mesh
  119993. */
  119994. buildMesh(): Mesh;
  119995. /**
  119996. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  119997. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  119998. * Thus the particles generated from `digest()` have their property `position` set yet.
  119999. * @param mesh ( Mesh ) is the mesh to be digested
  120000. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  120001. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  120002. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  120003. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120004. * @returns the current SPS
  120005. */
  120006. digest(mesh: Mesh, options?: {
  120007. facetNb?: number;
  120008. number?: number;
  120009. delta?: number;
  120010. storage?: [];
  120011. }): SolidParticleSystem;
  120012. /**
  120013. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  120014. * @hidden
  120015. */
  120016. private _unrotateFixedNormals;
  120017. /**
  120018. * Resets the temporary working copy particle
  120019. * @hidden
  120020. */
  120021. private _resetCopy;
  120022. /**
  120023. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  120024. * @param p the current index in the positions array to be updated
  120025. * @param ind the current index in the indices array
  120026. * @param shape a Vector3 array, the shape geometry
  120027. * @param positions the positions array to be updated
  120028. * @param meshInd the shape indices array
  120029. * @param indices the indices array to be updated
  120030. * @param meshUV the shape uv array
  120031. * @param uvs the uv array to be updated
  120032. * @param meshCol the shape color array
  120033. * @param colors the color array to be updated
  120034. * @param meshNor the shape normals array
  120035. * @param normals the normals array to be updated
  120036. * @param idx the particle index
  120037. * @param idxInShape the particle index in its shape
  120038. * @param options the addShape() method passed options
  120039. * @model the particle model
  120040. * @hidden
  120041. */
  120042. private _meshBuilder;
  120043. /**
  120044. * Returns a shape Vector3 array from positions float array
  120045. * @param positions float array
  120046. * @returns a vector3 array
  120047. * @hidden
  120048. */
  120049. private _posToShape;
  120050. /**
  120051. * Returns a shapeUV array from a float uvs (array deep copy)
  120052. * @param uvs as a float array
  120053. * @returns a shapeUV array
  120054. * @hidden
  120055. */
  120056. private _uvsToShapeUV;
  120057. /**
  120058. * Adds a new particle object in the particles array
  120059. * @param idx particle index in particles array
  120060. * @param id particle id
  120061. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  120062. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  120063. * @param model particle ModelShape object
  120064. * @param shapeId model shape identifier
  120065. * @param idxInShape index of the particle in the current model
  120066. * @param bInfo model bounding info object
  120067. * @param storage target storage array, if any
  120068. * @hidden
  120069. */
  120070. private _addParticle;
  120071. /**
  120072. * Adds some particles to the SPS from the model shape. Returns the shape id.
  120073. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  120074. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  120075. * @param nb (positive integer) the number of particles to be created from this model
  120076. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  120077. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  120078. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120079. * @returns the number of shapes in the system
  120080. */
  120081. addShape(mesh: Mesh, nb: number, options?: {
  120082. positionFunction?: any;
  120083. vertexFunction?: any;
  120084. storage?: [];
  120085. }): number;
  120086. /**
  120087. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  120088. * @hidden
  120089. */
  120090. private _rebuildParticle;
  120091. /**
  120092. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  120093. * @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.
  120094. * @returns the SPS.
  120095. */
  120096. rebuildMesh(reset?: boolean): SolidParticleSystem;
  120097. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  120098. * Returns an array with the removed particles.
  120099. * 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.
  120100. * The SPS can't be empty so at least one particle needs to remain in place.
  120101. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  120102. * @param start index of the first particle to remove
  120103. * @param end index of the last particle to remove (included)
  120104. * @returns an array populated with the removed particles
  120105. */
  120106. removeParticles(start: number, end: number): SolidParticle[];
  120107. /**
  120108. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  120109. * @param solidParticleArray an array populated with Solid Particles objects
  120110. * @returns the SPS
  120111. */
  120112. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  120113. /**
  120114. * Creates a new particle and modifies the SPS mesh geometry :
  120115. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  120116. * - calls _addParticle() to populate the particle array
  120117. * factorized code from addShape() and insertParticlesFromArray()
  120118. * @param idx particle index in the particles array
  120119. * @param i particle index in its shape
  120120. * @param modelShape particle ModelShape object
  120121. * @param shape shape vertex array
  120122. * @param meshInd shape indices array
  120123. * @param meshUV shape uv array
  120124. * @param meshCol shape color array
  120125. * @param meshNor shape normals array
  120126. * @param bbInfo shape bounding info
  120127. * @param storage target particle storage
  120128. * @options addShape() passed options
  120129. * @hidden
  120130. */
  120131. private _insertNewParticle;
  120132. /**
  120133. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  120134. * This method calls `updateParticle()` for each particle of the SPS.
  120135. * For an animated SPS, it is usually called within the render loop.
  120136. * 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.
  120137. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  120138. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  120139. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  120140. * @returns the SPS.
  120141. */
  120142. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  120143. /**
  120144. * Disposes the SPS.
  120145. */
  120146. dispose(): void;
  120147. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  120148. * idx is the particle index in the SPS
  120149. * faceId is the picked face index counted within this particle.
  120150. * Returns null if the pickInfo can't identify a picked particle.
  120151. * @param pickingInfo (PickingInfo object)
  120152. * @returns {idx: number, faceId: number} or null
  120153. */
  120154. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  120155. idx: number;
  120156. faceId: number;
  120157. }>;
  120158. /**
  120159. * Returns a SolidParticle object from its identifier : particle.id
  120160. * @param id (integer) the particle Id
  120161. * @returns the searched particle or null if not found in the SPS.
  120162. */
  120163. getParticleById(id: number): Nullable<SolidParticle>;
  120164. /**
  120165. * Returns a new array populated with the particles having the passed shapeId.
  120166. * @param shapeId (integer) the shape identifier
  120167. * @returns a new solid particle array
  120168. */
  120169. getParticlesByShapeId(shapeId: number): SolidParticle[];
  120170. /**
  120171. * Populates the passed array "ref" with the particles having the passed shapeId.
  120172. * @param shapeId the shape identifier
  120173. * @returns the SPS
  120174. * @param ref
  120175. */
  120176. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  120177. /**
  120178. * Computes the required SubMeshes according the materials assigned to the particles.
  120179. * @returns the solid particle system.
  120180. * Does nothing if called before the SPS mesh is built.
  120181. */
  120182. computeSubMeshes(): SolidParticleSystem;
  120183. /**
  120184. * Sorts the solid particles by material when MultiMaterial is enabled.
  120185. * Updates the indices32 array.
  120186. * Updates the indicesByMaterial array.
  120187. * Updates the mesh indices array.
  120188. * @returns the SPS
  120189. * @hidden
  120190. */
  120191. private _sortParticlesByMaterial;
  120192. /**
  120193. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  120194. * @hidden
  120195. */
  120196. private _setMaterialIndexesById;
  120197. /**
  120198. * Returns an array with unique values of Materials from the passed array
  120199. * @param array the material array to be checked and filtered
  120200. * @hidden
  120201. */
  120202. private _filterUniqueMaterialId;
  120203. /**
  120204. * Sets a new Standard Material as _defaultMaterial if not already set.
  120205. * @hidden
  120206. */
  120207. private _setDefaultMaterial;
  120208. /**
  120209. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  120210. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120211. * @returns the SPS.
  120212. */
  120213. refreshVisibleSize(): SolidParticleSystem;
  120214. /**
  120215. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  120216. * @param size the size (float) of the visibility box
  120217. * note : this doesn't lock the SPS mesh bounding box.
  120218. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120219. */
  120220. setVisibilityBox(size: number): void;
  120221. /**
  120222. * Gets whether the SPS as always visible or not
  120223. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120224. */
  120225. get isAlwaysVisible(): boolean;
  120226. /**
  120227. * Sets the SPS as always visible or not
  120228. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120229. */
  120230. set isAlwaysVisible(val: boolean);
  120231. /**
  120232. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  120233. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120234. */
  120235. set isVisibilityBoxLocked(val: boolean);
  120236. /**
  120237. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  120238. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120239. */
  120240. get isVisibilityBoxLocked(): boolean;
  120241. /**
  120242. * Tells to `setParticles()` to compute the particle rotations or not.
  120243. * Default value : true. The SPS is faster when it's set to false.
  120244. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  120245. */
  120246. set computeParticleRotation(val: boolean);
  120247. /**
  120248. * Tells to `setParticles()` to compute the particle colors or not.
  120249. * Default value : true. The SPS is faster when it's set to false.
  120250. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  120251. */
  120252. set computeParticleColor(val: boolean);
  120253. set computeParticleTexture(val: boolean);
  120254. /**
  120255. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  120256. * Default value : false. The SPS is faster when it's set to false.
  120257. * Note : the particle custom vertex positions aren't stored values.
  120258. */
  120259. set computeParticleVertex(val: boolean);
  120260. /**
  120261. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  120262. */
  120263. set computeBoundingBox(val: boolean);
  120264. /**
  120265. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  120266. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  120267. * Default : `true`
  120268. */
  120269. set depthSortParticles(val: boolean);
  120270. /**
  120271. * Gets if `setParticles()` computes the particle rotations or not.
  120272. * Default value : true. The SPS is faster when it's set to false.
  120273. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  120274. */
  120275. get computeParticleRotation(): boolean;
  120276. /**
  120277. * Gets if `setParticles()` computes the particle colors or not.
  120278. * Default value : true. The SPS is faster when it's set to false.
  120279. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  120280. */
  120281. get computeParticleColor(): boolean;
  120282. /**
  120283. * Gets if `setParticles()` computes the particle textures or not.
  120284. * Default value : true. The SPS is faster when it's set to false.
  120285. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  120286. */
  120287. get computeParticleTexture(): boolean;
  120288. /**
  120289. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  120290. * Default value : false. The SPS is faster when it's set to false.
  120291. * Note : the particle custom vertex positions aren't stored values.
  120292. */
  120293. get computeParticleVertex(): boolean;
  120294. /**
  120295. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  120296. */
  120297. get computeBoundingBox(): boolean;
  120298. /**
  120299. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  120300. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  120301. * Default : `true`
  120302. */
  120303. get depthSortParticles(): boolean;
  120304. /**
  120305. * Gets if the SPS is created as expandable at construction time.
  120306. * Default : `false`
  120307. */
  120308. get expandable(): boolean;
  120309. /**
  120310. * Gets if the SPS supports the Multi Materials
  120311. */
  120312. get multimaterialEnabled(): boolean;
  120313. /**
  120314. * Gets if the SPS uses the model materials for its own multimaterial.
  120315. */
  120316. get useModelMaterial(): boolean;
  120317. /**
  120318. * The SPS used material array.
  120319. */
  120320. get materials(): Material[];
  120321. /**
  120322. * Sets the SPS MultiMaterial from the passed materials.
  120323. * Note : the passed array is internally copied and not used then by reference.
  120324. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  120325. */
  120326. setMultiMaterial(materials: Material[]): void;
  120327. /**
  120328. * The SPS computed multimaterial object
  120329. */
  120330. get multimaterial(): MultiMaterial;
  120331. set multimaterial(mm: MultiMaterial);
  120332. /**
  120333. * If the subMeshes must be updated on the next call to setParticles()
  120334. */
  120335. get autoUpdateSubMeshes(): boolean;
  120336. set autoUpdateSubMeshes(val: boolean);
  120337. /**
  120338. * This function does nothing. It may be overwritten to set all the particle first values.
  120339. * The SPS doesn't call this function, you may have to call it by your own.
  120340. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120341. */
  120342. initParticles(): void;
  120343. /**
  120344. * This function does nothing. It may be overwritten to recycle a particle.
  120345. * The SPS doesn't call this function, you may have to call it by your own.
  120346. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120347. * @param particle The particle to recycle
  120348. * @returns the recycled particle
  120349. */
  120350. recycleParticle(particle: SolidParticle): SolidParticle;
  120351. /**
  120352. * Updates a particle : this function should be overwritten by the user.
  120353. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  120354. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120355. * @example : just set a particle position or velocity and recycle conditions
  120356. * @param particle The particle to update
  120357. * @returns the updated particle
  120358. */
  120359. updateParticle(particle: SolidParticle): SolidParticle;
  120360. /**
  120361. * Updates a vertex of a particle : it can be overwritten by the user.
  120362. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  120363. * @param particle the current particle
  120364. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  120365. * @param pt the index of the current vertex in the particle shape
  120366. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  120367. * @example : just set a vertex particle position or color
  120368. * @returns the sps
  120369. */
  120370. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  120371. /**
  120372. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  120373. * This does nothing and may be overwritten by the user.
  120374. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120375. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120376. * @param update the boolean update value actually passed to setParticles()
  120377. */
  120378. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  120379. /**
  120380. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  120381. * This will be passed three parameters.
  120382. * This does nothing and may be overwritten by the user.
  120383. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120384. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120385. * @param update the boolean update value actually passed to setParticles()
  120386. */
  120387. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  120388. }
  120389. }
  120390. declare module BABYLON {
  120391. /**
  120392. * Represents one particle of a solid particle system.
  120393. */
  120394. export class SolidParticle {
  120395. /**
  120396. * particle global index
  120397. */
  120398. idx: number;
  120399. /**
  120400. * particle identifier
  120401. */
  120402. id: number;
  120403. /**
  120404. * The color of the particle
  120405. */
  120406. color: Nullable<Color4>;
  120407. /**
  120408. * The world space position of the particle.
  120409. */
  120410. position: Vector3;
  120411. /**
  120412. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  120413. */
  120414. rotation: Vector3;
  120415. /**
  120416. * The world space rotation quaternion of the particle.
  120417. */
  120418. rotationQuaternion: Nullable<Quaternion>;
  120419. /**
  120420. * The scaling of the particle.
  120421. */
  120422. scaling: Vector3;
  120423. /**
  120424. * The uvs of the particle.
  120425. */
  120426. uvs: Vector4;
  120427. /**
  120428. * The current speed of the particle.
  120429. */
  120430. velocity: Vector3;
  120431. /**
  120432. * The pivot point in the particle local space.
  120433. */
  120434. pivot: Vector3;
  120435. /**
  120436. * Must the particle be translated from its pivot point in its local space ?
  120437. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  120438. * Default : false
  120439. */
  120440. translateFromPivot: boolean;
  120441. /**
  120442. * Is the particle active or not ?
  120443. */
  120444. alive: boolean;
  120445. /**
  120446. * Is the particle visible or not ?
  120447. */
  120448. isVisible: boolean;
  120449. /**
  120450. * Index of this particle in the global "positions" array (Internal use)
  120451. * @hidden
  120452. */
  120453. _pos: number;
  120454. /**
  120455. * @hidden Index of this particle in the global "indices" array (Internal use)
  120456. */
  120457. _ind: number;
  120458. /**
  120459. * @hidden ModelShape of this particle (Internal use)
  120460. */
  120461. _model: ModelShape;
  120462. /**
  120463. * ModelShape id of this particle
  120464. */
  120465. shapeId: number;
  120466. /**
  120467. * Index of the particle in its shape id
  120468. */
  120469. idxInShape: number;
  120470. /**
  120471. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  120472. */
  120473. _modelBoundingInfo: BoundingInfo;
  120474. /**
  120475. * @hidden Particle BoundingInfo object (Internal use)
  120476. */
  120477. _boundingInfo: BoundingInfo;
  120478. /**
  120479. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  120480. */
  120481. _sps: SolidParticleSystem;
  120482. /**
  120483. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  120484. */
  120485. _stillInvisible: boolean;
  120486. /**
  120487. * @hidden Last computed particle rotation matrix
  120488. */
  120489. _rotationMatrix: number[];
  120490. /**
  120491. * Parent particle Id, if any.
  120492. * Default null.
  120493. */
  120494. parentId: Nullable<number>;
  120495. /**
  120496. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  120497. */
  120498. materialIndex: Nullable<number>;
  120499. /**
  120500. * Custom object or properties.
  120501. */
  120502. props: Nullable<any>;
  120503. /**
  120504. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  120505. * The possible values are :
  120506. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120507. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120508. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120509. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120510. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120511. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  120512. * */
  120513. cullingStrategy: number;
  120514. /**
  120515. * @hidden Internal global position in the SPS.
  120516. */
  120517. _globalPosition: Vector3;
  120518. /**
  120519. * Creates a Solid Particle object.
  120520. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  120521. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  120522. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  120523. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  120524. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  120525. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  120526. * @param shapeId (integer) is the model shape identifier in the SPS.
  120527. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  120528. * @param sps defines the sps it is associated to
  120529. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  120530. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  120531. */
  120532. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  120533. /**
  120534. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  120535. * @param target the particle target
  120536. * @returns the current particle
  120537. */
  120538. copyToRef(target: SolidParticle): SolidParticle;
  120539. /**
  120540. * Legacy support, changed scale to scaling
  120541. */
  120542. get scale(): Vector3;
  120543. /**
  120544. * Legacy support, changed scale to scaling
  120545. */
  120546. set scale(scale: Vector3);
  120547. /**
  120548. * Legacy support, changed quaternion to rotationQuaternion
  120549. */
  120550. get quaternion(): Nullable<Quaternion>;
  120551. /**
  120552. * Legacy support, changed quaternion to rotationQuaternion
  120553. */
  120554. set quaternion(q: Nullable<Quaternion>);
  120555. /**
  120556. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  120557. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  120558. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  120559. * @returns true if it intersects
  120560. */
  120561. intersectsMesh(target: Mesh | SolidParticle): boolean;
  120562. /**
  120563. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  120564. * A particle is in the frustum if its bounding box intersects the frustum
  120565. * @param frustumPlanes defines the frustum to test
  120566. * @returns true if the particle is in the frustum planes
  120567. */
  120568. isInFrustum(frustumPlanes: Plane[]): boolean;
  120569. /**
  120570. * get the rotation matrix of the particle
  120571. * @hidden
  120572. */
  120573. getRotationMatrix(m: Matrix): void;
  120574. }
  120575. /**
  120576. * Represents the shape of the model used by one particle of a solid particle system.
  120577. * SPS internal tool, don't use it manually.
  120578. */
  120579. export class ModelShape {
  120580. /**
  120581. * The shape id
  120582. * @hidden
  120583. */
  120584. shapeID: number;
  120585. /**
  120586. * flat array of model positions (internal use)
  120587. * @hidden
  120588. */
  120589. _shape: Vector3[];
  120590. /**
  120591. * flat array of model UVs (internal use)
  120592. * @hidden
  120593. */
  120594. _shapeUV: number[];
  120595. /**
  120596. * color array of the model
  120597. * @hidden
  120598. */
  120599. _shapeColors: number[];
  120600. /**
  120601. * indices array of the model
  120602. * @hidden
  120603. */
  120604. _indices: number[];
  120605. /**
  120606. * normals array of the model
  120607. * @hidden
  120608. */
  120609. _normals: number[];
  120610. /**
  120611. * length of the shape in the model indices array (internal use)
  120612. * @hidden
  120613. */
  120614. _indicesLength: number;
  120615. /**
  120616. * Custom position function (internal use)
  120617. * @hidden
  120618. */
  120619. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  120620. /**
  120621. * Custom vertex function (internal use)
  120622. * @hidden
  120623. */
  120624. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  120625. /**
  120626. * Model material (internal use)
  120627. * @hidden
  120628. */
  120629. _material: Nullable<Material>;
  120630. /**
  120631. * 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.
  120632. * SPS internal tool, don't use it manually.
  120633. * @hidden
  120634. */
  120635. 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>);
  120636. }
  120637. /**
  120638. * Represents a Depth Sorted Particle in the solid particle system.
  120639. * @hidden
  120640. */
  120641. export class DepthSortedParticle {
  120642. /**
  120643. * Particle index
  120644. */
  120645. idx: number;
  120646. /**
  120647. * Index of the particle in the "indices" array
  120648. */
  120649. ind: number;
  120650. /**
  120651. * Length of the particle shape in the "indices" array
  120652. */
  120653. indicesLength: number;
  120654. /**
  120655. * Squared distance from the particle to the camera
  120656. */
  120657. sqDistance: number;
  120658. /**
  120659. * Material index when used with MultiMaterials
  120660. */
  120661. materialIndex: number;
  120662. /**
  120663. * Creates a new sorted particle
  120664. * @param materialIndex
  120665. */
  120666. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  120667. }
  120668. /**
  120669. * Represents a solid particle vertex
  120670. */
  120671. export class SolidParticleVertex {
  120672. /**
  120673. * Vertex position
  120674. */
  120675. position: Vector3;
  120676. /**
  120677. * Vertex color
  120678. */
  120679. color: Color4;
  120680. /**
  120681. * Vertex UV
  120682. */
  120683. uv: Vector2;
  120684. /**
  120685. * Creates a new solid particle vertex
  120686. */
  120687. constructor();
  120688. /** Vertex x coordinate */
  120689. get x(): number;
  120690. set x(val: number);
  120691. /** Vertex y coordinate */
  120692. get y(): number;
  120693. set y(val: number);
  120694. /** Vertex z coordinate */
  120695. get z(): number;
  120696. set z(val: number);
  120697. }
  120698. }
  120699. declare module BABYLON {
  120700. /**
  120701. * @hidden
  120702. */
  120703. export class _MeshCollisionData {
  120704. _checkCollisions: boolean;
  120705. _collisionMask: number;
  120706. _collisionGroup: number;
  120707. _surroundingMeshes: Nullable<AbstractMesh[]>;
  120708. _collider: Nullable<Collider>;
  120709. _oldPositionForCollisions: Vector3;
  120710. _diffPositionForCollisions: Vector3;
  120711. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  120712. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  120713. _collisionResponse: boolean;
  120714. }
  120715. }
  120716. declare module BABYLON {
  120717. /** @hidden */
  120718. class _FacetDataStorage {
  120719. facetPositions: Vector3[];
  120720. facetNormals: Vector3[];
  120721. facetPartitioning: number[][];
  120722. facetNb: number;
  120723. partitioningSubdivisions: number;
  120724. partitioningBBoxRatio: number;
  120725. facetDataEnabled: boolean;
  120726. facetParameters: any;
  120727. bbSize: Vector3;
  120728. subDiv: {
  120729. max: number;
  120730. X: number;
  120731. Y: number;
  120732. Z: number;
  120733. };
  120734. facetDepthSort: boolean;
  120735. facetDepthSortEnabled: boolean;
  120736. depthSortedIndices: IndicesArray;
  120737. depthSortedFacets: {
  120738. ind: number;
  120739. sqDistance: number;
  120740. }[];
  120741. facetDepthSortFunction: (f1: {
  120742. ind: number;
  120743. sqDistance: number;
  120744. }, f2: {
  120745. ind: number;
  120746. sqDistance: number;
  120747. }) => number;
  120748. facetDepthSortFrom: Vector3;
  120749. facetDepthSortOrigin: Vector3;
  120750. invertedMatrix: Matrix;
  120751. }
  120752. /**
  120753. * @hidden
  120754. **/
  120755. class _InternalAbstractMeshDataInfo {
  120756. _hasVertexAlpha: boolean;
  120757. _useVertexColors: boolean;
  120758. _numBoneInfluencers: number;
  120759. _applyFog: boolean;
  120760. _receiveShadows: boolean;
  120761. _facetData: _FacetDataStorage;
  120762. _visibility: number;
  120763. _skeleton: Nullable<Skeleton>;
  120764. _layerMask: number;
  120765. _computeBonesUsingShaders: boolean;
  120766. _isActive: boolean;
  120767. _onlyForInstances: boolean;
  120768. _isActiveIntermediate: boolean;
  120769. _onlyForInstancesIntermediate: boolean;
  120770. _actAsRegularMesh: boolean;
  120771. _currentLOD: Nullable<AbstractMesh>;
  120772. _currentLODIsUpToDate: boolean;
  120773. }
  120774. /**
  120775. * Class used to store all common mesh properties
  120776. */
  120777. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  120778. /** No occlusion */
  120779. static OCCLUSION_TYPE_NONE: number;
  120780. /** Occlusion set to optimisitic */
  120781. static OCCLUSION_TYPE_OPTIMISTIC: number;
  120782. /** Occlusion set to strict */
  120783. static OCCLUSION_TYPE_STRICT: number;
  120784. /** Use an accurante occlusion algorithm */
  120785. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  120786. /** Use a conservative occlusion algorithm */
  120787. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  120788. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  120789. * Test order :
  120790. * Is the bounding sphere outside the frustum ?
  120791. * If not, are the bounding box vertices outside the frustum ?
  120792. * It not, then the cullable object is in the frustum.
  120793. */
  120794. static readonly CULLINGSTRATEGY_STANDARD: number;
  120795. /** Culling strategy : Bounding Sphere Only.
  120796. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  120797. * It's also less accurate than the standard because some not visible objects can still be selected.
  120798. * Test : is the bounding sphere outside the frustum ?
  120799. * If not, then the cullable object is in the frustum.
  120800. */
  120801. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  120802. /** Culling strategy : Optimistic Inclusion.
  120803. * This in an inclusion test first, then the standard exclusion test.
  120804. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  120805. * 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.
  120806. * Anyway, it's as accurate as the standard strategy.
  120807. * Test :
  120808. * Is the cullable object bounding sphere center in the frustum ?
  120809. * If not, apply the default culling strategy.
  120810. */
  120811. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  120812. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  120813. * This in an inclusion test first, then the bounding sphere only exclusion test.
  120814. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  120815. * 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.
  120816. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  120817. * Test :
  120818. * Is the cullable object bounding sphere center in the frustum ?
  120819. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  120820. */
  120821. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  120822. /**
  120823. * No billboard
  120824. */
  120825. static get BILLBOARDMODE_NONE(): number;
  120826. /** Billboard on X axis */
  120827. static get BILLBOARDMODE_X(): number;
  120828. /** Billboard on Y axis */
  120829. static get BILLBOARDMODE_Y(): number;
  120830. /** Billboard on Z axis */
  120831. static get BILLBOARDMODE_Z(): number;
  120832. /** Billboard on all axes */
  120833. static get BILLBOARDMODE_ALL(): number;
  120834. /** Billboard on using position instead of orientation */
  120835. static get BILLBOARDMODE_USE_POSITION(): number;
  120836. /** @hidden */
  120837. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  120838. /**
  120839. * The culling strategy to use to check whether the mesh must be rendered or not.
  120840. * This value can be changed at any time and will be used on the next render mesh selection.
  120841. * The possible values are :
  120842. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120843. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120844. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120845. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120846. * Please read each static variable documentation to get details about the culling process.
  120847. * */
  120848. cullingStrategy: number;
  120849. /**
  120850. * Gets the number of facets in the mesh
  120851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120852. */
  120853. get facetNb(): number;
  120854. /**
  120855. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  120856. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120857. */
  120858. get partitioningSubdivisions(): number;
  120859. set partitioningSubdivisions(nb: number);
  120860. /**
  120861. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  120862. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  120863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120864. */
  120865. get partitioningBBoxRatio(): number;
  120866. set partitioningBBoxRatio(ratio: number);
  120867. /**
  120868. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  120869. * Works only for updatable meshes.
  120870. * Doesn't work with multi-materials
  120871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120872. */
  120873. get mustDepthSortFacets(): boolean;
  120874. set mustDepthSortFacets(sort: boolean);
  120875. /**
  120876. * The location (Vector3) where the facet depth sort must be computed from.
  120877. * By default, the active camera position.
  120878. * Used only when facet depth sort is enabled
  120879. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120880. */
  120881. get facetDepthSortFrom(): Vector3;
  120882. set facetDepthSortFrom(location: Vector3);
  120883. /**
  120884. * gets a boolean indicating if facetData is enabled
  120885. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120886. */
  120887. get isFacetDataEnabled(): boolean;
  120888. /** @hidden */
  120889. _updateNonUniformScalingState(value: boolean): boolean;
  120890. /**
  120891. * An event triggered when this mesh collides with another one
  120892. */
  120893. onCollideObservable: Observable<AbstractMesh>;
  120894. /** Set a function to call when this mesh collides with another one */
  120895. set onCollide(callback: () => void);
  120896. /**
  120897. * An event triggered when the collision's position changes
  120898. */
  120899. onCollisionPositionChangeObservable: Observable<Vector3>;
  120900. /** Set a function to call when the collision's position changes */
  120901. set onCollisionPositionChange(callback: () => void);
  120902. /**
  120903. * An event triggered when material is changed
  120904. */
  120905. onMaterialChangedObservable: Observable<AbstractMesh>;
  120906. /**
  120907. * Gets or sets the orientation for POV movement & rotation
  120908. */
  120909. definedFacingForward: boolean;
  120910. /** @hidden */
  120911. _occlusionQuery: Nullable<WebGLQuery>;
  120912. /** @hidden */
  120913. _renderingGroup: Nullable<RenderingGroup>;
  120914. /**
  120915. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120916. */
  120917. get visibility(): number;
  120918. /**
  120919. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120920. */
  120921. set visibility(value: number);
  120922. /** Gets or sets the alpha index used to sort transparent meshes
  120923. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  120924. */
  120925. alphaIndex: number;
  120926. /**
  120927. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  120928. */
  120929. isVisible: boolean;
  120930. /**
  120931. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  120932. */
  120933. isPickable: boolean;
  120934. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  120935. showSubMeshesBoundingBox: boolean;
  120936. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  120937. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120938. */
  120939. isBlocker: boolean;
  120940. /**
  120941. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  120942. */
  120943. enablePointerMoveEvents: boolean;
  120944. private _renderingGroupId;
  120945. /**
  120946. * Specifies the rendering group id for this mesh (0 by default)
  120947. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  120948. */
  120949. get renderingGroupId(): number;
  120950. set renderingGroupId(value: number);
  120951. private _material;
  120952. /** Gets or sets current material */
  120953. get material(): Nullable<Material>;
  120954. set material(value: Nullable<Material>);
  120955. /**
  120956. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  120957. * @see https://doc.babylonjs.com/babylon101/shadows
  120958. */
  120959. get receiveShadows(): boolean;
  120960. set receiveShadows(value: boolean);
  120961. /** Defines color to use when rendering outline */
  120962. outlineColor: Color3;
  120963. /** Define width to use when rendering outline */
  120964. outlineWidth: number;
  120965. /** Defines color to use when rendering overlay */
  120966. overlayColor: Color3;
  120967. /** Defines alpha to use when rendering overlay */
  120968. overlayAlpha: number;
  120969. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  120970. get hasVertexAlpha(): boolean;
  120971. set hasVertexAlpha(value: boolean);
  120972. /** 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) */
  120973. get useVertexColors(): boolean;
  120974. set useVertexColors(value: boolean);
  120975. /**
  120976. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  120977. */
  120978. get computeBonesUsingShaders(): boolean;
  120979. set computeBonesUsingShaders(value: boolean);
  120980. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  120981. get numBoneInfluencers(): number;
  120982. set numBoneInfluencers(value: number);
  120983. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  120984. get applyFog(): boolean;
  120985. set applyFog(value: boolean);
  120986. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  120987. useOctreeForRenderingSelection: boolean;
  120988. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  120989. useOctreeForPicking: boolean;
  120990. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  120991. useOctreeForCollisions: boolean;
  120992. /**
  120993. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  120994. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  120995. */
  120996. get layerMask(): number;
  120997. set layerMask(value: number);
  120998. /**
  120999. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  121000. */
  121001. alwaysSelectAsActiveMesh: boolean;
  121002. /**
  121003. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  121004. */
  121005. doNotSyncBoundingInfo: boolean;
  121006. /**
  121007. * Gets or sets the current action manager
  121008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121009. */
  121010. actionManager: Nullable<AbstractActionManager>;
  121011. private _meshCollisionData;
  121012. /**
  121013. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  121014. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121015. */
  121016. ellipsoid: Vector3;
  121017. /**
  121018. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  121019. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121020. */
  121021. ellipsoidOffset: Vector3;
  121022. /**
  121023. * Gets or sets a collision mask used to mask collisions (default is -1).
  121024. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121025. */
  121026. get collisionMask(): number;
  121027. set collisionMask(mask: number);
  121028. /**
  121029. * Gets or sets a collision response flag (default is true).
  121030. * when collisionResponse is false, events are still triggered but colliding entity has no response
  121031. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  121032. * to respond to the collision.
  121033. */
  121034. get collisionResponse(): boolean;
  121035. set collisionResponse(response: boolean);
  121036. /**
  121037. * Gets or sets the current collision group mask (-1 by default).
  121038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121039. */
  121040. get collisionGroup(): number;
  121041. set collisionGroup(mask: number);
  121042. /**
  121043. * Gets or sets current surrounding meshes (null by default).
  121044. *
  121045. * By default collision detection is tested against every mesh in the scene.
  121046. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  121047. * meshes will be tested for the collision.
  121048. *
  121049. * Note: if set to an empty array no collision will happen when this mesh is moved.
  121050. */
  121051. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  121052. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  121053. /**
  121054. * Defines edge width used when edgesRenderer is enabled
  121055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121056. */
  121057. edgesWidth: number;
  121058. /**
  121059. * Defines edge color used when edgesRenderer is enabled
  121060. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121061. */
  121062. edgesColor: Color4;
  121063. /** @hidden */
  121064. _edgesRenderer: Nullable<IEdgesRenderer>;
  121065. /** @hidden */
  121066. _masterMesh: Nullable<AbstractMesh>;
  121067. /** @hidden */
  121068. _boundingInfo: Nullable<BoundingInfo>;
  121069. /** @hidden */
  121070. _renderId: number;
  121071. /**
  121072. * Gets or sets the list of subMeshes
  121073. * @see https://doc.babylonjs.com/how_to/multi_materials
  121074. */
  121075. subMeshes: SubMesh[];
  121076. /** @hidden */
  121077. _intersectionsInProgress: AbstractMesh[];
  121078. /** @hidden */
  121079. _unIndexed: boolean;
  121080. /** @hidden */
  121081. _lightSources: Light[];
  121082. /** Gets the list of lights affecting that mesh */
  121083. get lightSources(): Light[];
  121084. /** @hidden */
  121085. get _positions(): Nullable<Vector3[]>;
  121086. /** @hidden */
  121087. _waitingData: {
  121088. lods: Nullable<any>;
  121089. actions: Nullable<any>;
  121090. freezeWorldMatrix: Nullable<boolean>;
  121091. };
  121092. /** @hidden */
  121093. _bonesTransformMatrices: Nullable<Float32Array>;
  121094. /** @hidden */
  121095. _transformMatrixTexture: Nullable<RawTexture>;
  121096. /**
  121097. * Gets or sets a skeleton to apply skining transformations
  121098. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121099. */
  121100. set skeleton(value: Nullable<Skeleton>);
  121101. get skeleton(): Nullable<Skeleton>;
  121102. /**
  121103. * An event triggered when the mesh is rebuilt.
  121104. */
  121105. onRebuildObservable: Observable<AbstractMesh>;
  121106. /**
  121107. * The current mesh unifom buffer.
  121108. * @hidden Internal use only.
  121109. */
  121110. _uniformBuffer: UniformBuffer;
  121111. /**
  121112. * Creates a new AbstractMesh
  121113. * @param name defines the name of the mesh
  121114. * @param scene defines the hosting scene
  121115. */
  121116. constructor(name: string, scene?: Nullable<Scene>);
  121117. protected _buildUniformLayout(): void;
  121118. /**
  121119. * Transfer the mesh values to its UBO.
  121120. * @param world The world matrix associated with the mesh
  121121. */
  121122. transferToEffect(world: Matrix): void;
  121123. /**
  121124. * Gets the mesh uniform buffer.
  121125. * @return the uniform buffer of the mesh.
  121126. */
  121127. getMeshUniformBuffer(): UniformBuffer;
  121128. /**
  121129. * Returns the string "AbstractMesh"
  121130. * @returns "AbstractMesh"
  121131. */
  121132. getClassName(): string;
  121133. /**
  121134. * Gets a string representation of the current mesh
  121135. * @param fullDetails defines a boolean indicating if full details must be included
  121136. * @returns a string representation of the current mesh
  121137. */
  121138. toString(fullDetails?: boolean): string;
  121139. /**
  121140. * @hidden
  121141. */
  121142. protected _getEffectiveParent(): Nullable<Node>;
  121143. /** @hidden */
  121144. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  121145. /** @hidden */
  121146. _rebuild(): void;
  121147. /** @hidden */
  121148. _resyncLightSources(): void;
  121149. /** @hidden */
  121150. _resyncLightSource(light: Light): void;
  121151. /** @hidden */
  121152. _unBindEffect(): void;
  121153. /** @hidden */
  121154. _removeLightSource(light: Light, dispose: boolean): void;
  121155. private _markSubMeshesAsDirty;
  121156. /** @hidden */
  121157. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  121158. /** @hidden */
  121159. _markSubMeshesAsAttributesDirty(): void;
  121160. /** @hidden */
  121161. _markSubMeshesAsMiscDirty(): void;
  121162. /**
  121163. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  121164. */
  121165. get scaling(): Vector3;
  121166. set scaling(newScaling: Vector3);
  121167. /**
  121168. * Returns true if the mesh is blocked. Implemented by child classes
  121169. */
  121170. get isBlocked(): boolean;
  121171. /**
  121172. * Returns the mesh itself by default. Implemented by child classes
  121173. * @param camera defines the camera to use to pick the right LOD level
  121174. * @returns the currentAbstractMesh
  121175. */
  121176. getLOD(camera: Camera): Nullable<AbstractMesh>;
  121177. /**
  121178. * Returns 0 by default. Implemented by child classes
  121179. * @returns an integer
  121180. */
  121181. getTotalVertices(): number;
  121182. /**
  121183. * Returns a positive integer : the total number of indices in this mesh geometry.
  121184. * @returns the numner of indices or zero if the mesh has no geometry.
  121185. */
  121186. getTotalIndices(): number;
  121187. /**
  121188. * Returns null by default. Implemented by child classes
  121189. * @returns null
  121190. */
  121191. getIndices(): Nullable<IndicesArray>;
  121192. /**
  121193. * Returns the array of the requested vertex data kind. Implemented by child classes
  121194. * @param kind defines the vertex data kind to use
  121195. * @returns null
  121196. */
  121197. getVerticesData(kind: string): Nullable<FloatArray>;
  121198. /**
  121199. * Sets the vertex data of the mesh geometry for the requested `kind`.
  121200. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  121201. * Note that a new underlying VertexBuffer object is created each call.
  121202. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  121203. * @param kind defines vertex data kind:
  121204. * * VertexBuffer.PositionKind
  121205. * * VertexBuffer.UVKind
  121206. * * VertexBuffer.UV2Kind
  121207. * * VertexBuffer.UV3Kind
  121208. * * VertexBuffer.UV4Kind
  121209. * * VertexBuffer.UV5Kind
  121210. * * VertexBuffer.UV6Kind
  121211. * * VertexBuffer.ColorKind
  121212. * * VertexBuffer.MatricesIndicesKind
  121213. * * VertexBuffer.MatricesIndicesExtraKind
  121214. * * VertexBuffer.MatricesWeightsKind
  121215. * * VertexBuffer.MatricesWeightsExtraKind
  121216. * @param data defines the data source
  121217. * @param updatable defines if the data must be flagged as updatable (or static)
  121218. * @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
  121219. * @returns the current mesh
  121220. */
  121221. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  121222. /**
  121223. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  121224. * If the mesh has no geometry, it is simply returned as it is.
  121225. * @param kind defines vertex data kind:
  121226. * * VertexBuffer.PositionKind
  121227. * * VertexBuffer.UVKind
  121228. * * VertexBuffer.UV2Kind
  121229. * * VertexBuffer.UV3Kind
  121230. * * VertexBuffer.UV4Kind
  121231. * * VertexBuffer.UV5Kind
  121232. * * VertexBuffer.UV6Kind
  121233. * * VertexBuffer.ColorKind
  121234. * * VertexBuffer.MatricesIndicesKind
  121235. * * VertexBuffer.MatricesIndicesExtraKind
  121236. * * VertexBuffer.MatricesWeightsKind
  121237. * * VertexBuffer.MatricesWeightsExtraKind
  121238. * @param data defines the data source
  121239. * @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
  121240. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  121241. * @returns the current mesh
  121242. */
  121243. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  121244. /**
  121245. * Sets the mesh indices,
  121246. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  121247. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  121248. * @param totalVertices Defines the total number of vertices
  121249. * @returns the current mesh
  121250. */
  121251. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  121252. /**
  121253. * Gets a boolean indicating if specific vertex data is present
  121254. * @param kind defines the vertex data kind to use
  121255. * @returns true is data kind is present
  121256. */
  121257. isVerticesDataPresent(kind: string): boolean;
  121258. /**
  121259. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  121260. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  121261. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  121262. * @returns a BoundingInfo
  121263. */
  121264. getBoundingInfo(): BoundingInfo;
  121265. /**
  121266. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  121267. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  121268. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  121269. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  121270. * @returns the current mesh
  121271. */
  121272. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  121273. /**
  121274. * Overwrite the current bounding info
  121275. * @param boundingInfo defines the new bounding info
  121276. * @returns the current mesh
  121277. */
  121278. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  121279. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  121280. get useBones(): boolean;
  121281. /** @hidden */
  121282. _preActivate(): void;
  121283. /** @hidden */
  121284. _preActivateForIntermediateRendering(renderId: number): void;
  121285. /** @hidden */
  121286. _activate(renderId: number, intermediateRendering: boolean): boolean;
  121287. /** @hidden */
  121288. _postActivate(): void;
  121289. /** @hidden */
  121290. _freeze(): void;
  121291. /** @hidden */
  121292. _unFreeze(): void;
  121293. /**
  121294. * Gets the current world matrix
  121295. * @returns a Matrix
  121296. */
  121297. getWorldMatrix(): Matrix;
  121298. /** @hidden */
  121299. _getWorldMatrixDeterminant(): number;
  121300. /**
  121301. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  121302. */
  121303. get isAnInstance(): boolean;
  121304. /**
  121305. * Gets a boolean indicating if this mesh has instances
  121306. */
  121307. get hasInstances(): boolean;
  121308. /**
  121309. * Gets a boolean indicating if this mesh has thin instances
  121310. */
  121311. get hasThinInstances(): boolean;
  121312. /**
  121313. * Perform relative position change from the point of view of behind the front of the mesh.
  121314. * This is performed taking into account the meshes current rotation, so you do not have to care.
  121315. * Supports definition of mesh facing forward or backward
  121316. * @param amountRight defines the distance on the right axis
  121317. * @param amountUp defines the distance on the up axis
  121318. * @param amountForward defines the distance on the forward axis
  121319. * @returns the current mesh
  121320. */
  121321. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  121322. /**
  121323. * Calculate relative position change from the point of view of behind the front of the mesh.
  121324. * This is performed taking into account the meshes current rotation, so you do not have to care.
  121325. * Supports definition of mesh facing forward or backward
  121326. * @param amountRight defines the distance on the right axis
  121327. * @param amountUp defines the distance on the up axis
  121328. * @param amountForward defines the distance on the forward axis
  121329. * @returns the new displacement vector
  121330. */
  121331. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  121332. /**
  121333. * Perform relative rotation change from the point of view of behind the front of the mesh.
  121334. * Supports definition of mesh facing forward or backward
  121335. * @param flipBack defines the flip
  121336. * @param twirlClockwise defines the twirl
  121337. * @param tiltRight defines the tilt
  121338. * @returns the current mesh
  121339. */
  121340. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  121341. /**
  121342. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  121343. * Supports definition of mesh facing forward or backward.
  121344. * @param flipBack defines the flip
  121345. * @param twirlClockwise defines the twirl
  121346. * @param tiltRight defines the tilt
  121347. * @returns the new rotation vector
  121348. */
  121349. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  121350. /**
  121351. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  121352. * This means the mesh underlying bounding box and sphere are recomputed.
  121353. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  121354. * @returns the current mesh
  121355. */
  121356. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  121357. /** @hidden */
  121358. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  121359. /** @hidden */
  121360. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  121361. /** @hidden */
  121362. _updateBoundingInfo(): AbstractMesh;
  121363. /** @hidden */
  121364. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  121365. /** @hidden */
  121366. protected _afterComputeWorldMatrix(): void;
  121367. /** @hidden */
  121368. get _effectiveMesh(): AbstractMesh;
  121369. /**
  121370. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  121371. * A mesh is in the frustum if its bounding box intersects the frustum
  121372. * @param frustumPlanes defines the frustum to test
  121373. * @returns true if the mesh is in the frustum planes
  121374. */
  121375. isInFrustum(frustumPlanes: Plane[]): boolean;
  121376. /**
  121377. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  121378. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  121379. * @param frustumPlanes defines the frustum to test
  121380. * @returns true if the mesh is completely in the frustum planes
  121381. */
  121382. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  121383. /**
  121384. * True if the mesh intersects another mesh or a SolidParticle object
  121385. * @param mesh defines a target mesh or SolidParticle to test
  121386. * @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)
  121387. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  121388. * @returns true if there is an intersection
  121389. */
  121390. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  121391. /**
  121392. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  121393. * @param point defines the point to test
  121394. * @returns true if there is an intersection
  121395. */
  121396. intersectsPoint(point: Vector3): boolean;
  121397. /**
  121398. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  121399. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121400. */
  121401. get checkCollisions(): boolean;
  121402. set checkCollisions(collisionEnabled: boolean);
  121403. /**
  121404. * Gets Collider object used to compute collisions (not physics)
  121405. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121406. */
  121407. get collider(): Nullable<Collider>;
  121408. /**
  121409. * Move the mesh using collision engine
  121410. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121411. * @param displacement defines the requested displacement vector
  121412. * @returns the current mesh
  121413. */
  121414. moveWithCollisions(displacement: Vector3): AbstractMesh;
  121415. private _onCollisionPositionChange;
  121416. /** @hidden */
  121417. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  121418. /** @hidden */
  121419. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  121420. /** @hidden */
  121421. _checkCollision(collider: Collider): AbstractMesh;
  121422. /** @hidden */
  121423. _generatePointsArray(): boolean;
  121424. /**
  121425. * Checks if the passed Ray intersects with the mesh
  121426. * @param ray defines the ray to use
  121427. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  121428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121429. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  121430. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  121431. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  121432. * @returns the picking info
  121433. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  121434. */
  121435. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  121436. /**
  121437. * Clones the current mesh
  121438. * @param name defines the mesh name
  121439. * @param newParent defines the new mesh parent
  121440. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  121441. * @returns the new mesh
  121442. */
  121443. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  121444. /**
  121445. * Disposes all the submeshes of the current meshnp
  121446. * @returns the current mesh
  121447. */
  121448. releaseSubMeshes(): AbstractMesh;
  121449. /**
  121450. * Releases resources associated with this abstract mesh.
  121451. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121452. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121453. */
  121454. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121455. /**
  121456. * Adds the passed mesh as a child to the current mesh
  121457. * @param mesh defines the child mesh
  121458. * @returns the current mesh
  121459. */
  121460. addChild(mesh: AbstractMesh): AbstractMesh;
  121461. /**
  121462. * Removes the passed mesh from the current mesh children list
  121463. * @param mesh defines the child mesh
  121464. * @returns the current mesh
  121465. */
  121466. removeChild(mesh: AbstractMesh): AbstractMesh;
  121467. /** @hidden */
  121468. private _initFacetData;
  121469. /**
  121470. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  121471. * This method can be called within the render loop.
  121472. * 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
  121473. * @returns the current mesh
  121474. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121475. */
  121476. updateFacetData(): AbstractMesh;
  121477. /**
  121478. * Returns the facetLocalNormals array.
  121479. * The normals are expressed in the mesh local spac
  121480. * @returns an array of Vector3
  121481. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121482. */
  121483. getFacetLocalNormals(): Vector3[];
  121484. /**
  121485. * Returns the facetLocalPositions array.
  121486. * The facet positions are expressed in the mesh local space
  121487. * @returns an array of Vector3
  121488. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121489. */
  121490. getFacetLocalPositions(): Vector3[];
  121491. /**
  121492. * Returns the facetLocalPartioning array
  121493. * @returns an array of array of numbers
  121494. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121495. */
  121496. getFacetLocalPartitioning(): number[][];
  121497. /**
  121498. * Returns the i-th facet position in the world system.
  121499. * This method allocates a new Vector3 per call
  121500. * @param i defines the facet index
  121501. * @returns a new Vector3
  121502. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121503. */
  121504. getFacetPosition(i: number): Vector3;
  121505. /**
  121506. * Sets the reference Vector3 with the i-th facet position in the world system
  121507. * @param i defines the facet index
  121508. * @param ref defines the target vector
  121509. * @returns the current mesh
  121510. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121511. */
  121512. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  121513. /**
  121514. * Returns the i-th facet normal in the world system.
  121515. * This method allocates a new Vector3 per call
  121516. * @param i defines the facet index
  121517. * @returns a new Vector3
  121518. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121519. */
  121520. getFacetNormal(i: number): Vector3;
  121521. /**
  121522. * Sets the reference Vector3 with the i-th facet normal in the world system
  121523. * @param i defines the facet index
  121524. * @param ref defines the target vector
  121525. * @returns the current mesh
  121526. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121527. */
  121528. getFacetNormalToRef(i: number, ref: Vector3): this;
  121529. /**
  121530. * 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)
  121531. * @param x defines x coordinate
  121532. * @param y defines y coordinate
  121533. * @param z defines z coordinate
  121534. * @returns the array of facet indexes
  121535. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121536. */
  121537. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  121538. /**
  121539. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  121540. * @param projected sets as the (x,y,z) world projection on the facet
  121541. * @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
  121542. * @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
  121543. * @param x defines x coordinate
  121544. * @param y defines y coordinate
  121545. * @param z defines z coordinate
  121546. * @returns the face index if found (or null instead)
  121547. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121548. */
  121549. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121550. /**
  121551. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  121552. * @param projected sets as the (x,y,z) local projection on the facet
  121553. * @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
  121554. * @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
  121555. * @param x defines x coordinate
  121556. * @param y defines y coordinate
  121557. * @param z defines z coordinate
  121558. * @returns the face index if found (or null instead)
  121559. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121560. */
  121561. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121562. /**
  121563. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  121564. * @returns the parameters
  121565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121566. */
  121567. getFacetDataParameters(): any;
  121568. /**
  121569. * Disables the feature FacetData and frees the related memory
  121570. * @returns the current mesh
  121571. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121572. */
  121573. disableFacetData(): AbstractMesh;
  121574. /**
  121575. * Updates the AbstractMesh indices array
  121576. * @param indices defines the data source
  121577. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  121578. * @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)
  121579. * @returns the current mesh
  121580. */
  121581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  121582. /**
  121583. * Creates new normals data for the mesh
  121584. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  121585. * @returns the current mesh
  121586. */
  121587. createNormals(updatable: boolean): AbstractMesh;
  121588. /**
  121589. * Align the mesh with a normal
  121590. * @param normal defines the normal to use
  121591. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  121592. * @returns the current mesh
  121593. */
  121594. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  121595. /** @hidden */
  121596. _checkOcclusionQuery(): boolean;
  121597. /**
  121598. * Disables the mesh edge rendering mode
  121599. * @returns the currentAbstractMesh
  121600. */
  121601. disableEdgesRendering(): AbstractMesh;
  121602. /**
  121603. * Enables the edge rendering mode on the mesh.
  121604. * This mode makes the mesh edges visible
  121605. * @param epsilon defines the maximal distance between two angles to detect a face
  121606. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  121607. * @param options options to the edge renderer
  121608. * @returns the currentAbstractMesh
  121609. * @see https://www.babylonjs-playground.com/#19O9TU#0
  121610. */
  121611. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  121612. /**
  121613. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  121614. * @returns an array of particle systems in the scene that use the mesh as an emitter
  121615. */
  121616. getConnectedParticleSystems(): IParticleSystem[];
  121617. }
  121618. }
  121619. declare module BABYLON {
  121620. /**
  121621. * Interface used to define ActionEvent
  121622. */
  121623. export interface IActionEvent {
  121624. /** The mesh or sprite that triggered the action */
  121625. source: any;
  121626. /** The X mouse cursor position at the time of the event */
  121627. pointerX: number;
  121628. /** The Y mouse cursor position at the time of the event */
  121629. pointerY: number;
  121630. /** The mesh that is currently pointed at (can be null) */
  121631. meshUnderPointer: Nullable<AbstractMesh>;
  121632. /** the original (browser) event that triggered the ActionEvent */
  121633. sourceEvent?: any;
  121634. /** additional data for the event */
  121635. additionalData?: any;
  121636. }
  121637. /**
  121638. * ActionEvent is the event being sent when an action is triggered.
  121639. */
  121640. export class ActionEvent implements IActionEvent {
  121641. /** The mesh or sprite that triggered the action */
  121642. source: any;
  121643. /** The X mouse cursor position at the time of the event */
  121644. pointerX: number;
  121645. /** The Y mouse cursor position at the time of the event */
  121646. pointerY: number;
  121647. /** The mesh that is currently pointed at (can be null) */
  121648. meshUnderPointer: Nullable<AbstractMesh>;
  121649. /** the original (browser) event that triggered the ActionEvent */
  121650. sourceEvent?: any;
  121651. /** additional data for the event */
  121652. additionalData?: any;
  121653. /**
  121654. * Creates a new ActionEvent
  121655. * @param source The mesh or sprite that triggered the action
  121656. * @param pointerX The X mouse cursor position at the time of the event
  121657. * @param pointerY The Y mouse cursor position at the time of the event
  121658. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  121659. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  121660. * @param additionalData additional data for the event
  121661. */
  121662. constructor(
  121663. /** The mesh or sprite that triggered the action */
  121664. source: any,
  121665. /** The X mouse cursor position at the time of the event */
  121666. pointerX: number,
  121667. /** The Y mouse cursor position at the time of the event */
  121668. pointerY: number,
  121669. /** The mesh that is currently pointed at (can be null) */
  121670. meshUnderPointer: Nullable<AbstractMesh>,
  121671. /** the original (browser) event that triggered the ActionEvent */
  121672. sourceEvent?: any,
  121673. /** additional data for the event */
  121674. additionalData?: any);
  121675. /**
  121676. * Helper function to auto-create an ActionEvent from a source mesh.
  121677. * @param source The source mesh that triggered the event
  121678. * @param evt The original (browser) event
  121679. * @param additionalData additional data for the event
  121680. * @returns the new ActionEvent
  121681. */
  121682. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  121683. /**
  121684. * Helper function to auto-create an ActionEvent from a source sprite
  121685. * @param source The source sprite that triggered the event
  121686. * @param scene Scene associated with the sprite
  121687. * @param evt The original (browser) event
  121688. * @param additionalData additional data for the event
  121689. * @returns the new ActionEvent
  121690. */
  121691. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  121692. /**
  121693. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  121694. * @param scene the scene where the event occurred
  121695. * @param evt The original (browser) event
  121696. * @returns the new ActionEvent
  121697. */
  121698. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  121699. /**
  121700. * Helper function to auto-create an ActionEvent from a primitive
  121701. * @param prim defines the target primitive
  121702. * @param pointerPos defines the pointer position
  121703. * @param evt The original (browser) event
  121704. * @param additionalData additional data for the event
  121705. * @returns the new ActionEvent
  121706. */
  121707. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  121708. }
  121709. }
  121710. declare module BABYLON {
  121711. /**
  121712. * Abstract class used to decouple action Manager from scene and meshes.
  121713. * Do not instantiate.
  121714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121715. */
  121716. export abstract class AbstractActionManager implements IDisposable {
  121717. /** Gets the list of active triggers */
  121718. static Triggers: {
  121719. [key: string]: number;
  121720. };
  121721. /** Gets the cursor to use when hovering items */
  121722. hoverCursor: string;
  121723. /** Gets the list of actions */
  121724. actions: IAction[];
  121725. /**
  121726. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  121727. */
  121728. isRecursive: boolean;
  121729. /**
  121730. * Releases all associated resources
  121731. */
  121732. abstract dispose(): void;
  121733. /**
  121734. * Does this action manager has pointer triggers
  121735. */
  121736. abstract get hasPointerTriggers(): boolean;
  121737. /**
  121738. * Does this action manager has pick triggers
  121739. */
  121740. abstract get hasPickTriggers(): boolean;
  121741. /**
  121742. * Process a specific trigger
  121743. * @param trigger defines the trigger to process
  121744. * @param evt defines the event details to be processed
  121745. */
  121746. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  121747. /**
  121748. * Does this action manager handles actions of any of the given triggers
  121749. * @param triggers defines the triggers to be tested
  121750. * @return a boolean indicating whether one (or more) of the triggers is handled
  121751. */
  121752. abstract hasSpecificTriggers(triggers: number[]): boolean;
  121753. /**
  121754. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  121755. * speed.
  121756. * @param triggerA defines the trigger to be tested
  121757. * @param triggerB defines the trigger to be tested
  121758. * @return a boolean indicating whether one (or more) of the triggers is handled
  121759. */
  121760. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  121761. /**
  121762. * Does this action manager handles actions of a given trigger
  121763. * @param trigger defines the trigger to be tested
  121764. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  121765. * @return whether the trigger is handled
  121766. */
  121767. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  121768. /**
  121769. * Serialize this manager to a JSON object
  121770. * @param name defines the property name to store this manager
  121771. * @returns a JSON representation of this manager
  121772. */
  121773. abstract serialize(name: string): any;
  121774. /**
  121775. * Registers an action to this action manager
  121776. * @param action defines the action to be registered
  121777. * @return the action amended (prepared) after registration
  121778. */
  121779. abstract registerAction(action: IAction): Nullable<IAction>;
  121780. /**
  121781. * Unregisters an action to this action manager
  121782. * @param action defines the action to be unregistered
  121783. * @return a boolean indicating whether the action has been unregistered
  121784. */
  121785. abstract unregisterAction(action: IAction): Boolean;
  121786. /**
  121787. * Does exist one action manager with at least one trigger
  121788. **/
  121789. static get HasTriggers(): boolean;
  121790. /**
  121791. * Does exist one action manager with at least one pick trigger
  121792. **/
  121793. static get HasPickTriggers(): boolean;
  121794. /**
  121795. * Does exist one action manager that handles actions of a given trigger
  121796. * @param trigger defines the trigger to be tested
  121797. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  121798. **/
  121799. static HasSpecificTrigger(trigger: number): boolean;
  121800. }
  121801. }
  121802. declare module BABYLON {
  121803. /**
  121804. * Defines how a node can be built from a string name.
  121805. */
  121806. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  121807. /**
  121808. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  121809. */
  121810. export class Node implements IBehaviorAware<Node> {
  121811. /** @hidden */
  121812. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  121813. private static _NodeConstructors;
  121814. /**
  121815. * Add a new node constructor
  121816. * @param type defines the type name of the node to construct
  121817. * @param constructorFunc defines the constructor function
  121818. */
  121819. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  121820. /**
  121821. * Returns a node constructor based on type name
  121822. * @param type defines the type name
  121823. * @param name defines the new node name
  121824. * @param scene defines the hosting scene
  121825. * @param options defines optional options to transmit to constructors
  121826. * @returns the new constructor or null
  121827. */
  121828. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  121829. /**
  121830. * Gets or sets the name of the node
  121831. */
  121832. name: string;
  121833. /**
  121834. * Gets or sets the id of the node
  121835. */
  121836. id: string;
  121837. /**
  121838. * Gets or sets the unique id of the node
  121839. */
  121840. uniqueId: number;
  121841. /**
  121842. * Gets or sets a string used to store user defined state for the node
  121843. */
  121844. state: string;
  121845. /**
  121846. * Gets or sets an object used to store user defined information for the node
  121847. */
  121848. metadata: any;
  121849. /**
  121850. * For internal use only. Please do not use.
  121851. */
  121852. reservedDataStore: any;
  121853. /**
  121854. * List of inspectable custom properties (used by the Inspector)
  121855. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121856. */
  121857. inspectableCustomProperties: IInspectable[];
  121858. private _doNotSerialize;
  121859. /**
  121860. * Gets or sets a boolean used to define if the node must be serialized
  121861. */
  121862. get doNotSerialize(): boolean;
  121863. set doNotSerialize(value: boolean);
  121864. /** @hidden */
  121865. _isDisposed: boolean;
  121866. /**
  121867. * Gets a list of Animations associated with the node
  121868. */
  121869. animations: Animation[];
  121870. protected _ranges: {
  121871. [name: string]: Nullable<AnimationRange>;
  121872. };
  121873. /**
  121874. * Callback raised when the node is ready to be used
  121875. */
  121876. onReady: Nullable<(node: Node) => void>;
  121877. private _isEnabled;
  121878. private _isParentEnabled;
  121879. private _isReady;
  121880. /** @hidden */
  121881. _currentRenderId: number;
  121882. private _parentUpdateId;
  121883. /** @hidden */
  121884. _childUpdateId: number;
  121885. /** @hidden */
  121886. _waitingParentId: Nullable<string>;
  121887. /** @hidden */
  121888. _scene: Scene;
  121889. /** @hidden */
  121890. _cache: any;
  121891. private _parentNode;
  121892. private _children;
  121893. /** @hidden */
  121894. _worldMatrix: Matrix;
  121895. /** @hidden */
  121896. _worldMatrixDeterminant: number;
  121897. /** @hidden */
  121898. _worldMatrixDeterminantIsDirty: boolean;
  121899. /** @hidden */
  121900. private _sceneRootNodesIndex;
  121901. /**
  121902. * Gets a boolean indicating if the node has been disposed
  121903. * @returns true if the node was disposed
  121904. */
  121905. isDisposed(): boolean;
  121906. /**
  121907. * Gets or sets the parent of the node (without keeping the current position in the scene)
  121908. * @see https://doc.babylonjs.com/how_to/parenting
  121909. */
  121910. set parent(parent: Nullable<Node>);
  121911. get parent(): Nullable<Node>;
  121912. /** @hidden */
  121913. _addToSceneRootNodes(): void;
  121914. /** @hidden */
  121915. _removeFromSceneRootNodes(): void;
  121916. private _animationPropertiesOverride;
  121917. /**
  121918. * Gets or sets the animation properties override
  121919. */
  121920. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  121921. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  121922. /**
  121923. * Gets a string identifying the name of the class
  121924. * @returns "Node" string
  121925. */
  121926. getClassName(): string;
  121927. /** @hidden */
  121928. readonly _isNode: boolean;
  121929. /**
  121930. * An event triggered when the mesh is disposed
  121931. */
  121932. onDisposeObservable: Observable<Node>;
  121933. private _onDisposeObserver;
  121934. /**
  121935. * Sets a callback that will be raised when the node will be disposed
  121936. */
  121937. set onDispose(callback: () => void);
  121938. /**
  121939. * Creates a new Node
  121940. * @param name the name and id to be given to this node
  121941. * @param scene the scene this node will be added to
  121942. */
  121943. constructor(name: string, scene?: Nullable<Scene>);
  121944. /**
  121945. * Gets the scene of the node
  121946. * @returns a scene
  121947. */
  121948. getScene(): Scene;
  121949. /**
  121950. * Gets the engine of the node
  121951. * @returns a Engine
  121952. */
  121953. getEngine(): Engine;
  121954. private _behaviors;
  121955. /**
  121956. * Attach a behavior to the node
  121957. * @see https://doc.babylonjs.com/features/behaviour
  121958. * @param behavior defines the behavior to attach
  121959. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  121960. * @returns the current Node
  121961. */
  121962. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  121963. /**
  121964. * Remove an attached behavior
  121965. * @see https://doc.babylonjs.com/features/behaviour
  121966. * @param behavior defines the behavior to attach
  121967. * @returns the current Node
  121968. */
  121969. removeBehavior(behavior: Behavior<Node>): Node;
  121970. /**
  121971. * Gets the list of attached behaviors
  121972. * @see https://doc.babylonjs.com/features/behaviour
  121973. */
  121974. get behaviors(): Behavior<Node>[];
  121975. /**
  121976. * Gets an attached behavior by name
  121977. * @param name defines the name of the behavior to look for
  121978. * @see https://doc.babylonjs.com/features/behaviour
  121979. * @returns null if behavior was not found else the requested behavior
  121980. */
  121981. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  121982. /**
  121983. * Returns the latest update of the World matrix
  121984. * @returns a Matrix
  121985. */
  121986. getWorldMatrix(): Matrix;
  121987. /** @hidden */
  121988. _getWorldMatrixDeterminant(): number;
  121989. /**
  121990. * Returns directly the latest state of the mesh World matrix.
  121991. * A Matrix is returned.
  121992. */
  121993. get worldMatrixFromCache(): Matrix;
  121994. /** @hidden */
  121995. _initCache(): void;
  121996. /** @hidden */
  121997. updateCache(force?: boolean): void;
  121998. /** @hidden */
  121999. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  122000. /** @hidden */
  122001. _updateCache(ignoreParentClass?: boolean): void;
  122002. /** @hidden */
  122003. _isSynchronized(): boolean;
  122004. /** @hidden */
  122005. _markSyncedWithParent(): void;
  122006. /** @hidden */
  122007. isSynchronizedWithParent(): boolean;
  122008. /** @hidden */
  122009. isSynchronized(): boolean;
  122010. /**
  122011. * Is this node ready to be used/rendered
  122012. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  122013. * @return true if the node is ready
  122014. */
  122015. isReady(completeCheck?: boolean): boolean;
  122016. /**
  122017. * Is this node enabled?
  122018. * 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
  122019. * @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
  122020. * @return whether this node (and its parent) is enabled
  122021. */
  122022. isEnabled(checkAncestors?: boolean): boolean;
  122023. /** @hidden */
  122024. protected _syncParentEnabledState(): void;
  122025. /**
  122026. * Set the enabled state of this node
  122027. * @param value defines the new enabled state
  122028. */
  122029. setEnabled(value: boolean): void;
  122030. /**
  122031. * Is this node a descendant of the given node?
  122032. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  122033. * @param ancestor defines the parent node to inspect
  122034. * @returns a boolean indicating if this node is a descendant of the given node
  122035. */
  122036. isDescendantOf(ancestor: Node): boolean;
  122037. /** @hidden */
  122038. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  122039. /**
  122040. * Will return all nodes that have this node as ascendant
  122041. * @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
  122042. * @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
  122043. * @return all children nodes of all types
  122044. */
  122045. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  122046. /**
  122047. * Get all child-meshes of this node
  122048. * @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)
  122049. * @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
  122050. * @returns an array of AbstractMesh
  122051. */
  122052. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  122053. /**
  122054. * Get all direct children of this node
  122055. * @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
  122056. * @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)
  122057. * @returns an array of Node
  122058. */
  122059. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  122060. /** @hidden */
  122061. _setReady(state: boolean): void;
  122062. /**
  122063. * Get an animation by name
  122064. * @param name defines the name of the animation to look for
  122065. * @returns null if not found else the requested animation
  122066. */
  122067. getAnimationByName(name: string): Nullable<Animation>;
  122068. /**
  122069. * Creates an animation range for this node
  122070. * @param name defines the name of the range
  122071. * @param from defines the starting key
  122072. * @param to defines the end key
  122073. */
  122074. createAnimationRange(name: string, from: number, to: number): void;
  122075. /**
  122076. * Delete a specific animation range
  122077. * @param name defines the name of the range to delete
  122078. * @param deleteFrames defines if animation frames from the range must be deleted as well
  122079. */
  122080. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  122081. /**
  122082. * Get an animation range by name
  122083. * @param name defines the name of the animation range to look for
  122084. * @returns null if not found else the requested animation range
  122085. */
  122086. getAnimationRange(name: string): Nullable<AnimationRange>;
  122087. /**
  122088. * Gets the list of all animation ranges defined on this node
  122089. * @returns an array
  122090. */
  122091. getAnimationRanges(): Nullable<AnimationRange>[];
  122092. /**
  122093. * Will start the animation sequence
  122094. * @param name defines the range frames for animation sequence
  122095. * @param loop defines if the animation should loop (false by default)
  122096. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  122097. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  122098. * @returns the object created for this animation. If range does not exist, it will return null
  122099. */
  122100. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  122101. /**
  122102. * Serialize animation ranges into a JSON compatible object
  122103. * @returns serialization object
  122104. */
  122105. serializeAnimationRanges(): any;
  122106. /**
  122107. * Computes the world matrix of the node
  122108. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  122109. * @returns the world matrix
  122110. */
  122111. computeWorldMatrix(force?: boolean): Matrix;
  122112. /**
  122113. * Releases resources associated with this node.
  122114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122116. */
  122117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122118. /**
  122119. * Parse animation range data from a serialization object and store them into a given node
  122120. * @param node defines where to store the animation ranges
  122121. * @param parsedNode defines the serialization object to read data from
  122122. * @param scene defines the hosting scene
  122123. */
  122124. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  122125. /**
  122126. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  122127. * @param includeDescendants Include bounding info from descendants as well (true by default)
  122128. * @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
  122129. * @returns the new bounding vectors
  122130. */
  122131. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  122132. min: Vector3;
  122133. max: Vector3;
  122134. };
  122135. }
  122136. }
  122137. declare module BABYLON {
  122138. /**
  122139. * @hidden
  122140. */
  122141. export class _IAnimationState {
  122142. key: number;
  122143. repeatCount: number;
  122144. workValue?: any;
  122145. loopMode?: number;
  122146. offsetValue?: any;
  122147. highLimitValue?: any;
  122148. }
  122149. /**
  122150. * Class used to store any kind of animation
  122151. */
  122152. export class Animation {
  122153. /**Name of the animation */
  122154. name: string;
  122155. /**Property to animate */
  122156. targetProperty: string;
  122157. /**The frames per second of the animation */
  122158. framePerSecond: number;
  122159. /**The data type of the animation */
  122160. dataType: number;
  122161. /**The loop mode of the animation */
  122162. loopMode?: number | undefined;
  122163. /**Specifies if blending should be enabled */
  122164. enableBlending?: boolean | undefined;
  122165. /**
  122166. * Use matrix interpolation instead of using direct key value when animating matrices
  122167. */
  122168. static AllowMatricesInterpolation: boolean;
  122169. /**
  122170. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  122171. */
  122172. static AllowMatrixDecomposeForInterpolation: boolean;
  122173. /** Define the Url to load snippets */
  122174. static SnippetUrl: string;
  122175. /** Snippet ID if the animation was created from the snippet server */
  122176. snippetId: string;
  122177. /**
  122178. * Stores the key frames of the animation
  122179. */
  122180. private _keys;
  122181. /**
  122182. * Stores the easing function of the animation
  122183. */
  122184. private _easingFunction;
  122185. /**
  122186. * @hidden Internal use only
  122187. */
  122188. _runtimeAnimations: RuntimeAnimation[];
  122189. /**
  122190. * The set of event that will be linked to this animation
  122191. */
  122192. private _events;
  122193. /**
  122194. * Stores an array of target property paths
  122195. */
  122196. targetPropertyPath: string[];
  122197. /**
  122198. * Stores the blending speed of the animation
  122199. */
  122200. blendingSpeed: number;
  122201. /**
  122202. * Stores the animation ranges for the animation
  122203. */
  122204. private _ranges;
  122205. /**
  122206. * @hidden Internal use
  122207. */
  122208. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  122209. /**
  122210. * Sets up an animation
  122211. * @param property The property to animate
  122212. * @param animationType The animation type to apply
  122213. * @param framePerSecond The frames per second of the animation
  122214. * @param easingFunction The easing function used in the animation
  122215. * @returns The created animation
  122216. */
  122217. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  122218. /**
  122219. * Create and start an animation on a node
  122220. * @param name defines the name of the global animation that will be run on all nodes
  122221. * @param node defines the root node where the animation will take place
  122222. * @param targetProperty defines property to animate
  122223. * @param framePerSecond defines the number of frame per second yo use
  122224. * @param totalFrame defines the number of frames in total
  122225. * @param from defines the initial value
  122226. * @param to defines the final value
  122227. * @param loopMode defines which loop mode you want to use (off by default)
  122228. * @param easingFunction defines the easing function to use (linear by default)
  122229. * @param onAnimationEnd defines the callback to call when animation end
  122230. * @returns the animatable created for this animation
  122231. */
  122232. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  122233. /**
  122234. * Create and start an animation on a node and its descendants
  122235. * @param name defines the name of the global animation that will be run on all nodes
  122236. * @param node defines the root node where the animation will take place
  122237. * @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
  122238. * @param targetProperty defines property to animate
  122239. * @param framePerSecond defines the number of frame per second to use
  122240. * @param totalFrame defines the number of frames in total
  122241. * @param from defines the initial value
  122242. * @param to defines the final value
  122243. * @param loopMode defines which loop mode you want to use (off by default)
  122244. * @param easingFunction defines the easing function to use (linear by default)
  122245. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  122246. * @returns the list of animatables created for all nodes
  122247. * @example https://www.babylonjs-playground.com/#MH0VLI
  122248. */
  122249. 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[]>;
  122250. /**
  122251. * Creates a new animation, merges it with the existing animations and starts it
  122252. * @param name Name of the animation
  122253. * @param node Node which contains the scene that begins the animations
  122254. * @param targetProperty Specifies which property to animate
  122255. * @param framePerSecond The frames per second of the animation
  122256. * @param totalFrame The total number of frames
  122257. * @param from The frame at the beginning of the animation
  122258. * @param to The frame at the end of the animation
  122259. * @param loopMode Specifies the loop mode of the animation
  122260. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  122261. * @param onAnimationEnd Callback to run once the animation is complete
  122262. * @returns Nullable animation
  122263. */
  122264. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  122265. /**
  122266. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  122267. * @param sourceAnimation defines the Animation containing keyframes to convert
  122268. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  122269. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  122270. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  122271. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  122272. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  122273. */
  122274. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  122275. /**
  122276. * Transition property of an host to the target Value
  122277. * @param property The property to transition
  122278. * @param targetValue The target Value of the property
  122279. * @param host The object where the property to animate belongs
  122280. * @param scene Scene used to run the animation
  122281. * @param frameRate Framerate (in frame/s) to use
  122282. * @param transition The transition type we want to use
  122283. * @param duration The duration of the animation, in milliseconds
  122284. * @param onAnimationEnd Callback trigger at the end of the animation
  122285. * @returns Nullable animation
  122286. */
  122287. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  122288. /**
  122289. * Return the array of runtime animations currently using this animation
  122290. */
  122291. get runtimeAnimations(): RuntimeAnimation[];
  122292. /**
  122293. * Specifies if any of the runtime animations are currently running
  122294. */
  122295. get hasRunningRuntimeAnimations(): boolean;
  122296. /**
  122297. * Initializes the animation
  122298. * @param name Name of the animation
  122299. * @param targetProperty Property to animate
  122300. * @param framePerSecond The frames per second of the animation
  122301. * @param dataType The data type of the animation
  122302. * @param loopMode The loop mode of the animation
  122303. * @param enableBlending Specifies if blending should be enabled
  122304. */
  122305. constructor(
  122306. /**Name of the animation */
  122307. name: string,
  122308. /**Property to animate */
  122309. targetProperty: string,
  122310. /**The frames per second of the animation */
  122311. framePerSecond: number,
  122312. /**The data type of the animation */
  122313. dataType: number,
  122314. /**The loop mode of the animation */
  122315. loopMode?: number | undefined,
  122316. /**Specifies if blending should be enabled */
  122317. enableBlending?: boolean | undefined);
  122318. /**
  122319. * Converts the animation to a string
  122320. * @param fullDetails support for multiple levels of logging within scene loading
  122321. * @returns String form of the animation
  122322. */
  122323. toString(fullDetails?: boolean): string;
  122324. /**
  122325. * Add an event to this animation
  122326. * @param event Event to add
  122327. */
  122328. addEvent(event: AnimationEvent): void;
  122329. /**
  122330. * Remove all events found at the given frame
  122331. * @param frame The frame to remove events from
  122332. */
  122333. removeEvents(frame: number): void;
  122334. /**
  122335. * Retrieves all the events from the animation
  122336. * @returns Events from the animation
  122337. */
  122338. getEvents(): AnimationEvent[];
  122339. /**
  122340. * Creates an animation range
  122341. * @param name Name of the animation range
  122342. * @param from Starting frame of the animation range
  122343. * @param to Ending frame of the animation
  122344. */
  122345. createRange(name: string, from: number, to: number): void;
  122346. /**
  122347. * Deletes an animation range by name
  122348. * @param name Name of the animation range to delete
  122349. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  122350. */
  122351. deleteRange(name: string, deleteFrames?: boolean): void;
  122352. /**
  122353. * Gets the animation range by name, or null if not defined
  122354. * @param name Name of the animation range
  122355. * @returns Nullable animation range
  122356. */
  122357. getRange(name: string): Nullable<AnimationRange>;
  122358. /**
  122359. * Gets the key frames from the animation
  122360. * @returns The key frames of the animation
  122361. */
  122362. getKeys(): Array<IAnimationKey>;
  122363. /**
  122364. * Gets the highest frame rate of the animation
  122365. * @returns Highest frame rate of the animation
  122366. */
  122367. getHighestFrame(): number;
  122368. /**
  122369. * Gets the easing function of the animation
  122370. * @returns Easing function of the animation
  122371. */
  122372. getEasingFunction(): IEasingFunction;
  122373. /**
  122374. * Sets the easing function of the animation
  122375. * @param easingFunction A custom mathematical formula for animation
  122376. */
  122377. setEasingFunction(easingFunction: EasingFunction): void;
  122378. /**
  122379. * Interpolates a scalar linearly
  122380. * @param startValue Start value of the animation curve
  122381. * @param endValue End value of the animation curve
  122382. * @param gradient Scalar amount to interpolate
  122383. * @returns Interpolated scalar value
  122384. */
  122385. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  122386. /**
  122387. * Interpolates a scalar cubically
  122388. * @param startValue Start value of the animation curve
  122389. * @param outTangent End tangent of the animation
  122390. * @param endValue End value of the animation curve
  122391. * @param inTangent Start tangent of the animation curve
  122392. * @param gradient Scalar amount to interpolate
  122393. * @returns Interpolated scalar value
  122394. */
  122395. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  122396. /**
  122397. * Interpolates a quaternion using a spherical linear interpolation
  122398. * @param startValue Start value of the animation curve
  122399. * @param endValue End value of the animation curve
  122400. * @param gradient Scalar amount to interpolate
  122401. * @returns Interpolated quaternion value
  122402. */
  122403. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  122404. /**
  122405. * Interpolates a quaternion cubically
  122406. * @param startValue Start value of the animation curve
  122407. * @param outTangent End tangent of the animation curve
  122408. * @param endValue End value of the animation curve
  122409. * @param inTangent Start tangent of the animation curve
  122410. * @param gradient Scalar amount to interpolate
  122411. * @returns Interpolated quaternion value
  122412. */
  122413. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  122414. /**
  122415. * Interpolates a Vector3 linearl
  122416. * @param startValue Start value of the animation curve
  122417. * @param endValue End value of the animation curve
  122418. * @param gradient Scalar amount to interpolate
  122419. * @returns Interpolated scalar value
  122420. */
  122421. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  122422. /**
  122423. * Interpolates a Vector3 cubically
  122424. * @param startValue Start value of the animation curve
  122425. * @param outTangent End tangent of the animation
  122426. * @param endValue End value of the animation curve
  122427. * @param inTangent Start tangent of the animation curve
  122428. * @param gradient Scalar amount to interpolate
  122429. * @returns InterpolatedVector3 value
  122430. */
  122431. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  122432. /**
  122433. * Interpolates a Vector2 linearly
  122434. * @param startValue Start value of the animation curve
  122435. * @param endValue End value of the animation curve
  122436. * @param gradient Scalar amount to interpolate
  122437. * @returns Interpolated Vector2 value
  122438. */
  122439. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  122440. /**
  122441. * Interpolates a Vector2 cubically
  122442. * @param startValue Start value of the animation curve
  122443. * @param outTangent End tangent of the animation
  122444. * @param endValue End value of the animation curve
  122445. * @param inTangent Start tangent of the animation curve
  122446. * @param gradient Scalar amount to interpolate
  122447. * @returns Interpolated Vector2 value
  122448. */
  122449. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  122450. /**
  122451. * Interpolates a size linearly
  122452. * @param startValue Start value of the animation curve
  122453. * @param endValue End value of the animation curve
  122454. * @param gradient Scalar amount to interpolate
  122455. * @returns Interpolated Size value
  122456. */
  122457. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  122458. /**
  122459. * Interpolates a Color3 linearly
  122460. * @param startValue Start value of the animation curve
  122461. * @param endValue End value of the animation curve
  122462. * @param gradient Scalar amount to interpolate
  122463. * @returns Interpolated Color3 value
  122464. */
  122465. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  122466. /**
  122467. * Interpolates a Color4 linearly
  122468. * @param startValue Start value of the animation curve
  122469. * @param endValue End value of the animation curve
  122470. * @param gradient Scalar amount to interpolate
  122471. * @returns Interpolated Color3 value
  122472. */
  122473. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  122474. /**
  122475. * @hidden Internal use only
  122476. */
  122477. _getKeyValue(value: any): any;
  122478. /**
  122479. * @hidden Internal use only
  122480. */
  122481. _interpolate(currentFrame: number, state: _IAnimationState): any;
  122482. /**
  122483. * Defines the function to use to interpolate matrices
  122484. * @param startValue defines the start matrix
  122485. * @param endValue defines the end matrix
  122486. * @param gradient defines the gradient between both matrices
  122487. * @param result defines an optional target matrix where to store the interpolation
  122488. * @returns the interpolated matrix
  122489. */
  122490. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  122491. /**
  122492. * Makes a copy of the animation
  122493. * @returns Cloned animation
  122494. */
  122495. clone(): Animation;
  122496. /**
  122497. * Sets the key frames of the animation
  122498. * @param values The animation key frames to set
  122499. */
  122500. setKeys(values: Array<IAnimationKey>): void;
  122501. /**
  122502. * Serializes the animation to an object
  122503. * @returns Serialized object
  122504. */
  122505. serialize(): any;
  122506. /**
  122507. * Float animation type
  122508. */
  122509. static readonly ANIMATIONTYPE_FLOAT: number;
  122510. /**
  122511. * Vector3 animation type
  122512. */
  122513. static readonly ANIMATIONTYPE_VECTOR3: number;
  122514. /**
  122515. * Quaternion animation type
  122516. */
  122517. static readonly ANIMATIONTYPE_QUATERNION: number;
  122518. /**
  122519. * Matrix animation type
  122520. */
  122521. static readonly ANIMATIONTYPE_MATRIX: number;
  122522. /**
  122523. * Color3 animation type
  122524. */
  122525. static readonly ANIMATIONTYPE_COLOR3: number;
  122526. /**
  122527. * Color3 animation type
  122528. */
  122529. static readonly ANIMATIONTYPE_COLOR4: number;
  122530. /**
  122531. * Vector2 animation type
  122532. */
  122533. static readonly ANIMATIONTYPE_VECTOR2: number;
  122534. /**
  122535. * Size animation type
  122536. */
  122537. static readonly ANIMATIONTYPE_SIZE: number;
  122538. /**
  122539. * Relative Loop Mode
  122540. */
  122541. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  122542. /**
  122543. * Cycle Loop Mode
  122544. */
  122545. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  122546. /**
  122547. * Constant Loop Mode
  122548. */
  122549. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  122550. /** @hidden */
  122551. static _UniversalLerp(left: any, right: any, amount: number): any;
  122552. /**
  122553. * Parses an animation object and creates an animation
  122554. * @param parsedAnimation Parsed animation object
  122555. * @returns Animation object
  122556. */
  122557. static Parse(parsedAnimation: any): Animation;
  122558. /**
  122559. * Appends the serialized animations from the source animations
  122560. * @param source Source containing the animations
  122561. * @param destination Target to store the animations
  122562. */
  122563. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122564. /**
  122565. * Creates a new animation or an array of animations from a snippet saved in a remote file
  122566. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  122567. * @param url defines the url to load from
  122568. * @returns a promise that will resolve to the new animation or an array of animations
  122569. */
  122570. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  122571. /**
  122572. * Creates an animation or an array of animations from a snippet saved by the Inspector
  122573. * @param snippetId defines the snippet to load
  122574. * @returns a promise that will resolve to the new animation or a new array of animations
  122575. */
  122576. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  122577. }
  122578. }
  122579. declare module BABYLON {
  122580. /**
  122581. * Interface containing an array of animations
  122582. */
  122583. export interface IAnimatable {
  122584. /**
  122585. * Array of animations
  122586. */
  122587. animations: Nullable<Array<Animation>>;
  122588. }
  122589. }
  122590. declare module BABYLON {
  122591. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  122592. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122593. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122594. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122595. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122596. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122597. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122598. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122599. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122600. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122601. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122602. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122603. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122604. /**
  122605. * Decorator used to define property that can be serialized as reference to a camera
  122606. * @param sourceName defines the name of the property to decorate
  122607. */
  122608. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122609. /**
  122610. * Class used to help serialization objects
  122611. */
  122612. export class SerializationHelper {
  122613. /** @hidden */
  122614. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  122615. /** @hidden */
  122616. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  122617. /** @hidden */
  122618. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  122619. /** @hidden */
  122620. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  122621. /**
  122622. * Appends the serialized animations from the source animations
  122623. * @param source Source containing the animations
  122624. * @param destination Target to store the animations
  122625. */
  122626. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122627. /**
  122628. * Static function used to serialized a specific entity
  122629. * @param entity defines the entity to serialize
  122630. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  122631. * @returns a JSON compatible object representing the serialization of the entity
  122632. */
  122633. static Serialize<T>(entity: T, serializationObject?: any): any;
  122634. /**
  122635. * Creates a new entity from a serialization data object
  122636. * @param creationFunction defines a function used to instanciated the new entity
  122637. * @param source defines the source serialization data
  122638. * @param scene defines the hosting scene
  122639. * @param rootUrl defines the root url for resources
  122640. * @returns a new entity
  122641. */
  122642. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  122643. /**
  122644. * Clones an object
  122645. * @param creationFunction defines the function used to instanciate the new object
  122646. * @param source defines the source object
  122647. * @returns the cloned object
  122648. */
  122649. static Clone<T>(creationFunction: () => T, source: T): T;
  122650. /**
  122651. * Instanciates a new object based on a source one (some data will be shared between both object)
  122652. * @param creationFunction defines the function used to instanciate the new object
  122653. * @param source defines the source object
  122654. * @returns the new object
  122655. */
  122656. static Instanciate<T>(creationFunction: () => T, source: T): T;
  122657. }
  122658. }
  122659. declare module BABYLON {
  122660. /**
  122661. * This is the base class of all the camera used in the application.
  122662. * @see https://doc.babylonjs.com/features/cameras
  122663. */
  122664. export class Camera extends Node {
  122665. /** @hidden */
  122666. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  122667. /**
  122668. * This is the default projection mode used by the cameras.
  122669. * It helps recreating a feeling of perspective and better appreciate depth.
  122670. * This is the best way to simulate real life cameras.
  122671. */
  122672. static readonly PERSPECTIVE_CAMERA: number;
  122673. /**
  122674. * This helps creating camera with an orthographic mode.
  122675. * 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.
  122676. */
  122677. static readonly ORTHOGRAPHIC_CAMERA: number;
  122678. /**
  122679. * This is the default FOV mode for perspective cameras.
  122680. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  122681. */
  122682. static readonly FOVMODE_VERTICAL_FIXED: number;
  122683. /**
  122684. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  122685. */
  122686. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  122687. /**
  122688. * This specifies ther is no need for a camera rig.
  122689. * Basically only one eye is rendered corresponding to the camera.
  122690. */
  122691. static readonly RIG_MODE_NONE: number;
  122692. /**
  122693. * Simulates a camera Rig with one blue eye and one red eye.
  122694. * This can be use with 3d blue and red glasses.
  122695. */
  122696. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  122697. /**
  122698. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  122699. */
  122700. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  122701. /**
  122702. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  122703. */
  122704. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  122705. /**
  122706. * Defines that both eyes of the camera will be rendered over under each other.
  122707. */
  122708. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  122709. /**
  122710. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  122711. */
  122712. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  122713. /**
  122714. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  122715. */
  122716. static readonly RIG_MODE_VR: number;
  122717. /**
  122718. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  122719. */
  122720. static readonly RIG_MODE_WEBVR: number;
  122721. /**
  122722. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  122723. */
  122724. static readonly RIG_MODE_CUSTOM: number;
  122725. /**
  122726. * Defines if by default attaching controls should prevent the default javascript event to continue.
  122727. */
  122728. static ForceAttachControlToAlwaysPreventDefault: boolean;
  122729. /**
  122730. * Define the input manager associated with the camera.
  122731. */
  122732. inputs: CameraInputsManager<Camera>;
  122733. /** @hidden */
  122734. _position: Vector3;
  122735. /**
  122736. * Define the current local position of the camera in the scene
  122737. */
  122738. get position(): Vector3;
  122739. set position(newPosition: Vector3);
  122740. protected _upVector: Vector3;
  122741. /**
  122742. * The vector the camera should consider as up.
  122743. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  122744. */
  122745. set upVector(vec: Vector3);
  122746. get upVector(): Vector3;
  122747. /**
  122748. * Define the current limit on the left side for an orthographic camera
  122749. * In scene unit
  122750. */
  122751. orthoLeft: Nullable<number>;
  122752. /**
  122753. * Define the current limit on the right side for an orthographic camera
  122754. * In scene unit
  122755. */
  122756. orthoRight: Nullable<number>;
  122757. /**
  122758. * Define the current limit on the bottom side for an orthographic camera
  122759. * In scene unit
  122760. */
  122761. orthoBottom: Nullable<number>;
  122762. /**
  122763. * Define the current limit on the top side for an orthographic camera
  122764. * In scene unit
  122765. */
  122766. orthoTop: Nullable<number>;
  122767. /**
  122768. * Field Of View is set in Radians. (default is 0.8)
  122769. */
  122770. fov: number;
  122771. /**
  122772. * Define the minimum distance the camera can see from.
  122773. * This is important to note that the depth buffer are not infinite and the closer it starts
  122774. * the more your scene might encounter depth fighting issue.
  122775. */
  122776. minZ: number;
  122777. /**
  122778. * Define the maximum distance the camera can see to.
  122779. * This is important to note that the depth buffer are not infinite and the further it end
  122780. * the more your scene might encounter depth fighting issue.
  122781. */
  122782. maxZ: number;
  122783. /**
  122784. * Define the default inertia of the camera.
  122785. * This helps giving a smooth feeling to the camera movement.
  122786. */
  122787. inertia: number;
  122788. /**
  122789. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  122790. */
  122791. mode: number;
  122792. /**
  122793. * Define whether the camera is intermediate.
  122794. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  122795. */
  122796. isIntermediate: boolean;
  122797. /**
  122798. * Define the viewport of the camera.
  122799. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  122800. */
  122801. viewport: Viewport;
  122802. /**
  122803. * Restricts the camera to viewing objects with the same layerMask.
  122804. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  122805. */
  122806. layerMask: number;
  122807. /**
  122808. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  122809. */
  122810. fovMode: number;
  122811. /**
  122812. * Rig mode of the camera.
  122813. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  122814. * This is normally controlled byt the camera themselves as internal use.
  122815. */
  122816. cameraRigMode: number;
  122817. /**
  122818. * Defines the distance between both "eyes" in case of a RIG
  122819. */
  122820. interaxialDistance: number;
  122821. /**
  122822. * Defines if stereoscopic rendering is done side by side or over under.
  122823. */
  122824. isStereoscopicSideBySide: boolean;
  122825. /**
  122826. * 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
  122827. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  122828. * else in the scene. (Eg. security camera)
  122829. *
  122830. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  122831. */
  122832. customRenderTargets: RenderTargetTexture[];
  122833. /**
  122834. * When set, the camera will render to this render target instead of the default canvas
  122835. *
  122836. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  122837. */
  122838. outputRenderTarget: Nullable<RenderTargetTexture>;
  122839. /**
  122840. * Observable triggered when the camera view matrix has changed.
  122841. */
  122842. onViewMatrixChangedObservable: Observable<Camera>;
  122843. /**
  122844. * Observable triggered when the camera Projection matrix has changed.
  122845. */
  122846. onProjectionMatrixChangedObservable: Observable<Camera>;
  122847. /**
  122848. * Observable triggered when the inputs have been processed.
  122849. */
  122850. onAfterCheckInputsObservable: Observable<Camera>;
  122851. /**
  122852. * Observable triggered when reset has been called and applied to the camera.
  122853. */
  122854. onRestoreStateObservable: Observable<Camera>;
  122855. /**
  122856. * Is this camera a part of a rig system?
  122857. */
  122858. isRigCamera: boolean;
  122859. /**
  122860. * If isRigCamera set to true this will be set with the parent camera.
  122861. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  122862. */
  122863. rigParent?: Camera;
  122864. /** @hidden */
  122865. _cameraRigParams: any;
  122866. /** @hidden */
  122867. _rigCameras: Camera[];
  122868. /** @hidden */
  122869. _rigPostProcess: Nullable<PostProcess>;
  122870. protected _webvrViewMatrix: Matrix;
  122871. /** @hidden */
  122872. _skipRendering: boolean;
  122873. /** @hidden */
  122874. _projectionMatrix: Matrix;
  122875. /** @hidden */
  122876. _postProcesses: Nullable<PostProcess>[];
  122877. /** @hidden */
  122878. _activeMeshes: SmartArray<AbstractMesh>;
  122879. protected _globalPosition: Vector3;
  122880. /** @hidden */
  122881. _computedViewMatrix: Matrix;
  122882. private _doNotComputeProjectionMatrix;
  122883. private _transformMatrix;
  122884. private _frustumPlanes;
  122885. private _refreshFrustumPlanes;
  122886. private _storedFov;
  122887. private _stateStored;
  122888. /**
  122889. * Instantiates a new camera object.
  122890. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  122891. * @see https://doc.babylonjs.com/features/cameras
  122892. * @param name Defines the name of the camera in the scene
  122893. * @param position Defines the position of the camera
  122894. * @param scene Defines the scene the camera belongs too
  122895. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  122896. */
  122897. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122898. /**
  122899. * Store current camera state (fov, position, etc..)
  122900. * @returns the camera
  122901. */
  122902. storeState(): Camera;
  122903. /**
  122904. * Restores the camera state values if it has been stored. You must call storeState() first
  122905. */
  122906. protected _restoreStateValues(): boolean;
  122907. /**
  122908. * Restored camera state. You must call storeState() first.
  122909. * @returns true if restored and false otherwise
  122910. */
  122911. restoreState(): boolean;
  122912. /**
  122913. * Gets the class name of the camera.
  122914. * @returns the class name
  122915. */
  122916. getClassName(): string;
  122917. /** @hidden */
  122918. readonly _isCamera: boolean;
  122919. /**
  122920. * Gets a string representation of the camera useful for debug purpose.
  122921. * @param fullDetails Defines that a more verboe level of logging is required
  122922. * @returns the string representation
  122923. */
  122924. toString(fullDetails?: boolean): string;
  122925. /**
  122926. * Gets the current world space position of the camera.
  122927. */
  122928. get globalPosition(): Vector3;
  122929. /**
  122930. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  122931. * @returns the active meshe list
  122932. */
  122933. getActiveMeshes(): SmartArray<AbstractMesh>;
  122934. /**
  122935. * Check whether a mesh is part of the current active mesh list of the camera
  122936. * @param mesh Defines the mesh to check
  122937. * @returns true if active, false otherwise
  122938. */
  122939. isActiveMesh(mesh: Mesh): boolean;
  122940. /**
  122941. * Is this camera ready to be used/rendered
  122942. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  122943. * @return true if the camera is ready
  122944. */
  122945. isReady(completeCheck?: boolean): boolean;
  122946. /** @hidden */
  122947. _initCache(): void;
  122948. /** @hidden */
  122949. _updateCache(ignoreParentClass?: boolean): void;
  122950. /** @hidden */
  122951. _isSynchronized(): boolean;
  122952. /** @hidden */
  122953. _isSynchronizedViewMatrix(): boolean;
  122954. /** @hidden */
  122955. _isSynchronizedProjectionMatrix(): boolean;
  122956. /**
  122957. * Attach the input controls to a specific dom element to get the input from.
  122958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122959. */
  122960. attachControl(noPreventDefault?: boolean): void;
  122961. /**
  122962. * Attach the input controls to a specific dom element to get the input from.
  122963. * @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
  122964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122965. * BACK COMPAT SIGNATURE ONLY.
  122966. */
  122967. attachControl(ignored: any, noPreventDefault?: boolean): void;
  122968. /**
  122969. * Detach the current controls from the specified dom element.
  122970. */
  122971. detachControl(): void;
  122972. /**
  122973. * Detach the current controls from the specified dom element.
  122974. * @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
  122975. */
  122976. detachControl(ignored: any): void;
  122977. /**
  122978. * Update the camera state according to the different inputs gathered during the frame.
  122979. */
  122980. update(): void;
  122981. /** @hidden */
  122982. _checkInputs(): void;
  122983. /** @hidden */
  122984. get rigCameras(): Camera[];
  122985. /**
  122986. * Gets the post process used by the rig cameras
  122987. */
  122988. get rigPostProcess(): Nullable<PostProcess>;
  122989. /**
  122990. * Internal, gets the first post proces.
  122991. * @returns the first post process to be run on this camera.
  122992. */
  122993. _getFirstPostProcess(): Nullable<PostProcess>;
  122994. private _cascadePostProcessesToRigCams;
  122995. /**
  122996. * Attach a post process to the camera.
  122997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  122998. * @param postProcess The post process to attach to the camera
  122999. * @param insertAt The position of the post process in case several of them are in use in the scene
  123000. * @returns the position the post process has been inserted at
  123001. */
  123002. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  123003. /**
  123004. * Detach a post process to the camera.
  123005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  123006. * @param postProcess The post process to detach from the camera
  123007. */
  123008. detachPostProcess(postProcess: PostProcess): void;
  123009. /**
  123010. * Gets the current world matrix of the camera
  123011. */
  123012. getWorldMatrix(): Matrix;
  123013. /** @hidden */
  123014. _getViewMatrix(): Matrix;
  123015. /**
  123016. * Gets the current view matrix of the camera.
  123017. * @param force forces the camera to recompute the matrix without looking at the cached state
  123018. * @returns the view matrix
  123019. */
  123020. getViewMatrix(force?: boolean): Matrix;
  123021. /**
  123022. * Freeze the projection matrix.
  123023. * It will prevent the cache check of the camera projection compute and can speed up perf
  123024. * if no parameter of the camera are meant to change
  123025. * @param projection Defines manually a projection if necessary
  123026. */
  123027. freezeProjectionMatrix(projection?: Matrix): void;
  123028. /**
  123029. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  123030. */
  123031. unfreezeProjectionMatrix(): void;
  123032. /**
  123033. * Gets the current projection matrix of the camera.
  123034. * @param force forces the camera to recompute the matrix without looking at the cached state
  123035. * @returns the projection matrix
  123036. */
  123037. getProjectionMatrix(force?: boolean): Matrix;
  123038. /**
  123039. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  123040. * @returns a Matrix
  123041. */
  123042. getTransformationMatrix(): Matrix;
  123043. private _updateFrustumPlanes;
  123044. /**
  123045. * Checks if a cullable object (mesh...) is in the camera frustum
  123046. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  123047. * @param target The object to check
  123048. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  123049. * @returns true if the object is in frustum otherwise false
  123050. */
  123051. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  123052. /**
  123053. * Checks if a cullable object (mesh...) is in the camera frustum
  123054. * Unlike isInFrustum this cheks the full bounding box
  123055. * @param target The object to check
  123056. * @returns true if the object is in frustum otherwise false
  123057. */
  123058. isCompletelyInFrustum(target: ICullable): boolean;
  123059. /**
  123060. * Gets a ray in the forward direction from the camera.
  123061. * @param length Defines the length of the ray to create
  123062. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  123063. * @param origin Defines the start point of the ray which defaults to the camera position
  123064. * @returns the forward ray
  123065. */
  123066. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123067. /**
  123068. * Gets a ray in the forward direction from the camera.
  123069. * @param refRay the ray to (re)use when setting the values
  123070. * @param length Defines the length of the ray to create
  123071. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  123072. * @param origin Defines the start point of the ray which defaults to the camera position
  123073. * @returns the forward ray
  123074. */
  123075. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123076. /**
  123077. * Releases resources associated with this node.
  123078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123080. */
  123081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123082. /** @hidden */
  123083. _isLeftCamera: boolean;
  123084. /**
  123085. * Gets the left camera of a rig setup in case of Rigged Camera
  123086. */
  123087. get isLeftCamera(): boolean;
  123088. /** @hidden */
  123089. _isRightCamera: boolean;
  123090. /**
  123091. * Gets the right camera of a rig setup in case of Rigged Camera
  123092. */
  123093. get isRightCamera(): boolean;
  123094. /**
  123095. * Gets the left camera of a rig setup in case of Rigged Camera
  123096. */
  123097. get leftCamera(): Nullable<FreeCamera>;
  123098. /**
  123099. * Gets the right camera of a rig setup in case of Rigged Camera
  123100. */
  123101. get rightCamera(): Nullable<FreeCamera>;
  123102. /**
  123103. * Gets the left camera target of a rig setup in case of Rigged Camera
  123104. * @returns the target position
  123105. */
  123106. getLeftTarget(): Nullable<Vector3>;
  123107. /**
  123108. * Gets the right camera target of a rig setup in case of Rigged Camera
  123109. * @returns the target position
  123110. */
  123111. getRightTarget(): Nullable<Vector3>;
  123112. /**
  123113. * @hidden
  123114. */
  123115. setCameraRigMode(mode: number, rigParams: any): void;
  123116. /** @hidden */
  123117. static _setStereoscopicRigMode(camera: Camera): void;
  123118. /** @hidden */
  123119. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  123120. /** @hidden */
  123121. static _setVRRigMode(camera: Camera, rigParams: any): void;
  123122. /** @hidden */
  123123. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  123124. /** @hidden */
  123125. _getVRProjectionMatrix(): Matrix;
  123126. protected _updateCameraRotationMatrix(): void;
  123127. protected _updateWebVRCameraRotationMatrix(): void;
  123128. /**
  123129. * This function MUST be overwritten by the different WebVR cameras available.
  123130. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  123131. * @hidden
  123132. */
  123133. _getWebVRProjectionMatrix(): Matrix;
  123134. /**
  123135. * This function MUST be overwritten by the different WebVR cameras available.
  123136. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  123137. * @hidden
  123138. */
  123139. _getWebVRViewMatrix(): Matrix;
  123140. /** @hidden */
  123141. setCameraRigParameter(name: string, value: any): void;
  123142. /**
  123143. * needs to be overridden by children so sub has required properties to be copied
  123144. * @hidden
  123145. */
  123146. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  123147. /**
  123148. * May need to be overridden by children
  123149. * @hidden
  123150. */
  123151. _updateRigCameras(): void;
  123152. /** @hidden */
  123153. _setupInputs(): void;
  123154. /**
  123155. * Serialiaze the camera setup to a json represention
  123156. * @returns the JSON representation
  123157. */
  123158. serialize(): any;
  123159. /**
  123160. * Clones the current camera.
  123161. * @param name The cloned camera name
  123162. * @returns the cloned camera
  123163. */
  123164. clone(name: string): Camera;
  123165. /**
  123166. * Gets the direction of the camera relative to a given local axis.
  123167. * @param localAxis Defines the reference axis to provide a relative direction.
  123168. * @return the direction
  123169. */
  123170. getDirection(localAxis: Vector3): Vector3;
  123171. /**
  123172. * Returns the current camera absolute rotation
  123173. */
  123174. get absoluteRotation(): Quaternion;
  123175. /**
  123176. * Gets the direction of the camera relative to a given local axis into a passed vector.
  123177. * @param localAxis Defines the reference axis to provide a relative direction.
  123178. * @param result Defines the vector to store the result in
  123179. */
  123180. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  123181. /**
  123182. * Gets a camera constructor for a given camera type
  123183. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  123184. * @param name The name of the camera the result will be able to instantiate
  123185. * @param scene The scene the result will construct the camera in
  123186. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  123187. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  123188. * @returns a factory method to construc the camera
  123189. */
  123190. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  123191. /**
  123192. * Compute the world matrix of the camera.
  123193. * @returns the camera world matrix
  123194. */
  123195. computeWorldMatrix(): Matrix;
  123196. /**
  123197. * Parse a JSON and creates the camera from the parsed information
  123198. * @param parsedCamera The JSON to parse
  123199. * @param scene The scene to instantiate the camera in
  123200. * @returns the newly constructed camera
  123201. */
  123202. static Parse(parsedCamera: any, scene: Scene): Camera;
  123203. }
  123204. }
  123205. declare module BABYLON {
  123206. /**
  123207. * PostProcessManager is used to manage one or more post processes or post process pipelines
  123208. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123209. */
  123210. export class PostProcessManager {
  123211. private _scene;
  123212. private _indexBuffer;
  123213. private _vertexBuffers;
  123214. /**
  123215. * Creates a new instance PostProcess
  123216. * @param scene The scene that the post process is associated with.
  123217. */
  123218. constructor(scene: Scene);
  123219. private _prepareBuffers;
  123220. private _buildIndexBuffer;
  123221. /**
  123222. * Rebuilds the vertex buffers of the manager.
  123223. * @hidden
  123224. */
  123225. _rebuild(): void;
  123226. /**
  123227. * Prepares a frame to be run through a post process.
  123228. * @param sourceTexture The input texture to the post procesess. (default: null)
  123229. * @param postProcesses An array of post processes to be run. (default: null)
  123230. * @returns True if the post processes were able to be run.
  123231. * @hidden
  123232. */
  123233. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  123234. /**
  123235. * Manually render a set of post processes to a texture.
  123236. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  123237. * @param postProcesses An array of post processes to be run.
  123238. * @param targetTexture The target texture to render to.
  123239. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  123240. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  123241. * @param lodLevel defines which lod of the texture to render to
  123242. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  123243. */
  123244. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  123245. /**
  123246. * Finalize the result of the output of the postprocesses.
  123247. * @param doNotPresent If true the result will not be displayed to the screen.
  123248. * @param targetTexture The target texture to render to.
  123249. * @param faceIndex The index of the face to bind the target texture to.
  123250. * @param postProcesses The array of post processes to render.
  123251. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  123252. * @hidden
  123253. */
  123254. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  123255. /**
  123256. * Disposes of the post process manager.
  123257. */
  123258. dispose(): void;
  123259. }
  123260. }
  123261. declare module BABYLON {
  123262. /**
  123263. * This Helps creating a texture that will be created from a camera in your scene.
  123264. * It is basically a dynamic texture that could be used to create special effects for instance.
  123265. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  123266. */
  123267. export class RenderTargetTexture extends Texture {
  123268. /**
  123269. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  123270. */
  123271. static readonly REFRESHRATE_RENDER_ONCE: number;
  123272. /**
  123273. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  123274. */
  123275. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  123276. /**
  123277. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  123278. * the central point of your effect and can save a lot of performances.
  123279. */
  123280. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  123281. /**
  123282. * Use this predicate to dynamically define the list of mesh you want to render.
  123283. * If set, the renderList property will be overwritten.
  123284. */
  123285. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  123286. private _renderList;
  123287. /**
  123288. * Use this list to define the list of mesh you want to render.
  123289. */
  123290. get renderList(): Nullable<Array<AbstractMesh>>;
  123291. set renderList(value: Nullable<Array<AbstractMesh>>);
  123292. /**
  123293. * Use this function to overload the renderList array at rendering time.
  123294. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  123295. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  123296. * the cube (if the RTT is a cube, else layerOrFace=0).
  123297. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  123298. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  123299. * hold dummy elements!
  123300. */
  123301. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  123302. private _hookArray;
  123303. /**
  123304. * Define if particles should be rendered in your texture.
  123305. */
  123306. renderParticles: boolean;
  123307. /**
  123308. * Define if sprites should be rendered in your texture.
  123309. */
  123310. renderSprites: boolean;
  123311. /**
  123312. * Define the camera used to render the texture.
  123313. */
  123314. activeCamera: Nullable<Camera>;
  123315. /**
  123316. * Override the mesh isReady function with your own one.
  123317. */
  123318. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  123319. /**
  123320. * Override the render function of the texture with your own one.
  123321. */
  123322. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  123323. /**
  123324. * Define if camera post processes should be use while rendering the texture.
  123325. */
  123326. useCameraPostProcesses: boolean;
  123327. /**
  123328. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  123329. */
  123330. ignoreCameraViewport: boolean;
  123331. private _postProcessManager;
  123332. private _postProcesses;
  123333. private _resizeObserver;
  123334. /**
  123335. * An event triggered when the texture is unbind.
  123336. */
  123337. onBeforeBindObservable: Observable<RenderTargetTexture>;
  123338. /**
  123339. * An event triggered when the texture is unbind.
  123340. */
  123341. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  123342. private _onAfterUnbindObserver;
  123343. /**
  123344. * Set a after unbind callback in the texture.
  123345. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  123346. */
  123347. set onAfterUnbind(callback: () => void);
  123348. /**
  123349. * An event triggered before rendering the texture
  123350. */
  123351. onBeforeRenderObservable: Observable<number>;
  123352. private _onBeforeRenderObserver;
  123353. /**
  123354. * Set a before render callback in the texture.
  123355. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  123356. */
  123357. set onBeforeRender(callback: (faceIndex: number) => void);
  123358. /**
  123359. * An event triggered after rendering the texture
  123360. */
  123361. onAfterRenderObservable: Observable<number>;
  123362. private _onAfterRenderObserver;
  123363. /**
  123364. * Set a after render callback in the texture.
  123365. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  123366. */
  123367. set onAfterRender(callback: (faceIndex: number) => void);
  123368. /**
  123369. * An event triggered after the texture clear
  123370. */
  123371. onClearObservable: Observable<Engine>;
  123372. private _onClearObserver;
  123373. /**
  123374. * Set a clear callback in the texture.
  123375. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  123376. */
  123377. set onClear(callback: (Engine: Engine) => void);
  123378. /**
  123379. * An event triggered when the texture is resized.
  123380. */
  123381. onResizeObservable: Observable<RenderTargetTexture>;
  123382. /**
  123383. * Define the clear color of the Render Target if it should be different from the scene.
  123384. */
  123385. clearColor: Color4;
  123386. protected _size: number | {
  123387. width: number;
  123388. height: number;
  123389. layers?: number;
  123390. };
  123391. protected _initialSizeParameter: number | {
  123392. width: number;
  123393. height: number;
  123394. } | {
  123395. ratio: number;
  123396. };
  123397. protected _sizeRatio: Nullable<number>;
  123398. /** @hidden */
  123399. _generateMipMaps: boolean;
  123400. protected _renderingManager: RenderingManager;
  123401. /** @hidden */
  123402. _waitingRenderList?: string[];
  123403. protected _doNotChangeAspectRatio: boolean;
  123404. protected _currentRefreshId: number;
  123405. protected _refreshRate: number;
  123406. protected _textureMatrix: Matrix;
  123407. protected _samples: number;
  123408. protected _renderTargetOptions: RenderTargetCreationOptions;
  123409. /**
  123410. * Gets render target creation options that were used.
  123411. */
  123412. get renderTargetOptions(): RenderTargetCreationOptions;
  123413. protected _onRatioRescale(): void;
  123414. /**
  123415. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  123416. * It must define where the camera used to render the texture is set
  123417. */
  123418. boundingBoxPosition: Vector3;
  123419. private _boundingBoxSize;
  123420. /**
  123421. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  123422. * When defined, the cubemap will switch to local mode
  123423. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123424. * @example https://www.babylonjs-playground.com/#RNASML
  123425. */
  123426. set boundingBoxSize(value: Vector3);
  123427. get boundingBoxSize(): Vector3;
  123428. /**
  123429. * In case the RTT has been created with a depth texture, get the associated
  123430. * depth texture.
  123431. * Otherwise, return null.
  123432. */
  123433. get depthStencilTexture(): Nullable<InternalTexture>;
  123434. /**
  123435. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  123436. * or used a shadow, depth texture...
  123437. * @param name The friendly name of the texture
  123438. * @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)
  123439. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  123440. * @param generateMipMaps True if mip maps need to be generated after render.
  123441. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  123442. * @param type The type of the buffer in the RTT (int, half float, float...)
  123443. * @param isCube True if a cube texture needs to be created
  123444. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  123445. * @param generateDepthBuffer True to generate a depth buffer
  123446. * @param generateStencilBuffer True to generate a stencil buffer
  123447. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  123448. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  123449. * @param delayAllocation if the texture allocation should be delayed (default: false)
  123450. * @param samples sample count to use when creating the RTT
  123451. */
  123452. constructor(name: string, size: number | {
  123453. width: number;
  123454. height: number;
  123455. layers?: number;
  123456. } | {
  123457. ratio: number;
  123458. }, 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);
  123459. /**
  123460. * Creates a depth stencil texture.
  123461. * This is only available in WebGL 2 or with the depth texture extension available.
  123462. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  123463. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  123464. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  123465. * @param samples sample count of the depth/stencil texture
  123466. */
  123467. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  123468. private _processSizeParameter;
  123469. /**
  123470. * Define the number of samples to use in case of MSAA.
  123471. * It defaults to one meaning no MSAA has been enabled.
  123472. */
  123473. get samples(): number;
  123474. set samples(value: number);
  123475. /**
  123476. * Resets the refresh counter of the texture and start bak from scratch.
  123477. * Could be useful to regenerate the texture if it is setup to render only once.
  123478. */
  123479. resetRefreshCounter(): void;
  123480. /**
  123481. * Define the refresh rate of the texture or the rendering frequency.
  123482. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  123483. */
  123484. get refreshRate(): number;
  123485. set refreshRate(value: number);
  123486. /**
  123487. * Adds a post process to the render target rendering passes.
  123488. * @param postProcess define the post process to add
  123489. */
  123490. addPostProcess(postProcess: PostProcess): void;
  123491. /**
  123492. * Clear all the post processes attached to the render target
  123493. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  123494. */
  123495. clearPostProcesses(dispose?: boolean): void;
  123496. /**
  123497. * Remove one of the post process from the list of attached post processes to the texture
  123498. * @param postProcess define the post process to remove from the list
  123499. */
  123500. removePostProcess(postProcess: PostProcess): void;
  123501. /** @hidden */
  123502. _shouldRender(): boolean;
  123503. /**
  123504. * Gets the actual render size of the texture.
  123505. * @returns the width of the render size
  123506. */
  123507. getRenderSize(): number;
  123508. /**
  123509. * Gets the actual render width of the texture.
  123510. * @returns the width of the render size
  123511. */
  123512. getRenderWidth(): number;
  123513. /**
  123514. * Gets the actual render height of the texture.
  123515. * @returns the height of the render size
  123516. */
  123517. getRenderHeight(): number;
  123518. /**
  123519. * Gets the actual number of layers of the texture.
  123520. * @returns the number of layers
  123521. */
  123522. getRenderLayers(): number;
  123523. /**
  123524. * Get if the texture can be rescaled or not.
  123525. */
  123526. get canRescale(): boolean;
  123527. /**
  123528. * Resize the texture using a ratio.
  123529. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  123530. */
  123531. scale(ratio: number): void;
  123532. /**
  123533. * Get the texture reflection matrix used to rotate/transform the reflection.
  123534. * @returns the reflection matrix
  123535. */
  123536. getReflectionTextureMatrix(): Matrix;
  123537. /**
  123538. * Resize the texture to a new desired size.
  123539. * Be carrefull as it will recreate all the data in the new texture.
  123540. * @param size Define the new size. It can be:
  123541. * - a number for squared texture,
  123542. * - an object containing { width: number, height: number }
  123543. * - or an object containing a ratio { ratio: number }
  123544. */
  123545. resize(size: number | {
  123546. width: number;
  123547. height: number;
  123548. } | {
  123549. ratio: number;
  123550. }): void;
  123551. private _defaultRenderListPrepared;
  123552. /**
  123553. * Renders all the objects from the render list into the texture.
  123554. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  123555. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  123556. */
  123557. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  123558. private _bestReflectionRenderTargetDimension;
  123559. private _prepareRenderingManager;
  123560. /**
  123561. * @hidden
  123562. * @param faceIndex face index to bind to if this is a cubetexture
  123563. * @param layer defines the index of the texture to bind in the array
  123564. */
  123565. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  123566. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123567. private renderToTarget;
  123568. /**
  123569. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123570. * This allowed control for front to back rendering or reversly depending of the special needs.
  123571. *
  123572. * @param renderingGroupId The rendering group id corresponding to its index
  123573. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123574. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123575. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123576. */
  123577. 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;
  123578. /**
  123579. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123580. *
  123581. * @param renderingGroupId The rendering group id corresponding to its index
  123582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123583. */
  123584. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  123585. /**
  123586. * Clones the texture.
  123587. * @returns the cloned texture
  123588. */
  123589. clone(): RenderTargetTexture;
  123590. /**
  123591. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  123592. * @returns The JSON representation of the texture
  123593. */
  123594. serialize(): any;
  123595. /**
  123596. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  123597. */
  123598. disposeFramebufferObjects(): void;
  123599. /**
  123600. * Dispose the texture and release its associated resources.
  123601. */
  123602. dispose(): void;
  123603. /** @hidden */
  123604. _rebuild(): void;
  123605. /**
  123606. * Clear the info related to rendering groups preventing retention point in material dispose.
  123607. */
  123608. freeRenderingGroups(): void;
  123609. /**
  123610. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  123611. * @returns the view count
  123612. */
  123613. getViewCount(): number;
  123614. }
  123615. }
  123616. declare module BABYLON {
  123617. /**
  123618. * Options to be used when creating an effect.
  123619. */
  123620. export interface IEffectCreationOptions {
  123621. /**
  123622. * Atrributes that will be used in the shader.
  123623. */
  123624. attributes: string[];
  123625. /**
  123626. * Uniform varible names that will be set in the shader.
  123627. */
  123628. uniformsNames: string[];
  123629. /**
  123630. * Uniform buffer variable names that will be set in the shader.
  123631. */
  123632. uniformBuffersNames: string[];
  123633. /**
  123634. * Sampler texture variable names that will be set in the shader.
  123635. */
  123636. samplers: string[];
  123637. /**
  123638. * Define statements that will be set in the shader.
  123639. */
  123640. defines: any;
  123641. /**
  123642. * Possible fallbacks for this effect to improve performance when needed.
  123643. */
  123644. fallbacks: Nullable<IEffectFallbacks>;
  123645. /**
  123646. * Callback that will be called when the shader is compiled.
  123647. */
  123648. onCompiled: Nullable<(effect: Effect) => void>;
  123649. /**
  123650. * Callback that will be called if an error occurs during shader compilation.
  123651. */
  123652. onError: Nullable<(effect: Effect, errors: string) => void>;
  123653. /**
  123654. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123655. */
  123656. indexParameters?: any;
  123657. /**
  123658. * Max number of lights that can be used in the shader.
  123659. */
  123660. maxSimultaneousLights?: number;
  123661. /**
  123662. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  123663. */
  123664. transformFeedbackVaryings?: Nullable<string[]>;
  123665. /**
  123666. * 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
  123667. */
  123668. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  123669. /**
  123670. * Is this effect rendering to several color attachments ?
  123671. */
  123672. multiTarget?: boolean;
  123673. }
  123674. /**
  123675. * Effect containing vertex and fragment shader that can be executed on an object.
  123676. */
  123677. export class Effect implements IDisposable {
  123678. /**
  123679. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  123680. */
  123681. static ShadersRepository: string;
  123682. /**
  123683. * Enable logging of the shader code when a compilation error occurs
  123684. */
  123685. static LogShaderCodeOnCompilationError: boolean;
  123686. /**
  123687. * Name of the effect.
  123688. */
  123689. name: any;
  123690. /**
  123691. * String container all the define statements that should be set on the shader.
  123692. */
  123693. defines: string;
  123694. /**
  123695. * Callback that will be called when the shader is compiled.
  123696. */
  123697. onCompiled: Nullable<(effect: Effect) => void>;
  123698. /**
  123699. * Callback that will be called if an error occurs during shader compilation.
  123700. */
  123701. onError: Nullable<(effect: Effect, errors: string) => void>;
  123702. /**
  123703. * Callback that will be called when effect is bound.
  123704. */
  123705. onBind: Nullable<(effect: Effect) => void>;
  123706. /**
  123707. * Unique ID of the effect.
  123708. */
  123709. uniqueId: number;
  123710. /**
  123711. * Observable that will be called when the shader is compiled.
  123712. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  123713. */
  123714. onCompileObservable: Observable<Effect>;
  123715. /**
  123716. * Observable that will be called if an error occurs during shader compilation.
  123717. */
  123718. onErrorObservable: Observable<Effect>;
  123719. /** @hidden */
  123720. _onBindObservable: Nullable<Observable<Effect>>;
  123721. /**
  123722. * @hidden
  123723. * Specifies if the effect was previously ready
  123724. */
  123725. _wasPreviouslyReady: boolean;
  123726. /**
  123727. * Observable that will be called when effect is bound.
  123728. */
  123729. get onBindObservable(): Observable<Effect>;
  123730. /** @hidden */
  123731. _bonesComputationForcedToCPU: boolean;
  123732. /** @hidden */
  123733. _uniformBuffersNames: {
  123734. [key: string]: number;
  123735. };
  123736. /** @hidden */
  123737. _samplerList: string[];
  123738. /** @hidden */
  123739. _multiTarget: boolean;
  123740. private static _uniqueIdSeed;
  123741. private _engine;
  123742. private _uniformBuffersNamesList;
  123743. private _uniformsNames;
  123744. private _samplers;
  123745. private _isReady;
  123746. private _compilationError;
  123747. private _allFallbacksProcessed;
  123748. private _attributesNames;
  123749. private _attributes;
  123750. private _attributeLocationByName;
  123751. private _uniforms;
  123752. /**
  123753. * Key for the effect.
  123754. * @hidden
  123755. */
  123756. _key: string;
  123757. private _indexParameters;
  123758. private _fallbacks;
  123759. private _vertexSourceCodeOverride;
  123760. private _fragmentSourceCodeOverride;
  123761. private _transformFeedbackVaryings;
  123762. /**
  123763. * Compiled shader to webGL program.
  123764. * @hidden
  123765. */
  123766. _pipelineContext: Nullable<IPipelineContext>;
  123767. /** @hidden */
  123768. _vertexSourceCode: string;
  123769. /** @hidden */
  123770. _fragmentSourceCode: string;
  123771. /** @hidden */
  123772. private _rawVertexSourceCode;
  123773. /** @hidden */
  123774. private _rawFragmentSourceCode;
  123775. private static _baseCache;
  123776. private _processingContext;
  123777. /**
  123778. * Instantiates an effect.
  123779. * An effect can be used to create/manage/execute vertex and fragment shaders.
  123780. * @param baseName Name of the effect.
  123781. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  123782. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  123783. * @param samplers List of sampler variables that will be passed to the shader.
  123784. * @param engine Engine to be used to render the effect
  123785. * @param defines Define statements to be added to the shader.
  123786. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  123787. * @param onCompiled Callback that will be called when the shader is compiled.
  123788. * @param onError Callback that will be called if an error occurs during shader compilation.
  123789. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123790. * @param key Effect Key identifying uniquely compiled shader variants
  123791. */
  123792. 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);
  123793. private _useFinalCode;
  123794. /**
  123795. * Unique key for this effect
  123796. */
  123797. get key(): string;
  123798. /**
  123799. * If the effect has been compiled and prepared.
  123800. * @returns if the effect is compiled and prepared.
  123801. */
  123802. isReady(): boolean;
  123803. private _isReadyInternal;
  123804. /**
  123805. * The engine the effect was initialized with.
  123806. * @returns the engine.
  123807. */
  123808. getEngine(): Engine;
  123809. /**
  123810. * The pipeline context for this effect
  123811. * @returns the associated pipeline context
  123812. */
  123813. getPipelineContext(): Nullable<IPipelineContext>;
  123814. /**
  123815. * The set of names of attribute variables for the shader.
  123816. * @returns An array of attribute names.
  123817. */
  123818. getAttributesNames(): string[];
  123819. /**
  123820. * Returns the attribute at the given index.
  123821. * @param index The index of the attribute.
  123822. * @returns The location of the attribute.
  123823. */
  123824. getAttributeLocation(index: number): number;
  123825. /**
  123826. * Returns the attribute based on the name of the variable.
  123827. * @param name of the attribute to look up.
  123828. * @returns the attribute location.
  123829. */
  123830. getAttributeLocationByName(name: string): number;
  123831. /**
  123832. * The number of attributes.
  123833. * @returns the numnber of attributes.
  123834. */
  123835. getAttributesCount(): number;
  123836. /**
  123837. * Gets the index of a uniform variable.
  123838. * @param uniformName of the uniform to look up.
  123839. * @returns the index.
  123840. */
  123841. getUniformIndex(uniformName: string): number;
  123842. /**
  123843. * Returns the attribute based on the name of the variable.
  123844. * @param uniformName of the uniform to look up.
  123845. * @returns the location of the uniform.
  123846. */
  123847. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  123848. /**
  123849. * Returns an array of sampler variable names
  123850. * @returns The array of sampler variable names.
  123851. */
  123852. getSamplers(): string[];
  123853. /**
  123854. * Returns an array of uniform variable names
  123855. * @returns The array of uniform variable names.
  123856. */
  123857. getUniformNames(): string[];
  123858. /**
  123859. * Returns an array of uniform buffer variable names
  123860. * @returns The array of uniform buffer variable names.
  123861. */
  123862. getUniformBuffersNames(): string[];
  123863. /**
  123864. * Returns the index parameters used to create the effect
  123865. * @returns The index parameters object
  123866. */
  123867. getIndexParameters(): any;
  123868. /**
  123869. * The error from the last compilation.
  123870. * @returns the error string.
  123871. */
  123872. getCompilationError(): string;
  123873. /**
  123874. * Gets a boolean indicating that all fallbacks were used during compilation
  123875. * @returns true if all fallbacks were used
  123876. */
  123877. allFallbacksProcessed(): boolean;
  123878. /**
  123879. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  123880. * @param func The callback to be used.
  123881. */
  123882. executeWhenCompiled(func: (effect: Effect) => void): void;
  123883. private _checkIsReady;
  123884. private _loadShader;
  123885. /**
  123886. * Gets the vertex shader source code of this effect
  123887. */
  123888. get vertexSourceCode(): string;
  123889. /**
  123890. * Gets the fragment shader source code of this effect
  123891. */
  123892. get fragmentSourceCode(): string;
  123893. /**
  123894. * Gets the vertex shader source code before it has been processed by the preprocessor
  123895. */
  123896. get rawVertexSourceCode(): string;
  123897. /**
  123898. * Gets the fragment shader source code before it has been processed by the preprocessor
  123899. */
  123900. get rawFragmentSourceCode(): string;
  123901. /**
  123902. * Recompiles the webGL program
  123903. * @param vertexSourceCode The source code for the vertex shader.
  123904. * @param fragmentSourceCode The source code for the fragment shader.
  123905. * @param onCompiled Callback called when completed.
  123906. * @param onError Callback called on error.
  123907. * @hidden
  123908. */
  123909. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  123910. /**
  123911. * Prepares the effect
  123912. * @hidden
  123913. */
  123914. _prepareEffect(): void;
  123915. private _getShaderCodeAndErrorLine;
  123916. private _processCompilationErrors;
  123917. /**
  123918. * Checks if the effect is supported. (Must be called after compilation)
  123919. */
  123920. get isSupported(): boolean;
  123921. /**
  123922. * Binds a texture to the engine to be used as output of the shader.
  123923. * @param channel Name of the output variable.
  123924. * @param texture Texture to bind.
  123925. * @hidden
  123926. */
  123927. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  123928. /**
  123929. * Sets a texture on the engine to be used in the shader.
  123930. * @param channel Name of the sampler variable.
  123931. * @param texture Texture to set.
  123932. */
  123933. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  123934. /**
  123935. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  123936. * @param channel Name of the sampler variable.
  123937. * @param texture Texture to set.
  123938. */
  123939. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  123940. /**
  123941. * Sets an array of textures on the engine to be used in the shader.
  123942. * @param channel Name of the variable.
  123943. * @param textures Textures to set.
  123944. */
  123945. setTextureArray(channel: string, textures: ThinTexture[]): void;
  123946. /**
  123947. * 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)
  123948. * @param channel Name of the sampler variable.
  123949. * @param postProcess Post process to get the input texture from.
  123950. */
  123951. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  123952. /**
  123953. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  123954. * 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)
  123955. * @param channel Name of the sampler variable.
  123956. * @param postProcess Post process to get the output texture from.
  123957. */
  123958. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  123959. /**
  123960. * Binds a buffer to a uniform.
  123961. * @param buffer Buffer to bind.
  123962. * @param name Name of the uniform variable to bind to.
  123963. */
  123964. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  123965. /**
  123966. * Binds block to a uniform.
  123967. * @param blockName Name of the block to bind.
  123968. * @param index Index to bind.
  123969. */
  123970. bindUniformBlock(blockName: string, index: number): void;
  123971. /**
  123972. * Sets an interger value on a uniform variable.
  123973. * @param uniformName Name of the variable.
  123974. * @param value Value to be set.
  123975. * @returns this effect.
  123976. */
  123977. setInt(uniformName: string, value: number): Effect;
  123978. /**
  123979. * Sets an int2 value on a uniform variable.
  123980. * @param uniformName Name of the variable.
  123981. * @param x First int in int2.
  123982. * @param y Second int in int2.
  123983. * @returns this effect.
  123984. */
  123985. setInt2(uniformName: string, x: number, y: number): Effect;
  123986. /**
  123987. * Sets an int3 value on a uniform variable.
  123988. * @param uniformName Name of the variable.
  123989. * @param x First int in int3.
  123990. * @param y Second int in int3.
  123991. * @param z Third int in int3.
  123992. * @returns this effect.
  123993. */
  123994. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  123995. /**
  123996. * Sets an int4 value on a uniform variable.
  123997. * @param uniformName Name of the variable.
  123998. * @param x First int in int4.
  123999. * @param y Second int in int4.
  124000. * @param z Third int in int4.
  124001. * @param w Fourth int in int4.
  124002. * @returns this effect.
  124003. */
  124004. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  124005. /**
  124006. * Sets an int array on a uniform variable.
  124007. * @param uniformName Name of the variable.
  124008. * @param array array to be set.
  124009. * @returns this effect.
  124010. */
  124011. setIntArray(uniformName: string, array: Int32Array): Effect;
  124012. /**
  124013. * 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)
  124014. * @param uniformName Name of the variable.
  124015. * @param array array to be set.
  124016. * @returns this effect.
  124017. */
  124018. setIntArray2(uniformName: string, array: Int32Array): Effect;
  124019. /**
  124020. * 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)
  124021. * @param uniformName Name of the variable.
  124022. * @param array array to be set.
  124023. * @returns this effect.
  124024. */
  124025. setIntArray3(uniformName: string, array: Int32Array): Effect;
  124026. /**
  124027. * 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)
  124028. * @param uniformName Name of the variable.
  124029. * @param array array to be set.
  124030. * @returns this effect.
  124031. */
  124032. setIntArray4(uniformName: string, array: Int32Array): Effect;
  124033. /**
  124034. * Sets an float array on a uniform variable.
  124035. * @param uniformName Name of the variable.
  124036. * @param array array to be set.
  124037. * @returns this effect.
  124038. */
  124039. setFloatArray(uniformName: string, array: FloatArray): Effect;
  124040. /**
  124041. * 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)
  124042. * @param uniformName Name of the variable.
  124043. * @param array array to be set.
  124044. * @returns this effect.
  124045. */
  124046. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  124047. /**
  124048. * 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)
  124049. * @param uniformName Name of the variable.
  124050. * @param array array to be set.
  124051. * @returns this effect.
  124052. */
  124053. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  124054. /**
  124055. * 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)
  124056. * @param uniformName Name of the variable.
  124057. * @param array array to be set.
  124058. * @returns this effect.
  124059. */
  124060. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  124061. /**
  124062. * Sets an array on a uniform variable.
  124063. * @param uniformName Name of the variable.
  124064. * @param array array to be set.
  124065. * @returns this effect.
  124066. */
  124067. setArray(uniformName: string, array: number[]): Effect;
  124068. /**
  124069. * 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)
  124070. * @param uniformName Name of the variable.
  124071. * @param array array to be set.
  124072. * @returns this effect.
  124073. */
  124074. setArray2(uniformName: string, array: number[]): Effect;
  124075. /**
  124076. * 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)
  124077. * @param uniformName Name of the variable.
  124078. * @param array array to be set.
  124079. * @returns this effect.
  124080. */
  124081. setArray3(uniformName: string, array: number[]): Effect;
  124082. /**
  124083. * 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)
  124084. * @param uniformName Name of the variable.
  124085. * @param array array to be set.
  124086. * @returns this effect.
  124087. */
  124088. setArray4(uniformName: string, array: number[]): Effect;
  124089. /**
  124090. * Sets matrices on a uniform variable.
  124091. * @param uniformName Name of the variable.
  124092. * @param matrices matrices to be set.
  124093. * @returns this effect.
  124094. */
  124095. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  124096. /**
  124097. * Sets matrix on a uniform variable.
  124098. * @param uniformName Name of the variable.
  124099. * @param matrix matrix to be set.
  124100. * @returns this effect.
  124101. */
  124102. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  124103. /**
  124104. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  124105. * @param uniformName Name of the variable.
  124106. * @param matrix matrix to be set.
  124107. * @returns this effect.
  124108. */
  124109. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  124110. /**
  124111. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  124112. * @param uniformName Name of the variable.
  124113. * @param matrix matrix to be set.
  124114. * @returns this effect.
  124115. */
  124116. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  124117. /**
  124118. * Sets a float on a uniform variable.
  124119. * @param uniformName Name of the variable.
  124120. * @param value value to be set.
  124121. * @returns this effect.
  124122. */
  124123. setFloat(uniformName: string, value: number): Effect;
  124124. /**
  124125. * Sets a boolean on a uniform variable.
  124126. * @param uniformName Name of the variable.
  124127. * @param bool value to be set.
  124128. * @returns this effect.
  124129. */
  124130. setBool(uniformName: string, bool: boolean): Effect;
  124131. /**
  124132. * Sets a Vector2 on a uniform variable.
  124133. * @param uniformName Name of the variable.
  124134. * @param vector2 vector2 to be set.
  124135. * @returns this effect.
  124136. */
  124137. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  124138. /**
  124139. * Sets a float2 on a uniform variable.
  124140. * @param uniformName Name of the variable.
  124141. * @param x First float in float2.
  124142. * @param y Second float in float2.
  124143. * @returns this effect.
  124144. */
  124145. setFloat2(uniformName: string, x: number, y: number): Effect;
  124146. /**
  124147. * Sets a Vector3 on a uniform variable.
  124148. * @param uniformName Name of the variable.
  124149. * @param vector3 Value to be set.
  124150. * @returns this effect.
  124151. */
  124152. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  124153. /**
  124154. * Sets a float3 on a uniform variable.
  124155. * @param uniformName Name of the variable.
  124156. * @param x First float in float3.
  124157. * @param y Second float in float3.
  124158. * @param z Third float in float3.
  124159. * @returns this effect.
  124160. */
  124161. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  124162. /**
  124163. * Sets a Vector4 on a uniform variable.
  124164. * @param uniformName Name of the variable.
  124165. * @param vector4 Value to be set.
  124166. * @returns this effect.
  124167. */
  124168. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  124169. /**
  124170. * Sets a float4 on a uniform variable.
  124171. * @param uniformName Name of the variable.
  124172. * @param x First float in float4.
  124173. * @param y Second float in float4.
  124174. * @param z Third float in float4.
  124175. * @param w Fourth float in float4.
  124176. * @returns this effect.
  124177. */
  124178. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  124179. /**
  124180. * Sets a Color3 on a uniform variable.
  124181. * @param uniformName Name of the variable.
  124182. * @param color3 Value to be set.
  124183. * @returns this effect.
  124184. */
  124185. setColor3(uniformName: string, color3: IColor3Like): Effect;
  124186. /**
  124187. * Sets a Color4 on a uniform variable.
  124188. * @param uniformName Name of the variable.
  124189. * @param color3 Value to be set.
  124190. * @param alpha Alpha value to be set.
  124191. * @returns this effect.
  124192. */
  124193. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  124194. /**
  124195. * Sets a Color4 on a uniform variable
  124196. * @param uniformName defines the name of the variable
  124197. * @param color4 defines the value to be set
  124198. * @returns this effect.
  124199. */
  124200. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  124201. /**
  124202. * Release all associated resources.
  124203. **/
  124204. dispose(): void;
  124205. /**
  124206. * This function will add a new shader to the shader store
  124207. * @param name the name of the shader
  124208. * @param pixelShader optional pixel shader content
  124209. * @param vertexShader optional vertex shader content
  124210. */
  124211. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  124212. /**
  124213. * Store of each shader (The can be looked up using effect.key)
  124214. */
  124215. static ShadersStore: {
  124216. [key: string]: string;
  124217. };
  124218. /**
  124219. * Store of each included file for a shader (The can be looked up using effect.key)
  124220. */
  124221. static IncludesShadersStore: {
  124222. [key: string]: string;
  124223. };
  124224. /**
  124225. * Resets the cache of effects.
  124226. */
  124227. static ResetCache(): void;
  124228. }
  124229. }
  124230. declare module BABYLON {
  124231. /**
  124232. * Interface used to describe the capabilities of the engine relatively to the current browser
  124233. */
  124234. export interface EngineCapabilities {
  124235. /** Maximum textures units per fragment shader */
  124236. maxTexturesImageUnits: number;
  124237. /** Maximum texture units per vertex shader */
  124238. maxVertexTextureImageUnits: number;
  124239. /** Maximum textures units in the entire pipeline */
  124240. maxCombinedTexturesImageUnits: number;
  124241. /** Maximum texture size */
  124242. maxTextureSize: number;
  124243. /** Maximum texture samples */
  124244. maxSamples?: number;
  124245. /** Maximum cube texture size */
  124246. maxCubemapTextureSize: number;
  124247. /** Maximum render texture size */
  124248. maxRenderTextureSize: number;
  124249. /** Maximum number of vertex attributes */
  124250. maxVertexAttribs: number;
  124251. /** Maximum number of varyings */
  124252. maxVaryingVectors: number;
  124253. /** Maximum number of uniforms per vertex shader */
  124254. maxVertexUniformVectors: number;
  124255. /** Maximum number of uniforms per fragment shader */
  124256. maxFragmentUniformVectors: number;
  124257. /** Defines if standard derivates (dx/dy) are supported */
  124258. standardDerivatives: boolean;
  124259. /** Defines if s3tc texture compression is supported */
  124260. s3tc?: WEBGL_compressed_texture_s3tc;
  124261. /** Defines if pvrtc texture compression is supported */
  124262. pvrtc: any;
  124263. /** Defines if etc1 texture compression is supported */
  124264. etc1: any;
  124265. /** Defines if etc2 texture compression is supported */
  124266. etc2: any;
  124267. /** Defines if astc texture compression is supported */
  124268. astc: any;
  124269. /** Defines if bptc texture compression is supported */
  124270. bptc: any;
  124271. /** Defines if float textures are supported */
  124272. textureFloat: boolean;
  124273. /** Defines if vertex array objects are supported */
  124274. vertexArrayObject: boolean;
  124275. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  124276. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  124277. /** Gets the maximum level of anisotropy supported */
  124278. maxAnisotropy: number;
  124279. /** Defines if instancing is supported */
  124280. instancedArrays: boolean;
  124281. /** Defines if 32 bits indices are supported */
  124282. uintIndices: boolean;
  124283. /** Defines if high precision shaders are supported */
  124284. highPrecisionShaderSupported: boolean;
  124285. /** Defines if depth reading in the fragment shader is supported */
  124286. fragmentDepthSupported: boolean;
  124287. /** Defines if float texture linear filtering is supported*/
  124288. textureFloatLinearFiltering: boolean;
  124289. /** Defines if rendering to float textures is supported */
  124290. textureFloatRender: boolean;
  124291. /** Defines if half float textures are supported*/
  124292. textureHalfFloat: boolean;
  124293. /** Defines if half float texture linear filtering is supported*/
  124294. textureHalfFloatLinearFiltering: boolean;
  124295. /** Defines if rendering to half float textures is supported */
  124296. textureHalfFloatRender: boolean;
  124297. /** Defines if textureLOD shader command is supported */
  124298. textureLOD: boolean;
  124299. /** Defines if draw buffers extension is supported */
  124300. drawBuffersExtension: boolean;
  124301. /** Defines if depth textures are supported */
  124302. depthTextureExtension: boolean;
  124303. /** Defines if float color buffer are supported */
  124304. colorBufferFloat: boolean;
  124305. /** Gets disjoint timer query extension (null if not supported) */
  124306. timerQuery?: EXT_disjoint_timer_query;
  124307. /** Defines if timestamp can be used with timer query */
  124308. canUseTimestampForTimerQuery: boolean;
  124309. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  124310. multiview?: any;
  124311. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  124312. oculusMultiview?: any;
  124313. /** Function used to let the system compiles shaders in background */
  124314. parallelShaderCompile?: {
  124315. COMPLETION_STATUS_KHR: number;
  124316. };
  124317. /** Max number of texture samples for MSAA */
  124318. maxMSAASamples: number;
  124319. /** Defines if the blend min max extension is supported */
  124320. blendMinMax: boolean;
  124321. /** 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 */
  124322. canUseGLInstanceID: boolean;
  124323. }
  124324. }
  124325. declare module BABYLON {
  124326. /**
  124327. * @hidden
  124328. **/
  124329. export class DepthCullingState {
  124330. private _isDepthTestDirty;
  124331. private _isDepthMaskDirty;
  124332. private _isDepthFuncDirty;
  124333. private _isCullFaceDirty;
  124334. private _isCullDirty;
  124335. private _isZOffsetDirty;
  124336. private _isFrontFaceDirty;
  124337. private _depthTest;
  124338. private _depthMask;
  124339. private _depthFunc;
  124340. private _cull;
  124341. private _cullFace;
  124342. private _zOffset;
  124343. private _frontFace;
  124344. /**
  124345. * Initializes the state.
  124346. */
  124347. constructor();
  124348. get isDirty(): boolean;
  124349. get zOffset(): number;
  124350. set zOffset(value: number);
  124351. get cullFace(): Nullable<number>;
  124352. set cullFace(value: Nullable<number>);
  124353. get cull(): Nullable<boolean>;
  124354. set cull(value: Nullable<boolean>);
  124355. get depthFunc(): Nullable<number>;
  124356. set depthFunc(value: Nullable<number>);
  124357. get depthMask(): boolean;
  124358. set depthMask(value: boolean);
  124359. get depthTest(): boolean;
  124360. set depthTest(value: boolean);
  124361. get frontFace(): Nullable<number>;
  124362. set frontFace(value: Nullable<number>);
  124363. reset(): void;
  124364. apply(gl: WebGLRenderingContext): void;
  124365. }
  124366. }
  124367. declare module BABYLON {
  124368. /**
  124369. * @hidden
  124370. **/
  124371. export class StencilState {
  124372. /** 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 */
  124373. static readonly ALWAYS: number;
  124374. /** Passed to stencilOperation to specify that stencil value must be kept */
  124375. static readonly KEEP: number;
  124376. /** Passed to stencilOperation to specify that stencil value must be replaced */
  124377. static readonly REPLACE: number;
  124378. private _isStencilTestDirty;
  124379. private _isStencilMaskDirty;
  124380. private _isStencilFuncDirty;
  124381. private _isStencilOpDirty;
  124382. private _stencilTest;
  124383. private _stencilMask;
  124384. private _stencilFunc;
  124385. private _stencilFuncRef;
  124386. private _stencilFuncMask;
  124387. private _stencilOpStencilFail;
  124388. private _stencilOpDepthFail;
  124389. private _stencilOpStencilDepthPass;
  124390. get isDirty(): boolean;
  124391. get stencilFunc(): number;
  124392. set stencilFunc(value: number);
  124393. get stencilFuncRef(): number;
  124394. set stencilFuncRef(value: number);
  124395. get stencilFuncMask(): number;
  124396. set stencilFuncMask(value: number);
  124397. get stencilOpStencilFail(): number;
  124398. set stencilOpStencilFail(value: number);
  124399. get stencilOpDepthFail(): number;
  124400. set stencilOpDepthFail(value: number);
  124401. get stencilOpStencilDepthPass(): number;
  124402. set stencilOpStencilDepthPass(value: number);
  124403. get stencilMask(): number;
  124404. set stencilMask(value: number);
  124405. get stencilTest(): boolean;
  124406. set stencilTest(value: boolean);
  124407. constructor();
  124408. reset(): void;
  124409. apply(gl: WebGLRenderingContext): void;
  124410. }
  124411. }
  124412. declare module BABYLON {
  124413. /**
  124414. * @hidden
  124415. **/
  124416. export class AlphaState {
  124417. _blendFunctionParameters: Nullable<number>[];
  124418. _blendEquationParameters: Nullable<number>[];
  124419. _blendConstants: Nullable<number>[];
  124420. _isBlendConstantsDirty: boolean;
  124421. private _alphaBlend;
  124422. private _isAlphaBlendDirty;
  124423. private _isBlendFunctionParametersDirty;
  124424. private _isBlendEquationParametersDirty;
  124425. /**
  124426. * Initializes the state.
  124427. */
  124428. constructor();
  124429. get isDirty(): boolean;
  124430. get alphaBlend(): boolean;
  124431. set alphaBlend(value: boolean);
  124432. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  124433. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  124434. setAlphaEquationParameters(rgb: number, alpha: number): void;
  124435. reset(): void;
  124436. apply(gl: WebGLRenderingContext): void;
  124437. }
  124438. }
  124439. declare module BABYLON {
  124440. /** @hidden */
  124441. export class WebGLShaderProcessor implements IShaderProcessor {
  124442. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124443. }
  124444. }
  124445. declare module BABYLON {
  124446. /** @hidden */
  124447. export class WebGL2ShaderProcessor implements IShaderProcessor {
  124448. attributeProcessor(attribute: string): string;
  124449. varyingProcessor(varying: string, isFragment: boolean): string;
  124450. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124451. }
  124452. }
  124453. declare module BABYLON {
  124454. /**
  124455. * Interface for attribute information associated with buffer instanciation
  124456. */
  124457. export interface InstancingAttributeInfo {
  124458. /**
  124459. * Name of the GLSL attribute
  124460. * if attribute index is not specified, this is used to retrieve the index from the effect
  124461. */
  124462. attributeName: string;
  124463. /**
  124464. * Index/offset of the attribute in the vertex shader
  124465. * if not specified, this will be computes from the name.
  124466. */
  124467. index?: number;
  124468. /**
  124469. * size of the attribute, 1, 2, 3 or 4
  124470. */
  124471. attributeSize: number;
  124472. /**
  124473. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  124474. */
  124475. offset: number;
  124476. /**
  124477. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  124478. * default to 1
  124479. */
  124480. divisor?: number;
  124481. /**
  124482. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  124483. * default is FLOAT
  124484. */
  124485. attributeType?: number;
  124486. /**
  124487. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  124488. */
  124489. normalized?: boolean;
  124490. }
  124491. }
  124492. declare module BABYLON {
  124493. /** @hidden */
  124494. export interface EngineFeatures {
  124495. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  124496. forceBitmapOverHTMLImageElement: boolean;
  124497. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  124498. supportRenderAndCopyToLodForFloatTextures: boolean;
  124499. /** Indicates that the engine support handling depth/stencil textures */
  124500. supportDepthStencilTexture: boolean;
  124501. /** Indicates that the engine support shadow samplers */
  124502. supportShadowSamplers: boolean;
  124503. /** 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 */
  124504. uniformBufferHardCheckMatrix: boolean;
  124505. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  124506. allowTexturePrefiltering: boolean;
  124507. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  124508. trackUbosInFrame: boolean;
  124509. /** Indicates that the Cascaded Shadow Map technic is supported */
  124510. supportCSM: boolean;
  124511. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  124512. basisNeedsPOT: boolean;
  124513. /** Indicates that the engine supports 3D textures */
  124514. support3DTextures: boolean;
  124515. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  124516. needTypeSuffixInShaderConstants: boolean;
  124517. /** Indicates that MSAA is supported */
  124518. supportMSAA: boolean;
  124519. /** Indicates that SSAO2 is supported */
  124520. supportSSAO2: boolean;
  124521. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  124522. supportExtendedTextureFormats: boolean;
  124523. /** Indicates that the switch/case construct is supported in shaders */
  124524. supportSwitchCaseInShader: boolean;
  124525. /** @hidden */
  124526. _collectUbosUpdatedInFrame: boolean;
  124527. }
  124528. }
  124529. declare module BABYLON {
  124530. /** @hidden */
  124531. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  124532. private _webGLTexture;
  124533. private _context;
  124534. get underlyingResource(): Nullable<WebGLTexture>;
  124535. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  124536. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  124537. set(hardwareTexture: WebGLTexture): void;
  124538. reset(): void;
  124539. release(): void;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. interface ThinEngine {
  124544. /**
  124545. * Update a video texture
  124546. * @param texture defines the texture to update
  124547. * @param video defines the video element to use
  124548. * @param invertY defines if data must be stored with Y axis inverted
  124549. */
  124550. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  124551. }
  124552. }
  124553. declare module BABYLON {
  124554. interface ThinEngine {
  124555. /**
  124556. * Creates a dynamic texture
  124557. * @param width defines the width of the texture
  124558. * @param height defines the height of the texture
  124559. * @param generateMipMaps defines if the engine should generate the mip levels
  124560. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  124561. * @returns the dynamic texture inside an InternalTexture
  124562. */
  124563. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  124564. /**
  124565. * Update the content of a dynamic texture
  124566. * @param texture defines the texture to update
  124567. * @param source defines the source containing the data
  124568. * @param invertY defines if data must be stored with Y axis inverted
  124569. * @param premulAlpha defines if alpha is stored as premultiplied
  124570. * @param format defines the format of the data
  124571. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  124572. */
  124573. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. /**
  124578. * Settings for finer control over video usage
  124579. */
  124580. export interface VideoTextureSettings {
  124581. /**
  124582. * Applies `autoplay` to video, if specified
  124583. */
  124584. autoPlay?: boolean;
  124585. /**
  124586. * Applies `muted` to video, if specified
  124587. */
  124588. muted?: boolean;
  124589. /**
  124590. * Applies `loop` to video, if specified
  124591. */
  124592. loop?: boolean;
  124593. /**
  124594. * Automatically updates internal texture from video at every frame in the render loop
  124595. */
  124596. autoUpdateTexture: boolean;
  124597. /**
  124598. * Image src displayed during the video loading or until the user interacts with the video.
  124599. */
  124600. poster?: string;
  124601. }
  124602. /**
  124603. * If you want to display a video in your scene, this is the special texture for that.
  124604. * This special texture works similar to other textures, with the exception of a few parameters.
  124605. * @see https://doc.babylonjs.com/how_to/video_texture
  124606. */
  124607. export class VideoTexture extends Texture {
  124608. /**
  124609. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  124610. */
  124611. readonly autoUpdateTexture: boolean;
  124612. /**
  124613. * The video instance used by the texture internally
  124614. */
  124615. readonly video: HTMLVideoElement;
  124616. private _onUserActionRequestedObservable;
  124617. /**
  124618. * Event triggerd when a dom action is required by the user to play the video.
  124619. * This happens due to recent changes in browser policies preventing video to auto start.
  124620. */
  124621. get onUserActionRequestedObservable(): Observable<Texture>;
  124622. private _generateMipMaps;
  124623. private _stillImageCaptured;
  124624. private _displayingPosterTexture;
  124625. private _settings;
  124626. private _createInternalTextureOnEvent;
  124627. private _frameId;
  124628. private _currentSrc;
  124629. /**
  124630. * Creates a video texture.
  124631. * If you want to display a video in your scene, this is the special texture for that.
  124632. * This special texture works similar to other textures, with the exception of a few parameters.
  124633. * @see https://doc.babylonjs.com/how_to/video_texture
  124634. * @param name optional name, will detect from video source, if not defined
  124635. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  124636. * @param scene is obviously the current scene.
  124637. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  124638. * @param invertY is false by default but can be used to invert video on Y axis
  124639. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  124640. * @param settings allows finer control over video usage
  124641. */
  124642. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  124643. private _getName;
  124644. private _getVideo;
  124645. private _createInternalTexture;
  124646. private reset;
  124647. /**
  124648. * @hidden Internal method to initiate `update`.
  124649. */
  124650. _rebuild(): void;
  124651. /**
  124652. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  124653. */
  124654. update(): void;
  124655. /**
  124656. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  124657. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  124658. */
  124659. updateTexture(isVisible: boolean): void;
  124660. protected _updateInternalTexture: () => void;
  124661. /**
  124662. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  124663. * @param url New url.
  124664. */
  124665. updateURL(url: string): void;
  124666. /**
  124667. * Clones the texture.
  124668. * @returns the cloned texture
  124669. */
  124670. clone(): VideoTexture;
  124671. /**
  124672. * Dispose the texture and release its associated resources.
  124673. */
  124674. dispose(): void;
  124675. /**
  124676. * Creates a video texture straight from a stream.
  124677. * @param scene Define the scene the texture should be created in
  124678. * @param stream Define the stream the texture should be created from
  124679. * @returns The created video texture as a promise
  124680. */
  124681. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  124682. /**
  124683. * Creates a video texture straight from your WebCam video feed.
  124684. * @param scene Define the scene the texture should be created in
  124685. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124686. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124687. * @returns The created video texture as a promise
  124688. */
  124689. static CreateFromWebCamAsync(scene: Scene, constraints: {
  124690. minWidth: number;
  124691. maxWidth: number;
  124692. minHeight: number;
  124693. maxHeight: number;
  124694. deviceId: string;
  124695. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  124696. /**
  124697. * Creates a video texture straight from your WebCam video feed.
  124698. * @param scene Define the scene the texture should be created in
  124699. * @param onReady Define a callback to triggered once the texture will be ready
  124700. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124701. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124702. */
  124703. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  124704. minWidth: number;
  124705. maxWidth: number;
  124706. minHeight: number;
  124707. maxHeight: number;
  124708. deviceId: string;
  124709. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  124710. }
  124711. }
  124712. declare module BABYLON {
  124713. /**
  124714. * Defines the interface used by objects working like Scene
  124715. * @hidden
  124716. */
  124717. export interface ISceneLike {
  124718. _addPendingData(data: any): void;
  124719. _removePendingData(data: any): void;
  124720. offlineProvider: IOfflineProvider;
  124721. }
  124722. /**
  124723. * Information about the current host
  124724. */
  124725. export interface HostInformation {
  124726. /**
  124727. * Defines if the current host is a mobile
  124728. */
  124729. isMobile: boolean;
  124730. }
  124731. /** Interface defining initialization parameters for Engine class */
  124732. export interface EngineOptions extends WebGLContextAttributes {
  124733. /**
  124734. * Defines if the engine should no exceed a specified device ratio
  124735. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  124736. */
  124737. limitDeviceRatio?: number;
  124738. /**
  124739. * Defines if webvr should be enabled automatically
  124740. * @see https://doc.babylonjs.com/how_to/webvr_camera
  124741. */
  124742. autoEnableWebVR?: boolean;
  124743. /**
  124744. * Defines if webgl2 should be turned off even if supported
  124745. * @see https://doc.babylonjs.com/features/webgl2
  124746. */
  124747. disableWebGL2Support?: boolean;
  124748. /**
  124749. * Defines if webaudio should be initialized as well
  124750. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  124751. */
  124752. audioEngine?: boolean;
  124753. /**
  124754. * Defines if animations should run using a deterministic lock step
  124755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124756. */
  124757. deterministicLockstep?: boolean;
  124758. /** Defines the maximum steps to use with deterministic lock step mode */
  124759. lockstepMaxSteps?: number;
  124760. /** Defines the seconds between each deterministic lock step */
  124761. timeStep?: number;
  124762. /**
  124763. * Defines that engine should ignore context lost events
  124764. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  124765. */
  124766. doNotHandleContextLost?: boolean;
  124767. /**
  124768. * Defines that engine should ignore modifying touch action attribute and style
  124769. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  124770. */
  124771. doNotHandleTouchAction?: boolean;
  124772. /**
  124773. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  124774. */
  124775. useHighPrecisionFloats?: boolean;
  124776. /**
  124777. * Make the canvas XR Compatible for XR sessions
  124778. */
  124779. xrCompatible?: boolean;
  124780. /**
  124781. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  124782. */
  124783. useHighPrecisionMatrix?: boolean;
  124784. /**
  124785. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  124786. */
  124787. failIfMajorPerformanceCaveat?: boolean;
  124788. /**
  124789. * Defines whether to adapt to the device's viewport characteristics (default: false)
  124790. */
  124791. adaptToDeviceRatio?: boolean;
  124792. }
  124793. /**
  124794. * The base engine class (root of all engines)
  124795. */
  124796. export class ThinEngine {
  124797. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  124798. static ExceptionList: ({
  124799. key: string;
  124800. capture: string;
  124801. captureConstraint: number;
  124802. targets: string[];
  124803. } | {
  124804. key: string;
  124805. capture: null;
  124806. captureConstraint: null;
  124807. targets: string[];
  124808. })[];
  124809. /** @hidden */
  124810. static _TextureLoaders: IInternalTextureLoader[];
  124811. /**
  124812. * Returns the current npm package of the sdk
  124813. */
  124814. static get NpmPackage(): string;
  124815. /**
  124816. * Returns the current version of the framework
  124817. */
  124818. static get Version(): string;
  124819. /**
  124820. * Returns a string describing the current engine
  124821. */
  124822. get description(): string;
  124823. /**
  124824. * Returns the name of the engine
  124825. */
  124826. get name(): string;
  124827. /**
  124828. * Returns the version of the engine
  124829. */
  124830. get version(): number;
  124831. /**
  124832. * Gets or sets the epsilon value used by collision engine
  124833. */
  124834. static CollisionsEpsilon: number;
  124835. /**
  124836. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  124837. */
  124838. static get ShadersRepository(): string;
  124839. static set ShadersRepository(value: string);
  124840. /** @hidden */
  124841. _shaderProcessor: Nullable<IShaderProcessor>;
  124842. /**
  124843. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  124844. */
  124845. forcePOTTextures: boolean;
  124846. /**
  124847. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  124848. */
  124849. isFullscreen: boolean;
  124850. /**
  124851. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  124852. */
  124853. cullBackFaces: boolean;
  124854. /**
  124855. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  124856. */
  124857. renderEvenInBackground: boolean;
  124858. /**
  124859. * Gets or sets a boolean indicating that cache can be kept between frames
  124860. */
  124861. preventCacheWipeBetweenFrames: boolean;
  124862. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  124863. validateShaderPrograms: boolean;
  124864. /**
  124865. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  124866. * This can provide greater z depth for distant objects.
  124867. */
  124868. useReverseDepthBuffer: boolean;
  124869. /**
  124870. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  124871. */
  124872. disableUniformBuffers: boolean;
  124873. private _frameId;
  124874. /**
  124875. * Gets the current frame id
  124876. */
  124877. get frameId(): number;
  124878. /** @hidden */
  124879. _uniformBuffers: UniformBuffer[];
  124880. /**
  124881. * Gets a boolean indicating that the engine supports uniform buffers
  124882. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  124883. */
  124884. get supportsUniformBuffers(): boolean;
  124885. /** @hidden */
  124886. _gl: WebGLRenderingContext;
  124887. /** @hidden */
  124888. _webGLVersion: number;
  124889. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  124890. protected _windowIsBackground: boolean;
  124891. protected _creationOptions: EngineOptions;
  124892. protected _highPrecisionShadersAllowed: boolean;
  124893. /** @hidden */
  124894. get _shouldUseHighPrecisionShader(): boolean;
  124895. /**
  124896. * Gets a boolean indicating that only power of 2 textures are supported
  124897. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  124898. */
  124899. get needPOTTextures(): boolean;
  124900. /** @hidden */
  124901. _badOS: boolean;
  124902. /** @hidden */
  124903. _badDesktopOS: boolean;
  124904. protected _hardwareScalingLevel: number;
  124905. /** @hidden */
  124906. _caps: EngineCapabilities;
  124907. /** @hidden */
  124908. _features: EngineFeatures;
  124909. protected _isStencilEnable: boolean;
  124910. private _glVersion;
  124911. private _glRenderer;
  124912. private _glVendor;
  124913. /** @hidden */
  124914. _videoTextureSupported: boolean;
  124915. protected _renderingQueueLaunched: boolean;
  124916. protected _activeRenderLoops: (() => void)[];
  124917. /**
  124918. * Observable signaled when a context lost event is raised
  124919. */
  124920. onContextLostObservable: Observable<ThinEngine>;
  124921. /**
  124922. * Observable signaled when a context restored event is raised
  124923. */
  124924. onContextRestoredObservable: Observable<ThinEngine>;
  124925. private _onContextLost;
  124926. private _onContextRestored;
  124927. protected _contextWasLost: boolean;
  124928. /** @hidden */
  124929. _doNotHandleContextLost: boolean;
  124930. /**
  124931. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  124932. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  124933. */
  124934. get doNotHandleContextLost(): boolean;
  124935. set doNotHandleContextLost(value: boolean);
  124936. /**
  124937. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  124938. */
  124939. disableVertexArrayObjects: boolean;
  124940. /** @hidden */
  124941. protected _colorWrite: boolean;
  124942. /** @hidden */
  124943. protected _colorWriteChanged: boolean;
  124944. /** @hidden */
  124945. protected _depthCullingState: DepthCullingState;
  124946. /** @hidden */
  124947. protected _stencilState: StencilState;
  124948. /** @hidden */
  124949. _alphaState: AlphaState;
  124950. /** @hidden */
  124951. _alphaMode: number;
  124952. /** @hidden */
  124953. _alphaEquation: number;
  124954. /** @hidden */
  124955. _internalTexturesCache: InternalTexture[];
  124956. /** @hidden */
  124957. protected _activeChannel: number;
  124958. private _currentTextureChannel;
  124959. /** @hidden */
  124960. protected _boundTexturesCache: {
  124961. [key: string]: Nullable<InternalTexture>;
  124962. };
  124963. /** @hidden */
  124964. protected _currentEffect: Nullable<Effect>;
  124965. /** @hidden */
  124966. protected _currentProgram: Nullable<WebGLProgram>;
  124967. protected _compiledEffects: {
  124968. [key: string]: Effect;
  124969. };
  124970. private _vertexAttribArraysEnabled;
  124971. /** @hidden */
  124972. protected _cachedViewport: Nullable<IViewportLike>;
  124973. private _cachedVertexArrayObject;
  124974. /** @hidden */
  124975. protected _cachedVertexBuffers: any;
  124976. /** @hidden */
  124977. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  124978. /** @hidden */
  124979. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  124980. /** @hidden */
  124981. _currentRenderTarget: Nullable<InternalTexture>;
  124982. private _uintIndicesCurrentlySet;
  124983. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  124984. /** @hidden */
  124985. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  124986. /** @hidden */
  124987. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  124988. private _currentBufferPointers;
  124989. private _currentInstanceLocations;
  124990. private _currentInstanceBuffers;
  124991. private _textureUnits;
  124992. /** @hidden */
  124993. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  124994. /** @hidden */
  124995. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  124996. /** @hidden */
  124997. _boundRenderFunction: any;
  124998. private _vaoRecordInProgress;
  124999. private _mustWipeVertexAttributes;
  125000. private _emptyTexture;
  125001. private _emptyCubeTexture;
  125002. private _emptyTexture3D;
  125003. private _emptyTexture2DArray;
  125004. /** @hidden */
  125005. _frameHandler: number;
  125006. private _nextFreeTextureSlots;
  125007. private _maxSimultaneousTextures;
  125008. private _activeRequests;
  125009. /** @hidden */
  125010. _transformTextureUrl: Nullable<(url: string) => string>;
  125011. /**
  125012. * Gets information about the current host
  125013. */
  125014. hostInformation: HostInformation;
  125015. protected get _supportsHardwareTextureRescaling(): boolean;
  125016. private _framebufferDimensionsObject;
  125017. /**
  125018. * sets the object from which width and height will be taken from when getting render width and height
  125019. * Will fallback to the gl object
  125020. * @param dimensions the framebuffer width and height that will be used.
  125021. */
  125022. set framebufferDimensionsObject(dimensions: Nullable<{
  125023. framebufferWidth: number;
  125024. framebufferHeight: number;
  125025. }>);
  125026. /**
  125027. * Gets the current viewport
  125028. */
  125029. get currentViewport(): Nullable<IViewportLike>;
  125030. /**
  125031. * Gets the default empty texture
  125032. */
  125033. get emptyTexture(): InternalTexture;
  125034. /**
  125035. * Gets the default empty 3D texture
  125036. */
  125037. get emptyTexture3D(): InternalTexture;
  125038. /**
  125039. * Gets the default empty 2D array texture
  125040. */
  125041. get emptyTexture2DArray(): InternalTexture;
  125042. /**
  125043. * Gets the default empty cube texture
  125044. */
  125045. get emptyCubeTexture(): InternalTexture;
  125046. /**
  125047. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  125048. */
  125049. premultipliedAlpha: boolean;
  125050. /**
  125051. * Observable event triggered before each texture is initialized
  125052. */
  125053. onBeforeTextureInitObservable: Observable<Texture>;
  125054. /** @hidden */
  125055. protected _isWebGPU: boolean;
  125056. /**
  125057. * Gets a boolean indicating if the engine runs in WebGPU or not.
  125058. */
  125059. get isWebGPU(): boolean;
  125060. /** @hidden */
  125061. protected _shaderPlatformName: string;
  125062. /**
  125063. * Gets the shader platfrom name used by the effects.
  125064. */
  125065. get shaderPlatformName(): string;
  125066. /**
  125067. * Creates a new engine
  125068. * @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
  125069. * @param antialias defines enable antialiasing (default: false)
  125070. * @param options defines further options to be sent to the getContext() function
  125071. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  125072. */
  125073. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  125074. /**
  125075. * @hidden
  125076. */
  125077. _debugPushGroup(groupName: string, targetObject?: number): void;
  125078. /**
  125079. * @hidden
  125080. */
  125081. _debugPopGroup(targetObject?: number): void;
  125082. /**
  125083. * @hidden
  125084. */
  125085. _debugInsertMarker(text: string, targetObject?: number): void;
  125086. /**
  125087. * Shared initialization across engines types.
  125088. * @param canvas The canvas associated with this instance of the engine.
  125089. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  125090. * @param audioEngine Defines if an audio engine should be created by default
  125091. */
  125092. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  125093. /**
  125094. * Gets a shader processor implementation fitting with the current engine type.
  125095. * @returns The shader processor implementation.
  125096. */
  125097. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  125098. /** @hidden */
  125099. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  125100. private _rebuildInternalTextures;
  125101. private _rebuildEffects;
  125102. /**
  125103. * Gets a boolean indicating if all created effects are ready
  125104. * @returns true if all effects are ready
  125105. */
  125106. areAllEffectsReady(): boolean;
  125107. protected _rebuildBuffers(): void;
  125108. protected _initGLContext(): void;
  125109. protected _initFeatures(): void;
  125110. /**
  125111. * Gets version of the current webGL context
  125112. * Keep it for back compat - use version instead
  125113. */
  125114. get webGLVersion(): number;
  125115. /**
  125116. * Gets a string identifying the name of the class
  125117. * @returns "Engine" string
  125118. */
  125119. getClassName(): string;
  125120. /**
  125121. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  125122. */
  125123. get isStencilEnable(): boolean;
  125124. /** @hidden */
  125125. _prepareWorkingCanvas(): void;
  125126. /**
  125127. * Reset the texture cache to empty state
  125128. */
  125129. resetTextureCache(): void;
  125130. /**
  125131. * Gets an object containing information about the current webGL context
  125132. * @returns an object containing the vender, the renderer and the version of the current webGL context
  125133. */
  125134. getGlInfo(): {
  125135. vendor: string;
  125136. renderer: string;
  125137. version: string;
  125138. };
  125139. /**
  125140. * Defines the hardware scaling level.
  125141. * By default the hardware scaling level is computed from the window device ratio.
  125142. * 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.
  125143. * @param level defines the level to use
  125144. */
  125145. setHardwareScalingLevel(level: number): void;
  125146. /**
  125147. * Gets the current hardware scaling level.
  125148. * By default the hardware scaling level is computed from the window device ratio.
  125149. * 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.
  125150. * @returns a number indicating the current hardware scaling level
  125151. */
  125152. getHardwareScalingLevel(): number;
  125153. /**
  125154. * Gets the list of loaded textures
  125155. * @returns an array containing all loaded textures
  125156. */
  125157. getLoadedTexturesCache(): InternalTexture[];
  125158. /**
  125159. * Gets the object containing all engine capabilities
  125160. * @returns the EngineCapabilities object
  125161. */
  125162. getCaps(): EngineCapabilities;
  125163. /**
  125164. * stop executing a render loop function and remove it from the execution array
  125165. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  125166. */
  125167. stopRenderLoop(renderFunction?: () => void): void;
  125168. /** @hidden */
  125169. _renderLoop(): void;
  125170. /**
  125171. * Gets the HTML canvas attached with the current webGL context
  125172. * @returns a HTML canvas
  125173. */
  125174. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  125175. /**
  125176. * Gets host window
  125177. * @returns the host window object
  125178. */
  125179. getHostWindow(): Nullable<Window>;
  125180. /**
  125181. * Gets the current render width
  125182. * @param useScreen defines if screen size must be used (or the current render target if any)
  125183. * @returns a number defining the current render width
  125184. */
  125185. getRenderWidth(useScreen?: boolean): number;
  125186. /**
  125187. * Gets the current render height
  125188. * @param useScreen defines if screen size must be used (or the current render target if any)
  125189. * @returns a number defining the current render height
  125190. */
  125191. getRenderHeight(useScreen?: boolean): number;
  125192. /**
  125193. * Can be used to override the current requestAnimationFrame requester.
  125194. * @hidden
  125195. */
  125196. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  125197. /**
  125198. * Register and execute a render loop. The engine can have more than one render function
  125199. * @param renderFunction defines the function to continuously execute
  125200. */
  125201. runRenderLoop(renderFunction: () => void): void;
  125202. /**
  125203. * Clear the current render buffer or the current render target (if any is set up)
  125204. * @param color defines the color to use
  125205. * @param backBuffer defines if the back buffer must be cleared
  125206. * @param depth defines if the depth buffer must be cleared
  125207. * @param stencil defines if the stencil buffer must be cleared
  125208. */
  125209. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  125210. protected _viewportCached: {
  125211. x: number;
  125212. y: number;
  125213. z: number;
  125214. w: number;
  125215. };
  125216. /** @hidden */
  125217. _viewport(x: number, y: number, width: number, height: number): void;
  125218. /**
  125219. * Set the WebGL's viewport
  125220. * @param viewport defines the viewport element to be used
  125221. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  125222. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  125223. */
  125224. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  125225. /**
  125226. * Begin a new frame
  125227. */
  125228. beginFrame(): void;
  125229. /**
  125230. * Enf the current frame
  125231. */
  125232. endFrame(): void;
  125233. /**
  125234. * Resize the view according to the canvas' size
  125235. * @param forceSetSize true to force setting the sizes of the underlying canvas
  125236. */
  125237. resize(forceSetSize?: boolean): void;
  125238. /**
  125239. * Force a specific size of the canvas
  125240. * @param width defines the new canvas' width
  125241. * @param height defines the new canvas' height
  125242. * @param forceSetSize true to force setting the sizes of the underlying canvas
  125243. * @returns true if the size was changed
  125244. */
  125245. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  125246. /**
  125247. * Binds the frame buffer to the specified texture.
  125248. * @param texture The texture to render to or null for the default canvas
  125249. * @param faceIndex The face of the texture to render to in case of cube texture
  125250. * @param requiredWidth The width of the target to render to
  125251. * @param requiredHeight The height of the target to render to
  125252. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  125253. * @param lodLevel defines the lod level to bind to the frame buffer
  125254. * @param layer defines the 2d array index to bind to frame buffer to
  125255. */
  125256. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  125257. /** @hidden */
  125258. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  125259. /**
  125260. * Unbind the current render target texture from the webGL context
  125261. * @param texture defines the render target texture to unbind
  125262. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  125263. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  125264. */
  125265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  125266. /**
  125267. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  125268. */
  125269. flushFramebuffer(): void;
  125270. /**
  125271. * Unbind the current render target and bind the default framebuffer
  125272. */
  125273. restoreDefaultFramebuffer(): void;
  125274. /** @hidden */
  125275. protected _resetVertexBufferBinding(): void;
  125276. /**
  125277. * Creates a vertex buffer
  125278. * @param data the data for the vertex buffer
  125279. * @returns the new WebGL static buffer
  125280. */
  125281. createVertexBuffer(data: DataArray): DataBuffer;
  125282. private _createVertexBuffer;
  125283. /**
  125284. * Creates a dynamic vertex buffer
  125285. * @param data the data for the dynamic vertex buffer
  125286. * @returns the new WebGL dynamic buffer
  125287. */
  125288. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  125289. protected _resetIndexBufferBinding(): void;
  125290. /**
  125291. * Creates a new index buffer
  125292. * @param indices defines the content of the index buffer
  125293. * @param updatable defines if the index buffer must be updatable
  125294. * @returns a new webGL buffer
  125295. */
  125296. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  125297. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  125298. /**
  125299. * Bind a webGL buffer to the webGL context
  125300. * @param buffer defines the buffer to bind
  125301. */
  125302. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  125303. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  125304. private bindBuffer;
  125305. /**
  125306. * update the bound buffer with the given data
  125307. * @param data defines the data to update
  125308. */
  125309. updateArrayBuffer(data: Float32Array): void;
  125310. private _vertexAttribPointer;
  125311. /** @hidden */
  125312. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  125313. private _bindVertexBuffersAttributes;
  125314. /**
  125315. * Records a vertex array object
  125316. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  125317. * @param vertexBuffers defines the list of vertex buffers to store
  125318. * @param indexBuffer defines the index buffer to store
  125319. * @param effect defines the effect to store
  125320. * @returns the new vertex array object
  125321. */
  125322. recordVertexArrayObject(vertexBuffers: {
  125323. [key: string]: VertexBuffer;
  125324. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  125325. /**
  125326. * Bind a specific vertex array object
  125327. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  125328. * @param vertexArrayObject defines the vertex array object to bind
  125329. * @param indexBuffer defines the index buffer to bind
  125330. */
  125331. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  125332. /**
  125333. * Bind webGl buffers directly to the webGL context
  125334. * @param vertexBuffer defines the vertex buffer to bind
  125335. * @param indexBuffer defines the index buffer to bind
  125336. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  125337. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  125338. * @param effect defines the effect associated with the vertex buffer
  125339. */
  125340. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  125341. private _unbindVertexArrayObject;
  125342. /**
  125343. * Bind a list of vertex buffers to the webGL context
  125344. * @param vertexBuffers defines the list of vertex buffers to bind
  125345. * @param indexBuffer defines the index buffer to bind
  125346. * @param effect defines the effect associated with the vertex buffers
  125347. */
  125348. bindBuffers(vertexBuffers: {
  125349. [key: string]: Nullable<VertexBuffer>;
  125350. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  125351. /**
  125352. * Unbind all instance attributes
  125353. */
  125354. unbindInstanceAttributes(): void;
  125355. /**
  125356. * Release and free the memory of a vertex array object
  125357. * @param vao defines the vertex array object to delete
  125358. */
  125359. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  125360. /** @hidden */
  125361. _releaseBuffer(buffer: DataBuffer): boolean;
  125362. protected _deleteBuffer(buffer: DataBuffer): void;
  125363. /**
  125364. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  125365. * @param instancesBuffer defines the webGL buffer to update and bind
  125366. * @param data defines the data to store in the buffer
  125367. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  125368. */
  125369. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  125370. /**
  125371. * Bind the content of a webGL buffer used with instantiation
  125372. * @param instancesBuffer defines the webGL buffer to bind
  125373. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  125374. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  125375. */
  125376. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  125377. /**
  125378. * Disable the instance attribute corresponding to the name in parameter
  125379. * @param name defines the name of the attribute to disable
  125380. */
  125381. disableInstanceAttributeByName(name: string): void;
  125382. /**
  125383. * Disable the instance attribute corresponding to the location in parameter
  125384. * @param attributeLocation defines the attribute location of the attribute to disable
  125385. */
  125386. disableInstanceAttribute(attributeLocation: number): void;
  125387. /**
  125388. * Disable the attribute corresponding to the location in parameter
  125389. * @param attributeLocation defines the attribute location of the attribute to disable
  125390. */
  125391. disableAttributeByIndex(attributeLocation: number): void;
  125392. /**
  125393. * Send a draw order
  125394. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  125395. * @param indexStart defines the starting index
  125396. * @param indexCount defines the number of index to draw
  125397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125398. */
  125399. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  125400. /**
  125401. * Draw a list of points
  125402. * @param verticesStart defines the index of first vertex to draw
  125403. * @param verticesCount defines the count of vertices to draw
  125404. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125405. */
  125406. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125407. /**
  125408. * Draw a list of unindexed primitives
  125409. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  125410. * @param verticesStart defines the index of first vertex to draw
  125411. * @param verticesCount defines the count of vertices to draw
  125412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125413. */
  125414. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125415. /**
  125416. * Draw a list of indexed primitives
  125417. * @param fillMode defines the primitive to use
  125418. * @param indexStart defines the starting index
  125419. * @param indexCount defines the number of index to draw
  125420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125421. */
  125422. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  125423. /**
  125424. * Draw a list of unindexed primitives
  125425. * @param fillMode defines the primitive to use
  125426. * @param verticesStart defines the index of first vertex to draw
  125427. * @param verticesCount defines the count of vertices to draw
  125428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125429. */
  125430. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125431. private _drawMode;
  125432. /** @hidden */
  125433. protected _reportDrawCall(): void;
  125434. /** @hidden */
  125435. _releaseEffect(effect: Effect): void;
  125436. /** @hidden */
  125437. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  125438. /**
  125439. * Create a new effect (used to store vertex/fragment shaders)
  125440. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  125441. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  125442. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  125443. * @param samplers defines an array of string used to represent textures
  125444. * @param defines defines the string containing the defines to use to compile the shaders
  125445. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125446. * @param onCompiled defines a function to call when the effect creation is successful
  125447. * @param onError defines a function to call when the effect creation has failed
  125448. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  125449. * @returns the new Effect
  125450. */
  125451. 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;
  125452. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  125453. private _compileShader;
  125454. private _compileRawShader;
  125455. /** @hidden */
  125456. _getShaderSource(shader: WebGLShader): Nullable<string>;
  125457. /**
  125458. * Directly creates a webGL program
  125459. * @param pipelineContext defines the pipeline context to attach to
  125460. * @param vertexCode defines the vertex shader code to use
  125461. * @param fragmentCode defines the fragment shader code to use
  125462. * @param context defines the webGL context to use (if not set, the current one will be used)
  125463. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125464. * @returns the new webGL program
  125465. */
  125466. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125467. /**
  125468. * Creates a webGL program
  125469. * @param pipelineContext defines the pipeline context to attach to
  125470. * @param vertexCode defines the vertex shader code to use
  125471. * @param fragmentCode defines the fragment shader code to use
  125472. * @param defines defines the string containing the defines to use to compile the shaders
  125473. * @param context defines the webGL context to use (if not set, the current one will be used)
  125474. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125475. * @returns the new webGL program
  125476. */
  125477. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125478. /**
  125479. * Creates a new pipeline context
  125480. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  125481. * @returns the new pipeline
  125482. */
  125483. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  125484. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125485. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  125486. /** @hidden */
  125487. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  125488. /** @hidden */
  125489. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  125490. /** @hidden */
  125491. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  125492. /**
  125493. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  125494. * @param pipelineContext defines the pipeline context to use
  125495. * @param uniformsNames defines the list of uniform names
  125496. * @returns an array of webGL uniform locations
  125497. */
  125498. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  125499. /**
  125500. * Gets the list of active attributes for a given webGL program
  125501. * @param pipelineContext defines the pipeline context to use
  125502. * @param attributesNames defines the list of attribute names to get
  125503. * @returns an array of indices indicating the offset of each attribute
  125504. */
  125505. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  125506. /**
  125507. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  125508. * @param effect defines the effect to activate
  125509. */
  125510. enableEffect(effect: Nullable<Effect>): void;
  125511. /**
  125512. * Set the value of an uniform to a number (int)
  125513. * @param uniform defines the webGL uniform location where to store the value
  125514. * @param value defines the int number to store
  125515. * @returns true if the value was set
  125516. */
  125517. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125518. /**
  125519. * Set the value of an uniform to a int2
  125520. * @param uniform defines the webGL uniform location where to store the value
  125521. * @param x defines the 1st component of the value
  125522. * @param y defines the 2nd component of the value
  125523. * @returns true if the value was set
  125524. */
  125525. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125526. /**
  125527. * Set the value of an uniform to a int3
  125528. * @param uniform defines the webGL uniform location where to store the value
  125529. * @param x defines the 1st component of the value
  125530. * @param y defines the 2nd component of the value
  125531. * @param z defines the 3rd component of the value
  125532. * @returns true if the value was set
  125533. */
  125534. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125535. /**
  125536. * Set the value of an uniform to a int4
  125537. * @param uniform defines the webGL uniform location where to store the value
  125538. * @param x defines the 1st component of the value
  125539. * @param y defines the 2nd component of the value
  125540. * @param z defines the 3rd component of the value
  125541. * @param w defines the 4th component of the value
  125542. * @returns true if the value was set
  125543. */
  125544. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125545. /**
  125546. * Set the value of an uniform to an array of int32
  125547. * @param uniform defines the webGL uniform location where to store the value
  125548. * @param array defines the array of int32 to store
  125549. * @returns true if the value was set
  125550. */
  125551. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125552. /**
  125553. * Set the value of an uniform to an array of int32 (stored as vec2)
  125554. * @param uniform defines the webGL uniform location where to store the value
  125555. * @param array defines the array of int32 to store
  125556. * @returns true if the value was set
  125557. */
  125558. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125559. /**
  125560. * Set the value of an uniform to an array of int32 (stored as vec3)
  125561. * @param uniform defines the webGL uniform location where to store the value
  125562. * @param array defines the array of int32 to store
  125563. * @returns true if the value was set
  125564. */
  125565. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125566. /**
  125567. * Set the value of an uniform to an array of int32 (stored as vec4)
  125568. * @param uniform defines the webGL uniform location where to store the value
  125569. * @param array defines the array of int32 to store
  125570. * @returns true if the value was set
  125571. */
  125572. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125573. /**
  125574. * Set the value of an uniform to an array of number
  125575. * @param uniform defines the webGL uniform location where to store the value
  125576. * @param array defines the array of number to store
  125577. * @returns true if the value was set
  125578. */
  125579. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125580. /**
  125581. * Set the value of an uniform to an array of number (stored as vec2)
  125582. * @param uniform defines the webGL uniform location where to store the value
  125583. * @param array defines the array of number to store
  125584. * @returns true if the value was set
  125585. */
  125586. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125587. /**
  125588. * Set the value of an uniform to an array of number (stored as vec3)
  125589. * @param uniform defines the webGL uniform location where to store the value
  125590. * @param array defines the array of number to store
  125591. * @returns true if the value was set
  125592. */
  125593. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125594. /**
  125595. * Set the value of an uniform to an array of number (stored as vec4)
  125596. * @param uniform defines the webGL uniform location where to store the value
  125597. * @param array defines the array of number to store
  125598. * @returns true if the value was set
  125599. */
  125600. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125601. /**
  125602. * Set the value of an uniform to an array of float32 (stored as matrices)
  125603. * @param uniform defines the webGL uniform location where to store the value
  125604. * @param matrices defines the array of float32 to store
  125605. * @returns true if the value was set
  125606. */
  125607. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  125608. /**
  125609. * Set the value of an uniform to a matrix (3x3)
  125610. * @param uniform defines the webGL uniform location where to store the value
  125611. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  125612. * @returns true if the value was set
  125613. */
  125614. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125615. /**
  125616. * Set the value of an uniform to a matrix (2x2)
  125617. * @param uniform defines the webGL uniform location where to store the value
  125618. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  125619. * @returns true if the value was set
  125620. */
  125621. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125622. /**
  125623. * Set the value of an uniform to a number (float)
  125624. * @param uniform defines the webGL uniform location where to store the value
  125625. * @param value defines the float number to store
  125626. * @returns true if the value was transfered
  125627. */
  125628. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125629. /**
  125630. * Set the value of an uniform to a vec2
  125631. * @param uniform defines the webGL uniform location where to store the value
  125632. * @param x defines the 1st component of the value
  125633. * @param y defines the 2nd component of the value
  125634. * @returns true if the value was set
  125635. */
  125636. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125637. /**
  125638. * Set the value of an uniform to a vec3
  125639. * @param uniform defines the webGL uniform location where to store the value
  125640. * @param x defines the 1st component of the value
  125641. * @param y defines the 2nd component of the value
  125642. * @param z defines the 3rd component of the value
  125643. * @returns true if the value was set
  125644. */
  125645. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125646. /**
  125647. * Set the value of an uniform to a vec4
  125648. * @param uniform defines the webGL uniform location where to store the value
  125649. * @param x defines the 1st component of the value
  125650. * @param y defines the 2nd component of the value
  125651. * @param z defines the 3rd component of the value
  125652. * @param w defines the 4th component of the value
  125653. * @returns true if the value was set
  125654. */
  125655. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125656. /**
  125657. * Apply all cached states (depth, culling, stencil and alpha)
  125658. */
  125659. applyStates(): void;
  125660. /**
  125661. * Enable or disable color writing
  125662. * @param enable defines the state to set
  125663. */
  125664. setColorWrite(enable: boolean): void;
  125665. /**
  125666. * Gets a boolean indicating if color writing is enabled
  125667. * @returns the current color writing state
  125668. */
  125669. getColorWrite(): boolean;
  125670. /**
  125671. * Gets the depth culling state manager
  125672. */
  125673. get depthCullingState(): DepthCullingState;
  125674. /**
  125675. * Gets the alpha state manager
  125676. */
  125677. get alphaState(): AlphaState;
  125678. /**
  125679. * Gets the stencil state manager
  125680. */
  125681. get stencilState(): StencilState;
  125682. /**
  125683. * Clears the list of texture accessible through engine.
  125684. * This can help preventing texture load conflict due to name collision.
  125685. */
  125686. clearInternalTexturesCache(): void;
  125687. /**
  125688. * Force the entire cache to be cleared
  125689. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  125690. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  125691. */
  125692. wipeCaches(bruteForce?: boolean): void;
  125693. /** @hidden */
  125694. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  125695. min: number;
  125696. mag: number;
  125697. };
  125698. /** @hidden */
  125699. protected _createTexture(): WebGLTexture;
  125700. /** @hidden */
  125701. _createHardwareTexture(): HardwareTextureWrapper;
  125702. 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 | {
  125703. width: number;
  125704. height: number;
  125705. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125706. width: number;
  125707. height: number;
  125708. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125709. width: number;
  125710. height: number;
  125711. }, 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;
  125712. /**
  125713. * Usually called from Texture.ts.
  125714. * Passed information to create a WebGLTexture
  125715. * @param url defines a value which contains one of the following:
  125716. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  125717. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  125718. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  125719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  125720. * @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)
  125721. * @param scene needed for loading to the correct scene
  125722. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  125723. * @param onLoad optional callback to be called upon successful completion
  125724. * @param onError optional callback to be called upon failure
  125725. * @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
  125726. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  125727. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  125728. * @param forcedExtension defines the extension to use to pick the right loader
  125729. * @param mimeType defines an optional mime type
  125730. * @param loaderOptions options to be passed to the loader
  125731. * @returns a InternalTexture for assignment back into BABYLON.Texture
  125732. */
  125733. 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;
  125734. /**
  125735. * Loads an image as an HTMLImageElement.
  125736. * @param input url string, ArrayBuffer, or Blob to load
  125737. * @param onLoad callback called when the image successfully loads
  125738. * @param onError callback called when the image fails to load
  125739. * @param offlineProvider offline provider for caching
  125740. * @param mimeType optional mime type
  125741. * @returns the HTMLImageElement of the loaded image
  125742. * @hidden
  125743. */
  125744. 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>;
  125745. /**
  125746. * @hidden
  125747. */
  125748. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  125749. private _unpackFlipYCached;
  125750. /**
  125751. * In case you are sharing the context with other applications, it might
  125752. * be interested to not cache the unpack flip y state to ensure a consistent
  125753. * value would be set.
  125754. */
  125755. enableUnpackFlipYCached: boolean;
  125756. /** @hidden */
  125757. _unpackFlipY(value: boolean): void;
  125758. /** @hidden */
  125759. _getUnpackAlignement(): number;
  125760. private _getTextureTarget;
  125761. /**
  125762. * Update the sampling mode of a given texture
  125763. * @param samplingMode defines the required sampling mode
  125764. * @param texture defines the texture to update
  125765. * @param generateMipMaps defines whether to generate mipmaps for the texture
  125766. */
  125767. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  125768. /**
  125769. * Update the dimensions of a texture
  125770. * @param texture texture to update
  125771. * @param width new width of the texture
  125772. * @param height new height of the texture
  125773. * @param depth new depth of the texture
  125774. */
  125775. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  125776. /**
  125777. * Update the sampling mode of a given texture
  125778. * @param texture defines the texture to update
  125779. * @param wrapU defines the texture wrap mode of the u coordinates
  125780. * @param wrapV defines the texture wrap mode of the v coordinates
  125781. * @param wrapR defines the texture wrap mode of the r coordinates
  125782. */
  125783. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  125784. /** @hidden */
  125785. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  125786. width: number;
  125787. height: number;
  125788. layers?: number;
  125789. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  125790. /** @hidden */
  125791. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125792. /** @hidden */
  125793. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  125794. /**
  125795. * Update a portion of an internal texture
  125796. * @param texture defines the texture to update
  125797. * @param imageData defines the data to store into the texture
  125798. * @param xOffset defines the x coordinates of the update rectangle
  125799. * @param yOffset defines the y coordinates of the update rectangle
  125800. * @param width defines the width of the update rectangle
  125801. * @param height defines the height of the update rectangle
  125802. * @param faceIndex defines the face index if texture is a cube (0 by default)
  125803. * @param lod defines the lod level to update (0 by default)
  125804. */
  125805. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  125806. /** @hidden */
  125807. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125808. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  125809. private _prepareWebGLTexture;
  125810. /** @hidden */
  125811. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  125812. private _getDepthStencilBuffer;
  125813. /** @hidden */
  125814. _releaseFramebufferObjects(texture: InternalTexture): void;
  125815. /** @hidden */
  125816. _releaseTexture(texture: InternalTexture): void;
  125817. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  125818. protected _setProgram(program: WebGLProgram): void;
  125819. protected _boundUniforms: {
  125820. [key: number]: WebGLUniformLocation;
  125821. };
  125822. /**
  125823. * Binds an effect to the webGL context
  125824. * @param effect defines the effect to bind
  125825. */
  125826. bindSamplers(effect: Effect): void;
  125827. private _activateCurrentTexture;
  125828. /** @hidden */
  125829. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  125830. /** @hidden */
  125831. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  125832. /**
  125833. * Unbind all textures from the webGL context
  125834. */
  125835. unbindAllTextures(): void;
  125836. /**
  125837. * Sets a texture to the according uniform.
  125838. * @param channel The texture channel
  125839. * @param uniform The uniform to set
  125840. * @param texture The texture to apply
  125841. * @param name The name of the uniform in the effect
  125842. */
  125843. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  125844. private _bindSamplerUniformToChannel;
  125845. private _getTextureWrapMode;
  125846. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  125847. /**
  125848. * Sets an array of texture to the webGL context
  125849. * @param channel defines the channel where the texture array must be set
  125850. * @param uniform defines the associated uniform location
  125851. * @param textures defines the array of textures to bind
  125852. * @param name name of the channel
  125853. */
  125854. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  125855. /** @hidden */
  125856. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  125857. private _setTextureParameterFloat;
  125858. private _setTextureParameterInteger;
  125859. /**
  125860. * Unbind all vertex attributes from the webGL context
  125861. */
  125862. unbindAllAttributes(): void;
  125863. /**
  125864. * 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
  125865. */
  125866. releaseEffects(): void;
  125867. /**
  125868. * Dispose and release all associated resources
  125869. */
  125870. dispose(): void;
  125871. /**
  125872. * Attach a new callback raised when context lost event is fired
  125873. * @param callback defines the callback to call
  125874. */
  125875. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125876. /**
  125877. * Attach a new callback raised when context restored event is fired
  125878. * @param callback defines the callback to call
  125879. */
  125880. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125881. /**
  125882. * Get the current error code of the webGL context
  125883. * @returns the error code
  125884. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  125885. */
  125886. getError(): number;
  125887. private _canRenderToFloatFramebuffer;
  125888. private _canRenderToHalfFloatFramebuffer;
  125889. private _canRenderToFramebuffer;
  125890. /** @hidden */
  125891. _getWebGLTextureType(type: number): number;
  125892. /** @hidden */
  125893. _getInternalFormat(format: number): number;
  125894. /** @hidden */
  125895. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  125896. /** @hidden */
  125897. _getRGBAMultiSampleBufferFormat(type: number): number;
  125898. /** @hidden */
  125899. _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;
  125900. /**
  125901. * Loads a file from a url
  125902. * @param url url to load
  125903. * @param onSuccess callback called when the file successfully loads
  125904. * @param onProgress callback called while file is loading (if the server supports this mode)
  125905. * @param offlineProvider defines the offline provider for caching
  125906. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125907. * @param onError callback called when the file fails to load
  125908. * @returns a file request object
  125909. * @hidden
  125910. */
  125911. 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;
  125912. /**
  125913. * Reads pixels from the current frame buffer. Please note that this function can be slow
  125914. * @param x defines the x coordinate of the rectangle where pixels must be read
  125915. * @param y defines the y coordinate of the rectangle where pixels must be read
  125916. * @param width defines the width of the rectangle where pixels must be read
  125917. * @param height defines the height of the rectangle where pixels must be read
  125918. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  125919. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  125920. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  125921. */
  125922. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  125923. private static _IsSupported;
  125924. private static _HasMajorPerformanceCaveat;
  125925. /**
  125926. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125927. */
  125928. static get IsSupported(): boolean;
  125929. /**
  125930. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125931. * @returns true if the engine can be created
  125932. * @ignorenaming
  125933. */
  125934. static isSupported(): boolean;
  125935. /**
  125936. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  125937. */
  125938. static get HasMajorPerformanceCaveat(): boolean;
  125939. /**
  125940. * Find the next highest power of two.
  125941. * @param x Number to start search from.
  125942. * @return Next highest power of two.
  125943. */
  125944. static CeilingPOT(x: number): number;
  125945. /**
  125946. * Find the next lowest power of two.
  125947. * @param x Number to start search from.
  125948. * @return Next lowest power of two.
  125949. */
  125950. static FloorPOT(x: number): number;
  125951. /**
  125952. * Find the nearest power of two.
  125953. * @param x Number to start search from.
  125954. * @return Next nearest power of two.
  125955. */
  125956. static NearestPOT(x: number): number;
  125957. /**
  125958. * Get the closest exponent of two
  125959. * @param value defines the value to approximate
  125960. * @param max defines the maximum value to return
  125961. * @param mode defines how to define the closest value
  125962. * @returns closest exponent of two of the given value
  125963. */
  125964. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  125965. /**
  125966. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  125967. * @param func - the function to be called
  125968. * @param requester - the object that will request the next frame. Falls back to window.
  125969. * @returns frame number
  125970. */
  125971. static QueueNewFrame(func: () => void, requester?: any): number;
  125972. /**
  125973. * Gets host document
  125974. * @returns the host document object
  125975. */
  125976. getHostDocument(): Nullable<Document>;
  125977. }
  125978. }
  125979. declare module BABYLON {
  125980. /**
  125981. * Defines the source of the internal texture
  125982. */
  125983. export enum InternalTextureSource {
  125984. /**
  125985. * The source of the texture data is unknown
  125986. */
  125987. Unknown = 0,
  125988. /**
  125989. * Texture data comes from an URL
  125990. */
  125991. Url = 1,
  125992. /**
  125993. * Texture data is only used for temporary storage
  125994. */
  125995. Temp = 2,
  125996. /**
  125997. * Texture data comes from raw data (ArrayBuffer)
  125998. */
  125999. Raw = 3,
  126000. /**
  126001. * Texture content is dynamic (video or dynamic texture)
  126002. */
  126003. Dynamic = 4,
  126004. /**
  126005. * Texture content is generated by rendering to it
  126006. */
  126007. RenderTarget = 5,
  126008. /**
  126009. * Texture content is part of a multi render target process
  126010. */
  126011. MultiRenderTarget = 6,
  126012. /**
  126013. * Texture data comes from a cube data file
  126014. */
  126015. Cube = 7,
  126016. /**
  126017. * Texture data comes from a raw cube data
  126018. */
  126019. CubeRaw = 8,
  126020. /**
  126021. * Texture data come from a prefiltered cube data file
  126022. */
  126023. CubePrefiltered = 9,
  126024. /**
  126025. * Texture content is raw 3D data
  126026. */
  126027. Raw3D = 10,
  126028. /**
  126029. * Texture content is raw 2D array data
  126030. */
  126031. Raw2DArray = 11,
  126032. /**
  126033. * Texture content is a depth texture
  126034. */
  126035. Depth = 12,
  126036. /**
  126037. * Texture data comes from a raw cube data encoded with RGBD
  126038. */
  126039. CubeRawRGBD = 13
  126040. }
  126041. /**
  126042. * Class used to store data associated with WebGL texture data for the engine
  126043. * This class should not be used directly
  126044. */
  126045. export class InternalTexture {
  126046. /** @hidden */
  126047. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  126048. /**
  126049. * Defines if the texture is ready
  126050. */
  126051. isReady: boolean;
  126052. /**
  126053. * Defines if the texture is a cube texture
  126054. */
  126055. isCube: boolean;
  126056. /**
  126057. * Defines if the texture contains 3D data
  126058. */
  126059. is3D: boolean;
  126060. /**
  126061. * Defines if the texture contains 2D array data
  126062. */
  126063. is2DArray: boolean;
  126064. /**
  126065. * Defines if the texture contains multiview data
  126066. */
  126067. isMultiview: boolean;
  126068. /**
  126069. * Gets the URL used to load this texture
  126070. */
  126071. url: string;
  126072. /** @hidden */
  126073. _originalUrl: string;
  126074. /**
  126075. * Gets the sampling mode of the texture
  126076. */
  126077. samplingMode: number;
  126078. /**
  126079. * Gets a boolean indicating if the texture needs mipmaps generation
  126080. */
  126081. generateMipMaps: boolean;
  126082. /**
  126083. * Gets the number of samples used by the texture (WebGL2+ only)
  126084. */
  126085. samples: number;
  126086. /**
  126087. * Gets the type of the texture (int, float...)
  126088. */
  126089. type: number;
  126090. /**
  126091. * Gets the format of the texture (RGB, RGBA...)
  126092. */
  126093. format: number;
  126094. /**
  126095. * Observable called when the texture is loaded
  126096. */
  126097. onLoadedObservable: Observable<InternalTexture>;
  126098. /**
  126099. * Gets the width of the texture
  126100. */
  126101. width: number;
  126102. /**
  126103. * Gets the height of the texture
  126104. */
  126105. height: number;
  126106. /**
  126107. * Gets the depth of the texture
  126108. */
  126109. depth: number;
  126110. /**
  126111. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  126112. */
  126113. baseWidth: number;
  126114. /**
  126115. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  126116. */
  126117. baseHeight: number;
  126118. /**
  126119. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  126120. */
  126121. baseDepth: number;
  126122. /**
  126123. * Gets a boolean indicating if the texture is inverted on Y axis
  126124. */
  126125. invertY: boolean;
  126126. /** @hidden */
  126127. _invertVScale: boolean;
  126128. /** @hidden */
  126129. _associatedChannel: number;
  126130. /** @hidden */
  126131. _source: InternalTextureSource;
  126132. /** @hidden */
  126133. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  126134. /** @hidden */
  126135. _bufferView: Nullable<ArrayBufferView>;
  126136. /** @hidden */
  126137. _bufferViewArray: Nullable<ArrayBufferView[]>;
  126138. /** @hidden */
  126139. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  126140. /** @hidden */
  126141. _size: number;
  126142. /** @hidden */
  126143. _extension: string;
  126144. /** @hidden */
  126145. _files: Nullable<string[]>;
  126146. /** @hidden */
  126147. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  126148. /** @hidden */
  126149. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  126150. /** @hidden */
  126151. _framebuffer: Nullable<WebGLFramebuffer>;
  126152. /** @hidden */
  126153. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  126154. /** @hidden */
  126155. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  126156. /** @hidden */
  126157. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  126158. /** @hidden */
  126159. _attachments: Nullable<number[]>;
  126160. /** @hidden */
  126161. _textureArray: Nullable<InternalTexture[]>;
  126162. /** @hidden */
  126163. _cachedCoordinatesMode: Nullable<number>;
  126164. /** @hidden */
  126165. _cachedWrapU: Nullable<number>;
  126166. /** @hidden */
  126167. _cachedWrapV: Nullable<number>;
  126168. /** @hidden */
  126169. _cachedWrapR: Nullable<number>;
  126170. /** @hidden */
  126171. _cachedAnisotropicFilteringLevel: Nullable<number>;
  126172. /** @hidden */
  126173. _isDisabled: boolean;
  126174. /** @hidden */
  126175. _compression: Nullable<string>;
  126176. /** @hidden */
  126177. _generateStencilBuffer: boolean;
  126178. /** @hidden */
  126179. _generateDepthBuffer: boolean;
  126180. /** @hidden */
  126181. _comparisonFunction: number;
  126182. /** @hidden */
  126183. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  126184. /** @hidden */
  126185. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  126186. /** @hidden */
  126187. _sphericalPolynomialComputed: boolean;
  126188. /** @hidden */
  126189. _lodGenerationScale: number;
  126190. /** @hidden */
  126191. _lodGenerationOffset: number;
  126192. /** @hidden */
  126193. _depthStencilTexture: Nullable<InternalTexture>;
  126194. /** @hidden */
  126195. _colorTextureArray: Nullable<WebGLTexture>;
  126196. /** @hidden */
  126197. _depthStencilTextureArray: Nullable<WebGLTexture>;
  126198. /** @hidden */
  126199. _lodTextureHigh: Nullable<BaseTexture>;
  126200. /** @hidden */
  126201. _lodTextureMid: Nullable<BaseTexture>;
  126202. /** @hidden */
  126203. _lodTextureLow: Nullable<BaseTexture>;
  126204. /** @hidden */
  126205. _isRGBD: boolean;
  126206. /** @hidden */
  126207. _linearSpecularLOD: boolean;
  126208. /** @hidden */
  126209. _irradianceTexture: Nullable<BaseTexture>;
  126210. /** @hidden */
  126211. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  126212. /** @hidden */
  126213. _references: number;
  126214. /** @hidden */
  126215. _gammaSpace: Nullable<boolean>;
  126216. private _engine;
  126217. private _uniqueId;
  126218. private static _Counter;
  126219. /** Gets the unique id of the internal texture */
  126220. get uniqueId(): number;
  126221. /**
  126222. * Gets the Engine the texture belongs to.
  126223. * @returns The babylon engine
  126224. */
  126225. getEngine(): ThinEngine;
  126226. /**
  126227. * Gets the data source type of the texture
  126228. */
  126229. get source(): InternalTextureSource;
  126230. /**
  126231. * Creates a new InternalTexture
  126232. * @param engine defines the engine to use
  126233. * @param source defines the type of data that will be used
  126234. * @param delayAllocation if the texture allocation should be delayed (default: false)
  126235. */
  126236. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  126237. /**
  126238. * Increments the number of references (ie. the number of Texture that point to it)
  126239. */
  126240. incrementReferences(): void;
  126241. /**
  126242. * Change the size of the texture (not the size of the content)
  126243. * @param width defines the new width
  126244. * @param height defines the new height
  126245. * @param depth defines the new depth (1 by default)
  126246. */
  126247. updateSize(width: int, height: int, depth?: int): void;
  126248. /** @hidden */
  126249. _rebuild(): void;
  126250. /** @hidden */
  126251. _swapAndDie(target: InternalTexture): void;
  126252. /**
  126253. * Dispose the current allocated resources
  126254. */
  126255. dispose(): void;
  126256. }
  126257. }
  126258. declare module BABYLON {
  126259. /**
  126260. * Interface used to present a loading screen while loading a scene
  126261. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126262. */
  126263. export interface ILoadingScreen {
  126264. /**
  126265. * Function called to display the loading screen
  126266. */
  126267. displayLoadingUI: () => void;
  126268. /**
  126269. * Function called to hide the loading screen
  126270. */
  126271. hideLoadingUI: () => void;
  126272. /**
  126273. * Gets or sets the color to use for the background
  126274. */
  126275. loadingUIBackgroundColor: string;
  126276. /**
  126277. * Gets or sets the text to display while loading
  126278. */
  126279. loadingUIText: string;
  126280. }
  126281. /**
  126282. * Class used for the default loading screen
  126283. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126284. */
  126285. export class DefaultLoadingScreen implements ILoadingScreen {
  126286. private _renderingCanvas;
  126287. private _loadingText;
  126288. private _loadingDivBackgroundColor;
  126289. private _loadingDiv;
  126290. private _loadingTextDiv;
  126291. /** Gets or sets the logo url to use for the default loading screen */
  126292. static DefaultLogoUrl: string;
  126293. /** Gets or sets the spinner url to use for the default loading screen */
  126294. static DefaultSpinnerUrl: string;
  126295. /**
  126296. * Creates a new default loading screen
  126297. * @param _renderingCanvas defines the canvas used to render the scene
  126298. * @param _loadingText defines the default text to display
  126299. * @param _loadingDivBackgroundColor defines the default background color
  126300. */
  126301. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  126302. /**
  126303. * Function called to display the loading screen
  126304. */
  126305. displayLoadingUI(): void;
  126306. /**
  126307. * Function called to hide the loading screen
  126308. */
  126309. hideLoadingUI(): void;
  126310. /**
  126311. * Gets or sets the text to display while loading
  126312. */
  126313. set loadingUIText(text: string);
  126314. get loadingUIText(): string;
  126315. /**
  126316. * Gets or sets the color to use for the background
  126317. */
  126318. get loadingUIBackgroundColor(): string;
  126319. set loadingUIBackgroundColor(color: string);
  126320. private _resizeLoadingUI;
  126321. }
  126322. }
  126323. declare module BABYLON {
  126324. /**
  126325. * Interface for any object that can request an animation frame
  126326. */
  126327. export interface ICustomAnimationFrameRequester {
  126328. /**
  126329. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  126330. */
  126331. renderFunction?: Function;
  126332. /**
  126333. * Called to request the next frame to render to
  126334. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  126335. */
  126336. requestAnimationFrame: Function;
  126337. /**
  126338. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  126339. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  126340. */
  126341. requestID?: number;
  126342. }
  126343. }
  126344. declare module BABYLON {
  126345. /**
  126346. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  126347. */
  126348. export class PerformanceMonitor {
  126349. private _enabled;
  126350. private _rollingFrameTime;
  126351. private _lastFrameTimeMs;
  126352. /**
  126353. * constructor
  126354. * @param frameSampleSize The number of samples required to saturate the sliding window
  126355. */
  126356. constructor(frameSampleSize?: number);
  126357. /**
  126358. * Samples current frame
  126359. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  126360. */
  126361. sampleFrame(timeMs?: number): void;
  126362. /**
  126363. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  126364. */
  126365. get averageFrameTime(): number;
  126366. /**
  126367. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  126368. */
  126369. get averageFrameTimeVariance(): number;
  126370. /**
  126371. * Returns the frame time of the most recent frame
  126372. */
  126373. get instantaneousFrameTime(): number;
  126374. /**
  126375. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  126376. */
  126377. get averageFPS(): number;
  126378. /**
  126379. * Returns the average framerate in frames per second using the most recent frame time
  126380. */
  126381. get instantaneousFPS(): number;
  126382. /**
  126383. * Returns true if enough samples have been taken to completely fill the sliding window
  126384. */
  126385. get isSaturated(): boolean;
  126386. /**
  126387. * Enables contributions to the sliding window sample set
  126388. */
  126389. enable(): void;
  126390. /**
  126391. * Disables contributions to the sliding window sample set
  126392. * Samples will not be interpolated over the disabled period
  126393. */
  126394. disable(): void;
  126395. /**
  126396. * Returns true if sampling is enabled
  126397. */
  126398. get isEnabled(): boolean;
  126399. /**
  126400. * Resets performance monitor
  126401. */
  126402. reset(): void;
  126403. }
  126404. /**
  126405. * RollingAverage
  126406. *
  126407. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  126408. */
  126409. export class RollingAverage {
  126410. /**
  126411. * Current average
  126412. */
  126413. average: number;
  126414. /**
  126415. * Current variance
  126416. */
  126417. variance: number;
  126418. protected _samples: Array<number>;
  126419. protected _sampleCount: number;
  126420. protected _pos: number;
  126421. protected _m2: number;
  126422. /**
  126423. * constructor
  126424. * @param length The number of samples required to saturate the sliding window
  126425. */
  126426. constructor(length: number);
  126427. /**
  126428. * Adds a sample to the sample set
  126429. * @param v The sample value
  126430. */
  126431. add(v: number): void;
  126432. /**
  126433. * Returns previously added values or null if outside of history or outside the sliding window domain
  126434. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  126435. * @return Value previously recorded with add() or null if outside of range
  126436. */
  126437. history(i: number): number;
  126438. /**
  126439. * Returns true if enough samples have been taken to completely fill the sliding window
  126440. * @return true if sample-set saturated
  126441. */
  126442. isSaturated(): boolean;
  126443. /**
  126444. * Resets the rolling average (equivalent to 0 samples taken so far)
  126445. */
  126446. reset(): void;
  126447. /**
  126448. * Wraps a value around the sample range boundaries
  126449. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  126450. * @return Wrapped position in sample range
  126451. */
  126452. protected _wrapPosition(i: number): number;
  126453. }
  126454. }
  126455. declare module BABYLON {
  126456. /**
  126457. * This class is used to track a performance counter which is number based.
  126458. * The user has access to many properties which give statistics of different nature.
  126459. *
  126460. * The implementer can track two kinds of Performance Counter: time and count.
  126461. * 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.
  126462. * 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.
  126463. */
  126464. export class PerfCounter {
  126465. /**
  126466. * Gets or sets a global boolean to turn on and off all the counters
  126467. */
  126468. static Enabled: boolean;
  126469. /**
  126470. * Returns the smallest value ever
  126471. */
  126472. get min(): number;
  126473. /**
  126474. * Returns the biggest value ever
  126475. */
  126476. get max(): number;
  126477. /**
  126478. * Returns the average value since the performance counter is running
  126479. */
  126480. get average(): number;
  126481. /**
  126482. * Returns the average value of the last second the counter was monitored
  126483. */
  126484. get lastSecAverage(): number;
  126485. /**
  126486. * Returns the current value
  126487. */
  126488. get current(): number;
  126489. /**
  126490. * Gets the accumulated total
  126491. */
  126492. get total(): number;
  126493. /**
  126494. * Gets the total value count
  126495. */
  126496. get count(): number;
  126497. /**
  126498. * Creates a new counter
  126499. */
  126500. constructor();
  126501. /**
  126502. * Call this method to start monitoring a new frame.
  126503. * 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.
  126504. */
  126505. fetchNewFrame(): void;
  126506. /**
  126507. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  126508. * @param newCount the count value to add to the monitored count
  126509. * @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.
  126510. */
  126511. addCount(newCount: number, fetchResult: boolean): void;
  126512. /**
  126513. * Start monitoring this performance counter
  126514. */
  126515. beginMonitoring(): void;
  126516. /**
  126517. * Compute the time lapsed since the previous beginMonitoring() call.
  126518. * @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
  126519. */
  126520. endMonitoring(newFrame?: boolean): void;
  126521. private _fetchResult;
  126522. private _startMonitoringTime;
  126523. private _min;
  126524. private _max;
  126525. private _average;
  126526. private _current;
  126527. private _totalValueCount;
  126528. private _totalAccumulated;
  126529. private _lastSecAverage;
  126530. private _lastSecAccumulated;
  126531. private _lastSecTime;
  126532. private _lastSecValueCount;
  126533. }
  126534. }
  126535. declare module BABYLON {
  126536. interface ThinEngine {
  126537. /** @hidden */
  126538. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126539. }
  126540. }
  126541. declare module BABYLON {
  126542. /**
  126543. * Class used to work with sound analyzer using fast fourier transform (FFT)
  126544. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126545. */
  126546. export class Analyser {
  126547. /**
  126548. * Gets or sets the smoothing
  126549. * @ignorenaming
  126550. */
  126551. SMOOTHING: number;
  126552. /**
  126553. * Gets or sets the FFT table size
  126554. * @ignorenaming
  126555. */
  126556. FFT_SIZE: number;
  126557. /**
  126558. * Gets or sets the bar graph amplitude
  126559. * @ignorenaming
  126560. */
  126561. BARGRAPHAMPLITUDE: number;
  126562. /**
  126563. * Gets or sets the position of the debug canvas
  126564. * @ignorenaming
  126565. */
  126566. DEBUGCANVASPOS: {
  126567. x: number;
  126568. y: number;
  126569. };
  126570. /**
  126571. * Gets or sets the debug canvas size
  126572. * @ignorenaming
  126573. */
  126574. DEBUGCANVASSIZE: {
  126575. width: number;
  126576. height: number;
  126577. };
  126578. private _byteFreqs;
  126579. private _byteTime;
  126580. private _floatFreqs;
  126581. private _webAudioAnalyser;
  126582. private _debugCanvas;
  126583. private _debugCanvasContext;
  126584. private _scene;
  126585. private _registerFunc;
  126586. private _audioEngine;
  126587. /**
  126588. * Creates a new analyser
  126589. * @param scene defines hosting scene
  126590. */
  126591. constructor(scene: Scene);
  126592. /**
  126593. * Get the number of data values you will have to play with for the visualization
  126594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  126595. * @returns a number
  126596. */
  126597. getFrequencyBinCount(): number;
  126598. /**
  126599. * Gets the current frequency data as a byte array
  126600. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126601. * @returns a Uint8Array
  126602. */
  126603. getByteFrequencyData(): Uint8Array;
  126604. /**
  126605. * Gets the current waveform as a byte array
  126606. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  126607. * @returns a Uint8Array
  126608. */
  126609. getByteTimeDomainData(): Uint8Array;
  126610. /**
  126611. * Gets the current frequency data as a float array
  126612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126613. * @returns a Float32Array
  126614. */
  126615. getFloatFrequencyData(): Float32Array;
  126616. /**
  126617. * Renders the debug canvas
  126618. */
  126619. drawDebugCanvas(): void;
  126620. /**
  126621. * Stops rendering the debug canvas and removes it
  126622. */
  126623. stopDebugCanvas(): void;
  126624. /**
  126625. * Connects two audio nodes
  126626. * @param inputAudioNode defines first node to connect
  126627. * @param outputAudioNode defines second node to connect
  126628. */
  126629. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  126630. /**
  126631. * Releases all associated resources
  126632. */
  126633. dispose(): void;
  126634. }
  126635. }
  126636. declare module BABYLON {
  126637. /**
  126638. * This represents an audio engine and it is responsible
  126639. * to play, synchronize and analyse sounds throughout the application.
  126640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126641. */
  126642. export interface IAudioEngine extends IDisposable {
  126643. /**
  126644. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126645. */
  126646. readonly canUseWebAudio: boolean;
  126647. /**
  126648. * Gets the current AudioContext if available.
  126649. */
  126650. readonly audioContext: Nullable<AudioContext>;
  126651. /**
  126652. * The master gain node defines the global audio volume of your audio engine.
  126653. */
  126654. readonly masterGain: GainNode;
  126655. /**
  126656. * Gets whether or not mp3 are supported by your browser.
  126657. */
  126658. readonly isMP3supported: boolean;
  126659. /**
  126660. * Gets whether or not ogg are supported by your browser.
  126661. */
  126662. readonly isOGGsupported: boolean;
  126663. /**
  126664. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126665. * @ignoreNaming
  126666. */
  126667. WarnedWebAudioUnsupported: boolean;
  126668. /**
  126669. * Defines if the audio engine relies on a custom unlocked button.
  126670. * In this case, the embedded button will not be displayed.
  126671. */
  126672. useCustomUnlockedButton: boolean;
  126673. /**
  126674. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  126675. */
  126676. readonly unlocked: boolean;
  126677. /**
  126678. * Event raised when audio has been unlocked on the browser.
  126679. */
  126680. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126681. /**
  126682. * Event raised when audio has been locked on the browser.
  126683. */
  126684. onAudioLockedObservable: Observable<IAudioEngine>;
  126685. /**
  126686. * Flags the audio engine in Locked state.
  126687. * This happens due to new browser policies preventing audio to autoplay.
  126688. */
  126689. lock(): void;
  126690. /**
  126691. * Unlocks the audio engine once a user action has been done on the dom.
  126692. * This is helpful to resume play once browser policies have been satisfied.
  126693. */
  126694. unlock(): void;
  126695. /**
  126696. * Gets the global volume sets on the master gain.
  126697. * @returns the global volume if set or -1 otherwise
  126698. */
  126699. getGlobalVolume(): number;
  126700. /**
  126701. * Sets the global volume of your experience (sets on the master gain).
  126702. * @param newVolume Defines the new global volume of the application
  126703. */
  126704. setGlobalVolume(newVolume: number): void;
  126705. /**
  126706. * Connect the audio engine to an audio analyser allowing some amazing
  126707. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126709. * @param analyser The analyser to connect to the engine
  126710. */
  126711. connectToAnalyser(analyser: Analyser): void;
  126712. }
  126713. }
  126714. declare module BABYLON {
  126715. /**
  126716. * Defines the interface used by display changed events
  126717. */
  126718. export interface IDisplayChangedEventArgs {
  126719. /** Gets the vrDisplay object (if any) */
  126720. vrDisplay: Nullable<any>;
  126721. /** Gets a boolean indicating if webVR is supported */
  126722. vrSupported: boolean;
  126723. }
  126724. /**
  126725. * Defines the interface used by objects containing a viewport (like a camera)
  126726. */
  126727. interface IViewportOwnerLike {
  126728. /**
  126729. * Gets or sets the viewport
  126730. */
  126731. viewport: IViewportLike;
  126732. }
  126733. /**
  126734. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  126735. */
  126736. export class Engine extends ThinEngine {
  126737. /** Defines that alpha blending is disabled */
  126738. static readonly ALPHA_DISABLE: number;
  126739. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  126740. static readonly ALPHA_ADD: number;
  126741. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  126742. static readonly ALPHA_COMBINE: number;
  126743. /** Defines that alpha blending to DEST - SRC * DEST */
  126744. static readonly ALPHA_SUBTRACT: number;
  126745. /** Defines that alpha blending to SRC * DEST */
  126746. static readonly ALPHA_MULTIPLY: number;
  126747. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  126748. static readonly ALPHA_MAXIMIZED: number;
  126749. /** Defines that alpha blending to SRC + DEST */
  126750. static readonly ALPHA_ONEONE: number;
  126751. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  126752. static readonly ALPHA_PREMULTIPLIED: number;
  126753. /**
  126754. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  126755. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  126756. */
  126757. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  126758. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  126759. static readonly ALPHA_INTERPOLATE: number;
  126760. /**
  126761. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  126762. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  126763. */
  126764. static readonly ALPHA_SCREENMODE: number;
  126765. /** Defines that the ressource is not delayed*/
  126766. static readonly DELAYLOADSTATE_NONE: number;
  126767. /** Defines that the ressource was successfully delay loaded */
  126768. static readonly DELAYLOADSTATE_LOADED: number;
  126769. /** Defines that the ressource is currently delay loading */
  126770. static readonly DELAYLOADSTATE_LOADING: number;
  126771. /** Defines that the ressource is delayed and has not started loading */
  126772. static readonly DELAYLOADSTATE_NOTLOADED: number;
  126773. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  126774. static readonly NEVER: number;
  126775. /** 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 */
  126776. static readonly ALWAYS: number;
  126777. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  126778. static readonly LESS: number;
  126779. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  126780. static readonly EQUAL: number;
  126781. /** 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 */
  126782. static readonly LEQUAL: number;
  126783. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  126784. static readonly GREATER: number;
  126785. /** 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 */
  126786. static readonly GEQUAL: number;
  126787. /** 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 */
  126788. static readonly NOTEQUAL: number;
  126789. /** Passed to stencilOperation to specify that stencil value must be kept */
  126790. static readonly KEEP: number;
  126791. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126792. static readonly REPLACE: number;
  126793. /** Passed to stencilOperation to specify that stencil value must be incremented */
  126794. static readonly INCR: number;
  126795. /** Passed to stencilOperation to specify that stencil value must be decremented */
  126796. static readonly DECR: number;
  126797. /** Passed to stencilOperation to specify that stencil value must be inverted */
  126798. static readonly INVERT: number;
  126799. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  126800. static readonly INCR_WRAP: number;
  126801. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  126802. static readonly DECR_WRAP: number;
  126803. /** Texture is not repeating outside of 0..1 UVs */
  126804. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  126805. /** Texture is repeating outside of 0..1 UVs */
  126806. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  126807. /** Texture is repeating and mirrored */
  126808. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  126809. /** ALPHA */
  126810. static readonly TEXTUREFORMAT_ALPHA: number;
  126811. /** LUMINANCE */
  126812. static readonly TEXTUREFORMAT_LUMINANCE: number;
  126813. /** LUMINANCE_ALPHA */
  126814. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  126815. /** RGB */
  126816. static readonly TEXTUREFORMAT_RGB: number;
  126817. /** RGBA */
  126818. static readonly TEXTUREFORMAT_RGBA: number;
  126819. /** RED */
  126820. static readonly TEXTUREFORMAT_RED: number;
  126821. /** RED (2nd reference) */
  126822. static readonly TEXTUREFORMAT_R: number;
  126823. /** RG */
  126824. static readonly TEXTUREFORMAT_RG: number;
  126825. /** RED_INTEGER */
  126826. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  126827. /** RED_INTEGER (2nd reference) */
  126828. static readonly TEXTUREFORMAT_R_INTEGER: number;
  126829. /** RG_INTEGER */
  126830. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  126831. /** RGB_INTEGER */
  126832. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  126833. /** RGBA_INTEGER */
  126834. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  126835. /** UNSIGNED_BYTE */
  126836. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  126837. /** UNSIGNED_BYTE (2nd reference) */
  126838. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  126839. /** FLOAT */
  126840. static readonly TEXTURETYPE_FLOAT: number;
  126841. /** HALF_FLOAT */
  126842. static readonly TEXTURETYPE_HALF_FLOAT: number;
  126843. /** BYTE */
  126844. static readonly TEXTURETYPE_BYTE: number;
  126845. /** SHORT */
  126846. static readonly TEXTURETYPE_SHORT: number;
  126847. /** UNSIGNED_SHORT */
  126848. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  126849. /** INT */
  126850. static readonly TEXTURETYPE_INT: number;
  126851. /** UNSIGNED_INT */
  126852. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  126853. /** UNSIGNED_SHORT_4_4_4_4 */
  126854. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  126855. /** UNSIGNED_SHORT_5_5_5_1 */
  126856. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  126857. /** UNSIGNED_SHORT_5_6_5 */
  126858. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  126859. /** UNSIGNED_INT_2_10_10_10_REV */
  126860. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  126861. /** UNSIGNED_INT_24_8 */
  126862. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  126863. /** UNSIGNED_INT_10F_11F_11F_REV */
  126864. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  126865. /** UNSIGNED_INT_5_9_9_9_REV */
  126866. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  126867. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  126868. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126869. /** nearest is mag = nearest and min = nearest and mip = none */
  126870. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  126871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126872. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  126873. /** Trilinear is mag = linear and min = linear and mip = linear */
  126874. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  126875. /** nearest is mag = nearest and min = nearest and mip = linear */
  126876. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  126877. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126878. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  126879. /** Trilinear is mag = linear and min = linear and mip = linear */
  126880. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  126881. /** mag = nearest and min = nearest and mip = nearest */
  126882. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  126883. /** mag = nearest and min = linear and mip = nearest */
  126884. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  126885. /** mag = nearest and min = linear and mip = linear */
  126886. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  126887. /** mag = nearest and min = linear and mip = none */
  126888. static readonly TEXTURE_NEAREST_LINEAR: number;
  126889. /** mag = nearest and min = nearest and mip = none */
  126890. static readonly TEXTURE_NEAREST_NEAREST: number;
  126891. /** mag = linear and min = nearest and mip = nearest */
  126892. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  126893. /** mag = linear and min = nearest and mip = linear */
  126894. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  126895. /** mag = linear and min = linear and mip = none */
  126896. static readonly TEXTURE_LINEAR_LINEAR: number;
  126897. /** mag = linear and min = nearest and mip = none */
  126898. static readonly TEXTURE_LINEAR_NEAREST: number;
  126899. /** Explicit coordinates mode */
  126900. static readonly TEXTURE_EXPLICIT_MODE: number;
  126901. /** Spherical coordinates mode */
  126902. static readonly TEXTURE_SPHERICAL_MODE: number;
  126903. /** Planar coordinates mode */
  126904. static readonly TEXTURE_PLANAR_MODE: number;
  126905. /** Cubic coordinates mode */
  126906. static readonly TEXTURE_CUBIC_MODE: number;
  126907. /** Projection coordinates mode */
  126908. static readonly TEXTURE_PROJECTION_MODE: number;
  126909. /** Skybox coordinates mode */
  126910. static readonly TEXTURE_SKYBOX_MODE: number;
  126911. /** Inverse Cubic coordinates mode */
  126912. static readonly TEXTURE_INVCUBIC_MODE: number;
  126913. /** Equirectangular coordinates mode */
  126914. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  126915. /** Equirectangular Fixed coordinates mode */
  126916. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  126917. /** Equirectangular Fixed Mirrored coordinates mode */
  126918. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  126919. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  126920. static readonly SCALEMODE_FLOOR: number;
  126921. /** Defines that texture rescaling will look for the nearest power of 2 size */
  126922. static readonly SCALEMODE_NEAREST: number;
  126923. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  126924. static readonly SCALEMODE_CEILING: number;
  126925. /**
  126926. * Returns the current npm package of the sdk
  126927. */
  126928. static get NpmPackage(): string;
  126929. /**
  126930. * Returns the current version of the framework
  126931. */
  126932. static get Version(): string;
  126933. /** Gets the list of created engines */
  126934. static get Instances(): Engine[];
  126935. /**
  126936. * Gets the latest created engine
  126937. */
  126938. static get LastCreatedEngine(): Nullable<Engine>;
  126939. /**
  126940. * Gets the latest created scene
  126941. */
  126942. static get LastCreatedScene(): Nullable<Scene>;
  126943. /**
  126944. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  126945. * @param flag defines which part of the materials must be marked as dirty
  126946. * @param predicate defines a predicate used to filter which materials should be affected
  126947. */
  126948. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126949. /**
  126950. * Method called to create the default loading screen.
  126951. * This can be overriden in your own app.
  126952. * @param canvas The rendering canvas element
  126953. * @returns The loading screen
  126954. */
  126955. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  126956. /**
  126957. * Method called to create the default rescale post process on each engine.
  126958. */
  126959. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  126960. /**
  126961. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  126962. **/
  126963. enableOfflineSupport: boolean;
  126964. /**
  126965. * 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)
  126966. **/
  126967. disableManifestCheck: boolean;
  126968. /**
  126969. * Gets the list of created scenes
  126970. */
  126971. scenes: Scene[];
  126972. /**
  126973. * Event raised when a new scene is created
  126974. */
  126975. onNewSceneAddedObservable: Observable<Scene>;
  126976. /**
  126977. * Gets the list of created postprocesses
  126978. */
  126979. postProcesses: PostProcess[];
  126980. /**
  126981. * Gets a boolean indicating if the pointer is currently locked
  126982. */
  126983. isPointerLock: boolean;
  126984. /**
  126985. * Observable event triggered each time the rendering canvas is resized
  126986. */
  126987. onResizeObservable: Observable<Engine>;
  126988. /**
  126989. * Observable event triggered each time the canvas loses focus
  126990. */
  126991. onCanvasBlurObservable: Observable<Engine>;
  126992. /**
  126993. * Observable event triggered each time the canvas gains focus
  126994. */
  126995. onCanvasFocusObservable: Observable<Engine>;
  126996. /**
  126997. * Observable event triggered each time the canvas receives pointerout event
  126998. */
  126999. onCanvasPointerOutObservable: Observable<PointerEvent>;
  127000. /**
  127001. * Observable raised when the engine begins a new frame
  127002. */
  127003. onBeginFrameObservable: Observable<Engine>;
  127004. /**
  127005. * If set, will be used to request the next animation frame for the render loop
  127006. */
  127007. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  127008. /**
  127009. * Observable raised when the engine ends the current frame
  127010. */
  127011. onEndFrameObservable: Observable<Engine>;
  127012. /**
  127013. * Observable raised when the engine is about to compile a shader
  127014. */
  127015. onBeforeShaderCompilationObservable: Observable<Engine>;
  127016. /**
  127017. * Observable raised when the engine has jsut compiled a shader
  127018. */
  127019. onAfterShaderCompilationObservable: Observable<Engine>;
  127020. /**
  127021. * Gets the audio engine
  127022. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127023. * @ignorenaming
  127024. */
  127025. static audioEngine: IAudioEngine;
  127026. /**
  127027. * Default AudioEngine factory responsible of creating the Audio Engine.
  127028. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  127029. */
  127030. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  127031. /**
  127032. * Default offline support factory responsible of creating a tool used to store data locally.
  127033. * By default, this will create a Database object if the workload has been embedded.
  127034. */
  127035. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  127036. private _loadingScreen;
  127037. private _pointerLockRequested;
  127038. private _rescalePostProcess;
  127039. protected _deterministicLockstep: boolean;
  127040. protected _lockstepMaxSteps: number;
  127041. protected _timeStep: number;
  127042. protected get _supportsHardwareTextureRescaling(): boolean;
  127043. private _fps;
  127044. private _deltaTime;
  127045. /** @hidden */
  127046. _drawCalls: PerfCounter;
  127047. /** 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 */
  127048. canvasTabIndex: number;
  127049. /**
  127050. * Turn this value on if you want to pause FPS computation when in background
  127051. */
  127052. disablePerformanceMonitorInBackground: boolean;
  127053. private _performanceMonitor;
  127054. /**
  127055. * Gets the performance monitor attached to this engine
  127056. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127057. */
  127058. get performanceMonitor(): PerformanceMonitor;
  127059. private _onFocus;
  127060. private _onBlur;
  127061. private _onCanvasPointerOut;
  127062. private _onCanvasBlur;
  127063. private _onCanvasFocus;
  127064. private _onFullscreenChange;
  127065. private _onPointerLockChange;
  127066. /**
  127067. * Gets the HTML element used to attach event listeners
  127068. * @returns a HTML element
  127069. */
  127070. getInputElement(): Nullable<HTMLElement>;
  127071. /**
  127072. * Creates a new engine
  127073. * @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
  127074. * @param antialias defines enable antialiasing (default: false)
  127075. * @param options defines further options to be sent to the getContext() function
  127076. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  127077. */
  127078. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  127079. /**
  127080. * Shared initialization across engines types.
  127081. * @param canvas The canvas associated with this instance of the engine.
  127082. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  127083. * @param audioEngine Defines if an audio engine should be created by default
  127084. */
  127085. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  127086. /**
  127087. * Gets current aspect ratio
  127088. * @param viewportOwner defines the camera to use to get the aspect ratio
  127089. * @param useScreen defines if screen size must be used (or the current render target if any)
  127090. * @returns a number defining the aspect ratio
  127091. */
  127092. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  127093. /**
  127094. * Gets current screen aspect ratio
  127095. * @returns a number defining the aspect ratio
  127096. */
  127097. getScreenAspectRatio(): number;
  127098. /**
  127099. * Gets the client rect of the HTML canvas attached with the current webGL context
  127100. * @returns a client rectanglee
  127101. */
  127102. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  127103. /**
  127104. * Gets the client rect of the HTML element used for events
  127105. * @returns a client rectanglee
  127106. */
  127107. getInputElementClientRect(): Nullable<ClientRect>;
  127108. /**
  127109. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127110. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127111. * @returns true if engine is in deterministic lock step mode
  127112. */
  127113. isDeterministicLockStep(): boolean;
  127114. /**
  127115. * Gets the max steps when engine is running in deterministic lock step
  127116. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127117. * @returns the max steps
  127118. */
  127119. getLockstepMaxSteps(): number;
  127120. /**
  127121. * Returns the time in ms between steps when using deterministic lock step.
  127122. * @returns time step in (ms)
  127123. */
  127124. getTimeStep(): number;
  127125. /**
  127126. * Force the mipmap generation for the given render target texture
  127127. * @param texture defines the render target texture to use
  127128. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  127129. */
  127130. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  127131. /** States */
  127132. /**
  127133. * Set various states to the webGL context
  127134. * @param culling defines backface culling state
  127135. * @param zOffset defines the value to apply to zOffset (0 by default)
  127136. * @param force defines if states must be applied even if cache is up to date
  127137. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127138. */
  127139. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127140. /**
  127141. * Set the z offset to apply to current rendering
  127142. * @param value defines the offset to apply
  127143. */
  127144. setZOffset(value: number): void;
  127145. /**
  127146. * Gets the current value of the zOffset
  127147. * @returns the current zOffset state
  127148. */
  127149. getZOffset(): number;
  127150. /**
  127151. * Gets a boolean indicating if depth testing is enabled
  127152. * @returns the current state
  127153. */
  127154. getDepthBuffer(): boolean;
  127155. /**
  127156. * Enable or disable depth buffering
  127157. * @param enable defines the state to set
  127158. */
  127159. setDepthBuffer(enable: boolean): void;
  127160. /**
  127161. * Gets a boolean indicating if depth writing is enabled
  127162. * @returns the current depth writing state
  127163. */
  127164. getDepthWrite(): boolean;
  127165. /**
  127166. * Enable or disable depth writing
  127167. * @param enable defines the state to set
  127168. */
  127169. setDepthWrite(enable: boolean): void;
  127170. /**
  127171. * Gets a boolean indicating if stencil buffer is enabled
  127172. * @returns the current stencil buffer state
  127173. */
  127174. getStencilBuffer(): boolean;
  127175. /**
  127176. * Enable or disable the stencil buffer
  127177. * @param enable defines if the stencil buffer must be enabled or disabled
  127178. */
  127179. setStencilBuffer(enable: boolean): void;
  127180. /**
  127181. * Gets the current stencil mask
  127182. * @returns a number defining the new stencil mask to use
  127183. */
  127184. getStencilMask(): number;
  127185. /**
  127186. * Sets the current stencil mask
  127187. * @param mask defines the new stencil mask to use
  127188. */
  127189. setStencilMask(mask: number): void;
  127190. /**
  127191. * Gets the current stencil function
  127192. * @returns a number defining the stencil function to use
  127193. */
  127194. getStencilFunction(): number;
  127195. /**
  127196. * Gets the current stencil reference value
  127197. * @returns a number defining the stencil reference value to use
  127198. */
  127199. getStencilFunctionReference(): number;
  127200. /**
  127201. * Gets the current stencil mask
  127202. * @returns a number defining the stencil mask to use
  127203. */
  127204. getStencilFunctionMask(): number;
  127205. /**
  127206. * Sets the current stencil function
  127207. * @param stencilFunc defines the new stencil function to use
  127208. */
  127209. setStencilFunction(stencilFunc: number): void;
  127210. /**
  127211. * Sets the current stencil reference
  127212. * @param reference defines the new stencil reference to use
  127213. */
  127214. setStencilFunctionReference(reference: number): void;
  127215. /**
  127216. * Sets the current stencil mask
  127217. * @param mask defines the new stencil mask to use
  127218. */
  127219. setStencilFunctionMask(mask: number): void;
  127220. /**
  127221. * Gets the current stencil operation when stencil fails
  127222. * @returns a number defining stencil operation to use when stencil fails
  127223. */
  127224. getStencilOperationFail(): number;
  127225. /**
  127226. * Gets the current stencil operation when depth fails
  127227. * @returns a number defining stencil operation to use when depth fails
  127228. */
  127229. getStencilOperationDepthFail(): number;
  127230. /**
  127231. * Gets the current stencil operation when stencil passes
  127232. * @returns a number defining stencil operation to use when stencil passes
  127233. */
  127234. getStencilOperationPass(): number;
  127235. /**
  127236. * Sets the stencil operation to use when stencil fails
  127237. * @param operation defines the stencil operation to use when stencil fails
  127238. */
  127239. setStencilOperationFail(operation: number): void;
  127240. /**
  127241. * Sets the stencil operation to use when depth fails
  127242. * @param operation defines the stencil operation to use when depth fails
  127243. */
  127244. setStencilOperationDepthFail(operation: number): void;
  127245. /**
  127246. * Sets the stencil operation to use when stencil passes
  127247. * @param operation defines the stencil operation to use when stencil passes
  127248. */
  127249. setStencilOperationPass(operation: number): void;
  127250. /**
  127251. * Sets a boolean indicating if the dithering state is enabled or disabled
  127252. * @param value defines the dithering state
  127253. */
  127254. setDitheringState(value: boolean): void;
  127255. /**
  127256. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  127257. * @param value defines the rasterizer state
  127258. */
  127259. setRasterizerState(value: boolean): void;
  127260. /**
  127261. * Gets the current depth function
  127262. * @returns a number defining the depth function
  127263. */
  127264. getDepthFunction(): Nullable<number>;
  127265. /**
  127266. * Sets the current depth function
  127267. * @param depthFunc defines the function to use
  127268. */
  127269. setDepthFunction(depthFunc: number): void;
  127270. /**
  127271. * Sets the current depth function to GREATER
  127272. */
  127273. setDepthFunctionToGreater(): void;
  127274. /**
  127275. * Sets the current depth function to GEQUAL
  127276. */
  127277. setDepthFunctionToGreaterOrEqual(): void;
  127278. /**
  127279. * Sets the current depth function to LESS
  127280. */
  127281. setDepthFunctionToLess(): void;
  127282. /**
  127283. * Sets the current depth function to LEQUAL
  127284. */
  127285. setDepthFunctionToLessOrEqual(): void;
  127286. private _cachedStencilBuffer;
  127287. private _cachedStencilFunction;
  127288. private _cachedStencilMask;
  127289. private _cachedStencilOperationPass;
  127290. private _cachedStencilOperationFail;
  127291. private _cachedStencilOperationDepthFail;
  127292. private _cachedStencilReference;
  127293. /**
  127294. * Caches the the state of the stencil buffer
  127295. */
  127296. cacheStencilState(): void;
  127297. /**
  127298. * Restores the state of the stencil buffer
  127299. */
  127300. restoreStencilState(): void;
  127301. /**
  127302. * Directly set the WebGL Viewport
  127303. * @param x defines the x coordinate of the viewport (in screen space)
  127304. * @param y defines the y coordinate of the viewport (in screen space)
  127305. * @param width defines the width of the viewport (in screen space)
  127306. * @param height defines the height of the viewport (in screen space)
  127307. * @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
  127308. */
  127309. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  127310. /**
  127311. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  127312. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  127313. * @param y defines the y-coordinate of the corner of the clear rectangle
  127314. * @param width defines the width of the clear rectangle
  127315. * @param height defines the height of the clear rectangle
  127316. * @param clearColor defines the clear color
  127317. */
  127318. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  127319. /**
  127320. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  127321. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  127322. * @param y defines the y-coordinate of the corner of the clear rectangle
  127323. * @param width defines the width of the clear rectangle
  127324. * @param height defines the height of the clear rectangle
  127325. */
  127326. enableScissor(x: number, y: number, width: number, height: number): void;
  127327. /**
  127328. * Disable previously set scissor test rectangle
  127329. */
  127330. disableScissor(): void;
  127331. protected _reportDrawCall(): void;
  127332. /**
  127333. * Initializes a webVR display and starts listening to display change events
  127334. * The onVRDisplayChangedObservable will be notified upon these changes
  127335. * @returns The onVRDisplayChangedObservable
  127336. */
  127337. initWebVR(): Observable<IDisplayChangedEventArgs>;
  127338. /** @hidden */
  127339. _prepareVRComponent(): void;
  127340. /** @hidden */
  127341. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  127342. /** @hidden */
  127343. _submitVRFrame(): void;
  127344. /**
  127345. * Call this function to leave webVR mode
  127346. * Will do nothing if webVR is not supported or if there is no webVR device
  127347. * @see https://doc.babylonjs.com/how_to/webvr_camera
  127348. */
  127349. disableVR(): void;
  127350. /**
  127351. * Gets a boolean indicating that the system is in VR mode and is presenting
  127352. * @returns true if VR mode is engaged
  127353. */
  127354. isVRPresenting(): boolean;
  127355. /** @hidden */
  127356. _requestVRFrame(): void;
  127357. /** @hidden */
  127358. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  127359. /**
  127360. * Gets the source code of the vertex shader associated with a specific webGL program
  127361. * @param program defines the program to use
  127362. * @returns a string containing the source code of the vertex shader associated with the program
  127363. */
  127364. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  127365. /**
  127366. * Gets the source code of the fragment shader associated with a specific webGL program
  127367. * @param program defines the program to use
  127368. * @returns a string containing the source code of the fragment shader associated with the program
  127369. */
  127370. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  127371. /**
  127372. * Sets a depth stencil texture from a render target to the according uniform.
  127373. * @param channel The texture channel
  127374. * @param uniform The uniform to set
  127375. * @param texture The render target texture containing the depth stencil texture to apply
  127376. * @param name The texture name
  127377. */
  127378. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  127379. /**
  127380. * Sets a texture to the webGL context from a postprocess
  127381. * @param channel defines the channel to use
  127382. * @param postProcess defines the source postprocess
  127383. * @param name name of the channel
  127384. */
  127385. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  127386. /**
  127387. * Binds the output of the passed in post process to the texture channel specified
  127388. * @param channel The channel the texture should be bound to
  127389. * @param postProcess The post process which's output should be bound
  127390. * @param name name of the channel
  127391. */
  127392. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  127393. protected _rebuildBuffers(): void;
  127394. /** @hidden */
  127395. _renderFrame(): void;
  127396. _renderLoop(): void;
  127397. /** @hidden */
  127398. _renderViews(): boolean;
  127399. /**
  127400. * Toggle full screen mode
  127401. * @param requestPointerLock defines if a pointer lock should be requested from the user
  127402. */
  127403. switchFullscreen(requestPointerLock: boolean): void;
  127404. /**
  127405. * Enters full screen mode
  127406. * @param requestPointerLock defines if a pointer lock should be requested from the user
  127407. */
  127408. enterFullscreen(requestPointerLock: boolean): void;
  127409. /**
  127410. * Exits full screen mode
  127411. */
  127412. exitFullscreen(): void;
  127413. /**
  127414. * Enters Pointerlock mode
  127415. */
  127416. enterPointerlock(): void;
  127417. /**
  127418. * Exits Pointerlock mode
  127419. */
  127420. exitPointerlock(): void;
  127421. /**
  127422. * Begin a new frame
  127423. */
  127424. beginFrame(): void;
  127425. /**
  127426. * End the current frame
  127427. */
  127428. endFrame(): void;
  127429. /**
  127430. * Resize the view according to the canvas' size
  127431. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127432. */
  127433. resize(forceSetSize?: boolean): void;
  127434. /**
  127435. * Force a specific size of the canvas
  127436. * @param width defines the new canvas' width
  127437. * @param height defines the new canvas' height
  127438. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127439. * @returns true if the size was changed
  127440. */
  127441. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  127442. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  127443. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127444. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127445. _releaseTexture(texture: InternalTexture): void;
  127446. /**
  127447. * @hidden
  127448. * Rescales a texture
  127449. * @param source input texutre
  127450. * @param destination destination texture
  127451. * @param scene scene to use to render the resize
  127452. * @param internalFormat format to use when resizing
  127453. * @param onComplete callback to be called when resize has completed
  127454. */
  127455. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  127456. /**
  127457. * Gets the current framerate
  127458. * @returns a number representing the framerate
  127459. */
  127460. getFps(): number;
  127461. /**
  127462. * Gets the time spent between current and previous frame
  127463. * @returns a number representing the delta time in ms
  127464. */
  127465. getDeltaTime(): number;
  127466. private _measureFps;
  127467. /** @hidden */
  127468. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  127469. /**
  127470. * Updates the sample count of a render target texture
  127471. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127472. * @param texture defines the texture to update
  127473. * @param samples defines the sample count to set
  127474. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127475. */
  127476. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  127477. /**
  127478. * Updates a depth texture Comparison Mode and Function.
  127479. * If the comparison Function is equal to 0, the mode will be set to none.
  127480. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  127481. * @param texture The texture to set the comparison function for
  127482. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  127483. */
  127484. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  127485. /**
  127486. * Creates a webGL buffer to use with instanciation
  127487. * @param capacity defines the size of the buffer
  127488. * @returns the webGL buffer
  127489. */
  127490. createInstancesBuffer(capacity: number): DataBuffer;
  127491. /**
  127492. * Delete a webGL buffer used with instanciation
  127493. * @param buffer defines the webGL buffer to delete
  127494. */
  127495. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  127496. private _clientWaitAsync;
  127497. /** @hidden */
  127498. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  127499. dispose(): void;
  127500. private _disableTouchAction;
  127501. /**
  127502. * Display the loading screen
  127503. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127504. */
  127505. displayLoadingUI(): void;
  127506. /**
  127507. * Hide the loading screen
  127508. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127509. */
  127510. hideLoadingUI(): void;
  127511. /**
  127512. * Gets the current loading screen object
  127513. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127514. */
  127515. get loadingScreen(): ILoadingScreen;
  127516. /**
  127517. * Sets the current loading screen object
  127518. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127519. */
  127520. set loadingScreen(loadingScreen: ILoadingScreen);
  127521. /**
  127522. * Sets the current loading screen text
  127523. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127524. */
  127525. set loadingUIText(text: string);
  127526. /**
  127527. * Sets the current loading screen background color
  127528. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127529. */
  127530. set loadingUIBackgroundColor(color: string);
  127531. /** Pointerlock and fullscreen */
  127532. /**
  127533. * Ask the browser to promote the current element to pointerlock mode
  127534. * @param element defines the DOM element to promote
  127535. */
  127536. static _RequestPointerlock(element: HTMLElement): void;
  127537. /**
  127538. * Asks the browser to exit pointerlock mode
  127539. */
  127540. static _ExitPointerlock(): void;
  127541. /**
  127542. * Ask the browser to promote the current element to fullscreen rendering mode
  127543. * @param element defines the DOM element to promote
  127544. */
  127545. static _RequestFullscreen(element: HTMLElement): void;
  127546. /**
  127547. * Asks the browser to exit fullscreen mode
  127548. */
  127549. static _ExitFullscreen(): void;
  127550. }
  127551. }
  127552. declare module BABYLON {
  127553. /**
  127554. * The engine store class is responsible to hold all the instances of Engine and Scene created
  127555. * during the life time of the application.
  127556. */
  127557. export class EngineStore {
  127558. /** Gets the list of created engines */
  127559. static Instances: Engine[];
  127560. /** @hidden */
  127561. static _LastCreatedScene: Nullable<Scene>;
  127562. /**
  127563. * Gets the latest created engine
  127564. */
  127565. static get LastCreatedEngine(): Nullable<Engine>;
  127566. /**
  127567. * Gets the latest created scene
  127568. */
  127569. static get LastCreatedScene(): Nullable<Scene>;
  127570. /**
  127571. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127572. * @ignorenaming
  127573. */
  127574. static UseFallbackTexture: boolean;
  127575. /**
  127576. * Texture content used if a texture cannot loaded
  127577. * @ignorenaming
  127578. */
  127579. static FallbackTexture: string;
  127580. }
  127581. }
  127582. declare module BABYLON {
  127583. /**
  127584. * Helper class that provides a small promise polyfill
  127585. */
  127586. export class PromisePolyfill {
  127587. /**
  127588. * Static function used to check if the polyfill is required
  127589. * If this is the case then the function will inject the polyfill to window.Promise
  127590. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  127591. */
  127592. static Apply(force?: boolean): void;
  127593. }
  127594. }
  127595. declare module BABYLON {
  127596. /**
  127597. * Interface for screenshot methods with describe argument called `size` as object with options
  127598. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  127599. */
  127600. export interface IScreenshotSize {
  127601. /**
  127602. * number in pixels for canvas height
  127603. */
  127604. height?: number;
  127605. /**
  127606. * multiplier allowing render at a higher or lower resolution
  127607. * If value is defined then height and width will be ignored and taken from camera
  127608. */
  127609. precision?: number;
  127610. /**
  127611. * number in pixels for canvas width
  127612. */
  127613. width?: number;
  127614. }
  127615. }
  127616. declare module BABYLON {
  127617. interface IColor4Like {
  127618. r: float;
  127619. g: float;
  127620. b: float;
  127621. a: float;
  127622. }
  127623. /**
  127624. * Class containing a set of static utilities functions
  127625. */
  127626. export class Tools {
  127627. /**
  127628. * Gets or sets the base URL to use to load assets
  127629. */
  127630. static get BaseUrl(): string;
  127631. static set BaseUrl(value: string);
  127632. /**
  127633. * Enable/Disable Custom HTTP Request Headers globally.
  127634. * default = false
  127635. * @see CustomRequestHeaders
  127636. */
  127637. static UseCustomRequestHeaders: boolean;
  127638. /**
  127639. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  127640. * i.e. when loading files, where the server/service expects an Authorization header
  127641. */
  127642. static CustomRequestHeaders: {
  127643. [key: string]: string;
  127644. };
  127645. /**
  127646. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  127647. */
  127648. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  127649. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  127650. /**
  127651. * Default behaviour for cors in the application.
  127652. * It can be a string if the expected behavior is identical in the entire app.
  127653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  127654. */
  127655. static get CorsBehavior(): string | ((url: string | string[]) => string);
  127656. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  127657. /**
  127658. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127659. * @ignorenaming
  127660. */
  127661. static get UseFallbackTexture(): boolean;
  127662. static set UseFallbackTexture(value: boolean);
  127663. /**
  127664. * Use this object to register external classes like custom textures or material
  127665. * to allow the laoders to instantiate them
  127666. */
  127667. static get RegisteredExternalClasses(): {
  127668. [key: string]: Object;
  127669. };
  127670. static set RegisteredExternalClasses(classes: {
  127671. [key: string]: Object;
  127672. });
  127673. /**
  127674. * Texture content used if a texture cannot loaded
  127675. * @ignorenaming
  127676. */
  127677. static get fallbackTexture(): string;
  127678. static set fallbackTexture(value: string);
  127679. /**
  127680. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  127681. * @param u defines the coordinate on X axis
  127682. * @param v defines the coordinate on Y axis
  127683. * @param width defines the width of the source data
  127684. * @param height defines the height of the source data
  127685. * @param pixels defines the source byte array
  127686. * @param color defines the output color
  127687. */
  127688. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  127689. /**
  127690. * Interpolates between a and b via alpha
  127691. * @param a The lower value (returned when alpha = 0)
  127692. * @param b The upper value (returned when alpha = 1)
  127693. * @param alpha The interpolation-factor
  127694. * @return The mixed value
  127695. */
  127696. static Mix(a: number, b: number, alpha: number): number;
  127697. /**
  127698. * Tries to instantiate a new object from a given class name
  127699. * @param className defines the class name to instantiate
  127700. * @returns the new object or null if the system was not able to do the instantiation
  127701. */
  127702. static Instantiate(className: string): any;
  127703. /**
  127704. * Provides a slice function that will work even on IE
  127705. * @param data defines the array to slice
  127706. * @param start defines the start of the data (optional)
  127707. * @param end defines the end of the data (optional)
  127708. * @returns the new sliced array
  127709. */
  127710. static Slice<T>(data: T, start?: number, end?: number): T;
  127711. /**
  127712. * Provides a slice function that will work even on IE
  127713. * The difference between this and Slice is that this will force-convert to array
  127714. * @param data defines the array to slice
  127715. * @param start defines the start of the data (optional)
  127716. * @param end defines the end of the data (optional)
  127717. * @returns the new sliced array
  127718. */
  127719. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  127720. /**
  127721. * Polyfill for setImmediate
  127722. * @param action defines the action to execute after the current execution block
  127723. */
  127724. static SetImmediate(action: () => void): void;
  127725. /**
  127726. * Function indicating if a number is an exponent of 2
  127727. * @param value defines the value to test
  127728. * @returns true if the value is an exponent of 2
  127729. */
  127730. static IsExponentOfTwo(value: number): boolean;
  127731. private static _tmpFloatArray;
  127732. /**
  127733. * Returns the nearest 32-bit single precision float representation of a Number
  127734. * @param value A Number. If the parameter is of a different type, it will get converted
  127735. * to a number or to NaN if it cannot be converted
  127736. * @returns number
  127737. */
  127738. static FloatRound(value: number): number;
  127739. /**
  127740. * Extracts the filename from a path
  127741. * @param path defines the path to use
  127742. * @returns the filename
  127743. */
  127744. static GetFilename(path: string): string;
  127745. /**
  127746. * Extracts the "folder" part of a path (everything before the filename).
  127747. * @param uri The URI to extract the info from
  127748. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  127749. * @returns The "folder" part of the path
  127750. */
  127751. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  127752. /**
  127753. * Extracts text content from a DOM element hierarchy
  127754. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  127755. */
  127756. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  127757. /**
  127758. * Convert an angle in radians to degrees
  127759. * @param angle defines the angle to convert
  127760. * @returns the angle in degrees
  127761. */
  127762. static ToDegrees(angle: number): number;
  127763. /**
  127764. * Convert an angle in degrees to radians
  127765. * @param angle defines the angle to convert
  127766. * @returns the angle in radians
  127767. */
  127768. static ToRadians(angle: number): number;
  127769. /**
  127770. * Returns an array if obj is not an array
  127771. * @param obj defines the object to evaluate as an array
  127772. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  127773. * @returns either obj directly if obj is an array or a new array containing obj
  127774. */
  127775. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  127776. /**
  127777. * Gets the pointer prefix to use
  127778. * @param engine defines the engine we are finding the prefix for
  127779. * @returns "pointer" if touch is enabled. Else returns "mouse"
  127780. */
  127781. static GetPointerPrefix(engine: Engine): string;
  127782. /**
  127783. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  127784. * @param url define the url we are trying
  127785. * @param element define the dom element where to configure the cors policy
  127786. */
  127787. static SetCorsBehavior(url: string | string[], element: {
  127788. crossOrigin: string | null;
  127789. }): void;
  127790. /**
  127791. * Removes unwanted characters from an url
  127792. * @param url defines the url to clean
  127793. * @returns the cleaned url
  127794. */
  127795. static CleanUrl(url: string): string;
  127796. /**
  127797. * Gets or sets a function used to pre-process url before using them to load assets
  127798. */
  127799. static get PreprocessUrl(): (url: string) => string;
  127800. static set PreprocessUrl(processor: (url: string) => string);
  127801. /**
  127802. * Loads an image as an HTMLImageElement.
  127803. * @param input url string, ArrayBuffer, or Blob to load
  127804. * @param onLoad callback called when the image successfully loads
  127805. * @param onError callback called when the image fails to load
  127806. * @param offlineProvider offline provider for caching
  127807. * @param mimeType optional mime type
  127808. * @returns the HTMLImageElement of the loaded image
  127809. */
  127810. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  127811. /**
  127812. * Loads a file from a url
  127813. * @param url url string, ArrayBuffer, or Blob to load
  127814. * @param onSuccess callback called when the file successfully loads
  127815. * @param onProgress callback called while file is loading (if the server supports this mode)
  127816. * @param offlineProvider defines the offline provider for caching
  127817. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127818. * @param onError callback called when the file fails to load
  127819. * @returns a file request object
  127820. */
  127821. 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;
  127822. /**
  127823. * Loads a file from a url
  127824. * @param url the file url to load
  127825. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127826. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  127827. */
  127828. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  127829. /**
  127830. * Load a script (identified by an url). When the url returns, the
  127831. * content of this file is added into a new script element, attached to the DOM (body element)
  127832. * @param scriptUrl defines the url of the script to laod
  127833. * @param onSuccess defines the callback called when the script is loaded
  127834. * @param onError defines the callback to call if an error occurs
  127835. * @param scriptId defines the id of the script element
  127836. */
  127837. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  127838. /**
  127839. * Load an asynchronous script (identified by an url). When the url returns, the
  127840. * content of this file is added into a new script element, attached to the DOM (body element)
  127841. * @param scriptUrl defines the url of the script to laod
  127842. * @param scriptId defines the id of the script element
  127843. * @returns a promise request object
  127844. */
  127845. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  127846. /**
  127847. * Loads a file from a blob
  127848. * @param fileToLoad defines the blob to use
  127849. * @param callback defines the callback to call when data is loaded
  127850. * @param progressCallback defines the callback to call during loading process
  127851. * @returns a file request object
  127852. */
  127853. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  127854. /**
  127855. * Reads a file from a File object
  127856. * @param file defines the file to load
  127857. * @param onSuccess defines the callback to call when data is loaded
  127858. * @param onProgress defines the callback to call during loading process
  127859. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127860. * @param onError defines the callback to call when an error occurs
  127861. * @returns a file request object
  127862. */
  127863. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  127864. /**
  127865. * Creates a data url from a given string content
  127866. * @param content defines the content to convert
  127867. * @returns the new data url link
  127868. */
  127869. static FileAsURL(content: string): string;
  127870. /**
  127871. * Format the given number to a specific decimal format
  127872. * @param value defines the number to format
  127873. * @param decimals defines the number of decimals to use
  127874. * @returns the formatted string
  127875. */
  127876. static Format(value: number, decimals?: number): string;
  127877. /**
  127878. * Tries to copy an object by duplicating every property
  127879. * @param source defines the source object
  127880. * @param destination defines the target object
  127881. * @param doNotCopyList defines a list of properties to avoid
  127882. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  127883. */
  127884. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  127885. /**
  127886. * Gets a boolean indicating if the given object has no own property
  127887. * @param obj defines the object to test
  127888. * @returns true if object has no own property
  127889. */
  127890. static IsEmpty(obj: any): boolean;
  127891. /**
  127892. * Function used to register events at window level
  127893. * @param windowElement defines the Window object to use
  127894. * @param events defines the events to register
  127895. */
  127896. static RegisterTopRootEvents(windowElement: Window, events: {
  127897. name: string;
  127898. handler: Nullable<(e: FocusEvent) => any>;
  127899. }[]): void;
  127900. /**
  127901. * Function used to unregister events from window level
  127902. * @param windowElement defines the Window object to use
  127903. * @param events defines the events to unregister
  127904. */
  127905. static UnregisterTopRootEvents(windowElement: Window, events: {
  127906. name: string;
  127907. handler: Nullable<(e: FocusEvent) => any>;
  127908. }[]): void;
  127909. /**
  127910. * @ignore
  127911. */
  127912. static _ScreenshotCanvas: HTMLCanvasElement;
  127913. /**
  127914. * Dumps the current bound framebuffer
  127915. * @param width defines the rendering width
  127916. * @param height defines the rendering height
  127917. * @param engine defines the hosting engine
  127918. * @param successCallback defines the callback triggered once the data are available
  127919. * @param mimeType defines the mime type of the result
  127920. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127921. * @return a void promise
  127922. */
  127923. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  127924. /**
  127925. * Dumps an array buffer
  127926. * @param width defines the rendering width
  127927. * @param height defines the rendering height
  127928. * @param data the data array
  127929. * @param successCallback defines the callback triggered once the data are available
  127930. * @param mimeType defines the mime type of the result
  127931. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127932. * @param invertY true to invert the picture in the Y dimension
  127933. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127934. */
  127935. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  127936. /**
  127937. * Dumps an array buffer
  127938. * @param width defines the rendering width
  127939. * @param height defines the rendering height
  127940. * @param data the data array
  127941. * @param successCallback defines the callback triggered once the data are available
  127942. * @param mimeType defines the mime type of the result
  127943. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127944. * @param invertY true to invert the picture in the Y dimension
  127945. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127946. * @return a promise that resolve to the final data
  127947. */
  127948. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  127949. /**
  127950. * Converts the canvas data to blob.
  127951. * This acts as a polyfill for browsers not supporting the to blob function.
  127952. * @param canvas Defines the canvas to extract the data from
  127953. * @param successCallback Defines the callback triggered once the data are available
  127954. * @param mimeType Defines the mime type of the result
  127955. */
  127956. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  127957. /**
  127958. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  127959. * @param successCallback defines the callback triggered once the data are available
  127960. * @param mimeType defines the mime type of the result
  127961. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  127962. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  127963. */
  127964. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  127965. /**
  127966. * Downloads a blob in the browser
  127967. * @param blob defines the blob to download
  127968. * @param fileName defines the name of the downloaded file
  127969. */
  127970. static Download(blob: Blob, fileName: string): void;
  127971. /**
  127972. * Will return the right value of the noPreventDefault variable
  127973. * Needed to keep backwards compatibility to the old API.
  127974. *
  127975. * @param args arguments passed to the attachControl function
  127976. * @returns the correct value for noPreventDefault
  127977. */
  127978. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  127979. /**
  127980. * Captures a screenshot of the current rendering
  127981. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127982. * @param engine defines the rendering engine
  127983. * @param camera defines the source camera
  127984. * @param size This parameter can be set to a single number or to an object with the
  127985. * following (optional) properties: precision, width, height. If a single number is passed,
  127986. * it will be used for both width and height. If an object is passed, the screenshot size
  127987. * will be derived from the parameters. The precision property is a multiplier allowing
  127988. * rendering at a higher or lower resolution
  127989. * @param successCallback defines the callback receives a single parameter which contains the
  127990. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127991. * src parameter of an <img> to display it
  127992. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127993. * Check your browser for supported MIME types
  127994. */
  127995. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127996. /**
  127997. * Captures a screenshot of the current rendering
  127998. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127999. * @param engine defines the rendering engine
  128000. * @param camera defines the source camera
  128001. * @param size This parameter can be set to a single number or to an object with the
  128002. * following (optional) properties: precision, width, height. If a single number is passed,
  128003. * it will be used for both width and height. If an object is passed, the screenshot size
  128004. * will be derived from the parameters. The precision property is a multiplier allowing
  128005. * rendering at a higher or lower resolution
  128006. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128007. * Check your browser for supported MIME types
  128008. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128009. * to the src parameter of an <img> to display it
  128010. */
  128011. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  128012. /**
  128013. * Generates an image screenshot from the specified camera.
  128014. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128015. * @param engine The engine to use for rendering
  128016. * @param camera The camera to use for rendering
  128017. * @param size This parameter can be set to a single number or to an object with the
  128018. * following (optional) properties: precision, width, height. If a single number is passed,
  128019. * it will be used for both width and height. If an object is passed, the screenshot size
  128020. * will be derived from the parameters. The precision property is a multiplier allowing
  128021. * rendering at a higher or lower resolution
  128022. * @param successCallback The callback receives a single parameter which contains the
  128023. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128024. * src parameter of an <img> to display it
  128025. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128026. * Check your browser for supported MIME types
  128027. * @param samples Texture samples (default: 1)
  128028. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128029. * @param fileName A name for for the downloaded file.
  128030. */
  128031. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128032. /**
  128033. * Generates an image screenshot from the specified camera.
  128034. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128035. * @param engine The engine to use for rendering
  128036. * @param camera The camera to use for rendering
  128037. * @param size This parameter can be set to a single number or to an object with the
  128038. * following (optional) properties: precision, width, height. If a single number is passed,
  128039. * it will be used for both width and height. If an object is passed, the screenshot size
  128040. * will be derived from the parameters. The precision property is a multiplier allowing
  128041. * rendering at a higher or lower resolution
  128042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128043. * Check your browser for supported MIME types
  128044. * @param samples Texture samples (default: 1)
  128045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128046. * @param fileName A name for for the downloaded file.
  128047. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128048. * to the src parameter of an <img> to display it
  128049. */
  128050. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128051. /**
  128052. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  128053. * Be aware Math.random() could cause collisions, but:
  128054. * "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"
  128055. * @returns a pseudo random id
  128056. */
  128057. static RandomId(): string;
  128058. /**
  128059. * Test if the given uri is a base64 string
  128060. * @param uri The uri to test
  128061. * @return True if the uri is a base64 string or false otherwise
  128062. */
  128063. static IsBase64(uri: string): boolean;
  128064. /**
  128065. * Decode the given base64 uri.
  128066. * @param uri The uri to decode
  128067. * @return The decoded base64 data.
  128068. */
  128069. static DecodeBase64(uri: string): ArrayBuffer;
  128070. /**
  128071. * Gets the absolute url.
  128072. * @param url the input url
  128073. * @return the absolute url
  128074. */
  128075. static GetAbsoluteUrl(url: string): string;
  128076. /**
  128077. * No log
  128078. */
  128079. static readonly NoneLogLevel: number;
  128080. /**
  128081. * Only message logs
  128082. */
  128083. static readonly MessageLogLevel: number;
  128084. /**
  128085. * Only warning logs
  128086. */
  128087. static readonly WarningLogLevel: number;
  128088. /**
  128089. * Only error logs
  128090. */
  128091. static readonly ErrorLogLevel: number;
  128092. /**
  128093. * All logs
  128094. */
  128095. static readonly AllLogLevel: number;
  128096. /**
  128097. * Gets a value indicating the number of loading errors
  128098. * @ignorenaming
  128099. */
  128100. static get errorsCount(): number;
  128101. /**
  128102. * Callback called when a new log is added
  128103. */
  128104. static OnNewCacheEntry: (entry: string) => void;
  128105. /**
  128106. * Log a message to the console
  128107. * @param message defines the message to log
  128108. */
  128109. static Log(message: string): void;
  128110. /**
  128111. * Write a warning message to the console
  128112. * @param message defines the message to log
  128113. */
  128114. static Warn(message: string): void;
  128115. /**
  128116. * Write an error message to the console
  128117. * @param message defines the message to log
  128118. */
  128119. static Error(message: string): void;
  128120. /**
  128121. * Gets current log cache (list of logs)
  128122. */
  128123. static get LogCache(): string;
  128124. /**
  128125. * Clears the log cache
  128126. */
  128127. static ClearLogCache(): void;
  128128. /**
  128129. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  128130. */
  128131. static set LogLevels(level: number);
  128132. /**
  128133. * Checks if the window object exists
  128134. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  128135. */
  128136. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  128137. /**
  128138. * No performance log
  128139. */
  128140. static readonly PerformanceNoneLogLevel: number;
  128141. /**
  128142. * Use user marks to log performance
  128143. */
  128144. static readonly PerformanceUserMarkLogLevel: number;
  128145. /**
  128146. * Log performance to the console
  128147. */
  128148. static readonly PerformanceConsoleLogLevel: number;
  128149. private static _performance;
  128150. /**
  128151. * Sets the current performance log level
  128152. */
  128153. static set PerformanceLogLevel(level: number);
  128154. private static _StartPerformanceCounterDisabled;
  128155. private static _EndPerformanceCounterDisabled;
  128156. private static _StartUserMark;
  128157. private static _EndUserMark;
  128158. private static _StartPerformanceConsole;
  128159. private static _EndPerformanceConsole;
  128160. /**
  128161. * Starts a performance counter
  128162. */
  128163. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  128164. /**
  128165. * Ends a specific performance coutner
  128166. */
  128167. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  128168. /**
  128169. * Gets either window.performance.now() if supported or Date.now() else
  128170. */
  128171. static get Now(): number;
  128172. /**
  128173. * This method will return the name of the class used to create the instance of the given object.
  128174. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  128175. * @param object the object to get the class name from
  128176. * @param isType defines if the object is actually a type
  128177. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  128178. */
  128179. static GetClassName(object: any, isType?: boolean): string;
  128180. /**
  128181. * Gets the first element of an array satisfying a given predicate
  128182. * @param array defines the array to browse
  128183. * @param predicate defines the predicate to use
  128184. * @returns null if not found or the element
  128185. */
  128186. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  128187. /**
  128188. * This method will return the name of the full name of the class, including its owning module (if any).
  128189. * 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).
  128190. * @param object the object to get the class name from
  128191. * @param isType defines if the object is actually a type
  128192. * @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.
  128193. * @ignorenaming
  128194. */
  128195. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  128196. /**
  128197. * Returns a promise that resolves after the given amount of time.
  128198. * @param delay Number of milliseconds to delay
  128199. * @returns Promise that resolves after the given amount of time
  128200. */
  128201. static DelayAsync(delay: number): Promise<void>;
  128202. /**
  128203. * Utility function to detect if the current user agent is Safari
  128204. * @returns whether or not the current user agent is safari
  128205. */
  128206. static IsSafari(): boolean;
  128207. }
  128208. /**
  128209. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  128210. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  128211. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  128212. * @param name The name of the class, case should be preserved
  128213. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  128214. */
  128215. export function className(name: string, module?: string): (target: Object) => void;
  128216. /**
  128217. * An implementation of a loop for asynchronous functions.
  128218. */
  128219. export class AsyncLoop {
  128220. /**
  128221. * Defines the number of iterations for the loop
  128222. */
  128223. iterations: number;
  128224. /**
  128225. * Defines the current index of the loop.
  128226. */
  128227. index: number;
  128228. private _done;
  128229. private _fn;
  128230. private _successCallback;
  128231. /**
  128232. * Constructor.
  128233. * @param iterations the number of iterations.
  128234. * @param func the function to run each iteration
  128235. * @param successCallback the callback that will be called upon succesful execution
  128236. * @param offset starting offset.
  128237. */
  128238. constructor(
  128239. /**
  128240. * Defines the number of iterations for the loop
  128241. */
  128242. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  128243. /**
  128244. * Execute the next iteration. Must be called after the last iteration was finished.
  128245. */
  128246. executeNext(): void;
  128247. /**
  128248. * Break the loop and run the success callback.
  128249. */
  128250. breakLoop(): void;
  128251. /**
  128252. * Create and run an async loop.
  128253. * @param iterations the number of iterations.
  128254. * @param fn the function to run each iteration
  128255. * @param successCallback the callback that will be called upon succesful execution
  128256. * @param offset starting offset.
  128257. * @returns the created async loop object
  128258. */
  128259. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  128260. /**
  128261. * A for-loop that will run a given number of iterations synchronous and the rest async.
  128262. * @param iterations total number of iterations
  128263. * @param syncedIterations number of synchronous iterations in each async iteration.
  128264. * @param fn the function to call each iteration.
  128265. * @param callback a success call back that will be called when iterating stops.
  128266. * @param breakFunction a break condition (optional)
  128267. * @param timeout timeout settings for the setTimeout function. default - 0.
  128268. * @returns the created async loop object
  128269. */
  128270. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  128271. }
  128272. }
  128273. declare module BABYLON {
  128274. /**
  128275. * This class implement a typical dictionary using a string as key and the generic type T as value.
  128276. * The underlying implementation relies on an associative array to ensure the best performances.
  128277. * The value can be anything including 'null' but except 'undefined'
  128278. */
  128279. export class StringDictionary<T> {
  128280. /**
  128281. * This will clear this dictionary and copy the content from the 'source' one.
  128282. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  128283. * @param source the dictionary to take the content from and copy to this dictionary
  128284. */
  128285. copyFrom(source: StringDictionary<T>): void;
  128286. /**
  128287. * Get a value based from its key
  128288. * @param key the given key to get the matching value from
  128289. * @return the value if found, otherwise undefined is returned
  128290. */
  128291. get(key: string): T | undefined;
  128292. /**
  128293. * Get a value from its key or add it if it doesn't exist.
  128294. * This method will ensure you that a given key/data will be present in the dictionary.
  128295. * @param key the given key to get the matching value from
  128296. * @param factory the factory that will create the value if the key is not present in the dictionary.
  128297. * The factory will only be invoked if there's no data for the given key.
  128298. * @return the value corresponding to the key.
  128299. */
  128300. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  128301. /**
  128302. * Get a value from its key if present in the dictionary otherwise add it
  128303. * @param key the key to get the value from
  128304. * @param val if there's no such key/value pair in the dictionary add it with this value
  128305. * @return the value corresponding to the key
  128306. */
  128307. getOrAdd(key: string, val: T): T;
  128308. /**
  128309. * Check if there's a given key in the dictionary
  128310. * @param key the key to check for
  128311. * @return true if the key is present, false otherwise
  128312. */
  128313. contains(key: string): boolean;
  128314. /**
  128315. * Add a new key and its corresponding value
  128316. * @param key the key to add
  128317. * @param value the value corresponding to the key
  128318. * @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
  128319. */
  128320. add(key: string, value: T): boolean;
  128321. /**
  128322. * Update a specific value associated to a key
  128323. * @param key defines the key to use
  128324. * @param value defines the value to store
  128325. * @returns true if the value was updated (or false if the key was not found)
  128326. */
  128327. set(key: string, value: T): boolean;
  128328. /**
  128329. * Get the element of the given key and remove it from the dictionary
  128330. * @param key defines the key to search
  128331. * @returns the value associated with the key or null if not found
  128332. */
  128333. getAndRemove(key: string): Nullable<T>;
  128334. /**
  128335. * Remove a key/value from the dictionary.
  128336. * @param key the key to remove
  128337. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  128338. */
  128339. remove(key: string): boolean;
  128340. /**
  128341. * Clear the whole content of the dictionary
  128342. */
  128343. clear(): void;
  128344. /**
  128345. * Gets the current count
  128346. */
  128347. get count(): number;
  128348. /**
  128349. * Execute a callback on each key/val of the dictionary.
  128350. * Note that you can remove any element in this dictionary in the callback implementation
  128351. * @param callback the callback to execute on a given key/value pair
  128352. */
  128353. forEach(callback: (key: string, val: T) => void): void;
  128354. /**
  128355. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  128356. * If the callback returns null or undefined the method will iterate to the next key/value pair
  128357. * Note that you can remove any element in this dictionary in the callback implementation
  128358. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  128359. * @returns the first item
  128360. */
  128361. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  128362. private _count;
  128363. private _data;
  128364. }
  128365. }
  128366. declare module BABYLON {
  128367. /** @hidden */
  128368. export interface ICollisionCoordinator {
  128369. createCollider(): Collider;
  128370. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  128371. init(scene: Scene): void;
  128372. }
  128373. /** @hidden */
  128374. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  128375. private _scene;
  128376. private _scaledPosition;
  128377. private _scaledVelocity;
  128378. private _finalPosition;
  128379. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  128380. createCollider(): Collider;
  128381. init(scene: Scene): void;
  128382. private _collideWithWorld;
  128383. }
  128384. }
  128385. declare module BABYLON {
  128386. /**
  128387. * Class used to manage all inputs for the scene.
  128388. */
  128389. export class InputManager {
  128390. /** The distance in pixel that you have to move to prevent some events */
  128391. static DragMovementThreshold: number;
  128392. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  128393. static LongPressDelay: number;
  128394. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  128395. static DoubleClickDelay: number;
  128396. /** If you need to check double click without raising a single click at first click, enable this flag */
  128397. static ExclusiveDoubleClickMode: boolean;
  128398. /** 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. */
  128399. private _alreadyAttached;
  128400. private _alreadyAttachedTo;
  128401. private _wheelEventName;
  128402. private _onPointerMove;
  128403. private _onPointerDown;
  128404. private _onPointerUp;
  128405. private _initClickEvent;
  128406. private _initActionManager;
  128407. private _delayedSimpleClick;
  128408. private _delayedSimpleClickTimeout;
  128409. private _previousDelayedSimpleClickTimeout;
  128410. private _meshPickProceed;
  128411. private _previousButtonPressed;
  128412. private _currentPickResult;
  128413. private _previousPickResult;
  128414. private _totalPointersPressed;
  128415. private _doubleClickOccured;
  128416. private _pointerOverMesh;
  128417. private _pickedDownMesh;
  128418. private _pickedUpMesh;
  128419. private _pointerX;
  128420. private _pointerY;
  128421. private _unTranslatedPointerX;
  128422. private _unTranslatedPointerY;
  128423. private _startingPointerPosition;
  128424. private _previousStartingPointerPosition;
  128425. private _startingPointerTime;
  128426. private _previousStartingPointerTime;
  128427. private _pointerCaptures;
  128428. private _meshUnderPointerId;
  128429. private _onKeyDown;
  128430. private _onKeyUp;
  128431. private _keyboardIsAttached;
  128432. private _onCanvasFocusObserver;
  128433. private _onCanvasBlurObserver;
  128434. private _scene;
  128435. /**
  128436. * Creates a new InputManager
  128437. * @param scene defines the hosting scene
  128438. */
  128439. constructor(scene: Scene);
  128440. /**
  128441. * Gets the mesh that is currently under the pointer
  128442. */
  128443. get meshUnderPointer(): Nullable<AbstractMesh>;
  128444. /**
  128445. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  128446. * @param pointerId the pointer id to use
  128447. * @returns The mesh under this pointer id or null if not found
  128448. */
  128449. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  128450. /**
  128451. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  128452. */
  128453. get unTranslatedPointer(): Vector2;
  128454. /**
  128455. * Gets or sets the current on-screen X position of the pointer
  128456. */
  128457. get pointerX(): number;
  128458. set pointerX(value: number);
  128459. /**
  128460. * Gets or sets the current on-screen Y position of the pointer
  128461. */
  128462. get pointerY(): number;
  128463. set pointerY(value: number);
  128464. private _updatePointerPosition;
  128465. private _processPointerMove;
  128466. private _setRayOnPointerInfo;
  128467. private _checkPrePointerObservable;
  128468. /**
  128469. * Use this method to simulate a pointer move on a mesh
  128470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128473. */
  128474. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128475. /**
  128476. * Use this method to simulate a pointer down on a mesh
  128477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128480. */
  128481. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128482. private _processPointerDown;
  128483. /** @hidden */
  128484. _isPointerSwiping(): boolean;
  128485. /**
  128486. * Use this method to simulate a pointer up on a mesh
  128487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128491. */
  128492. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  128493. private _processPointerUp;
  128494. /**
  128495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128497. * @returns true if the pointer was captured
  128498. */
  128499. isPointerCaptured(pointerId?: number): boolean;
  128500. /**
  128501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128502. * @param attachUp defines if you want to attach events to pointerup
  128503. * @param attachDown defines if you want to attach events to pointerdown
  128504. * @param attachMove defines if you want to attach events to pointermove
  128505. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  128506. */
  128507. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  128508. /**
  128509. * Detaches all event handlers
  128510. */
  128511. detachControl(): void;
  128512. /**
  128513. * Force the value of meshUnderPointer
  128514. * @param mesh defines the mesh to use
  128515. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  128516. */
  128517. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  128518. /**
  128519. * Gets the mesh under the pointer
  128520. * @returns a Mesh or null if no mesh is under the pointer
  128521. */
  128522. getPointerOverMesh(): Nullable<AbstractMesh>;
  128523. }
  128524. }
  128525. declare module BABYLON {
  128526. /**
  128527. * This class defines the direct association between an animation and a target
  128528. */
  128529. export class TargetedAnimation {
  128530. /**
  128531. * Animation to perform
  128532. */
  128533. animation: Animation;
  128534. /**
  128535. * Target to animate
  128536. */
  128537. target: any;
  128538. /**
  128539. * Returns the string "TargetedAnimation"
  128540. * @returns "TargetedAnimation"
  128541. */
  128542. getClassName(): string;
  128543. /**
  128544. * Serialize the object
  128545. * @returns the JSON object representing the current entity
  128546. */
  128547. serialize(): any;
  128548. }
  128549. /**
  128550. * Use this class to create coordinated animations on multiple targets
  128551. */
  128552. export class AnimationGroup implements IDisposable {
  128553. /** The name of the animation group */
  128554. name: string;
  128555. private _scene;
  128556. private _targetedAnimations;
  128557. private _animatables;
  128558. private _from;
  128559. private _to;
  128560. private _isStarted;
  128561. private _isPaused;
  128562. private _speedRatio;
  128563. private _loopAnimation;
  128564. private _isAdditive;
  128565. /**
  128566. * Gets or sets the unique id of the node
  128567. */
  128568. uniqueId: number;
  128569. /**
  128570. * This observable will notify when one animation have ended
  128571. */
  128572. onAnimationEndObservable: Observable<TargetedAnimation>;
  128573. /**
  128574. * Observer raised when one animation loops
  128575. */
  128576. onAnimationLoopObservable: Observable<TargetedAnimation>;
  128577. /**
  128578. * Observer raised when all animations have looped
  128579. */
  128580. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  128581. /**
  128582. * This observable will notify when all animations have ended.
  128583. */
  128584. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  128585. /**
  128586. * This observable will notify when all animations have paused.
  128587. */
  128588. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  128589. /**
  128590. * This observable will notify when all animations are playing.
  128591. */
  128592. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  128593. /**
  128594. * Gets the first frame
  128595. */
  128596. get from(): number;
  128597. /**
  128598. * Gets the last frame
  128599. */
  128600. get to(): number;
  128601. /**
  128602. * Define if the animations are started
  128603. */
  128604. get isStarted(): boolean;
  128605. /**
  128606. * Gets a value indicating that the current group is playing
  128607. */
  128608. get isPlaying(): boolean;
  128609. /**
  128610. * Gets or sets the speed ratio to use for all animations
  128611. */
  128612. get speedRatio(): number;
  128613. /**
  128614. * Gets or sets the speed ratio to use for all animations
  128615. */
  128616. set speedRatio(value: number);
  128617. /**
  128618. * Gets or sets if all animations should loop or not
  128619. */
  128620. get loopAnimation(): boolean;
  128621. set loopAnimation(value: boolean);
  128622. /**
  128623. * Gets or sets if all animations should be evaluated additively
  128624. */
  128625. get isAdditive(): boolean;
  128626. set isAdditive(value: boolean);
  128627. /**
  128628. * Gets the targeted animations for this animation group
  128629. */
  128630. get targetedAnimations(): Array<TargetedAnimation>;
  128631. /**
  128632. * returning the list of animatables controlled by this animation group.
  128633. */
  128634. get animatables(): Array<Animatable>;
  128635. /**
  128636. * Gets the list of target animations
  128637. */
  128638. get children(): TargetedAnimation[];
  128639. /**
  128640. * Instantiates a new Animation Group.
  128641. * This helps managing several animations at once.
  128642. * @see https://doc.babylonjs.com/how_to/group
  128643. * @param name Defines the name of the group
  128644. * @param scene Defines the scene the group belongs to
  128645. */
  128646. constructor(
  128647. /** The name of the animation group */
  128648. name: string, scene?: Nullable<Scene>);
  128649. /**
  128650. * Add an animation (with its target) in the group
  128651. * @param animation defines the animation we want to add
  128652. * @param target defines the target of the animation
  128653. * @returns the TargetedAnimation object
  128654. */
  128655. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  128656. /**
  128657. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  128658. * It can add constant keys at begin or end
  128659. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  128660. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  128661. * @returns the animation group
  128662. */
  128663. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  128664. private _animationLoopCount;
  128665. private _animationLoopFlags;
  128666. private _processLoop;
  128667. /**
  128668. * Start all animations on given targets
  128669. * @param loop defines if animations must loop
  128670. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  128671. * @param from defines the from key (optional)
  128672. * @param to defines the to key (optional)
  128673. * @param isAdditive defines the additive state for the resulting animatables (optional)
  128674. * @returns the current animation group
  128675. */
  128676. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  128677. /**
  128678. * Pause all animations
  128679. * @returns the animation group
  128680. */
  128681. pause(): AnimationGroup;
  128682. /**
  128683. * Play all animations to initial state
  128684. * This function will start() the animations if they were not started or will restart() them if they were paused
  128685. * @param loop defines if animations must loop
  128686. * @returns the animation group
  128687. */
  128688. play(loop?: boolean): AnimationGroup;
  128689. /**
  128690. * Reset all animations to initial state
  128691. * @returns the animation group
  128692. */
  128693. reset(): AnimationGroup;
  128694. /**
  128695. * Restart animations from key 0
  128696. * @returns the animation group
  128697. */
  128698. restart(): AnimationGroup;
  128699. /**
  128700. * Stop all animations
  128701. * @returns the animation group
  128702. */
  128703. stop(): AnimationGroup;
  128704. /**
  128705. * Set animation weight for all animatables
  128706. * @param weight defines the weight to use
  128707. * @return the animationGroup
  128708. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128709. */
  128710. setWeightForAllAnimatables(weight: number): AnimationGroup;
  128711. /**
  128712. * Synchronize and normalize all animatables with a source animatable
  128713. * @param root defines the root animatable to synchronize with
  128714. * @return the animationGroup
  128715. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128716. */
  128717. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  128718. /**
  128719. * Goes to a specific frame in this animation group
  128720. * @param frame the frame number to go to
  128721. * @return the animationGroup
  128722. */
  128723. goToFrame(frame: number): AnimationGroup;
  128724. /**
  128725. * Dispose all associated resources
  128726. */
  128727. dispose(): void;
  128728. private _checkAnimationGroupEnded;
  128729. /**
  128730. * Clone the current animation group and returns a copy
  128731. * @param newName defines the name of the new group
  128732. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  128733. * @returns the new aniamtion group
  128734. */
  128735. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  128736. /**
  128737. * Serializes the animationGroup to an object
  128738. * @returns Serialized object
  128739. */
  128740. serialize(): any;
  128741. /**
  128742. * Returns a new AnimationGroup object parsed from the source provided.
  128743. * @param parsedAnimationGroup defines the source
  128744. * @param scene defines the scene that will receive the animationGroup
  128745. * @returns a new AnimationGroup
  128746. */
  128747. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  128748. /**
  128749. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  128750. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  128751. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  128752. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  128753. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  128754. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  128755. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  128756. */
  128757. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  128758. /**
  128759. * Returns the string "AnimationGroup"
  128760. * @returns "AnimationGroup"
  128761. */
  128762. getClassName(): string;
  128763. /**
  128764. * Creates a detailled string about the object
  128765. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  128766. * @returns a string representing the object
  128767. */
  128768. toString(fullDetails?: boolean): string;
  128769. }
  128770. }
  128771. declare module BABYLON {
  128772. /**
  128773. * @hidden
  128774. **/
  128775. export class _TimeToken {
  128776. _startTimeQuery: Nullable<WebGLQuery>;
  128777. _endTimeQuery: Nullable<WebGLQuery>;
  128778. _timeElapsedQuery: Nullable<WebGLQuery>;
  128779. _timeElapsedQueryEnded: boolean;
  128780. }
  128781. }
  128782. declare module BABYLON {
  128783. /** @hidden */
  128784. export enum ExtensionName {
  128785. DepthClamping = "depth-clamping",
  128786. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128787. Depth32FloatStencil8 = "depth32float-stencil8",
  128788. PipelineStatisticsQuery = "pipeline-statistics-query",
  128789. TextureCompressionBC = "texture-compression-bc",
  128790. TimestampQuery = "timestamp-query"
  128791. }
  128792. /** @hidden */
  128793. export enum AddressMode {
  128794. ClampToEdge = "clamp-to-edge",
  128795. Repeat = "repeat",
  128796. MirrorRepeat = "mirror-repeat"
  128797. }
  128798. /** @hidden */
  128799. export enum BindingType {
  128800. UniformBuffer = "uniform-buffer",
  128801. StorageBuffer = "storage-buffer",
  128802. ReadonlyStorageBuffer = "readonly-storage-buffer",
  128803. Sampler = "sampler",
  128804. ComparisonSampler = "comparison-sampler",
  128805. SampledTexture = "sampled-texture",
  128806. ReadonlyStorageTexture = "readonly-storage-texture",
  128807. WriteonlyStorageTexture = "writeonly-storage-texture"
  128808. }
  128809. /** @hidden */
  128810. export enum BlendFactor {
  128811. Zero = "zero",
  128812. One = "one",
  128813. SrcColor = "src-color",
  128814. OneMinusSrcColor = "one-minus-src-color",
  128815. SrcAlpha = "src-alpha",
  128816. OneMinusSrcAlpha = "one-minus-src-alpha",
  128817. DstColor = "dst-color",
  128818. OneMinusDstColor = "one-minus-dst-color",
  128819. DstAlpha = "dst-alpha",
  128820. OneMinusDstAlpha = "one-minus-dst-alpha",
  128821. SrcAlphaSaturated = "src-alpha-saturated",
  128822. BlendColor = "blend-color",
  128823. OneMinusBlendColor = "one-minus-blend-color"
  128824. }
  128825. /** @hidden */
  128826. export enum BlendOperation {
  128827. Add = "add",
  128828. Subtract = "subtract",
  128829. ReverseSubtract = "reverse-subtract",
  128830. Min = "min",
  128831. Max = "max"
  128832. }
  128833. /** @hidden */
  128834. export enum CompareFunction {
  128835. Never = "never",
  128836. Less = "less",
  128837. Equal = "equal",
  128838. LessEqual = "less-equal",
  128839. Greater = "greater",
  128840. NotEqual = "not-equal",
  128841. GreaterEqual = "greater-equal",
  128842. Always = "always"
  128843. }
  128844. /** @hidden */
  128845. export enum CullMode {
  128846. None = "none",
  128847. Front = "front",
  128848. Back = "back"
  128849. }
  128850. /** @hidden */
  128851. export enum FilterMode {
  128852. Nearest = "nearest",
  128853. Linear = "linear"
  128854. }
  128855. /** @hidden */
  128856. export enum FrontFace {
  128857. CCW = "ccw",
  128858. CW = "cw"
  128859. }
  128860. /** @hidden */
  128861. export enum IndexFormat {
  128862. Uint16 = "uint16",
  128863. Uint32 = "uint32"
  128864. }
  128865. /** @hidden */
  128866. export enum InputStepMode {
  128867. Vertex = "vertex",
  128868. Instance = "instance"
  128869. }
  128870. /** @hidden */
  128871. export enum LoadOp {
  128872. Load = "load"
  128873. }
  128874. /** @hidden */
  128875. export enum PrimitiveTopology {
  128876. PointList = "point-list",
  128877. LineList = "line-list",
  128878. LineStrip = "line-strip",
  128879. TriangleList = "triangle-list",
  128880. TriangleStrip = "triangle-strip"
  128881. }
  128882. /** @hidden */
  128883. export enum StencilOperation {
  128884. Keep = "keep",
  128885. Zero = "zero",
  128886. Replace = "replace",
  128887. Invert = "invert",
  128888. IncrementClamp = "increment-clamp",
  128889. DecrementClamp = "decrement-clamp",
  128890. IncrementWrap = "increment-wrap",
  128891. DecrementWrap = "decrement-wrap"
  128892. }
  128893. /** @hidden */
  128894. export enum StoreOp {
  128895. Store = "store",
  128896. Clear = "clear"
  128897. }
  128898. /** @hidden */
  128899. export enum TextureDimension {
  128900. E1d = "1d",
  128901. E2d = "2d",
  128902. E3d = "3d"
  128903. }
  128904. /** @hidden */
  128905. export enum TextureFormat {
  128906. R8Unorm = "r8unorm",
  128907. R8Snorm = "r8snorm",
  128908. R8Uint = "r8uint",
  128909. R8Sint = "r8sint",
  128910. R16Uint = "r16uint",
  128911. R16Sint = "r16sint",
  128912. R16Float = "r16float",
  128913. RG8Unorm = "rg8unorm",
  128914. RG8Snorm = "rg8snorm",
  128915. RG8Uint = "rg8uint",
  128916. RG8Sint = "rg8sint",
  128917. R32Uint = "r32uint",
  128918. R32Sint = "r32sint",
  128919. R32Float = "r32float",
  128920. RG16Uint = "rg16uint",
  128921. RG16Sint = "rg16sint",
  128922. RG16Float = "rg16float",
  128923. RGBA8Unorm = "rgba8unorm",
  128924. RGBA8UnormSRGB = "rgba8unorm-srgb",
  128925. RGBA8Snorm = "rgba8snorm",
  128926. RGBA8Uint = "rgba8uint",
  128927. RGBA8Sint = "rgba8sint",
  128928. BGRA8Unorm = "bgra8unorm",
  128929. BGRA8UnormSRGB = "bgra8unorm-srgb",
  128930. RGB9E5UFloat = "rgb9e5ufloat",
  128931. RGB10A2Unorm = "rgb10a2unorm",
  128932. RG11B10UFloat = "rg11b10ufloat",
  128933. RG32Uint = "rg32uint",
  128934. RG32Sint = "rg32sint",
  128935. RG32Float = "rg32float",
  128936. RGBA16Uint = "rgba16uint",
  128937. RGBA16Sint = "rgba16sint",
  128938. RGBA16Float = "rgba16float",
  128939. RGBA32Uint = "rgba32uint",
  128940. RGBA32Sint = "rgba32sint",
  128941. RGBA32Float = "rgba32float",
  128942. Stencil8 = "stencil8",
  128943. Depth16Unorm = "depth16unorm",
  128944. Depth24Plus = "depth24plus",
  128945. Depth24PlusStencil8 = "depth24plus-stencil8",
  128946. Depth32Float = "depth32float",
  128947. BC1RGBAUNorm = "bc1-rgba-unorm",
  128948. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  128949. BC2RGBAUnorm = "bc2-rgba-unorm",
  128950. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  128951. BC3RGBAUnorm = "bc3-rgba-unorm",
  128952. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  128953. BC4RUnorm = "bc4-r-unorm",
  128954. BC4RSnorm = "bc4-r-snorm",
  128955. BC5RGUnorm = "bc5-rg-unorm",
  128956. BC5RGSnorm = "bc5-rg-snorm",
  128957. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  128958. BC6HRGBFloat = "bc6h-rgb-float",
  128959. BC7RGBAUnorm = "bc7-rgba-unorm",
  128960. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  128961. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128962. Depth32FloatStencil8 = "depth32float-stencil8"
  128963. }
  128964. /** @hidden */
  128965. export enum TextureComponentType {
  128966. Float = "float",
  128967. Sint = "sint",
  128968. Uint = "uint",
  128969. DepthComparison = "depth-comparison"
  128970. }
  128971. /** @hidden */
  128972. export enum TextureViewDimension {
  128973. E1d = "1d",
  128974. E2d = "2d",
  128975. E2dArray = "2d-array",
  128976. Cube = "cube",
  128977. CubeArray = "cube-array",
  128978. E3d = "3d"
  128979. }
  128980. /** @hidden */
  128981. export enum VertexFormat {
  128982. Uchar2 = "uchar2",
  128983. Uchar4 = "uchar4",
  128984. Char2 = "char2",
  128985. Char4 = "char4",
  128986. Uchar2Norm = "uchar2norm",
  128987. Uchar4Norm = "uchar4norm",
  128988. Char2Norm = "char2norm",
  128989. Char4Norm = "char4norm",
  128990. Ushort2 = "ushort2",
  128991. Ushort4 = "ushort4",
  128992. Short2 = "short2",
  128993. Short4 = "short4",
  128994. Ushort2Norm = "ushort2norm",
  128995. Ushort4Norm = "ushort4norm",
  128996. Short2Norm = "short2norm",
  128997. Short4Norm = "short4norm",
  128998. Half2 = "half2",
  128999. Half4 = "half4",
  129000. Float = "float",
  129001. Float2 = "float2",
  129002. Float3 = "float3",
  129003. Float4 = "float4",
  129004. Uint = "uint",
  129005. Uint2 = "uint2",
  129006. Uint3 = "uint3",
  129007. Uint4 = "uint4",
  129008. Int = "int",
  129009. Int2 = "int2",
  129010. Int3 = "int3",
  129011. Int4 = "int4"
  129012. }
  129013. /** @hidden */
  129014. export enum TextureAspect {
  129015. All = "all",
  129016. StencilOnly = "stencil-only",
  129017. DepthOnly = "depth-only"
  129018. }
  129019. /** @hidden */
  129020. export enum CompilationMessageType {
  129021. Error = "error",
  129022. Warning = "warning",
  129023. Info = "info"
  129024. }
  129025. /** @hidden */
  129026. export enum QueryType {
  129027. Occlusion = "occlusion"
  129028. }
  129029. /** @hidden */
  129030. export enum BufferUsage {
  129031. MapRead = 1,
  129032. MapWrite = 2,
  129033. CopySrc = 4,
  129034. CopyDst = 8,
  129035. Index = 16,
  129036. Vertex = 32,
  129037. Uniform = 64,
  129038. Storage = 128,
  129039. Indirect = 256,
  129040. QueryResolve = 512
  129041. }
  129042. /** @hidden */
  129043. export enum ColorWrite {
  129044. Red = 1,
  129045. Green = 2,
  129046. Blue = 4,
  129047. Alpha = 8,
  129048. All = 15
  129049. }
  129050. /** @hidden */
  129051. export enum ShaderStage {
  129052. Vertex = 1,
  129053. Fragment = 2,
  129054. Compute = 4
  129055. }
  129056. /** @hidden */
  129057. export enum TextureUsage {
  129058. CopySrc = 1,
  129059. CopyDst = 2,
  129060. Sampled = 4,
  129061. Storage = 8,
  129062. OutputAttachment = 16
  129063. }
  129064. /** @hidden */
  129065. export enum MapMode {
  129066. Read = 1,
  129067. Write = 2
  129068. }
  129069. }
  129070. declare module BABYLON {
  129071. /** @hidden */
  129072. export interface WebGPUBindingInfo {
  129073. setIndex: number;
  129074. bindingIndex: number;
  129075. }
  129076. /** @hidden */
  129077. export interface WebGPUTextureSamplerBindingDescription {
  129078. sampler: WebGPUBindingInfo;
  129079. isTextureArray: boolean;
  129080. textures: Array<WebGPUBindingInfo>;
  129081. }
  129082. /** @hidden
  129083. * If the binding is a UBO, isSampler=isTexture=false
  129084. */
  129085. export interface WebGPUBindingDescription {
  129086. name: string;
  129087. usedInVertex: boolean;
  129088. usedInFragment: boolean;
  129089. isSampler: boolean;
  129090. isComparisonSampler?: boolean;
  129091. isTexture: boolean;
  129092. componentType?: GPUTextureComponentType;
  129093. textureDimension?: GPUTextureViewDimension;
  129094. }
  129095. /**
  129096. * @hidden
  129097. */
  129098. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  129099. uboNextBindingIndex: number;
  129100. freeSetIndex: number;
  129101. freeBindingIndex: number;
  129102. availableVaryings: {
  129103. [key: string]: number;
  129104. };
  129105. availableAttributes: {
  129106. [key: string]: number;
  129107. };
  129108. availableUBOs: {
  129109. [key: string]: {
  129110. setIndex: number;
  129111. bindingIndex: number;
  129112. };
  129113. };
  129114. availableSamplers: {
  129115. [key: string]: WebGPUTextureSamplerBindingDescription;
  129116. };
  129117. leftOverUniforms: {
  129118. name: string;
  129119. type: string;
  129120. length: number;
  129121. }[];
  129122. orderedAttributes: string[];
  129123. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  129124. uniformBufferNames: string[];
  129125. private _attributeNextLocation;
  129126. private _varyingNextLocation;
  129127. constructor();
  129128. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  129129. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  129130. getNextFreeUBOBinding(): {
  129131. setIndex: number;
  129132. bindingIndex: number;
  129133. };
  129134. private _getNextFreeBinding;
  129135. }
  129136. }
  129137. declare module BABYLON {
  129138. /** @hidden */
  129139. export interface IWebGPUPipelineContextSamplerCache {
  129140. samplerBinding: number;
  129141. firstTextureName: string;
  129142. }
  129143. /** @hidden */
  129144. export interface IWebGPUPipelineContextTextureCache {
  129145. textureBinding: number;
  129146. texture: InternalTexture;
  129147. }
  129148. /** @hidden */
  129149. export interface IWebGPUPipelineContextVertexInputsCache {
  129150. indexBuffer: Nullable<GPUBuffer>;
  129151. indexOffset: number;
  129152. vertexStartSlot: number;
  129153. vertexBuffers: GPUBuffer[];
  129154. vertexOffsets: number[];
  129155. }
  129156. /** @hidden */
  129157. export interface IWebGPURenderPipelineStageDescriptor {
  129158. vertexStage: GPUProgrammableStageDescriptor;
  129159. fragmentStage?: GPUProgrammableStageDescriptor;
  129160. }
  129161. /** @hidden */
  129162. export class WebGPUPipelineContext implements IPipelineContext {
  129163. engine: WebGPUEngine;
  129164. shaderProcessingContext: WebGPUShaderProcessingContext;
  129165. leftOverUniformsByName: {
  129166. [name: string]: string;
  129167. };
  129168. sources: {
  129169. vertex: string;
  129170. fragment: string;
  129171. rawVertex: string;
  129172. rawFragment: string;
  129173. };
  129174. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  129175. samplers: {
  129176. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  129177. };
  129178. textures: {
  129179. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  129180. };
  129181. bindGroupLayouts: GPUBindGroupLayout[];
  129182. bindGroupsCache: {
  129183. [key: string]: GPUBindGroup[];
  129184. };
  129185. /**
  129186. * Stores the uniform buffer
  129187. */
  129188. uniformBuffer: Nullable<UniformBuffer>;
  129189. onCompiled?: () => void;
  129190. get isAsync(): boolean;
  129191. get isReady(): boolean;
  129192. /** @hidden */
  129193. _name: string;
  129194. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  129195. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  129196. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  129197. [key: string]: number;
  129198. }, uniformsNames: string[], uniforms: {
  129199. [key: string]: Nullable<WebGLUniformLocation>;
  129200. }, samplerList: string[], samplers: {
  129201. [key: string]: number;
  129202. }, attributesNames: string[], attributes: number[]): void;
  129203. /** @hidden */
  129204. /**
  129205. * Build the uniform buffer used in the material.
  129206. */
  129207. buildUniformLayout(): void;
  129208. /**
  129209. * Release all associated resources.
  129210. **/
  129211. dispose(): void;
  129212. /**
  129213. * Sets an integer value on a uniform variable.
  129214. * @param uniformName Name of the variable.
  129215. * @param value Value to be set.
  129216. */
  129217. setInt(uniformName: string, value: number): void;
  129218. /**
  129219. * Sets an int2 value on a uniform variable.
  129220. * @param uniformName Name of the variable.
  129221. * @param x First int in int2.
  129222. * @param y Second int in int2.
  129223. */
  129224. setInt2(uniformName: string, x: number, y: number): void;
  129225. /**
  129226. * Sets an int3 value on a uniform variable.
  129227. * @param uniformName Name of the variable.
  129228. * @param x First int in int3.
  129229. * @param y Second int in int3.
  129230. * @param z Third int in int3.
  129231. */
  129232. setInt3(uniformName: string, x: number, y: number, z: number): void;
  129233. /**
  129234. * Sets an int4 value on a uniform variable.
  129235. * @param uniformName Name of the variable.
  129236. * @param x First int in int4.
  129237. * @param y Second int in int4.
  129238. * @param z Third int in int4.
  129239. * @param w Fourth int in int4.
  129240. */
  129241. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  129242. /**
  129243. * Sets an int array on a uniform variable.
  129244. * @param uniformName Name of the variable.
  129245. * @param array array to be set.
  129246. */
  129247. setIntArray(uniformName: string, array: Int32Array): void;
  129248. /**
  129249. * 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)
  129250. * @param uniformName Name of the variable.
  129251. * @param array array to be set.
  129252. */
  129253. setIntArray2(uniformName: string, array: Int32Array): void;
  129254. /**
  129255. * 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)
  129256. * @param uniformName Name of the variable.
  129257. * @param array array to be set.
  129258. */
  129259. setIntArray3(uniformName: string, array: Int32Array): void;
  129260. /**
  129261. * 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)
  129262. * @param uniformName Name of the variable.
  129263. * @param array array to be set.
  129264. */
  129265. setIntArray4(uniformName: string, array: Int32Array): void;
  129266. /**
  129267. * Sets an array on a uniform variable.
  129268. * @param uniformName Name of the variable.
  129269. * @param array array to be set.
  129270. */
  129271. setArray(uniformName: string, array: number[]): void;
  129272. /**
  129273. * 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)
  129274. * @param uniformName Name of the variable.
  129275. * @param array array to be set.
  129276. */
  129277. setArray2(uniformName: string, array: number[]): void;
  129278. /**
  129279. * 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)
  129280. * @param uniformName Name of the variable.
  129281. * @param array array to be set.
  129282. * @returns this effect.
  129283. */
  129284. setArray3(uniformName: string, array: number[]): void;
  129285. /**
  129286. * 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)
  129287. * @param uniformName Name of the variable.
  129288. * @param array array to be set.
  129289. */
  129290. setArray4(uniformName: string, array: number[]): void;
  129291. /**
  129292. * Sets matrices on a uniform variable.
  129293. * @param uniformName Name of the variable.
  129294. * @param matrices matrices to be set.
  129295. */
  129296. setMatrices(uniformName: string, matrices: Float32Array): void;
  129297. /**
  129298. * Sets matrix on a uniform variable.
  129299. * @param uniformName Name of the variable.
  129300. * @param matrix matrix to be set.
  129301. */
  129302. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  129303. /**
  129304. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  129305. * @param uniformName Name of the variable.
  129306. * @param matrix matrix to be set.
  129307. */
  129308. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  129309. /**
  129310. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  129311. * @param uniformName Name of the variable.
  129312. * @param matrix matrix to be set.
  129313. */
  129314. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  129315. /**
  129316. * Sets a float on a uniform variable.
  129317. * @param uniformName Name of the variable.
  129318. * @param value value to be set.
  129319. * @returns this effect.
  129320. */
  129321. setFloat(uniformName: string, value: number): void;
  129322. /**
  129323. * Sets a Vector2 on a uniform variable.
  129324. * @param uniformName Name of the variable.
  129325. * @param vector2 vector2 to be set.
  129326. */
  129327. setVector2(uniformName: string, vector2: IVector2Like): void;
  129328. /**
  129329. * Sets a float2 on a uniform variable.
  129330. * @param uniformName Name of the variable.
  129331. * @param x First float in float2.
  129332. * @param y Second float in float2.
  129333. */
  129334. setFloat2(uniformName: string, x: number, y: number): void;
  129335. /**
  129336. * Sets a Vector3 on a uniform variable.
  129337. * @param uniformName Name of the variable.
  129338. * @param vector3 Value to be set.
  129339. */
  129340. setVector3(uniformName: string, vector3: IVector3Like): void;
  129341. /**
  129342. * Sets a float3 on a uniform variable.
  129343. * @param uniformName Name of the variable.
  129344. * @param x First float in float3.
  129345. * @param y Second float in float3.
  129346. * @param z Third float in float3.
  129347. */
  129348. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  129349. /**
  129350. * Sets a Vector4 on a uniform variable.
  129351. * @param uniformName Name of the variable.
  129352. * @param vector4 Value to be set.
  129353. */
  129354. setVector4(uniformName: string, vector4: IVector4Like): void;
  129355. /**
  129356. * Sets a float4 on a uniform variable.
  129357. * @param uniformName Name of the variable.
  129358. * @param x First float in float4.
  129359. * @param y Second float in float4.
  129360. * @param z Third float in float4.
  129361. * @param w Fourth float in float4.
  129362. * @returns this effect.
  129363. */
  129364. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  129365. /**
  129366. * Sets a Color3 on a uniform variable.
  129367. * @param uniformName Name of the variable.
  129368. * @param color3 Value to be set.
  129369. */
  129370. setColor3(uniformName: string, color3: IColor3Like): void;
  129371. /**
  129372. * Sets a Color4 on a uniform variable.
  129373. * @param uniformName Name of the variable.
  129374. * @param color3 Value to be set.
  129375. * @param alpha Alpha value to be set.
  129376. */
  129377. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  129378. /**
  129379. * Sets a Color4 on a uniform variable
  129380. * @param uniformName defines the name of the variable
  129381. * @param color4 defines the value to be set
  129382. */
  129383. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  129384. _getVertexShaderCode(): string | null;
  129385. _getFragmentShaderCode(): string | null;
  129386. }
  129387. }
  129388. declare module BABYLON {
  129389. /** @hidden */
  129390. export class WebGPUDataBuffer extends DataBuffer {
  129391. private _buffer;
  129392. constructor(resource: GPUBuffer);
  129393. get underlyingResource(): any;
  129394. }
  129395. }
  129396. declare module BABYLON {
  129397. /**
  129398. * Class used to inline functions in shader code
  129399. */
  129400. export class ShaderCodeInliner {
  129401. private static readonly _RegexpFindFunctionNameAndType;
  129402. private _sourceCode;
  129403. private _functionDescr;
  129404. private _numMaxIterations;
  129405. /** Gets or sets the token used to mark the functions to inline */
  129406. inlineToken: string;
  129407. /** Gets or sets the debug mode */
  129408. debug: boolean;
  129409. /** Gets the code after the inlining process */
  129410. get code(): string;
  129411. /**
  129412. * Initializes the inliner
  129413. * @param sourceCode shader code source to inline
  129414. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129415. */
  129416. constructor(sourceCode: string, numMaxIterations?: number);
  129417. /**
  129418. * Start the processing of the shader code
  129419. */
  129420. processCode(): void;
  129421. private _collectFunctions;
  129422. private _processInlining;
  129423. private _extractBetweenMarkers;
  129424. private _skipWhitespaces;
  129425. private _isIdentifierChar;
  129426. private _removeComments;
  129427. private _replaceFunctionCallsByCode;
  129428. private _findBackward;
  129429. private _escapeRegExp;
  129430. private _replaceNames;
  129431. }
  129432. }
  129433. declare module BABYLON {
  129434. /** @hidden */
  129435. export class WebGPUShaderProcessor implements IShaderProcessor {
  129436. protected _missingVaryings: Array<string>;
  129437. protected _textureArrayProcessing: Array<string>;
  129438. protected _preProcessors: {
  129439. [key: string]: string;
  129440. };
  129441. private _getArraySize;
  129442. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  129443. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  129444. [key: string]: string;
  129445. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129446. attributeProcessor(attribute: string, preProcessors: {
  129447. [key: string]: string;
  129448. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129449. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  129450. [key: string]: string;
  129451. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129452. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129453. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129454. private _applyTextureArrayProcessing;
  129455. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  129456. vertexCode: string;
  129457. fragmentCode: string;
  129458. };
  129459. }
  129460. }
  129461. declare module BABYLON {
  129462. /** @hidden */
  129463. export class WebGPUBufferManager {
  129464. private _device;
  129465. private _deferredReleaseBuffers;
  129466. private static _IsGPUBuffer;
  129467. constructor(device: GPUDevice);
  129468. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  129469. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  129470. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  129471. private _FromHalfFloat;
  129472. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  129473. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  129474. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  129475. destroyDeferredBuffers(): void;
  129476. }
  129477. }
  129478. declare module BABYLON {
  129479. /** @hidden */
  129480. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  129481. private _webgpuTexture;
  129482. private _webgpuMSAATexture;
  129483. get underlyingResource(): Nullable<GPUTexture>;
  129484. get msaaTexture(): Nullable<GPUTexture>;
  129485. set msaaTexture(texture: Nullable<GPUTexture>);
  129486. view: Nullable<GPUTextureView>;
  129487. format: GPUTextureFormat;
  129488. textureUsages: number;
  129489. constructor(existingTexture?: Nullable<GPUTexture>);
  129490. set(hardwareTexture: GPUTexture): void;
  129491. setMSAATexture(hardwareTexture: GPUTexture): void;
  129492. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  129493. createView(descriptor?: GPUTextureViewDescriptor): void;
  129494. reset(): void;
  129495. release(): void;
  129496. }
  129497. }
  129498. declare module BABYLON {
  129499. /** @hidden */
  129500. export class WebGPUTextureHelper {
  129501. private _device;
  129502. private _glslang;
  129503. private _bufferManager;
  129504. private _mipmapSampler;
  129505. private _invertYPreMultiplyAlphaSampler;
  129506. private _pipelines;
  129507. private _compiledShaders;
  129508. private _deferredReleaseTextures;
  129509. private _commandEncoderForCreation;
  129510. static ComputeNumMipmapLevels(width: number, height: number): number;
  129511. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  129512. private _getPipeline;
  129513. private static _GetTextureTypeFromFormat;
  129514. private static _GetBlockInformationFromFormat;
  129515. private static _IsHardwareTexture;
  129516. private static _IsInternalTexture;
  129517. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  129518. static IsImageBitmap(imageBitmap: ImageBitmap | {
  129519. width: number;
  129520. height: number;
  129521. }): imageBitmap is ImageBitmap;
  129522. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  129523. width: number;
  129524. height: number;
  129525. }): imageBitmap is ImageBitmap[];
  129526. setCommandEncoder(encoder: GPUCommandEncoder): void;
  129527. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  129528. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  129529. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129530. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  129531. createTexture(imageBitmap: ImageBitmap | {
  129532. width: number;
  129533. height: number;
  129534. layers: number;
  129535. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129536. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  129537. width: number;
  129538. height: number;
  129539. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129540. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  129541. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129542. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  129543. createMSAATexture(texture: InternalTexture, samples: number): void;
  129544. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  129545. 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;
  129546. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  129547. releaseTexture(texture: InternalTexture | GPUTexture): void;
  129548. destroyDeferredTextures(): void;
  129549. }
  129550. }
  129551. declare module BABYLON {
  129552. /** @hidden */
  129553. export class WebGPURenderPassWrapper {
  129554. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  129555. renderPass: Nullable<GPURenderPassEncoder>;
  129556. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129557. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129558. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  129559. depthTextureFormat: GPUTextureFormat | undefined;
  129560. constructor();
  129561. reset(fullReset?: boolean): void;
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /** @hidden */
  129566. export class WebGPUCacheSampler {
  129567. private _samplers;
  129568. private _device;
  129569. disabled: boolean;
  129570. constructor(device: GPUDevice);
  129571. private static _GetSamplerHashCode;
  129572. private static _GetSamplerFilterDescriptor;
  129573. private static _GetWrappingMode;
  129574. private static _GetSamplerWrappingDescriptor;
  129575. private static _GetSamplerDescriptor;
  129576. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  129577. }
  129578. }
  129579. declare module BABYLON {
  129580. /** @hidden */
  129581. export class WebGPUShaderManager {
  129582. private _shaders;
  129583. private _device;
  129584. constructor(device: GPUDevice);
  129585. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  129586. }
  129587. }
  129588. declare module BABYLON {
  129589. /** @hidden */
  129590. export class WebGPUCacheRenderPipeline {
  129591. static NumCacheHitWithoutHash: number;
  129592. static NumCacheHitWithHash: number;
  129593. static NumCacheMiss: number;
  129594. static NumPipelineCreationLastFrame: number;
  129595. disabled: boolean;
  129596. private static _Cache;
  129597. private static _NumPipelineCreationCurrentFrame;
  129598. private _device;
  129599. private _states;
  129600. private _isDirty;
  129601. private _currentRenderPipeline;
  129602. private _emptyVertexBuffer;
  129603. private _shaderId;
  129604. private _alphaToCoverageEnabled;
  129605. private _frontFace;
  129606. private _cullEnabled;
  129607. private _cullFace;
  129608. private _clampDepth;
  129609. private _rasterizationState;
  129610. private _depthBias;
  129611. private _depthBiasClamp;
  129612. private _depthBiasSlopeScale;
  129613. private _colorFormat;
  129614. private _webgpuColorFormat;
  129615. private _mrtAttachments1;
  129616. private _mrtAttachments2;
  129617. private _mrtFormats;
  129618. private _alphaBlendEnabled;
  129619. private _alphaBlendFuncParams;
  129620. private _alphaBlendEqParams;
  129621. private _writeMask;
  129622. private _colorStates;
  129623. private _depthStencilFormat;
  129624. private _webgpuDepthStencilFormat;
  129625. private _depthTestEnabled;
  129626. private _depthWriteEnabled;
  129627. private _depthCompare;
  129628. private _stencilEnabled;
  129629. private _stencilFrontCompare;
  129630. private _stencilFrontDepthFailOp;
  129631. private _stencilFrontPassOp;
  129632. private _stencilFrontFailOp;
  129633. private _stencilReadMask;
  129634. private _stencilWriteMask;
  129635. private _depthStencilState;
  129636. private _vertexBuffers;
  129637. private _indexBuffer;
  129638. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  129639. reset(): void;
  129640. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  129641. endFrame(): void;
  129642. setAlphaToCoverage(enabled: boolean): void;
  129643. setFrontFace(frontFace: number): void;
  129644. setCullEnabled(enabled: boolean): void;
  129645. setCullFace(cullFace: number): void;
  129646. setClampDepth(clampDepth: boolean): void;
  129647. resetDepthCullingState(): void;
  129648. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  129649. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  129650. setColorFormat(format: GPUTextureFormat): void;
  129651. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  129652. setAlphaBlendEnabled(enabled: boolean): void;
  129653. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  129654. setWriteMask(mask: number): void;
  129655. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  129656. setDepthTestEnabled(enabled: boolean): void;
  129657. setDepthWriteEnabled(enabled: boolean): void;
  129658. setDepthCompare(func: Nullable<number>): void;
  129659. setStencilEnabled(enabled: boolean): void;
  129660. setStencilCompare(func: Nullable<number>): void;
  129661. setStencilDepthFailOp(op: Nullable<number>): void;
  129662. setStencilPassOp(op: Nullable<number>): void;
  129663. setStencilFailOp(op: Nullable<number>): void;
  129664. setStencilReadMask(mask: number): void;
  129665. setStencilWriteMask(mask: number): void;
  129666. resetStencilState(): void;
  129667. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  129668. setBuffers(vertexBuffers: Nullable<{
  129669. [key: string]: Nullable<VertexBuffer>;
  129670. }>, indexBuffer: Nullable<DataBuffer>): void;
  129671. private static _GetTopology;
  129672. private static _GetAphaBlendOperation;
  129673. private static _GetAphaBlendFactor;
  129674. private static _GetCompareFunction;
  129675. private static _GetStencilOpFunction;
  129676. private static _GetVertexInputDescriptorFormat;
  129677. private _getAphaBlendState;
  129678. private _getColorBlendState;
  129679. private _setShaderStage;
  129680. private _setRasterizationState;
  129681. private _setColorStates;
  129682. private _setDepthStencilState;
  129683. private _setVertexState;
  129684. private _createPipelineLayout;
  129685. private _getVertexInputDescriptor;
  129686. private _createRenderPipeline;
  129687. }
  129688. }
  129689. declare module BABYLON {
  129690. /** @hidden */
  129691. export var clearQuadVertexShader: {
  129692. name: string;
  129693. shader: string;
  129694. };
  129695. }
  129696. declare module BABYLON {
  129697. /** @hidden */
  129698. export var clearQuadPixelShader: {
  129699. name: string;
  129700. shader: string;
  129701. };
  129702. }
  129703. declare module BABYLON {
  129704. /**
  129705. * Options to load the associated Glslang library
  129706. */
  129707. export interface GlslangOptions {
  129708. /**
  129709. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  129710. */
  129711. glslang?: any;
  129712. /**
  129713. * Defines the URL of the glslang JS File.
  129714. */
  129715. jsPath?: string;
  129716. /**
  129717. * Defines the URL of the glslang WASM File.
  129718. */
  129719. wasmPath?: string;
  129720. }
  129721. /**
  129722. * Options to create the WebGPU engine
  129723. */
  129724. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  129725. /**
  129726. * If delta time between frames should be constant
  129727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129728. */
  129729. deterministicLockstep?: boolean;
  129730. /**
  129731. * Maximum about of steps between frames (Default: 4)
  129732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129733. */
  129734. lockstepMaxSteps?: number;
  129735. /**
  129736. * Defines the seconds between each deterministic lock step
  129737. */
  129738. timeStep?: number;
  129739. /**
  129740. * Defines that engine should ignore modifying touch action attribute and style
  129741. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  129742. */
  129743. doNotHandleTouchAction?: boolean;
  129744. /**
  129745. * Defines if webaudio should be initialized as well
  129746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  129747. */
  129748. audioEngine?: boolean;
  129749. /**
  129750. * Defines the category of adapter to use.
  129751. * Is it the discrete or integrated device.
  129752. */
  129753. powerPreference?: GPUPowerPreference;
  129754. /**
  129755. * Defines the device descriptor used to create a device.
  129756. */
  129757. deviceDescriptor?: GPUDeviceDescriptor;
  129758. /**
  129759. * Defines the requested Swap Chain Format.
  129760. */
  129761. swapChainFormat?: GPUTextureFormat;
  129762. /**
  129763. * Defines wether MSAA is enabled on the canvas.
  129764. */
  129765. antialiasing?: boolean;
  129766. /**
  129767. * Defines wether the stencil buffer should be enabled.
  129768. */
  129769. stencil?: boolean;
  129770. /**
  129771. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  129772. */
  129773. enableGPUDebugMarkers?: boolean;
  129774. /**
  129775. * Options to load the associated Glslang library
  129776. */
  129777. glslangOptions?: GlslangOptions;
  129778. }
  129779. /**
  129780. * The web GPU engine class provides support for WebGPU version of babylon.js.
  129781. */
  129782. export class WebGPUEngine extends Engine {
  129783. private static readonly _glslangDefaultOptions;
  129784. private readonly _uploadEncoderDescriptor;
  129785. private readonly _renderEncoderDescriptor;
  129786. private readonly _renderTargetEncoderDescriptor;
  129787. private readonly _clearDepthValue;
  129788. private readonly _clearReverseDepthValue;
  129789. private readonly _clearStencilValue;
  129790. private readonly _defaultSampleCount;
  129791. private _canvas;
  129792. private _options;
  129793. private _glslang;
  129794. private _adapter;
  129795. private _adapterSupportedExtensions;
  129796. private _device;
  129797. private _deviceEnabledExtensions;
  129798. private _context;
  129799. private _swapChain;
  129800. private _swapChainTexture;
  129801. private _mainPassSampleCount;
  129802. private _textureHelper;
  129803. private _bufferManager;
  129804. private _shaderManager;
  129805. private _cacheSampler;
  129806. private _cacheRenderPipeline;
  129807. private _emptyVertexBuffer;
  129808. private _lastCachedWrapU;
  129809. private _lastCachedWrapV;
  129810. private _lastCachedWrapR;
  129811. private _mrtAttachments;
  129812. private _counters;
  129813. private _mainTexture;
  129814. private _depthTexture;
  129815. private _mainTextureExtends;
  129816. private _depthTextureFormat;
  129817. private _colorFormat;
  129818. private _uploadEncoder;
  129819. private _renderEncoder;
  129820. private _renderTargetEncoder;
  129821. private _commandBuffers;
  129822. private _currentRenderPass;
  129823. private _mainRenderPassWrapper;
  129824. private _rttRenderPassWrapper;
  129825. private _pendingDebugCommands;
  129826. private _currentVertexBuffers;
  129827. private _currentIndexBuffer;
  129828. private __colorWrite;
  129829. private _uniformsBuffers;
  129830. private _forceEnableEffect;
  129831. /** @hidden */
  129832. dbgShowShaderCode: boolean;
  129833. /** @hidden */
  129834. dbgSanityChecks: boolean;
  129835. /** @hidden */
  129836. dbgGenerateLogs: boolean;
  129837. /** @hidden */
  129838. dbgVerboseLogsForFirstFrames: boolean;
  129839. /** @hidden */
  129840. dbgVerboseLogsNumFrames: number;
  129841. /** @hidden */
  129842. dbgShowWarningsNotImplemented: boolean;
  129843. /**
  129844. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  129845. */
  129846. get disableCacheSamplers(): boolean;
  129847. set disableCacheSamplers(disable: boolean);
  129848. /**
  129849. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  129850. */
  129851. get disableCacheRenderPipelines(): boolean;
  129852. set disableCacheRenderPipelines(disable: boolean);
  129853. /**
  129854. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  129855. * @returns true if the engine can be created
  129856. */
  129857. static get IsSupported(): boolean;
  129858. /**
  129859. * Gets a boolean indicating that the engine supports uniform buffers
  129860. */
  129861. get supportsUniformBuffers(): boolean;
  129862. /** Gets the supported extensions by the WebGPU adapter */
  129863. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  129864. /** Gets the currently enabled extensions on the WebGPU device */
  129865. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  129866. /**
  129867. * Returns the name of the engine
  129868. */
  129869. get name(): string;
  129870. /**
  129871. * Returns a string describing the current engine
  129872. */
  129873. get description(): string;
  129874. /**
  129875. * Returns the version of the engine
  129876. */
  129877. get version(): number;
  129878. /**
  129879. * Create a new instance of the gpu engine asynchronously
  129880. * @param canvas Defines the canvas to use to display the result
  129881. * @param options Defines the options passed to the engine to create the GPU context dependencies
  129882. * @returns a promise that resolves with the created engine
  129883. */
  129884. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  129885. /**
  129886. * Create a new instance of the gpu engine.
  129887. * @param canvas Defines the canvas to use to display the result
  129888. * @param options Defines the options passed to the engine to create the GPU context dependencies
  129889. */
  129890. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  129891. /**
  129892. * Initializes the WebGPU context and dependencies.
  129893. * @param glslangOptions Defines the GLSLang compiler options if necessary
  129894. * @returns a promise notifying the readiness of the engine.
  129895. */
  129896. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  129897. private _initGlslang;
  129898. private _initializeLimits;
  129899. private _initializeContextAndSwapChain;
  129900. private _initializeMainAttachments;
  129901. /**
  129902. * Force a specific size of the canvas
  129903. * @param width defines the new canvas' width
  129904. * @param height defines the new canvas' height
  129905. * @param forceSetSize true to force setting the sizes of the underlying canvas
  129906. * @returns true if the size was changed
  129907. */
  129908. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  129909. /**
  129910. * Gets a shader processor implementation fitting with the current engine type.
  129911. * @returns The shader processor implementation.
  129912. */
  129913. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  129914. /** @hidden */
  129915. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  129916. /**
  129917. * Force the entire cache to be cleared
  129918. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  129919. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129920. */
  129921. wipeCaches(bruteForce?: boolean): void;
  129922. /**
  129923. * Enable or disable color writing
  129924. * @param enable defines the state to set
  129925. */
  129926. setColorWrite(enable: boolean): void;
  129927. /**
  129928. * Gets a boolean indicating if color writing is enabled
  129929. * @returns the current color writing state
  129930. */
  129931. getColorWrite(): boolean;
  129932. private _viewportsCurrent;
  129933. private _resetCurrentViewport;
  129934. private _applyViewport;
  129935. /** @hidden */
  129936. _viewport(x: number, y: number, width: number, height: number): void;
  129937. private _scissorsCurrent;
  129938. protected _scissorCached: {
  129939. x: number;
  129940. y: number;
  129941. z: number;
  129942. w: number;
  129943. };
  129944. private _resetCurrentScissor;
  129945. private _applyScissor;
  129946. private _scissorIsActive;
  129947. enableScissor(x: number, y: number, width: number, height: number): void;
  129948. disableScissor(): void;
  129949. /**
  129950. * Clear the current render buffer or the current render target (if any is set up)
  129951. * @param color defines the color to use
  129952. * @param backBuffer defines if the back buffer must be cleared
  129953. * @param depth defines if the depth buffer must be cleared
  129954. * @param stencil defines if the stencil buffer must be cleared
  129955. */
  129956. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129957. /**
  129958. * Clears a list of attachments
  129959. * @param attachments list of the attachments
  129960. * @param colorMain clear color for the main attachment (the first one)
  129961. * @param colorOthers clear color for the other attachments
  129962. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  129963. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  129964. */
  129965. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  129966. /**
  129967. * Creates a vertex buffer
  129968. * @param data the data for the vertex buffer
  129969. * @returns the new buffer
  129970. */
  129971. createVertexBuffer(data: DataArray): DataBuffer;
  129972. /**
  129973. * Creates a vertex buffer
  129974. * @param data the data for the dynamic vertex buffer
  129975. * @returns the new buffer
  129976. */
  129977. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129978. /**
  129979. * Updates a vertex buffer.
  129980. * @param vertexBuffer the vertex buffer to update
  129981. * @param data the data used to update the vertex buffer
  129982. * @param byteOffset the byte offset of the data
  129983. * @param byteLength the byte length of the data
  129984. */
  129985. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129986. /**
  129987. * Creates a new index buffer
  129988. * @param indices defines the content of the index buffer
  129989. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  129990. * @returns a new buffer
  129991. */
  129992. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  129993. /**
  129994. * Update an index buffer
  129995. * @param indexBuffer defines the target index buffer
  129996. * @param indices defines the data to update
  129997. * @param offset defines the offset in the target index buffer where update should start
  129998. */
  129999. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130000. /** @hidden */
  130001. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  130002. /** @hidden */
  130003. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  130004. /**
  130005. * Bind a list of vertex buffers with the engine
  130006. * @param vertexBuffers defines the list of vertex buffers to bind
  130007. * @param indexBuffer defines the index buffer to bind
  130008. * @param effect defines the effect associated with the vertex buffers
  130009. */
  130010. bindBuffers(vertexBuffers: {
  130011. [key: string]: Nullable<VertexBuffer>;
  130012. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  130013. /** @hidden */
  130014. _releaseBuffer(buffer: DataBuffer): boolean;
  130015. createUniformBuffer(elements: FloatArray): DataBuffer;
  130016. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  130017. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  130018. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  130019. /**
  130020. * Create a new effect (used to store vertex/fragment shaders)
  130021. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  130022. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  130023. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  130024. * @param samplers defines an array of string used to represent textures
  130025. * @param defines defines the string containing the defines to use to compile the shaders
  130026. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  130027. * @param onCompiled defines a function to call when the effect creation is successful
  130028. * @param onError defines a function to call when the effect creation has failed
  130029. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  130030. * @returns the new Effect
  130031. */
  130032. 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;
  130033. private _compileRawShaderToSpirV;
  130034. private _compileShaderToSpirV;
  130035. private _createPipelineStageDescriptor;
  130036. private _compileRawPipelineStageDescriptor;
  130037. private _compilePipelineStageDescriptor;
  130038. /** @hidden */
  130039. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  130040. /** @hidden */
  130041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  130042. /**
  130043. * Creates a new pipeline context
  130044. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  130045. * @returns the new pipeline
  130046. */
  130047. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  130048. /** @hidden */
  130049. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  130050. /**
  130051. * Gets the list of active attributes for a given WebGPU program
  130052. * @param pipelineContext defines the pipeline context to use
  130053. * @param attributesNames defines the list of attribute names to get
  130054. * @returns an array of indices indicating the offset of each attribute
  130055. */
  130056. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130057. /**
  130058. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130059. * @param effect defines the effect to activate
  130060. */
  130061. enableEffect(effect: Nullable<Effect>): void;
  130062. /** @hidden */
  130063. _releaseEffect(effect: Effect): void;
  130064. /**
  130065. * 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
  130066. */
  130067. releaseEffects(): void;
  130068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130069. /**
  130070. * Gets a boolean indicating that only power of 2 textures are supported
  130071. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  130072. */
  130073. get needPOTTextures(): boolean;
  130074. /** @hidden */
  130075. _createHardwareTexture(): HardwareTextureWrapper;
  130076. /** @hidden */
  130077. _releaseTexture(texture: InternalTexture): void;
  130078. /** @hidden */
  130079. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  130080. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  130081. /**
  130082. * Usually called from Texture.ts.
  130083. * Passed information to create a hardware texture
  130084. * @param url defines a value which contains one of the following:
  130085. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130086. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130087. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130088. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130089. * @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)
  130090. * @param scene needed for loading to the correct scene
  130091. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130092. * @param onLoad optional callback to be called upon successful completion
  130093. * @param onError optional callback to be called upon failure
  130094. * @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
  130095. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130096. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130097. * @param forcedExtension defines the extension to use to pick the right loader
  130098. * @param mimeType defines an optional mime type
  130099. * @param loaderOptions options to be passed to the loader
  130100. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130101. */
  130102. 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;
  130103. /** @hidden */
  130104. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  130105. /**
  130106. * Creates a cube texture
  130107. * @param rootUrl defines the url where the files to load is located
  130108. * @param scene defines the current scene
  130109. * @param files defines the list of files to load (1 per face)
  130110. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130111. * @param onLoad defines an optional callback raised when the texture is loaded
  130112. * @param onError defines an optional callback raised if there is an issue to load the texture
  130113. * @param format defines the format of the data
  130114. * @param forcedExtension defines the extension to use to pick the right loader
  130115. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130116. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130117. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130118. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130119. * @param loaderOptions options to be passed to the loader
  130120. * @returns the cube texture as an InternalTexture
  130121. */
  130122. 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;
  130123. /**
  130124. * Creates a raw texture
  130125. * @param data defines the data to store in the texture
  130126. * @param width defines the width of the texture
  130127. * @param height defines the height of the texture
  130128. * @param format defines the format of the data
  130129. * @param generateMipMaps defines if the engine should generate the mip levels
  130130. * @param invertY defines if data must be stored with Y axis inverted
  130131. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  130132. * @param compression defines the compression used (null by default)
  130133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130134. * @returns the raw texture inside an InternalTexture
  130135. */
  130136. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  130137. /**
  130138. * Creates a new raw cube texture
  130139. * @param data defines the array of data to use to create each face
  130140. * @param size defines the size of the textures
  130141. * @param format defines the format of the data
  130142. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130143. * @param generateMipMaps defines if the engine should generate the mip levels
  130144. * @param invertY defines if data must be stored with Y axis inverted
  130145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130146. * @param compression defines the compression used (null by default)
  130147. * @returns the cube texture as an InternalTexture
  130148. */
  130149. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  130150. /**
  130151. * Creates a new raw cube texture from a specified url
  130152. * @param url defines the url where the data is located
  130153. * @param scene defines the current scene
  130154. * @param size defines the size of the textures
  130155. * @param format defines the format of the data
  130156. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130157. * @param noMipmap defines if the engine should avoid generating the mip levels
  130158. * @param callback defines a callback used to extract texture data from loaded data
  130159. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  130160. * @param onLoad defines a callback called when texture is loaded
  130161. * @param onError defines a callback called if there is an error
  130162. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130163. * @param invertY defines if data must be stored with Y axis inverted
  130164. * @returns the cube texture as an InternalTexture
  130165. */
  130166. 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;
  130167. /**
  130168. * Creates a new raw 2D array texture
  130169. * @param data defines the data used to create the texture
  130170. * @param width defines the width of the texture
  130171. * @param height defines the height of the texture
  130172. * @param depth defines the number of layers of the texture
  130173. * @param format defines the format of the texture
  130174. * @param generateMipMaps defines if the engine must generate mip levels
  130175. * @param invertY defines if data must be stored with Y axis inverted
  130176. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130177. * @param compression defines the compressed used (can be null)
  130178. * @param textureType defines the compressed used (can be null)
  130179. * @returns a new raw 2D array texture (stored in an InternalTexture)
  130180. */
  130181. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  130182. /**
  130183. * Creates a new raw 3D texture
  130184. * @param data defines the data used to create the texture
  130185. * @param width defines the width of the texture
  130186. * @param height defines the height of the texture
  130187. * @param depth defines the depth of the texture
  130188. * @param format defines the format of the texture
  130189. * @param generateMipMaps defines if the engine must generate mip levels
  130190. * @param invertY defines if data must be stored with Y axis inverted
  130191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130192. * @param compression defines the compressed used (can be null)
  130193. * @param textureType defines the compressed used (can be null)
  130194. * @returns a new raw 3D texture (stored in an InternalTexture)
  130195. */
  130196. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  130197. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  130198. /**
  130199. * Update the sampling mode of a given texture
  130200. * @param samplingMode defines the required sampling mode
  130201. * @param texture defines the texture to update
  130202. * @param generateMipMaps defines whether to generate mipmaps for the texture
  130203. */
  130204. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  130205. /**
  130206. * Update the sampling mode of a given texture
  130207. * @param texture defines the texture to update
  130208. * @param wrapU defines the texture wrap mode of the u coordinates
  130209. * @param wrapV defines the texture wrap mode of the v coordinates
  130210. * @param wrapR defines the texture wrap mode of the r coordinates
  130211. */
  130212. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  130213. /**
  130214. * Update the dimensions of a texture
  130215. * @param texture texture to update
  130216. * @param width new width of the texture
  130217. * @param height new height of the texture
  130218. * @param depth new depth of the texture
  130219. */
  130220. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  130221. private _setInternalTexture;
  130222. /**
  130223. * Sets a texture to the according uniform.
  130224. * @param channel The texture channel
  130225. * @param unused unused parameter
  130226. * @param texture The texture to apply
  130227. * @param name The name of the uniform in the effect
  130228. */
  130229. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  130230. /**
  130231. * Sets an array of texture to the WebGPU context
  130232. * @param channel defines the channel where the texture array must be set
  130233. * @param unused unused parameter
  130234. * @param textures defines the array of textures to bind
  130235. * @param name name of the channel
  130236. */
  130237. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  130238. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  130239. /** @hidden */
  130240. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  130241. /** @hidden */
  130242. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  130243. private _generateMipmaps;
  130244. /**
  130245. * Update the content of a texture
  130246. * @param texture defines the texture to update
  130247. * @param canvas defines the source containing the data
  130248. * @param invertY defines if data must be stored with Y axis inverted
  130249. * @param premulAlpha defines if alpha is stored as premultiplied
  130250. * @param format defines the format of the data
  130251. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130252. */
  130253. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  130254. /**
  130255. * Update a portion of an internal texture
  130256. * @param texture defines the texture to update
  130257. * @param imageData defines the data to store into the texture
  130258. * @param xOffset defines the x coordinates of the update rectangle
  130259. * @param yOffset defines the y coordinates of the update rectangle
  130260. * @param width defines the width of the update rectangle
  130261. * @param height defines the height of the update rectangle
  130262. * @param faceIndex defines the face index if texture is a cube (0 by default)
  130263. * @param lod defines the lod level to update (0 by default)
  130264. */
  130265. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  130266. /**
  130267. * Update a video texture
  130268. * @param texture defines the texture to update
  130269. * @param video defines the video element to use
  130270. * @param invertY defines if data must be stored with Y axis inverted
  130271. */
  130272. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  130273. /** @hidden */
  130274. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130275. /** @hidden */
  130276. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  130277. /** @hidden */
  130278. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130279. /** @hidden */
  130280. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  130281. /**
  130282. * Update a raw texture
  130283. * @param texture defines the texture to update
  130284. * @param bufferView defines the data to store in the texture
  130285. * @param format defines the format of the data
  130286. * @param invertY defines if data must be stored with Y axis inverted
  130287. * @param compression defines the compression used (null by default)
  130288. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130289. */
  130290. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  130291. /**
  130292. * Update a raw cube texture
  130293. * @param texture defines the texture to udpdate
  130294. * @param bufferView defines the data to store
  130295. * @param format defines the data format
  130296. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130297. * @param invertY defines if data must be stored with Y axis inverted
  130298. * @param compression defines the compression used (null by default)
  130299. * @param level defines which level of the texture to update
  130300. */
  130301. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  130302. /**
  130303. * Update a raw 2D array texture
  130304. * @param texture defines the texture to update
  130305. * @param bufferView defines the data to store
  130306. * @param format defines the data format
  130307. * @param invertY defines if data must be stored with Y axis inverted
  130308. * @param compression defines the used compression (can be null)
  130309. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130310. */
  130311. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  130312. /**
  130313. * Update a raw 3D texture
  130314. * @param texture defines the texture to update
  130315. * @param bufferView defines the data to store
  130316. * @param format defines the data format
  130317. * @param invertY defines if data must be stored with Y axis inverted
  130318. * @param compression defines the used compression (can be null)
  130319. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130320. */
  130321. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  130322. /**
  130323. * Reads pixels from the current frame buffer. Please note that this function can be slow
  130324. * @param x defines the x coordinate of the rectangle where pixels must be read
  130325. * @param y defines the y coordinate of the rectangle where pixels must be read
  130326. * @param width defines the width of the rectangle where pixels must be read
  130327. * @param height defines the height of the rectangle where pixels must be read
  130328. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  130329. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  130330. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  130331. */
  130332. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  130333. /** @hidden */
  130334. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  130335. /**
  130336. * Creates a new render target texture
  130337. * @param size defines the size of the texture
  130338. * @param options defines the options used to create the texture
  130339. * @returns a new render target texture stored in an InternalTexture
  130340. */
  130341. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130342. /**
  130343. * Create a multi render target texture
  130344. * @param size defines the size of the texture
  130345. * @param options defines the creation options
  130346. * @returns the cube texture as an InternalTexture
  130347. */
  130348. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  130349. /**
  130350. * Creates a new render target cube texture
  130351. * @param size defines the size of the texture
  130352. * @param options defines the options used to create the texture
  130353. * @returns a new render target cube texture stored in an InternalTexture
  130354. */
  130355. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  130356. /** @hidden */
  130357. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  130358. width: number;
  130359. height: number;
  130360. layers?: number;
  130361. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  130362. /** @hidden */
  130363. _createDepthStencilTexture(size: number | {
  130364. width: number;
  130365. height: number;
  130366. layers?: number;
  130367. }, options: DepthTextureCreationOptions): InternalTexture;
  130368. /** @hidden */
  130369. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  130370. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  130371. /**
  130372. * Update the sample count for a given multiple render target texture
  130373. * @param textures defines the textures to update
  130374. * @param samples defines the sample count to set
  130375. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  130376. */
  130377. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  130378. /**
  130379. * Begin a new frame
  130380. */
  130381. beginFrame(): void;
  130382. /**
  130383. * End the current frame
  130384. */
  130385. endFrame(): void;
  130386. /**
  130387. * Force a WebGPU flush (ie. a flush of all waiting commands)
  130388. */
  130389. flushFramebuffer(): void;
  130390. private _startRenderTargetRenderPass;
  130391. private _endRenderTargetRenderPass;
  130392. private _getCurrentRenderPass;
  130393. private _startMainRenderPass;
  130394. private _endMainRenderPass;
  130395. /**
  130396. * Restores the WebGPU state to only draw on the main color attachment
  130397. */
  130398. restoreSingleAttachment(): void;
  130399. /**
  130400. * Creates a layout object to draw/clear on specific textures in a MRT
  130401. * @param textureStatus textureStatus[i] indicates if the i-th is active
  130402. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  130403. */
  130404. buildTextureLayout(textureStatus: boolean[]): number[];
  130405. /**
  130406. * Select a subsets of attachments to draw to.
  130407. * @param attachments index of attachments
  130408. */
  130409. bindAttachments(attachments: number[]): void;
  130410. /**
  130411. * Binds the frame buffer to the specified texture.
  130412. * @param texture The texture to render to or null for the default canvas
  130413. * @param faceIndex The face of the texture to render to in case of cube texture
  130414. * @param requiredWidth The width of the target to render to
  130415. * @param requiredHeight The height of the target to render to
  130416. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130417. * @param lodLevel defines the lod level to bind to the frame buffer
  130418. * @param layer defines the 2d array index to bind to frame buffer to
  130419. */
  130420. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  130421. /**
  130422. * Unbind the current render target texture from the WebGPU context
  130423. * @param texture defines the render target texture to unbind
  130424. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130425. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130426. */
  130427. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130428. /**
  130429. * Unbind a list of render target textures from the WebGPU context
  130430. * @param textures defines the render target textures to unbind
  130431. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130432. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130433. */
  130434. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130435. /**
  130436. * Unbind the current render target and bind the default framebuffer
  130437. */
  130438. restoreDefaultFramebuffer(): void;
  130439. setZOffset(value: number): void;
  130440. private _setColorFormat;
  130441. private _setDepthTextureFormat;
  130442. setDepthBuffer(enable: boolean): void;
  130443. setDepthWrite(enable: boolean): void;
  130444. setStencilBuffer(enable: boolean): void;
  130445. setStencilMask(mask: number): void;
  130446. setStencilFunction(stencilFunc: number): void;
  130447. setStencilFunctionReference(reference: number): void;
  130448. setStencilFunctionMask(mask: number): void;
  130449. setStencilOperationFail(operation: number): void;
  130450. setStencilOperationDepthFail(operation: number): void;
  130451. setStencilOperationPass(operation: number): void;
  130452. setDitheringState(value: boolean): void;
  130453. setRasterizerState(value: boolean): void;
  130454. setDepthFunction(depthFunc: number): void;
  130455. setDepthFunctionToGreater(): void;
  130456. setDepthFunctionToGreaterOrEqual(): void;
  130457. setDepthFunctionToLess(): void;
  130458. setDepthFunctionToLessOrEqual(): void;
  130459. /**
  130460. * Set various states to the context
  130461. * @param culling defines backface culling state
  130462. * @param zOffset defines the value to apply to zOffset (0 by default)
  130463. * @param force defines if states must be applied even if cache is up to date
  130464. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130465. */
  130466. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130467. /**
  130468. * Sets the current alpha mode
  130469. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130470. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130472. */
  130473. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130474. /**
  130475. * Sets the current alpha equation
  130476. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  130477. */
  130478. setAlphaEquation(equation: number): void;
  130479. private _getBindGroupsToRender;
  130480. private _bindVertexInputs;
  130481. private _setRenderBindGroups;
  130482. private _setRenderPipeline;
  130483. /**
  130484. * Draw a list of indexed primitives
  130485. * @param fillMode defines the primitive to use
  130486. * @param indexStart defines the starting index
  130487. * @param indexCount defines the number of index to draw
  130488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130489. */
  130490. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130491. /**
  130492. * Draw a list of unindexed primitives
  130493. * @param fillMode defines the primitive to use
  130494. * @param verticesStart defines the index of first vertex to draw
  130495. * @param verticesCount defines the count of vertices to draw
  130496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130497. */
  130498. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130499. private _bundleEncoder;
  130500. /**
  130501. * Start recording all the gpu calls into a bundle.
  130502. */
  130503. startRecordBundle(): void;
  130504. /**
  130505. * Stops recording the bundle.
  130506. * @returns the recorded bundle
  130507. */
  130508. stopRecordBundle(): GPURenderBundle;
  130509. /**
  130510. * Execute the previously recorded bundle.
  130511. * @param bundles defines the bundle to replay
  130512. */
  130513. executeBundles(bundles: GPURenderBundle[]): void;
  130514. /**
  130515. * Dispose and release all associated resources
  130516. */
  130517. dispose(): void;
  130518. /**
  130519. * Gets the current render width
  130520. * @param useScreen defines if screen size must be used (or the current render target if any)
  130521. * @returns a number defining the current render width
  130522. */
  130523. getRenderWidth(useScreen?: boolean): number;
  130524. /**
  130525. * Gets the current render height
  130526. * @param useScreen defines if screen size must be used (or the current render target if any)
  130527. * @returns a number defining the current render height
  130528. */
  130529. getRenderHeight(useScreen?: boolean): number;
  130530. /**
  130531. * Gets the HTML canvas attached with the current WebGPU context
  130532. * @returns a HTML canvas
  130533. */
  130534. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  130535. /** @hidden */
  130536. _debugPushGroup(groupName: string, targetObject?: number): void;
  130537. /** @hidden */
  130538. _debugPopGroup(targetObject?: number): void;
  130539. /** @hidden */
  130540. _debugInsertMarker(text: string, targetObject?: number): void;
  130541. private _debugFlushPendingCommands;
  130542. /**
  130543. * Get the current error code of the WebGPU context
  130544. * @returns the error code
  130545. */
  130546. getError(): number;
  130547. /** @hidden */
  130548. bindSamplers(effect: Effect): void;
  130549. /** @hidden */
  130550. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  130551. /** @hidden */
  130552. _releaseFramebufferObjects(texture: InternalTexture): void;
  130553. /** @hidden */
  130554. applyStates(): void;
  130555. /**
  130556. * Gets a boolean indicating if all created effects are ready
  130557. * @returns always true - No parallel shader compilation
  130558. */
  130559. areAllEffectsReady(): boolean;
  130560. /** @hidden */
  130561. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130562. /** @hidden */
  130563. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130564. /** @hidden */
  130565. _getUnpackAlignement(): number;
  130566. /** @hidden */
  130567. _unpackFlipY(value: boolean): void;
  130568. /** @hidden */
  130569. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  130570. min: number;
  130571. mag: number;
  130572. };
  130573. /** @hidden */
  130574. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130575. /** @hidden */
  130576. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130577. /** @hidden */
  130578. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130579. /** @hidden */
  130580. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130581. /** @hidden */
  130582. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130583. /** @hidden */
  130584. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130585. /** @hidden */
  130586. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  130587. /** @hidden */
  130588. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  130589. /** @hidden */
  130590. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  130591. /** @hidden */
  130592. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  130593. /** @hidden */
  130594. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  130595. /** @hidden */
  130596. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130597. /** @hidden */
  130598. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130599. /** @hidden */
  130600. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  130601. /** @hidden */
  130602. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  130603. /** @hidden */
  130604. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  130605. /** @hidden */
  130606. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * Define an interface for all classes that will hold resources
  130612. */
  130613. export interface IDisposable {
  130614. /**
  130615. * Releases all held resources
  130616. */
  130617. dispose(): void;
  130618. }
  130619. /** Interface defining initialization parameters for Scene class */
  130620. export interface SceneOptions {
  130621. /**
  130622. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  130623. * It will improve performance when the number of geometries becomes important.
  130624. */
  130625. useGeometryUniqueIdsMap?: boolean;
  130626. /**
  130627. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  130628. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130629. */
  130630. useMaterialMeshMap?: boolean;
  130631. /**
  130632. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  130633. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130634. */
  130635. useClonedMeshMap?: boolean;
  130636. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  130637. virtual?: boolean;
  130638. }
  130639. /**
  130640. * Represents a scene to be rendered by the engine.
  130641. * @see https://doc.babylonjs.com/features/scene
  130642. */
  130643. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  130644. /** The fog is deactivated */
  130645. static readonly FOGMODE_NONE: number;
  130646. /** The fog density is following an exponential function */
  130647. static readonly FOGMODE_EXP: number;
  130648. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  130649. static readonly FOGMODE_EXP2: number;
  130650. /** The fog density is following a linear function. */
  130651. static readonly FOGMODE_LINEAR: number;
  130652. /**
  130653. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  130654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130655. */
  130656. static MinDeltaTime: number;
  130657. /**
  130658. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  130659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130660. */
  130661. static MaxDeltaTime: number;
  130662. /**
  130663. * Factory used to create the default material.
  130664. * @param name The name of the material to create
  130665. * @param scene The scene to create the material for
  130666. * @returns The default material
  130667. */
  130668. static DefaultMaterialFactory(scene: Scene): Material;
  130669. /**
  130670. * Factory used to create the a collision coordinator.
  130671. * @returns The collision coordinator
  130672. */
  130673. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  130674. /** @hidden */
  130675. _inputManager: InputManager;
  130676. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  130677. cameraToUseForPointers: Nullable<Camera>;
  130678. /** @hidden */
  130679. readonly _isScene: boolean;
  130680. /** @hidden */
  130681. _blockEntityCollection: boolean;
  130682. /**
  130683. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  130684. */
  130685. autoClear: boolean;
  130686. /**
  130687. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  130688. */
  130689. autoClearDepthAndStencil: boolean;
  130690. /**
  130691. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  130692. */
  130693. clearColor: Color4;
  130694. /**
  130695. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  130696. */
  130697. ambientColor: Color3;
  130698. /**
  130699. * This is use to store the default BRDF lookup for PBR materials in your scene.
  130700. * It should only be one of the following (if not the default embedded one):
  130701. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  130702. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  130703. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  130704. * The material properties need to be setup according to the type of texture in use.
  130705. */
  130706. environmentBRDFTexture: BaseTexture;
  130707. /**
  130708. * Texture used in all pbr material as the reflection texture.
  130709. * As in the majority of the scene they are the same (exception for multi room and so on),
  130710. * this is easier to reference from here than from all the materials.
  130711. */
  130712. get environmentTexture(): Nullable<BaseTexture>;
  130713. /**
  130714. * Texture used in all pbr material as the reflection texture.
  130715. * As in the majority of the scene they are the same (exception for multi room and so on),
  130716. * this is easier to set here than in all the materials.
  130717. */
  130718. set environmentTexture(value: Nullable<BaseTexture>);
  130719. /** @hidden */
  130720. protected _environmentIntensity: number;
  130721. /**
  130722. * Intensity of the environment in all pbr material.
  130723. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130724. * As in the majority of the scene they are the same (exception for multi room and so on),
  130725. * this is easier to reference from here than from all the materials.
  130726. */
  130727. get environmentIntensity(): number;
  130728. /**
  130729. * Intensity of the environment in all pbr material.
  130730. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130731. * As in the majority of the scene they are the same (exception for multi room and so on),
  130732. * this is easier to set here than in all the materials.
  130733. */
  130734. set environmentIntensity(value: number);
  130735. /** @hidden */
  130736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130737. /**
  130738. * Default image processing configuration used either in the rendering
  130739. * Forward main pass or through the imageProcessingPostProcess if present.
  130740. * As in the majority of the scene they are the same (exception for multi camera),
  130741. * this is easier to reference from here than from all the materials and post process.
  130742. *
  130743. * No setter as we it is a shared configuration, you can set the values instead.
  130744. */
  130745. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130746. private _forceWireframe;
  130747. /**
  130748. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130749. */
  130750. set forceWireframe(value: boolean);
  130751. get forceWireframe(): boolean;
  130752. private _skipFrustumClipping;
  130753. /**
  130754. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  130755. */
  130756. set skipFrustumClipping(value: boolean);
  130757. get skipFrustumClipping(): boolean;
  130758. private _forcePointsCloud;
  130759. /**
  130760. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130761. */
  130762. set forcePointsCloud(value: boolean);
  130763. get forcePointsCloud(): boolean;
  130764. /**
  130765. * Gets or sets the active clipplane 1
  130766. */
  130767. clipPlane: Nullable<Plane>;
  130768. /**
  130769. * Gets or sets the active clipplane 2
  130770. */
  130771. clipPlane2: Nullable<Plane>;
  130772. /**
  130773. * Gets or sets the active clipplane 3
  130774. */
  130775. clipPlane3: Nullable<Plane>;
  130776. /**
  130777. * Gets or sets the active clipplane 4
  130778. */
  130779. clipPlane4: Nullable<Plane>;
  130780. /**
  130781. * Gets or sets the active clipplane 5
  130782. */
  130783. clipPlane5: Nullable<Plane>;
  130784. /**
  130785. * Gets or sets the active clipplane 6
  130786. */
  130787. clipPlane6: Nullable<Plane>;
  130788. /**
  130789. * Gets or sets a boolean indicating if animations are enabled
  130790. */
  130791. animationsEnabled: boolean;
  130792. private _animationPropertiesOverride;
  130793. /**
  130794. * Gets or sets the animation properties override
  130795. */
  130796. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  130797. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  130798. /**
  130799. * Gets or sets a boolean indicating if a constant deltatime has to be used
  130800. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  130801. */
  130802. useConstantAnimationDeltaTime: boolean;
  130803. /**
  130804. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  130805. * Please note that it requires to run a ray cast through the scene on every frame
  130806. */
  130807. constantlyUpdateMeshUnderPointer: boolean;
  130808. /**
  130809. * Defines the HTML cursor to use when hovering over interactive elements
  130810. */
  130811. hoverCursor: string;
  130812. /**
  130813. * Defines the HTML default cursor to use (empty by default)
  130814. */
  130815. defaultCursor: string;
  130816. /**
  130817. * Defines whether cursors are handled by the scene.
  130818. */
  130819. doNotHandleCursors: boolean;
  130820. /**
  130821. * This is used to call preventDefault() on pointer down
  130822. * in order to block unwanted artifacts like system double clicks
  130823. */
  130824. preventDefaultOnPointerDown: boolean;
  130825. /**
  130826. * This is used to call preventDefault() on pointer up
  130827. * in order to block unwanted artifacts like system double clicks
  130828. */
  130829. preventDefaultOnPointerUp: boolean;
  130830. /**
  130831. * Gets or sets user defined metadata
  130832. */
  130833. metadata: any;
  130834. /**
  130835. * For internal use only. Please do not use.
  130836. */
  130837. reservedDataStore: any;
  130838. /**
  130839. * Gets the name of the plugin used to load this scene (null by default)
  130840. */
  130841. loadingPluginName: string;
  130842. /**
  130843. * Use this array to add regular expressions used to disable offline support for specific urls
  130844. */
  130845. disableOfflineSupportExceptionRules: RegExp[];
  130846. /**
  130847. * An event triggered when the scene is disposed.
  130848. */
  130849. onDisposeObservable: Observable<Scene>;
  130850. private _onDisposeObserver;
  130851. /** Sets a function to be executed when this scene is disposed. */
  130852. set onDispose(callback: () => void);
  130853. /**
  130854. * An event triggered before rendering the scene (right after animations and physics)
  130855. */
  130856. onBeforeRenderObservable: Observable<Scene>;
  130857. private _onBeforeRenderObserver;
  130858. /** Sets a function to be executed before rendering this scene */
  130859. set beforeRender(callback: Nullable<() => void>);
  130860. /**
  130861. * An event triggered after rendering the scene
  130862. */
  130863. onAfterRenderObservable: Observable<Scene>;
  130864. /**
  130865. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  130866. */
  130867. onAfterRenderCameraObservable: Observable<Camera>;
  130868. private _onAfterRenderObserver;
  130869. /** Sets a function to be executed after rendering this scene */
  130870. set afterRender(callback: Nullable<() => void>);
  130871. /**
  130872. * An event triggered before animating the scene
  130873. */
  130874. onBeforeAnimationsObservable: Observable<Scene>;
  130875. /**
  130876. * An event triggered after animations processing
  130877. */
  130878. onAfterAnimationsObservable: Observable<Scene>;
  130879. /**
  130880. * An event triggered before draw calls are ready to be sent
  130881. */
  130882. onBeforeDrawPhaseObservable: Observable<Scene>;
  130883. /**
  130884. * An event triggered after draw calls have been sent
  130885. */
  130886. onAfterDrawPhaseObservable: Observable<Scene>;
  130887. /**
  130888. * An event triggered when the scene is ready
  130889. */
  130890. onReadyObservable: Observable<Scene>;
  130891. /**
  130892. * An event triggered before rendering a camera
  130893. */
  130894. onBeforeCameraRenderObservable: Observable<Camera>;
  130895. private _onBeforeCameraRenderObserver;
  130896. /** Sets a function to be executed before rendering a camera*/
  130897. set beforeCameraRender(callback: () => void);
  130898. /**
  130899. * An event triggered after rendering a camera
  130900. */
  130901. onAfterCameraRenderObservable: Observable<Camera>;
  130902. private _onAfterCameraRenderObserver;
  130903. /** Sets a function to be executed after rendering a camera*/
  130904. set afterCameraRender(callback: () => void);
  130905. /**
  130906. * An event triggered when active meshes evaluation is about to start
  130907. */
  130908. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  130909. /**
  130910. * An event triggered when active meshes evaluation is done
  130911. */
  130912. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  130913. /**
  130914. * An event triggered when particles rendering is about to start
  130915. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130916. */
  130917. onBeforeParticlesRenderingObservable: Observable<Scene>;
  130918. /**
  130919. * An event triggered when particles rendering is done
  130920. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130921. */
  130922. onAfterParticlesRenderingObservable: Observable<Scene>;
  130923. /**
  130924. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  130925. */
  130926. onDataLoadedObservable: Observable<Scene>;
  130927. /**
  130928. * An event triggered when a camera is created
  130929. */
  130930. onNewCameraAddedObservable: Observable<Camera>;
  130931. /**
  130932. * An event triggered when a camera is removed
  130933. */
  130934. onCameraRemovedObservable: Observable<Camera>;
  130935. /**
  130936. * An event triggered when a light is created
  130937. */
  130938. onNewLightAddedObservable: Observable<Light>;
  130939. /**
  130940. * An event triggered when a light is removed
  130941. */
  130942. onLightRemovedObservable: Observable<Light>;
  130943. /**
  130944. * An event triggered when a geometry is created
  130945. */
  130946. onNewGeometryAddedObservable: Observable<Geometry>;
  130947. /**
  130948. * An event triggered when a geometry is removed
  130949. */
  130950. onGeometryRemovedObservable: Observable<Geometry>;
  130951. /**
  130952. * An event triggered when a transform node is created
  130953. */
  130954. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  130955. /**
  130956. * An event triggered when a transform node is removed
  130957. */
  130958. onTransformNodeRemovedObservable: Observable<TransformNode>;
  130959. /**
  130960. * An event triggered when a mesh is created
  130961. */
  130962. onNewMeshAddedObservable: Observable<AbstractMesh>;
  130963. /**
  130964. * An event triggered when a mesh is removed
  130965. */
  130966. onMeshRemovedObservable: Observable<AbstractMesh>;
  130967. /**
  130968. * An event triggered when a skeleton is created
  130969. */
  130970. onNewSkeletonAddedObservable: Observable<Skeleton>;
  130971. /**
  130972. * An event triggered when a skeleton is removed
  130973. */
  130974. onSkeletonRemovedObservable: Observable<Skeleton>;
  130975. /**
  130976. * An event triggered when a material is created
  130977. */
  130978. onNewMaterialAddedObservable: Observable<Material>;
  130979. /**
  130980. * An event triggered when a multi material is created
  130981. */
  130982. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  130983. /**
  130984. * An event triggered when a material is removed
  130985. */
  130986. onMaterialRemovedObservable: Observable<Material>;
  130987. /**
  130988. * An event triggered when a multi material is removed
  130989. */
  130990. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  130991. /**
  130992. * An event triggered when a texture is created
  130993. */
  130994. onNewTextureAddedObservable: Observable<BaseTexture>;
  130995. /**
  130996. * An event triggered when a texture is removed
  130997. */
  130998. onTextureRemovedObservable: Observable<BaseTexture>;
  130999. /**
  131000. * An event triggered when render targets are about to be rendered
  131001. * Can happen multiple times per frame.
  131002. */
  131003. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  131004. /**
  131005. * An event triggered when render targets were rendered.
  131006. * Can happen multiple times per frame.
  131007. */
  131008. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  131009. /**
  131010. * An event triggered before calculating deterministic simulation step
  131011. */
  131012. onBeforeStepObservable: Observable<Scene>;
  131013. /**
  131014. * An event triggered after calculating deterministic simulation step
  131015. */
  131016. onAfterStepObservable: Observable<Scene>;
  131017. /**
  131018. * An event triggered when the activeCamera property is updated
  131019. */
  131020. onActiveCameraChanged: Observable<Scene>;
  131021. /**
  131022. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  131023. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  131024. * 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)
  131025. */
  131026. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  131027. /**
  131028. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  131029. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  131030. * 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)
  131031. */
  131032. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  131033. /**
  131034. * This Observable will when a mesh has been imported into the scene.
  131035. */
  131036. onMeshImportedObservable: Observable<AbstractMesh>;
  131037. /**
  131038. * This Observable will when an animation file has been imported into the scene.
  131039. */
  131040. onAnimationFileImportedObservable: Observable<Scene>;
  131041. /**
  131042. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  131043. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  131044. */
  131045. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  131046. /** @hidden */
  131047. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  131048. /**
  131049. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  131050. */
  131051. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  131052. /**
  131053. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  131054. */
  131055. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  131056. /**
  131057. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  131058. */
  131059. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  131060. /** Callback called when a pointer move is detected */
  131061. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  131062. /** Callback called when a pointer down is detected */
  131063. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  131064. /** Callback called when a pointer up is detected */
  131065. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  131066. /** Callback called when a pointer pick is detected */
  131067. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  131068. /**
  131069. * 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).
  131070. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  131071. */
  131072. onPrePointerObservable: Observable<PointerInfoPre>;
  131073. /**
  131074. * Observable event triggered each time an input event is received from the rendering canvas
  131075. */
  131076. onPointerObservable: Observable<PointerInfo>;
  131077. /**
  131078. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  131079. */
  131080. get unTranslatedPointer(): Vector2;
  131081. /**
  131082. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  131083. */
  131084. static get DragMovementThreshold(): number;
  131085. static set DragMovementThreshold(value: number);
  131086. /**
  131087. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  131088. */
  131089. static get LongPressDelay(): number;
  131090. static set LongPressDelay(value: number);
  131091. /**
  131092. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  131093. */
  131094. static get DoubleClickDelay(): number;
  131095. static set DoubleClickDelay(value: number);
  131096. /** If you need to check double click without raising a single click at first click, enable this flag */
  131097. static get ExclusiveDoubleClickMode(): boolean;
  131098. static set ExclusiveDoubleClickMode(value: boolean);
  131099. /** @hidden */
  131100. _mirroredCameraPosition: Nullable<Vector3>;
  131101. /**
  131102. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  131103. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  131104. */
  131105. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  131106. /**
  131107. * Observable event triggered each time an keyboard event is received from the hosting window
  131108. */
  131109. onKeyboardObservable: Observable<KeyboardInfo>;
  131110. private _useRightHandedSystem;
  131111. /**
  131112. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  131113. */
  131114. set useRightHandedSystem(value: boolean);
  131115. get useRightHandedSystem(): boolean;
  131116. private _timeAccumulator;
  131117. private _currentStepId;
  131118. private _currentInternalStep;
  131119. /**
  131120. * Sets the step Id used by deterministic lock step
  131121. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131122. * @param newStepId defines the step Id
  131123. */
  131124. setStepId(newStepId: number): void;
  131125. /**
  131126. * Gets the step Id used by deterministic lock step
  131127. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131128. * @returns the step Id
  131129. */
  131130. getStepId(): number;
  131131. /**
  131132. * Gets the internal step used by deterministic lock step
  131133. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131134. * @returns the internal step
  131135. */
  131136. getInternalStep(): number;
  131137. private _fogEnabled;
  131138. /**
  131139. * Gets or sets a boolean indicating if fog is enabled on this scene
  131140. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131141. * (Default is true)
  131142. */
  131143. set fogEnabled(value: boolean);
  131144. get fogEnabled(): boolean;
  131145. private _fogMode;
  131146. /**
  131147. * Gets or sets the fog mode to use
  131148. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131149. * | mode | value |
  131150. * | --- | --- |
  131151. * | FOGMODE_NONE | 0 |
  131152. * | FOGMODE_EXP | 1 |
  131153. * | FOGMODE_EXP2 | 2 |
  131154. * | FOGMODE_LINEAR | 3 |
  131155. */
  131156. set fogMode(value: number);
  131157. get fogMode(): number;
  131158. /**
  131159. * Gets or sets the fog color to use
  131160. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131161. * (Default is Color3(0.2, 0.2, 0.3))
  131162. */
  131163. fogColor: Color3;
  131164. /**
  131165. * Gets or sets the fog density to use
  131166. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131167. * (Default is 0.1)
  131168. */
  131169. fogDensity: number;
  131170. /**
  131171. * Gets or sets the fog start distance to use
  131172. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131173. * (Default is 0)
  131174. */
  131175. fogStart: number;
  131176. /**
  131177. * Gets or sets the fog end distance to use
  131178. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131179. * (Default is 1000)
  131180. */
  131181. fogEnd: number;
  131182. /**
  131183. * Flag indicating that the frame buffer binding is handled by another component
  131184. */
  131185. prePass: boolean;
  131186. private _shadowsEnabled;
  131187. /**
  131188. * Gets or sets a boolean indicating if shadows are enabled on this scene
  131189. */
  131190. set shadowsEnabled(value: boolean);
  131191. get shadowsEnabled(): boolean;
  131192. private _lightsEnabled;
  131193. /**
  131194. * Gets or sets a boolean indicating if lights are enabled on this scene
  131195. */
  131196. set lightsEnabled(value: boolean);
  131197. get lightsEnabled(): boolean;
  131198. /** All of the active cameras added to this scene. */
  131199. activeCameras: Nullable<Camera[]>;
  131200. /** @hidden */
  131201. _activeCamera: Nullable<Camera>;
  131202. /** Gets or sets the current active camera */
  131203. get activeCamera(): Nullable<Camera>;
  131204. set activeCamera(value: Nullable<Camera>);
  131205. private _defaultMaterial;
  131206. /** The default material used on meshes when no material is affected */
  131207. get defaultMaterial(): Material;
  131208. /** The default material used on meshes when no material is affected */
  131209. set defaultMaterial(value: Material);
  131210. private _texturesEnabled;
  131211. /**
  131212. * Gets or sets a boolean indicating if textures are enabled on this scene
  131213. */
  131214. set texturesEnabled(value: boolean);
  131215. get texturesEnabled(): boolean;
  131216. /**
  131217. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  131218. */
  131219. physicsEnabled: boolean;
  131220. /**
  131221. * Gets or sets a boolean indicating if particles are enabled on this scene
  131222. */
  131223. particlesEnabled: boolean;
  131224. /**
  131225. * Gets or sets a boolean indicating if sprites are enabled on this scene
  131226. */
  131227. spritesEnabled: boolean;
  131228. private _skeletonsEnabled;
  131229. /**
  131230. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  131231. */
  131232. set skeletonsEnabled(value: boolean);
  131233. get skeletonsEnabled(): boolean;
  131234. /**
  131235. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  131236. */
  131237. lensFlaresEnabled: boolean;
  131238. /**
  131239. * Gets or sets a boolean indicating if collisions are enabled on this scene
  131240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  131241. */
  131242. collisionsEnabled: boolean;
  131243. private _collisionCoordinator;
  131244. /** @hidden */
  131245. get collisionCoordinator(): ICollisionCoordinator;
  131246. /**
  131247. * Defines the gravity applied to this scene (used only for collisions)
  131248. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  131249. */
  131250. gravity: Vector3;
  131251. /**
  131252. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  131253. */
  131254. postProcessesEnabled: boolean;
  131255. /**
  131256. * Gets the current postprocess manager
  131257. */
  131258. postProcessManager: PostProcessManager;
  131259. /**
  131260. * Gets or sets a boolean indicating if render targets are enabled on this scene
  131261. */
  131262. renderTargetsEnabled: boolean;
  131263. /**
  131264. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  131265. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  131266. */
  131267. dumpNextRenderTargets: boolean;
  131268. /**
  131269. * The list of user defined render targets added to the scene
  131270. */
  131271. customRenderTargets: RenderTargetTexture[];
  131272. /**
  131273. * Defines if texture loading must be delayed
  131274. * If true, textures will only be loaded when they need to be rendered
  131275. */
  131276. useDelayedTextureLoading: boolean;
  131277. /**
  131278. * Gets the list of meshes imported to the scene through SceneLoader
  131279. */
  131280. importedMeshesFiles: String[];
  131281. /**
  131282. * Gets or sets a boolean indicating if probes are enabled on this scene
  131283. */
  131284. probesEnabled: boolean;
  131285. /**
  131286. * Gets or sets the current offline provider to use to store scene data
  131287. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131288. */
  131289. offlineProvider: IOfflineProvider;
  131290. /**
  131291. * Gets or sets the action manager associated with the scene
  131292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  131293. */
  131294. actionManager: AbstractActionManager;
  131295. private _meshesForIntersections;
  131296. /**
  131297. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  131298. */
  131299. proceduralTexturesEnabled: boolean;
  131300. private _engine;
  131301. private _totalVertices;
  131302. /** @hidden */
  131303. _activeIndices: PerfCounter;
  131304. /** @hidden */
  131305. _activeParticles: PerfCounter;
  131306. /** @hidden */
  131307. _activeBones: PerfCounter;
  131308. private _animationRatio;
  131309. /** @hidden */
  131310. _animationTimeLast: number;
  131311. /** @hidden */
  131312. _animationTime: number;
  131313. /**
  131314. * Gets or sets a general scale for animation speed
  131315. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  131316. */
  131317. animationTimeScale: number;
  131318. /** @hidden */
  131319. _cachedMaterial: Nullable<Material>;
  131320. /** @hidden */
  131321. _cachedEffect: Nullable<Effect>;
  131322. /** @hidden */
  131323. _cachedVisibility: Nullable<number>;
  131324. private _renderId;
  131325. private _frameId;
  131326. private _executeWhenReadyTimeoutId;
  131327. private _intermediateRendering;
  131328. private _viewUpdateFlag;
  131329. private _projectionUpdateFlag;
  131330. /** @hidden */
  131331. _toBeDisposed: Nullable<IDisposable>[];
  131332. private _activeRequests;
  131333. /** @hidden */
  131334. _pendingData: any[];
  131335. private _isDisposed;
  131336. /**
  131337. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  131338. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  131339. */
  131340. dispatchAllSubMeshesOfActiveMeshes: boolean;
  131341. private _activeMeshes;
  131342. private _processedMaterials;
  131343. private _renderTargets;
  131344. /** @hidden */
  131345. _activeParticleSystems: SmartArray<IParticleSystem>;
  131346. private _activeSkeletons;
  131347. private _softwareSkinnedMeshes;
  131348. private _renderingManager;
  131349. /** @hidden */
  131350. _activeAnimatables: Animatable[];
  131351. private _transformMatrix;
  131352. private _sceneUbo;
  131353. /** @hidden */
  131354. _viewMatrix: Matrix;
  131355. /** @hidden */
  131356. _projectionMatrix: Matrix;
  131357. /** @hidden */
  131358. _forcedViewPosition: Nullable<Vector3>;
  131359. /** @hidden */
  131360. _frustumPlanes: Plane[];
  131361. /**
  131362. * Gets the list of frustum planes (built from the active camera)
  131363. */
  131364. get frustumPlanes(): Plane[];
  131365. /**
  131366. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  131367. * This is useful if there are more lights that the maximum simulteanous authorized
  131368. */
  131369. requireLightSorting: boolean;
  131370. /** @hidden */
  131371. readonly useMaterialMeshMap: boolean;
  131372. /** @hidden */
  131373. readonly useClonedMeshMap: boolean;
  131374. private _externalData;
  131375. private _uid;
  131376. /**
  131377. * @hidden
  131378. * Backing store of defined scene components.
  131379. */
  131380. _components: ISceneComponent[];
  131381. /**
  131382. * @hidden
  131383. * Backing store of defined scene components.
  131384. */
  131385. _serializableComponents: ISceneSerializableComponent[];
  131386. /**
  131387. * List of components to register on the next registration step.
  131388. */
  131389. private _transientComponents;
  131390. /**
  131391. * Registers the transient components if needed.
  131392. */
  131393. private _registerTransientComponents;
  131394. /**
  131395. * @hidden
  131396. * Add a component to the scene.
  131397. * Note that the ccomponent could be registered on th next frame if this is called after
  131398. * the register component stage.
  131399. * @param component Defines the component to add to the scene
  131400. */
  131401. _addComponent(component: ISceneComponent): void;
  131402. /**
  131403. * @hidden
  131404. * Gets a component from the scene.
  131405. * @param name defines the name of the component to retrieve
  131406. * @returns the component or null if not present
  131407. */
  131408. _getComponent(name: string): Nullable<ISceneComponent>;
  131409. /**
  131410. * @hidden
  131411. * Defines the actions happening before camera updates.
  131412. */
  131413. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  131414. /**
  131415. * @hidden
  131416. * Defines the actions happening before clear the canvas.
  131417. */
  131418. _beforeClearStage: Stage<SimpleStageAction>;
  131419. /**
  131420. * @hidden
  131421. * Defines the actions when collecting render targets for the frame.
  131422. */
  131423. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  131424. /**
  131425. * @hidden
  131426. * Defines the actions happening for one camera in the frame.
  131427. */
  131428. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  131429. /**
  131430. * @hidden
  131431. * Defines the actions happening during the per mesh ready checks.
  131432. */
  131433. _isReadyForMeshStage: Stage<MeshStageAction>;
  131434. /**
  131435. * @hidden
  131436. * Defines the actions happening before evaluate active mesh checks.
  131437. */
  131438. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  131439. /**
  131440. * @hidden
  131441. * Defines the actions happening during the evaluate sub mesh checks.
  131442. */
  131443. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  131444. /**
  131445. * @hidden
  131446. * Defines the actions happening during the active mesh stage.
  131447. */
  131448. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  131449. /**
  131450. * @hidden
  131451. * Defines the actions happening during the per camera render target step.
  131452. */
  131453. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  131454. /**
  131455. * @hidden
  131456. * Defines the actions happening just before the active camera is drawing.
  131457. */
  131458. _beforeCameraDrawStage: Stage<CameraStageAction>;
  131459. /**
  131460. * @hidden
  131461. * Defines the actions happening just before a render target is drawing.
  131462. */
  131463. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  131464. /**
  131465. * @hidden
  131466. * Defines the actions happening just before a rendering group is drawing.
  131467. */
  131468. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  131469. /**
  131470. * @hidden
  131471. * Defines the actions happening just before a mesh is drawing.
  131472. */
  131473. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  131474. /**
  131475. * @hidden
  131476. * Defines the actions happening just after a mesh has been drawn.
  131477. */
  131478. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  131479. /**
  131480. * @hidden
  131481. * Defines the actions happening just after a rendering group has been drawn.
  131482. */
  131483. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  131484. /**
  131485. * @hidden
  131486. * Defines the actions happening just after the active camera has been drawn.
  131487. */
  131488. _afterCameraDrawStage: Stage<CameraStageAction>;
  131489. /**
  131490. * @hidden
  131491. * Defines the actions happening just after a render target has been drawn.
  131492. */
  131493. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  131494. /**
  131495. * @hidden
  131496. * Defines the actions happening just after rendering all cameras and computing intersections.
  131497. */
  131498. _afterRenderStage: Stage<SimpleStageAction>;
  131499. /**
  131500. * @hidden
  131501. * Defines the actions happening when a pointer move event happens.
  131502. */
  131503. _pointerMoveStage: Stage<PointerMoveStageAction>;
  131504. /**
  131505. * @hidden
  131506. * Defines the actions happening when a pointer down event happens.
  131507. */
  131508. _pointerDownStage: Stage<PointerUpDownStageAction>;
  131509. /**
  131510. * @hidden
  131511. * Defines the actions happening when a pointer up event happens.
  131512. */
  131513. _pointerUpStage: Stage<PointerUpDownStageAction>;
  131514. /**
  131515. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  131516. */
  131517. private geometriesByUniqueId;
  131518. private _renderBundles;
  131519. /**
  131520. * Creates a new Scene
  131521. * @param engine defines the engine to use to render this scene
  131522. * @param options defines the scene options
  131523. */
  131524. constructor(engine: Engine, options?: SceneOptions);
  131525. /**
  131526. * Gets a string identifying the name of the class
  131527. * @returns "Scene" string
  131528. */
  131529. getClassName(): string;
  131530. private _defaultMeshCandidates;
  131531. /**
  131532. * @hidden
  131533. */
  131534. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131535. private _defaultSubMeshCandidates;
  131536. /**
  131537. * @hidden
  131538. */
  131539. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131540. /**
  131541. * Sets the default candidate providers for the scene.
  131542. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  131543. * and getCollidingSubMeshCandidates to their default function
  131544. */
  131545. setDefaultCandidateProviders(): void;
  131546. /**
  131547. * Gets the mesh that is currently under the pointer
  131548. */
  131549. get meshUnderPointer(): Nullable<AbstractMesh>;
  131550. /**
  131551. * Gets or sets the current on-screen X position of the pointer
  131552. */
  131553. get pointerX(): number;
  131554. set pointerX(value: number);
  131555. /**
  131556. * Gets or sets the current on-screen Y position of the pointer
  131557. */
  131558. get pointerY(): number;
  131559. set pointerY(value: number);
  131560. /**
  131561. * Gets the cached material (ie. the latest rendered one)
  131562. * @returns the cached material
  131563. */
  131564. getCachedMaterial(): Nullable<Material>;
  131565. /**
  131566. * Gets the cached effect (ie. the latest rendered one)
  131567. * @returns the cached effect
  131568. */
  131569. getCachedEffect(): Nullable<Effect>;
  131570. /**
  131571. * Gets the cached visibility state (ie. the latest rendered one)
  131572. * @returns the cached visibility state
  131573. */
  131574. getCachedVisibility(): Nullable<number>;
  131575. /**
  131576. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  131577. * @param material defines the current material
  131578. * @param effect defines the current effect
  131579. * @param visibility defines the current visibility state
  131580. * @returns true if one parameter is not cached
  131581. */
  131582. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  131583. /**
  131584. * Gets the engine associated with the scene
  131585. * @returns an Engine
  131586. */
  131587. getEngine(): Engine;
  131588. /**
  131589. * Gets the total number of vertices rendered per frame
  131590. * @returns the total number of vertices rendered per frame
  131591. */
  131592. getTotalVertices(): number;
  131593. /**
  131594. * Gets the performance counter for total vertices
  131595. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131596. */
  131597. get totalVerticesPerfCounter(): PerfCounter;
  131598. /**
  131599. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  131600. * @returns the total number of active indices rendered per frame
  131601. */
  131602. getActiveIndices(): number;
  131603. /**
  131604. * Gets the performance counter for active indices
  131605. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131606. */
  131607. get totalActiveIndicesPerfCounter(): PerfCounter;
  131608. /**
  131609. * Gets the total number of active particles rendered per frame
  131610. * @returns the total number of active particles rendered per frame
  131611. */
  131612. getActiveParticles(): number;
  131613. /**
  131614. * Gets the performance counter for active particles
  131615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131616. */
  131617. get activeParticlesPerfCounter(): PerfCounter;
  131618. /**
  131619. * Gets the total number of active bones rendered per frame
  131620. * @returns the total number of active bones rendered per frame
  131621. */
  131622. getActiveBones(): number;
  131623. /**
  131624. * Gets the performance counter for active bones
  131625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131626. */
  131627. get activeBonesPerfCounter(): PerfCounter;
  131628. /**
  131629. * Gets the array of active meshes
  131630. * @returns an array of AbstractMesh
  131631. */
  131632. getActiveMeshes(): SmartArray<AbstractMesh>;
  131633. /**
  131634. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  131635. * @returns a number
  131636. */
  131637. getAnimationRatio(): number;
  131638. /**
  131639. * Gets an unique Id for the current render phase
  131640. * @returns a number
  131641. */
  131642. getRenderId(): number;
  131643. /**
  131644. * Gets an unique Id for the current frame
  131645. * @returns a number
  131646. */
  131647. getFrameId(): number;
  131648. /** Call this function if you want to manually increment the render Id*/
  131649. incrementRenderId(): void;
  131650. private _createUbo;
  131651. /**
  131652. * Use this method to simulate a pointer move on a mesh
  131653. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131654. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131655. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131656. * @returns the current scene
  131657. */
  131658. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131659. /**
  131660. * Use this method to simulate a pointer down on a mesh
  131661. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131662. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131663. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131664. * @returns the current scene
  131665. */
  131666. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131667. /**
  131668. * Use this method to simulate a pointer up on a mesh
  131669. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131670. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131671. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131672. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  131673. * @returns the current scene
  131674. */
  131675. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  131676. /**
  131677. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  131678. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  131679. * @returns true if the pointer was captured
  131680. */
  131681. isPointerCaptured(pointerId?: number): boolean;
  131682. /**
  131683. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  131684. * @param attachUp defines if you want to attach events to pointerup
  131685. * @param attachDown defines if you want to attach events to pointerdown
  131686. * @param attachMove defines if you want to attach events to pointermove
  131687. */
  131688. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  131689. /** Detaches all event handlers*/
  131690. detachControl(): void;
  131691. /**
  131692. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131693. * Delay loaded resources are not taking in account
  131694. * @return true if all required resources are ready
  131695. */
  131696. isReady(): boolean;
  131697. /** Resets all cached information relative to material (including effect and visibility) */
  131698. resetCachedMaterial(): void;
  131699. /**
  131700. * Registers a function to be called before every frame render
  131701. * @param func defines the function to register
  131702. */
  131703. registerBeforeRender(func: () => void): void;
  131704. /**
  131705. * Unregisters a function called before every frame render
  131706. * @param func defines the function to unregister
  131707. */
  131708. unregisterBeforeRender(func: () => void): void;
  131709. /**
  131710. * Registers a function to be called after every frame render
  131711. * @param func defines the function to register
  131712. */
  131713. registerAfterRender(func: () => void): void;
  131714. /**
  131715. * Unregisters a function called after every frame render
  131716. * @param func defines the function to unregister
  131717. */
  131718. unregisterAfterRender(func: () => void): void;
  131719. private _executeOnceBeforeRender;
  131720. /**
  131721. * The provided function will run before render once and will be disposed afterwards.
  131722. * A timeout delay can be provided so that the function will be executed in N ms.
  131723. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131724. * @param func The function to be executed.
  131725. * @param timeout optional delay in ms
  131726. */
  131727. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  131728. /** @hidden */
  131729. _addPendingData(data: any): void;
  131730. /** @hidden */
  131731. _removePendingData(data: any): void;
  131732. /**
  131733. * Returns the number of items waiting to be loaded
  131734. * @returns the number of items waiting to be loaded
  131735. */
  131736. getWaitingItemsCount(): number;
  131737. /**
  131738. * Returns a boolean indicating if the scene is still loading data
  131739. */
  131740. get isLoading(): boolean;
  131741. /**
  131742. * Registers a function to be executed when the scene is ready
  131743. * @param {Function} func - the function to be executed
  131744. */
  131745. executeWhenReady(func: () => void): void;
  131746. /**
  131747. * Returns a promise that resolves when the scene is ready
  131748. * @returns A promise that resolves when the scene is ready
  131749. */
  131750. whenReadyAsync(): Promise<void>;
  131751. /** @hidden */
  131752. _checkIsReady(): void;
  131753. /**
  131754. * Gets all animatable attached to the scene
  131755. */
  131756. get animatables(): Animatable[];
  131757. /**
  131758. * Resets the last animation time frame.
  131759. * Useful to override when animations start running when loading a scene for the first time.
  131760. */
  131761. resetLastAnimationTimeFrame(): void;
  131762. /**
  131763. * Gets the current view matrix
  131764. * @returns a Matrix
  131765. */
  131766. getViewMatrix(): Matrix;
  131767. /**
  131768. * Gets the current projection matrix
  131769. * @returns a Matrix
  131770. */
  131771. getProjectionMatrix(): Matrix;
  131772. /**
  131773. * Gets the current transform matrix
  131774. * @returns a Matrix made of View * Projection
  131775. */
  131776. getTransformMatrix(): Matrix;
  131777. /**
  131778. * Sets the current transform matrix
  131779. * @param viewL defines the View matrix to use
  131780. * @param projectionL defines the Projection matrix to use
  131781. * @param viewR defines the right View matrix to use (if provided)
  131782. * @param projectionR defines the right Projection matrix to use (if provided)
  131783. */
  131784. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  131785. /**
  131786. * Gets the uniform buffer used to store scene data
  131787. * @returns a UniformBuffer
  131788. */
  131789. getSceneUniformBuffer(): UniformBuffer;
  131790. /**
  131791. * Gets an unique (relatively to the current scene) Id
  131792. * @returns an unique number for the scene
  131793. */
  131794. getUniqueId(): number;
  131795. /**
  131796. * Add a mesh to the list of scene's meshes
  131797. * @param newMesh defines the mesh to add
  131798. * @param recursive if all child meshes should also be added to the scene
  131799. */
  131800. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  131801. /**
  131802. * Remove a mesh for the list of scene's meshes
  131803. * @param toRemove defines the mesh to remove
  131804. * @param recursive if all child meshes should also be removed from the scene
  131805. * @returns the index where the mesh was in the mesh list
  131806. */
  131807. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  131808. /**
  131809. * Add a transform node to the list of scene's transform nodes
  131810. * @param newTransformNode defines the transform node to add
  131811. */
  131812. addTransformNode(newTransformNode: TransformNode): void;
  131813. /**
  131814. * Remove a transform node for the list of scene's transform nodes
  131815. * @param toRemove defines the transform node to remove
  131816. * @returns the index where the transform node was in the transform node list
  131817. */
  131818. removeTransformNode(toRemove: TransformNode): number;
  131819. /**
  131820. * Remove a skeleton for the list of scene's skeletons
  131821. * @param toRemove defines the skeleton to remove
  131822. * @returns the index where the skeleton was in the skeleton list
  131823. */
  131824. removeSkeleton(toRemove: Skeleton): number;
  131825. /**
  131826. * Remove a morph target for the list of scene's morph targets
  131827. * @param toRemove defines the morph target to remove
  131828. * @returns the index where the morph target was in the morph target list
  131829. */
  131830. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  131831. /**
  131832. * Remove a light for the list of scene's lights
  131833. * @param toRemove defines the light to remove
  131834. * @returns the index where the light was in the light list
  131835. */
  131836. removeLight(toRemove: Light): number;
  131837. /**
  131838. * Remove a camera for the list of scene's cameras
  131839. * @param toRemove defines the camera to remove
  131840. * @returns the index where the camera was in the camera list
  131841. */
  131842. removeCamera(toRemove: Camera): number;
  131843. /**
  131844. * Remove a particle system for the list of scene's particle systems
  131845. * @param toRemove defines the particle system to remove
  131846. * @returns the index where the particle system was in the particle system list
  131847. */
  131848. removeParticleSystem(toRemove: IParticleSystem): number;
  131849. /**
  131850. * Remove a animation for the list of scene's animations
  131851. * @param toRemove defines the animation to remove
  131852. * @returns the index where the animation was in the animation list
  131853. */
  131854. removeAnimation(toRemove: Animation): number;
  131855. /**
  131856. * Will stop the animation of the given target
  131857. * @param target - the target
  131858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  131859. * @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)
  131860. */
  131861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  131862. /**
  131863. * Removes the given animation group from this scene.
  131864. * @param toRemove The animation group to remove
  131865. * @returns The index of the removed animation group
  131866. */
  131867. removeAnimationGroup(toRemove: AnimationGroup): number;
  131868. /**
  131869. * Removes the given multi-material from this scene.
  131870. * @param toRemove The multi-material to remove
  131871. * @returns The index of the removed multi-material
  131872. */
  131873. removeMultiMaterial(toRemove: MultiMaterial): number;
  131874. /**
  131875. * Removes the given material from this scene.
  131876. * @param toRemove The material to remove
  131877. * @returns The index of the removed material
  131878. */
  131879. removeMaterial(toRemove: Material): number;
  131880. /**
  131881. * Removes the given action manager from this scene.
  131882. * @param toRemove The action manager to remove
  131883. * @returns The index of the removed action manager
  131884. */
  131885. removeActionManager(toRemove: AbstractActionManager): number;
  131886. /**
  131887. * Removes the given texture from this scene.
  131888. * @param toRemove The texture to remove
  131889. * @returns The index of the removed texture
  131890. */
  131891. removeTexture(toRemove: BaseTexture): number;
  131892. /**
  131893. * Adds the given light to this scene
  131894. * @param newLight The light to add
  131895. */
  131896. addLight(newLight: Light): void;
  131897. /**
  131898. * Sorts the list list based on light priorities
  131899. */
  131900. sortLightsByPriority(): void;
  131901. /**
  131902. * Adds the given camera to this scene
  131903. * @param newCamera The camera to add
  131904. */
  131905. addCamera(newCamera: Camera): void;
  131906. /**
  131907. * Adds the given skeleton to this scene
  131908. * @param newSkeleton The skeleton to add
  131909. */
  131910. addSkeleton(newSkeleton: Skeleton): void;
  131911. /**
  131912. * Adds the given particle system to this scene
  131913. * @param newParticleSystem The particle system to add
  131914. */
  131915. addParticleSystem(newParticleSystem: IParticleSystem): void;
  131916. /**
  131917. * Adds the given animation to this scene
  131918. * @param newAnimation The animation to add
  131919. */
  131920. addAnimation(newAnimation: Animation): void;
  131921. /**
  131922. * Adds the given animation group to this scene.
  131923. * @param newAnimationGroup The animation group to add
  131924. */
  131925. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  131926. /**
  131927. * Adds the given multi-material to this scene
  131928. * @param newMultiMaterial The multi-material to add
  131929. */
  131930. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  131931. /**
  131932. * Adds the given material to this scene
  131933. * @param newMaterial The material to add
  131934. */
  131935. addMaterial(newMaterial: Material): void;
  131936. /**
  131937. * Adds the given morph target to this scene
  131938. * @param newMorphTargetManager The morph target to add
  131939. */
  131940. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  131941. /**
  131942. * Adds the given geometry to this scene
  131943. * @param newGeometry The geometry to add
  131944. */
  131945. addGeometry(newGeometry: Geometry): void;
  131946. /**
  131947. * Adds the given action manager to this scene
  131948. * @param newActionManager The action manager to add
  131949. */
  131950. addActionManager(newActionManager: AbstractActionManager): void;
  131951. /**
  131952. * Adds the given texture to this scene.
  131953. * @param newTexture The texture to add
  131954. */
  131955. addTexture(newTexture: BaseTexture): void;
  131956. /**
  131957. * Switch active camera
  131958. * @param newCamera defines the new active camera
  131959. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  131960. */
  131961. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  131962. /**
  131963. * sets the active camera of the scene using its ID
  131964. * @param id defines the camera's ID
  131965. * @return the new active camera or null if none found.
  131966. */
  131967. setActiveCameraByID(id: string): Nullable<Camera>;
  131968. /**
  131969. * sets the active camera of the scene using its name
  131970. * @param name defines the camera's name
  131971. * @returns the new active camera or null if none found.
  131972. */
  131973. setActiveCameraByName(name: string): Nullable<Camera>;
  131974. /**
  131975. * get an animation group using its name
  131976. * @param name defines the material's name
  131977. * @return the animation group or null if none found.
  131978. */
  131979. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  131980. /**
  131981. * Get a material using its unique id
  131982. * @param uniqueId defines the material's unique id
  131983. * @return the material or null if none found.
  131984. */
  131985. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  131986. /**
  131987. * get a material using its id
  131988. * @param id defines the material's ID
  131989. * @return the material or null if none found.
  131990. */
  131991. getMaterialByID(id: string): Nullable<Material>;
  131992. /**
  131993. * Gets a the last added material using a given id
  131994. * @param id defines the material's ID
  131995. * @return the last material with the given id or null if none found.
  131996. */
  131997. getLastMaterialByID(id: string): Nullable<Material>;
  131998. /**
  131999. * Gets a material using its name
  132000. * @param name defines the material's name
  132001. * @return the material or null if none found.
  132002. */
  132003. getMaterialByName(name: string): Nullable<Material>;
  132004. /**
  132005. * Get a texture using its unique id
  132006. * @param uniqueId defines the texture's unique id
  132007. * @return the texture or null if none found.
  132008. */
  132009. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  132010. /**
  132011. * Gets a camera using its id
  132012. * @param id defines the id to look for
  132013. * @returns the camera or null if not found
  132014. */
  132015. getCameraByID(id: string): Nullable<Camera>;
  132016. /**
  132017. * Gets a camera using its unique id
  132018. * @param uniqueId defines the unique id to look for
  132019. * @returns the camera or null if not found
  132020. */
  132021. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  132022. /**
  132023. * Gets a camera using its name
  132024. * @param name defines the camera's name
  132025. * @return the camera or null if none found.
  132026. */
  132027. getCameraByName(name: string): Nullable<Camera>;
  132028. /**
  132029. * Gets a bone using its id
  132030. * @param id defines the bone's id
  132031. * @return the bone or null if not found
  132032. */
  132033. getBoneByID(id: string): Nullable<Bone>;
  132034. /**
  132035. * Gets a bone using its id
  132036. * @param name defines the bone's name
  132037. * @return the bone or null if not found
  132038. */
  132039. getBoneByName(name: string): Nullable<Bone>;
  132040. /**
  132041. * Gets a light node using its name
  132042. * @param name defines the the light's name
  132043. * @return the light or null if none found.
  132044. */
  132045. getLightByName(name: string): Nullable<Light>;
  132046. /**
  132047. * Gets a light node using its id
  132048. * @param id defines the light's id
  132049. * @return the light or null if none found.
  132050. */
  132051. getLightByID(id: string): Nullable<Light>;
  132052. /**
  132053. * Gets a light node using its scene-generated unique ID
  132054. * @param uniqueId defines the light's unique id
  132055. * @return the light or null if none found.
  132056. */
  132057. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  132058. /**
  132059. * Gets a particle system by id
  132060. * @param id defines the particle system id
  132061. * @return the corresponding system or null if none found
  132062. */
  132063. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  132064. /**
  132065. * Gets a geometry using its ID
  132066. * @param id defines the geometry's id
  132067. * @return the geometry or null if none found.
  132068. */
  132069. getGeometryByID(id: string): Nullable<Geometry>;
  132070. private _getGeometryByUniqueID;
  132071. /**
  132072. * Add a new geometry to this scene
  132073. * @param geometry defines the geometry to be added to the scene.
  132074. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  132075. * @return a boolean defining if the geometry was added or not
  132076. */
  132077. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  132078. /**
  132079. * Removes an existing geometry
  132080. * @param geometry defines the geometry to be removed from the scene
  132081. * @return a boolean defining if the geometry was removed or not
  132082. */
  132083. removeGeometry(geometry: Geometry): boolean;
  132084. /**
  132085. * Gets the list of geometries attached to the scene
  132086. * @returns an array of Geometry
  132087. */
  132088. getGeometries(): Geometry[];
  132089. /**
  132090. * Gets the first added mesh found of a given ID
  132091. * @param id defines the id to search for
  132092. * @return the mesh found or null if not found at all
  132093. */
  132094. getMeshByID(id: string): Nullable<AbstractMesh>;
  132095. /**
  132096. * Gets a list of meshes using their id
  132097. * @param id defines the id to search for
  132098. * @returns a list of meshes
  132099. */
  132100. getMeshesByID(id: string): Array<AbstractMesh>;
  132101. /**
  132102. * Gets the first added transform node found of a given ID
  132103. * @param id defines the id to search for
  132104. * @return the found transform node or null if not found at all.
  132105. */
  132106. getTransformNodeByID(id: string): Nullable<TransformNode>;
  132107. /**
  132108. * Gets a transform node with its auto-generated unique id
  132109. * @param uniqueId efines the unique id to search for
  132110. * @return the found transform node or null if not found at all.
  132111. */
  132112. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  132113. /**
  132114. * Gets a list of transform nodes using their id
  132115. * @param id defines the id to search for
  132116. * @returns a list of transform nodes
  132117. */
  132118. getTransformNodesByID(id: string): Array<TransformNode>;
  132119. /**
  132120. * Gets a mesh with its auto-generated unique id
  132121. * @param uniqueId defines the unique id to search for
  132122. * @return the found mesh or null if not found at all.
  132123. */
  132124. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  132125. /**
  132126. * Gets a the last added mesh using a given id
  132127. * @param id defines the id to search for
  132128. * @return the found mesh or null if not found at all.
  132129. */
  132130. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  132131. /**
  132132. * Gets a the last added node (Mesh, Camera, Light) using a given id
  132133. * @param id defines the id to search for
  132134. * @return the found node or null if not found at all
  132135. */
  132136. getLastEntryByID(id: string): Nullable<Node>;
  132137. /**
  132138. * Gets a node (Mesh, Camera, Light) using a given id
  132139. * @param id defines the id to search for
  132140. * @return the found node or null if not found at all
  132141. */
  132142. getNodeByID(id: string): Nullable<Node>;
  132143. /**
  132144. * Gets a node (Mesh, Camera, Light) using a given name
  132145. * @param name defines the name to search for
  132146. * @return the found node or null if not found at all.
  132147. */
  132148. getNodeByName(name: string): Nullable<Node>;
  132149. /**
  132150. * Gets a mesh using a given name
  132151. * @param name defines the name to search for
  132152. * @return the found mesh or null if not found at all.
  132153. */
  132154. getMeshByName(name: string): Nullable<AbstractMesh>;
  132155. /**
  132156. * Gets a transform node using a given name
  132157. * @param name defines the name to search for
  132158. * @return the found transform node or null if not found at all.
  132159. */
  132160. getTransformNodeByName(name: string): Nullable<TransformNode>;
  132161. /**
  132162. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  132163. * @param id defines the id to search for
  132164. * @return the found skeleton or null if not found at all.
  132165. */
  132166. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  132167. /**
  132168. * Gets a skeleton using a given auto generated unique id
  132169. * @param uniqueId defines the unique id to search for
  132170. * @return the found skeleton or null if not found at all.
  132171. */
  132172. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  132173. /**
  132174. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  132175. * @param id defines the id to search for
  132176. * @return the found skeleton or null if not found at all.
  132177. */
  132178. getSkeletonById(id: string): Nullable<Skeleton>;
  132179. /**
  132180. * Gets a skeleton using a given name
  132181. * @param name defines the name to search for
  132182. * @return the found skeleton or null if not found at all.
  132183. */
  132184. getSkeletonByName(name: string): Nullable<Skeleton>;
  132185. /**
  132186. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  132187. * @param id defines the id to search for
  132188. * @return the found morph target manager or null if not found at all.
  132189. */
  132190. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  132191. /**
  132192. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  132193. * @param id defines the id to search for
  132194. * @return the found morph target or null if not found at all.
  132195. */
  132196. getMorphTargetById(id: string): Nullable<MorphTarget>;
  132197. /**
  132198. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  132199. * @param name defines the name to search for
  132200. * @return the found morph target or null if not found at all.
  132201. */
  132202. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  132203. /**
  132204. * Gets a post process using a given name (if many are found, this function will pick the first one)
  132205. * @param name defines the name to search for
  132206. * @return the found post process or null if not found at all.
  132207. */
  132208. getPostProcessByName(name: string): Nullable<PostProcess>;
  132209. /**
  132210. * Gets a boolean indicating if the given mesh is active
  132211. * @param mesh defines the mesh to look for
  132212. * @returns true if the mesh is in the active list
  132213. */
  132214. isActiveMesh(mesh: AbstractMesh): boolean;
  132215. /**
  132216. * Return a unique id as a string which can serve as an identifier for the scene
  132217. */
  132218. get uid(): string;
  132219. /**
  132220. * Add an externaly attached data from its key.
  132221. * This method call will fail and return false, if such key already exists.
  132222. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  132223. * @param key the unique key that identifies the data
  132224. * @param data the data object to associate to the key for this Engine instance
  132225. * @return true if no such key were already present and the data was added successfully, false otherwise
  132226. */
  132227. addExternalData<T>(key: string, data: T): boolean;
  132228. /**
  132229. * Get an externaly attached data from its key
  132230. * @param key the unique key that identifies the data
  132231. * @return the associated data, if present (can be null), or undefined if not present
  132232. */
  132233. getExternalData<T>(key: string): Nullable<T>;
  132234. /**
  132235. * Get an externaly attached data from its key, create it using a factory if it's not already present
  132236. * @param key the unique key that identifies the data
  132237. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  132238. * @return the associated data, can be null if the factory returned null.
  132239. */
  132240. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  132241. /**
  132242. * Remove an externaly attached data from the Engine instance
  132243. * @param key the unique key that identifies the data
  132244. * @return true if the data was successfully removed, false if it doesn't exist
  132245. */
  132246. removeExternalData(key: string): boolean;
  132247. private _evaluateSubMesh;
  132248. /**
  132249. * Clear the processed materials smart array preventing retention point in material dispose.
  132250. */
  132251. freeProcessedMaterials(): void;
  132252. private _preventFreeActiveMeshesAndRenderingGroups;
  132253. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  132254. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  132255. * when disposing several meshes in a row or a hierarchy of meshes.
  132256. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  132257. */
  132258. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  132259. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  132260. /**
  132261. * Clear the active meshes smart array preventing retention point in mesh dispose.
  132262. */
  132263. freeActiveMeshes(): void;
  132264. /**
  132265. * Clear the info related to rendering groups preventing retention points during dispose.
  132266. */
  132267. freeRenderingGroups(): void;
  132268. /** @hidden */
  132269. _isInIntermediateRendering(): boolean;
  132270. /**
  132271. * Lambda returning the list of potentially active meshes.
  132272. */
  132273. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  132274. /**
  132275. * Lambda returning the list of potentially active sub meshes.
  132276. */
  132277. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  132278. /**
  132279. * Lambda returning the list of potentially intersecting sub meshes.
  132280. */
  132281. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  132282. /**
  132283. * Lambda returning the list of potentially colliding sub meshes.
  132284. */
  132285. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  132286. /** @hidden */
  132287. _activeMeshesFrozen: boolean;
  132288. private _skipEvaluateActiveMeshesCompletely;
  132289. /**
  132290. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  132291. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  132292. * @param onSuccess optional success callback
  132293. * @param onError optional error callback
  132294. * @returns the current scene
  132295. */
  132296. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  132297. /**
  132298. * Use this function to restart evaluating active meshes on every frame
  132299. * @returns the current scene
  132300. */
  132301. unfreezeActiveMeshes(): Scene;
  132302. private _evaluateActiveMeshes;
  132303. private _activeMesh;
  132304. /**
  132305. * Update the transform matrix to update from the current active camera
  132306. * @param force defines a boolean used to force the update even if cache is up to date
  132307. */
  132308. updateTransformMatrix(force?: boolean): void;
  132309. private _bindFrameBuffer;
  132310. /** @hidden */
  132311. _allowPostProcessClearColor: boolean;
  132312. /** @hidden */
  132313. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  132314. private _processSubCameras;
  132315. private _checkIntersections;
  132316. /** @hidden */
  132317. _advancePhysicsEngineStep(step: number): void;
  132318. /**
  132319. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  132320. */
  132321. getDeterministicFrameTime: () => number;
  132322. /** @hidden */
  132323. _animate(): void;
  132324. /** Execute all animations (for a frame) */
  132325. animate(): void;
  132326. /**
  132327. * Render the scene
  132328. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  132329. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  132330. */
  132331. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  132332. /**
  132333. * Freeze all materials
  132334. * A frozen material will not be updatable but should be faster to render
  132335. */
  132336. freezeMaterials(): void;
  132337. /**
  132338. * Unfreeze all materials
  132339. * A frozen material will not be updatable but should be faster to render
  132340. */
  132341. unfreezeMaterials(): void;
  132342. /**
  132343. * Releases all held ressources
  132344. */
  132345. dispose(): void;
  132346. /**
  132347. * Gets if the scene is already disposed
  132348. */
  132349. get isDisposed(): boolean;
  132350. /**
  132351. * Call this function to reduce memory footprint of the scene.
  132352. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  132353. */
  132354. clearCachedVertexData(): void;
  132355. /**
  132356. * This function will remove the local cached buffer data from texture.
  132357. * It will save memory but will prevent the texture from being rebuilt
  132358. */
  132359. cleanCachedTextureBuffer(): void;
  132360. /**
  132361. * Get the world extend vectors with an optional filter
  132362. *
  132363. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  132364. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  132365. */
  132366. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  132367. min: Vector3;
  132368. max: Vector3;
  132369. };
  132370. /**
  132371. * Creates a ray that can be used to pick in the scene
  132372. * @param x defines the x coordinate of the origin (on-screen)
  132373. * @param y defines the y coordinate of the origin (on-screen)
  132374. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132375. * @param camera defines the camera to use for the picking
  132376. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132377. * @returns a Ray
  132378. */
  132379. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  132380. /**
  132381. * Creates a ray that can be used to pick in the scene
  132382. * @param x defines the x coordinate of the origin (on-screen)
  132383. * @param y defines the y coordinate of the origin (on-screen)
  132384. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132385. * @param result defines the ray where to store the picking ray
  132386. * @param camera defines the camera to use for the picking
  132387. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132388. * @returns the current scene
  132389. */
  132390. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  132391. /**
  132392. * Creates a ray that can be used to pick in the scene
  132393. * @param x defines the x coordinate of the origin (on-screen)
  132394. * @param y defines the y coordinate of the origin (on-screen)
  132395. * @param camera defines the camera to use for the picking
  132396. * @returns a Ray
  132397. */
  132398. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  132399. /**
  132400. * Creates a ray that can be used to pick in the scene
  132401. * @param x defines the x coordinate of the origin (on-screen)
  132402. * @param y defines the y coordinate of the origin (on-screen)
  132403. * @param result defines the ray where to store the picking ray
  132404. * @param camera defines the camera to use for the picking
  132405. * @returns the current scene
  132406. */
  132407. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  132408. /** Launch a ray to try to pick a mesh in the scene
  132409. * @param x position on screen
  132410. * @param y position on screen
  132411. * @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
  132412. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132413. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132414. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132415. * @returns a PickingInfo
  132416. */
  132417. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  132418. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  132419. * @param x position on screen
  132420. * @param y position on screen
  132421. * @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
  132422. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132423. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132424. * @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)
  132425. */
  132426. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  132427. /** Use the given ray to pick a mesh in the scene
  132428. * @param ray The ray to use to pick meshes
  132429. * @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
  132430. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132431. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132432. * @returns a PickingInfo
  132433. */
  132434. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  132435. /**
  132436. * Launch a ray to try to pick a mesh in the scene
  132437. * @param x X position on screen
  132438. * @param y Y position on screen
  132439. * @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
  132440. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132441. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132442. * @returns an array of PickingInfo
  132443. */
  132444. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  132445. /**
  132446. * Launch a ray to try to pick a mesh in the scene
  132447. * @param ray Ray to use
  132448. * @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
  132449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132450. * @returns an array of PickingInfo
  132451. */
  132452. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  132453. /**
  132454. * Force the value of meshUnderPointer
  132455. * @param mesh defines the mesh to use
  132456. * @param pointerId optional pointer id when using more than one pointer
  132457. */
  132458. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  132459. /**
  132460. * Gets the mesh under the pointer
  132461. * @returns a Mesh or null if no mesh is under the pointer
  132462. */
  132463. getPointerOverMesh(): Nullable<AbstractMesh>;
  132464. /** @hidden */
  132465. _rebuildGeometries(): void;
  132466. /** @hidden */
  132467. _rebuildTextures(): void;
  132468. private _getByTags;
  132469. /**
  132470. * Get a list of meshes by tags
  132471. * @param tagsQuery defines the tags query to use
  132472. * @param forEach defines a predicate used to filter results
  132473. * @returns an array of Mesh
  132474. */
  132475. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  132476. /**
  132477. * Get a list of cameras by tags
  132478. * @param tagsQuery defines the tags query to use
  132479. * @param forEach defines a predicate used to filter results
  132480. * @returns an array of Camera
  132481. */
  132482. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  132483. /**
  132484. * Get a list of lights by tags
  132485. * @param tagsQuery defines the tags query to use
  132486. * @param forEach defines a predicate used to filter results
  132487. * @returns an array of Light
  132488. */
  132489. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  132490. /**
  132491. * Get a list of materials by tags
  132492. * @param tagsQuery defines the tags query to use
  132493. * @param forEach defines a predicate used to filter results
  132494. * @returns an array of Material
  132495. */
  132496. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  132497. /**
  132498. * Get a list of transform nodes by tags
  132499. * @param tagsQuery defines the tags query to use
  132500. * @param forEach defines a predicate used to filter results
  132501. * @returns an array of TransformNode
  132502. */
  132503. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  132504. /**
  132505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  132506. * This allowed control for front to back rendering or reversly depending of the special needs.
  132507. *
  132508. * @param renderingGroupId The rendering group id corresponding to its index
  132509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  132510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  132511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  132512. */
  132513. 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;
  132514. /**
  132515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  132516. *
  132517. * @param renderingGroupId The rendering group id corresponding to its index
  132518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  132520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  132521. */
  132522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  132523. /**
  132524. * Gets the current auto clear configuration for one rendering group of the rendering
  132525. * manager.
  132526. * @param index the rendering group index to get the information for
  132527. * @returns The auto clear setup for the requested rendering group
  132528. */
  132529. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  132530. private _blockMaterialDirtyMechanism;
  132531. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  132532. get blockMaterialDirtyMechanism(): boolean;
  132533. set blockMaterialDirtyMechanism(value: boolean);
  132534. /**
  132535. * Will flag all materials as dirty to trigger new shader compilation
  132536. * @param flag defines the flag used to specify which material part must be marked as dirty
  132537. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  132538. */
  132539. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  132540. /** @hidden */
  132541. _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;
  132542. /** @hidden */
  132543. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132544. /** @hidden */
  132545. _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;
  132546. /** @hidden */
  132547. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  132548. /** @hidden */
  132549. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  132550. /** @hidden */
  132551. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132552. }
  132553. }
  132554. declare module BABYLON {
  132555. /**
  132556. * Set of assets to keep when moving a scene into an asset container.
  132557. */
  132558. export class KeepAssets extends AbstractScene {
  132559. }
  132560. /**
  132561. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  132562. */
  132563. export class InstantiatedEntries {
  132564. /**
  132565. * List of new root nodes (eg. nodes with no parent)
  132566. */
  132567. rootNodes: TransformNode[];
  132568. /**
  132569. * List of new skeletons
  132570. */
  132571. skeletons: Skeleton[];
  132572. /**
  132573. * List of new animation groups
  132574. */
  132575. animationGroups: AnimationGroup[];
  132576. }
  132577. /**
  132578. * Container with a set of assets that can be added or removed from a scene.
  132579. */
  132580. export class AssetContainer extends AbstractScene {
  132581. private _wasAddedToScene;
  132582. /**
  132583. * The scene the AssetContainer belongs to.
  132584. */
  132585. scene: Scene;
  132586. /**
  132587. * Instantiates an AssetContainer.
  132588. * @param scene The scene the AssetContainer belongs to.
  132589. */
  132590. constructor(scene: Scene);
  132591. /**
  132592. * Instantiate or clone all meshes and add the new ones to the scene.
  132593. * Skeletons and animation groups will all be cloned
  132594. * @param nameFunction defines an optional function used to get new names for clones
  132595. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  132596. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  132597. */
  132598. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  132599. /**
  132600. * Adds all the assets from the container to the scene.
  132601. */
  132602. addAllToScene(): void;
  132603. /**
  132604. * Removes all the assets in the container from the scene
  132605. */
  132606. removeAllFromScene(): void;
  132607. /**
  132608. * Disposes all the assets in the container
  132609. */
  132610. dispose(): void;
  132611. private _moveAssets;
  132612. /**
  132613. * Removes all the assets contained in the scene and adds them to the container.
  132614. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132615. */
  132616. moveAllFromScene(keepAssets?: KeepAssets): void;
  132617. /**
  132618. * 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.
  132619. * @returns the root mesh
  132620. */
  132621. createRootMesh(): Mesh;
  132622. /**
  132623. * Merge animations (direct and animation groups) from this asset container into a scene
  132624. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132625. * @param animatables set of animatables to retarget to a node from the scene
  132626. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  132627. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  132628. */
  132629. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  132630. }
  132631. }
  132632. declare module BABYLON {
  132633. /**
  132634. * Defines how the parser contract is defined.
  132635. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  132636. */
  132637. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  132638. /**
  132639. * Defines how the individual parser contract is defined.
  132640. * These parser can parse an individual asset
  132641. */
  132642. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  132643. /**
  132644. * Base class of the scene acting as a container for the different elements composing a scene.
  132645. * This class is dynamically extended by the different components of the scene increasing
  132646. * flexibility and reducing coupling
  132647. */
  132648. export abstract class AbstractScene {
  132649. /**
  132650. * Stores the list of available parsers in the application.
  132651. */
  132652. private static _BabylonFileParsers;
  132653. /**
  132654. * Stores the list of available individual parsers in the application.
  132655. */
  132656. private static _IndividualBabylonFileParsers;
  132657. /**
  132658. * Adds a parser in the list of available ones
  132659. * @param name Defines the name of the parser
  132660. * @param parser Defines the parser to add
  132661. */
  132662. static AddParser(name: string, parser: BabylonFileParser): void;
  132663. /**
  132664. * Gets a general parser from the list of avaialble ones
  132665. * @param name Defines the name of the parser
  132666. * @returns the requested parser or null
  132667. */
  132668. static GetParser(name: string): Nullable<BabylonFileParser>;
  132669. /**
  132670. * Adds n individual parser in the list of available ones
  132671. * @param name Defines the name of the parser
  132672. * @param parser Defines the parser to add
  132673. */
  132674. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  132675. /**
  132676. * Gets an individual parser from the list of avaialble ones
  132677. * @param name Defines the name of the parser
  132678. * @returns the requested parser or null
  132679. */
  132680. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  132681. /**
  132682. * Parser json data and populate both a scene and its associated container object
  132683. * @param jsonData Defines the data to parse
  132684. * @param scene Defines the scene to parse the data for
  132685. * @param container Defines the container attached to the parsing sequence
  132686. * @param rootUrl Defines the root url of the data
  132687. */
  132688. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  132689. /**
  132690. * Gets the list of root nodes (ie. nodes with no parent)
  132691. */
  132692. rootNodes: Node[];
  132693. /** All of the cameras added to this scene
  132694. * @see https://doc.babylonjs.com/babylon101/cameras
  132695. */
  132696. cameras: Camera[];
  132697. /**
  132698. * All of the lights added to this scene
  132699. * @see https://doc.babylonjs.com/babylon101/lights
  132700. */
  132701. lights: Light[];
  132702. /**
  132703. * All of the (abstract) meshes added to this scene
  132704. */
  132705. meshes: AbstractMesh[];
  132706. /**
  132707. * The list of skeletons added to the scene
  132708. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132709. */
  132710. skeletons: Skeleton[];
  132711. /**
  132712. * All of the particle systems added to this scene
  132713. * @see https://doc.babylonjs.com/babylon101/particles
  132714. */
  132715. particleSystems: IParticleSystem[];
  132716. /**
  132717. * Gets a list of Animations associated with the scene
  132718. */
  132719. animations: Animation[];
  132720. /**
  132721. * All of the animation groups added to this scene
  132722. * @see https://doc.babylonjs.com/how_to/group
  132723. */
  132724. animationGroups: AnimationGroup[];
  132725. /**
  132726. * All of the multi-materials added to this scene
  132727. * @see https://doc.babylonjs.com/how_to/multi_materials
  132728. */
  132729. multiMaterials: MultiMaterial[];
  132730. /**
  132731. * All of the materials added to this scene
  132732. * In the context of a Scene, it is not supposed to be modified manually.
  132733. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  132734. * Note also that the order of the Material within the array is not significant and might change.
  132735. * @see https://doc.babylonjs.com/babylon101/materials
  132736. */
  132737. materials: Material[];
  132738. /**
  132739. * The list of morph target managers added to the scene
  132740. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132741. */
  132742. morphTargetManagers: MorphTargetManager[];
  132743. /**
  132744. * The list of geometries used in the scene.
  132745. */
  132746. geometries: Geometry[];
  132747. /**
  132748. * All of the tranform nodes added to this scene
  132749. * In the context of a Scene, it is not supposed to be modified manually.
  132750. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132751. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132752. * @see https://doc.babylonjs.com/how_to/transformnode
  132753. */
  132754. transformNodes: TransformNode[];
  132755. /**
  132756. * ActionManagers available on the scene.
  132757. */
  132758. actionManagers: AbstractActionManager[];
  132759. /**
  132760. * Textures to keep.
  132761. */
  132762. textures: BaseTexture[];
  132763. /** @hidden */
  132764. protected _environmentTexture: Nullable<BaseTexture>;
  132765. /**
  132766. * Texture used in all pbr material as the reflection texture.
  132767. * As in the majority of the scene they are the same (exception for multi room and so on),
  132768. * this is easier to reference from here than from all the materials.
  132769. */
  132770. get environmentTexture(): Nullable<BaseTexture>;
  132771. set environmentTexture(value: Nullable<BaseTexture>);
  132772. /**
  132773. * The list of postprocesses added to the scene
  132774. */
  132775. postProcesses: PostProcess[];
  132776. /**
  132777. * @returns all meshes, lights, cameras, transformNodes and bones
  132778. */
  132779. getNodes(): Array<Node>;
  132780. }
  132781. }
  132782. declare module BABYLON {
  132783. /**
  132784. * Interface used to define options for Sound class
  132785. */
  132786. export interface ISoundOptions {
  132787. /**
  132788. * Does the sound autoplay once loaded.
  132789. */
  132790. autoplay?: boolean;
  132791. /**
  132792. * Does the sound loop after it finishes playing once.
  132793. */
  132794. loop?: boolean;
  132795. /**
  132796. * Sound's volume
  132797. */
  132798. volume?: number;
  132799. /**
  132800. * Is it a spatial sound?
  132801. */
  132802. spatialSound?: boolean;
  132803. /**
  132804. * Maximum distance to hear that sound
  132805. */
  132806. maxDistance?: number;
  132807. /**
  132808. * Uses user defined attenuation function
  132809. */
  132810. useCustomAttenuation?: boolean;
  132811. /**
  132812. * Define the roll off factor of spatial sounds.
  132813. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132814. */
  132815. rolloffFactor?: number;
  132816. /**
  132817. * Define the reference distance the sound should be heard perfectly.
  132818. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132819. */
  132820. refDistance?: number;
  132821. /**
  132822. * Define the distance attenuation model the sound will follow.
  132823. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132824. */
  132825. distanceModel?: string;
  132826. /**
  132827. * Defines the playback speed (1 by default)
  132828. */
  132829. playbackRate?: number;
  132830. /**
  132831. * Defines if the sound is from a streaming source
  132832. */
  132833. streaming?: boolean;
  132834. /**
  132835. * Defines an optional length (in seconds) inside the sound file
  132836. */
  132837. length?: number;
  132838. /**
  132839. * Defines an optional offset (in seconds) inside the sound file
  132840. */
  132841. offset?: number;
  132842. /**
  132843. * If true, URLs will not be required to state the audio file codec to use.
  132844. */
  132845. skipCodecCheck?: boolean;
  132846. }
  132847. }
  132848. declare module BABYLON {
  132849. /**
  132850. * Defines a sound that can be played in the application.
  132851. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  132852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132853. */
  132854. export class Sound {
  132855. /**
  132856. * The name of the sound in the scene.
  132857. */
  132858. name: string;
  132859. /**
  132860. * Does the sound autoplay once loaded.
  132861. */
  132862. autoplay: boolean;
  132863. private _loop;
  132864. /**
  132865. * Does the sound loop after it finishes playing once.
  132866. */
  132867. get loop(): boolean;
  132868. set loop(value: boolean);
  132869. /**
  132870. * Does the sound use a custom attenuation curve to simulate the falloff
  132871. * happening when the source gets further away from the camera.
  132872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  132873. */
  132874. useCustomAttenuation: boolean;
  132875. /**
  132876. * The sound track id this sound belongs to.
  132877. */
  132878. soundTrackId: number;
  132879. /**
  132880. * Is this sound currently played.
  132881. */
  132882. isPlaying: boolean;
  132883. /**
  132884. * Is this sound currently paused.
  132885. */
  132886. isPaused: boolean;
  132887. /**
  132888. * Does this sound enables spatial sound.
  132889. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132890. */
  132891. spatialSound: boolean;
  132892. /**
  132893. * Define the reference distance the sound should be heard perfectly.
  132894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132895. */
  132896. refDistance: number;
  132897. /**
  132898. * Define the roll off factor of spatial sounds.
  132899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132900. */
  132901. rolloffFactor: number;
  132902. /**
  132903. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  132904. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132905. */
  132906. maxDistance: number;
  132907. /**
  132908. * Define the distance attenuation model the sound will follow.
  132909. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132910. */
  132911. distanceModel: string;
  132912. /**
  132913. * @hidden
  132914. * Back Compat
  132915. **/
  132916. onended: () => any;
  132917. /**
  132918. * Gets or sets an object used to store user defined information for the sound.
  132919. */
  132920. metadata: any;
  132921. /**
  132922. * Observable event when the current playing sound finishes.
  132923. */
  132924. onEndedObservable: Observable<Sound>;
  132925. /**
  132926. * Gets the current time for the sound.
  132927. */
  132928. get currentTime(): number;
  132929. private _panningModel;
  132930. private _playbackRate;
  132931. private _streaming;
  132932. private _startTime;
  132933. private _startOffset;
  132934. private _position;
  132935. /** @hidden */
  132936. _positionInEmitterSpace: boolean;
  132937. private _localDirection;
  132938. private _volume;
  132939. private _isReadyToPlay;
  132940. private _isDirectional;
  132941. private _readyToPlayCallback;
  132942. private _audioBuffer;
  132943. private _soundSource;
  132944. private _streamingSource;
  132945. private _soundPanner;
  132946. private _soundGain;
  132947. private _inputAudioNode;
  132948. private _outputAudioNode;
  132949. private _coneInnerAngle;
  132950. private _coneOuterAngle;
  132951. private _coneOuterGain;
  132952. private _scene;
  132953. private _connectedTransformNode;
  132954. private _customAttenuationFunction;
  132955. private _registerFunc;
  132956. private _isOutputConnected;
  132957. private _htmlAudioElement;
  132958. private _urlType;
  132959. private _length?;
  132960. private _offset?;
  132961. /** @hidden */
  132962. static _SceneComponentInitialization: (scene: Scene) => void;
  132963. /**
  132964. * Create a sound and attach it to a scene
  132965. * @param name Name of your sound
  132966. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  132967. * @param scene defines the scene the sound belongs to
  132968. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  132969. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  132970. */
  132971. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  132972. /**
  132973. * Release the sound and its associated resources
  132974. */
  132975. dispose(): void;
  132976. /**
  132977. * Gets if the sounds is ready to be played or not.
  132978. * @returns true if ready, otherwise false
  132979. */
  132980. isReady(): boolean;
  132981. /**
  132982. * Get the current class name.
  132983. * @returns current class name
  132984. */
  132985. getClassName(): string;
  132986. private _soundLoaded;
  132987. /**
  132988. * Sets the data of the sound from an audiobuffer
  132989. * @param audioBuffer The audioBuffer containing the data
  132990. */
  132991. setAudioBuffer(audioBuffer: AudioBuffer): void;
  132992. /**
  132993. * Updates the current sounds options such as maxdistance, loop...
  132994. * @param options A JSON object containing values named as the object properties
  132995. */
  132996. updateOptions(options: ISoundOptions): void;
  132997. private _createSpatialParameters;
  132998. private _updateSpatialParameters;
  132999. /**
  133000. * Switch the panning model to HRTF:
  133001. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  133002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133003. */
  133004. switchPanningModelToHRTF(): void;
  133005. /**
  133006. * Switch the panning model to Equal Power:
  133007. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  133008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133009. */
  133010. switchPanningModelToEqualPower(): void;
  133011. private _switchPanningModel;
  133012. /**
  133013. * Connect this sound to a sound track audio node like gain...
  133014. * @param soundTrackAudioNode the sound track audio node to connect to
  133015. */
  133016. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  133017. /**
  133018. * Transform this sound into a directional source
  133019. * @param coneInnerAngle Size of the inner cone in degree
  133020. * @param coneOuterAngle Size of the outer cone in degree
  133021. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  133022. */
  133023. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  133024. /**
  133025. * Gets or sets the inner angle for the directional cone.
  133026. */
  133027. get directionalConeInnerAngle(): number;
  133028. /**
  133029. * Gets or sets the inner angle for the directional cone.
  133030. */
  133031. set directionalConeInnerAngle(value: number);
  133032. /**
  133033. * Gets or sets the outer angle for the directional cone.
  133034. */
  133035. get directionalConeOuterAngle(): number;
  133036. /**
  133037. * Gets or sets the outer angle for the directional cone.
  133038. */
  133039. set directionalConeOuterAngle(value: number);
  133040. /**
  133041. * Sets the position of the emitter if spatial sound is enabled
  133042. * @param newPosition Defines the new posisiton
  133043. */
  133044. setPosition(newPosition: Vector3): void;
  133045. /**
  133046. * Sets the local direction of the emitter if spatial sound is enabled
  133047. * @param newLocalDirection Defines the new local direction
  133048. */
  133049. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  133050. private _updateDirection;
  133051. /** @hidden */
  133052. updateDistanceFromListener(): void;
  133053. /**
  133054. * Sets a new custom attenuation function for the sound.
  133055. * @param callback Defines the function used for the attenuation
  133056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  133057. */
  133058. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  133059. /**
  133060. * Play the sound
  133061. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  133062. * @param offset (optional) Start the sound at a specific time in seconds
  133063. * @param length (optional) Sound duration (in seconds)
  133064. */
  133065. play(time?: number, offset?: number, length?: number): void;
  133066. private _onended;
  133067. /**
  133068. * Stop the sound
  133069. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  133070. */
  133071. stop(time?: number): void;
  133072. /**
  133073. * Put the sound in pause
  133074. */
  133075. pause(): void;
  133076. /**
  133077. * Sets a dedicated volume for this sounds
  133078. * @param newVolume Define the new volume of the sound
  133079. * @param time Define time for gradual change to new volume
  133080. */
  133081. setVolume(newVolume: number, time?: number): void;
  133082. /**
  133083. * Set the sound play back rate
  133084. * @param newPlaybackRate Define the playback rate the sound should be played at
  133085. */
  133086. setPlaybackRate(newPlaybackRate: number): void;
  133087. /**
  133088. * Gets the volume of the sound.
  133089. * @returns the volume of the sound
  133090. */
  133091. getVolume(): number;
  133092. /**
  133093. * Attach the sound to a dedicated mesh
  133094. * @param transformNode The transform node to connect the sound with
  133095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  133096. */
  133097. attachToMesh(transformNode: TransformNode): void;
  133098. /**
  133099. * Detach the sound from the previously attached mesh
  133100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  133101. */
  133102. detachFromMesh(): void;
  133103. private _onRegisterAfterWorldMatrixUpdate;
  133104. /**
  133105. * Clone the current sound in the scene.
  133106. * @returns the new sound clone
  133107. */
  133108. clone(): Nullable<Sound>;
  133109. /**
  133110. * Gets the current underlying audio buffer containing the data
  133111. * @returns the audio buffer
  133112. */
  133113. getAudioBuffer(): Nullable<AudioBuffer>;
  133114. /**
  133115. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  133116. * @returns the source node
  133117. */
  133118. getSoundSource(): Nullable<AudioBufferSourceNode>;
  133119. /**
  133120. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  133121. * @returns the gain node
  133122. */
  133123. getSoundGain(): Nullable<GainNode>;
  133124. /**
  133125. * Serializes the Sound in a JSON representation
  133126. * @returns the JSON representation of the sound
  133127. */
  133128. serialize(): any;
  133129. /**
  133130. * Parse a JSON representation of a sound to innstantiate in a given scene
  133131. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  133132. * @param scene Define the scene the new parsed sound should be created in
  133133. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  133134. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  133135. * @returns the newly parsed sound
  133136. */
  133137. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  133138. }
  133139. }
  133140. declare module BABYLON {
  133141. /**
  133142. * This defines an action helpful to play a defined sound on a triggered action.
  133143. */
  133144. export class PlaySoundAction extends Action {
  133145. private _sound;
  133146. /**
  133147. * Instantiate the action
  133148. * @param triggerOptions defines the trigger options
  133149. * @param sound defines the sound to play
  133150. * @param condition defines the trigger related conditions
  133151. */
  133152. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  133153. /** @hidden */
  133154. _prepare(): void;
  133155. /**
  133156. * Execute the action and play the sound.
  133157. */
  133158. execute(): void;
  133159. /**
  133160. * Serializes the actions and its related information.
  133161. * @param parent defines the object to serialize in
  133162. * @returns the serialized object
  133163. */
  133164. serialize(parent: any): any;
  133165. }
  133166. /**
  133167. * This defines an action helpful to stop a defined sound on a triggered action.
  133168. */
  133169. export class StopSoundAction extends Action {
  133170. private _sound;
  133171. /**
  133172. * Instantiate the action
  133173. * @param triggerOptions defines the trigger options
  133174. * @param sound defines the sound to stop
  133175. * @param condition defines the trigger related conditions
  133176. */
  133177. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  133178. /** @hidden */
  133179. _prepare(): void;
  133180. /**
  133181. * Execute the action and stop the sound.
  133182. */
  133183. execute(): void;
  133184. /**
  133185. * Serializes the actions and its related information.
  133186. * @param parent defines the object to serialize in
  133187. * @returns the serialized object
  133188. */
  133189. serialize(parent: any): any;
  133190. }
  133191. }
  133192. declare module BABYLON {
  133193. /**
  133194. * This defines an action responsible to change the value of a property
  133195. * by interpolating between its current value and the newly set one once triggered.
  133196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  133197. */
  133198. export class InterpolateValueAction extends Action {
  133199. /**
  133200. * Defines the path of the property where the value should be interpolated
  133201. */
  133202. propertyPath: string;
  133203. /**
  133204. * Defines the target value at the end of the interpolation.
  133205. */
  133206. value: any;
  133207. /**
  133208. * Defines the time it will take for the property to interpolate to the value.
  133209. */
  133210. duration: number;
  133211. /**
  133212. * Defines if the other scene animations should be stopped when the action has been triggered
  133213. */
  133214. stopOtherAnimations?: boolean;
  133215. /**
  133216. * Defines a callback raised once the interpolation animation has been done.
  133217. */
  133218. onInterpolationDone?: () => void;
  133219. /**
  133220. * Observable triggered once the interpolation animation has been done.
  133221. */
  133222. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  133223. private _target;
  133224. private _effectiveTarget;
  133225. private _property;
  133226. /**
  133227. * Instantiate the action
  133228. * @param triggerOptions defines the trigger options
  133229. * @param target defines the object containing the value to interpolate
  133230. * @param propertyPath defines the path to the property in the target object
  133231. * @param value defines the target value at the end of the interpolation
  133232. * @param duration deines the time it will take for the property to interpolate to the value.
  133233. * @param condition defines the trigger related conditions
  133234. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  133235. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  133236. */
  133237. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  133238. /** @hidden */
  133239. _prepare(): void;
  133240. /**
  133241. * Execute the action starts the value interpolation.
  133242. */
  133243. execute(): void;
  133244. /**
  133245. * Serializes the actions and its related information.
  133246. * @param parent defines the object to serialize in
  133247. * @returns the serialized object
  133248. */
  133249. serialize(parent: any): any;
  133250. }
  133251. }
  133252. declare module BABYLON {
  133253. /**
  133254. * This represents the default audio engine used in babylon.
  133255. * It is responsible to play, synchronize and analyse sounds throughout the application.
  133256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133257. */
  133258. export class AudioEngine implements IAudioEngine {
  133259. private _audioContext;
  133260. private _audioContextInitialized;
  133261. private _muteButton;
  133262. private _hostElement;
  133263. /**
  133264. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  133265. */
  133266. canUseWebAudio: boolean;
  133267. /**
  133268. * The master gain node defines the global audio volume of your audio engine.
  133269. */
  133270. masterGain: GainNode;
  133271. /**
  133272. * Defines if Babylon should emit a warning if WebAudio is not supported.
  133273. * @ignoreNaming
  133274. */
  133275. WarnedWebAudioUnsupported: boolean;
  133276. /**
  133277. * Gets whether or not mp3 are supported by your browser.
  133278. */
  133279. isMP3supported: boolean;
  133280. /**
  133281. * Gets whether or not ogg are supported by your browser.
  133282. */
  133283. isOGGsupported: boolean;
  133284. /**
  133285. * Gets whether audio has been unlocked on the device.
  133286. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  133287. * a user interaction has happened.
  133288. */
  133289. unlocked: boolean;
  133290. /**
  133291. * Defines if the audio engine relies on a custom unlocked button.
  133292. * In this case, the embedded button will not be displayed.
  133293. */
  133294. useCustomUnlockedButton: boolean;
  133295. /**
  133296. * Event raised when audio has been unlocked on the browser.
  133297. */
  133298. onAudioUnlockedObservable: Observable<IAudioEngine>;
  133299. /**
  133300. * Event raised when audio has been locked on the browser.
  133301. */
  133302. onAudioLockedObservable: Observable<IAudioEngine>;
  133303. /**
  133304. * Gets the current AudioContext if available.
  133305. */
  133306. get audioContext(): Nullable<AudioContext>;
  133307. private _connectedAnalyser;
  133308. /**
  133309. * Instantiates a new audio engine.
  133310. *
  133311. * There should be only one per page as some browsers restrict the number
  133312. * of audio contexts you can create.
  133313. * @param hostElement defines the host element where to display the mute icon if necessary
  133314. */
  133315. constructor(hostElement?: Nullable<HTMLElement>);
  133316. /**
  133317. * Flags the audio engine in Locked state.
  133318. * This happens due to new browser policies preventing audio to autoplay.
  133319. */
  133320. lock(): void;
  133321. /**
  133322. * Unlocks the audio engine once a user action has been done on the dom.
  133323. * This is helpful to resume play once browser policies have been satisfied.
  133324. */
  133325. unlock(): void;
  133326. private _resumeAudioContext;
  133327. private _initializeAudioContext;
  133328. private _tryToRun;
  133329. private _triggerRunningState;
  133330. private _triggerSuspendedState;
  133331. private _displayMuteButton;
  133332. private _moveButtonToTopLeft;
  133333. private _onResize;
  133334. private _hideMuteButton;
  133335. /**
  133336. * Destroy and release the resources associated with the audio ccontext.
  133337. */
  133338. dispose(): void;
  133339. /**
  133340. * Gets the global volume sets on the master gain.
  133341. * @returns the global volume if set or -1 otherwise
  133342. */
  133343. getGlobalVolume(): number;
  133344. /**
  133345. * Sets the global volume of your experience (sets on the master gain).
  133346. * @param newVolume Defines the new global volume of the application
  133347. */
  133348. setGlobalVolume(newVolume: number): void;
  133349. /**
  133350. * Connect the audio engine to an audio analyser allowing some amazing
  133351. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  133352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  133353. * @param analyser The analyser to connect to the engine
  133354. */
  133355. connectToAnalyser(analyser: Analyser): void;
  133356. }
  133357. }
  133358. declare module BABYLON {
  133359. /**
  133360. * Options allowed during the creation of a sound track.
  133361. */
  133362. export interface ISoundTrackOptions {
  133363. /**
  133364. * The volume the sound track should take during creation
  133365. */
  133366. volume?: number;
  133367. /**
  133368. * Define if the sound track is the main sound track of the scene
  133369. */
  133370. mainTrack?: boolean;
  133371. }
  133372. /**
  133373. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  133374. * It will be also used in a future release to apply effects on a specific track.
  133375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  133376. */
  133377. export class SoundTrack {
  133378. /**
  133379. * The unique identifier of the sound track in the scene.
  133380. */
  133381. id: number;
  133382. /**
  133383. * The list of sounds included in the sound track.
  133384. */
  133385. soundCollection: Array<Sound>;
  133386. private _outputAudioNode;
  133387. private _scene;
  133388. private _connectedAnalyser;
  133389. private _options;
  133390. private _isInitialized;
  133391. /**
  133392. * Creates a new sound track.
  133393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  133394. * @param scene Define the scene the sound track belongs to
  133395. * @param options
  133396. */
  133397. constructor(scene: Scene, options?: ISoundTrackOptions);
  133398. private _initializeSoundTrackAudioGraph;
  133399. /**
  133400. * Release the sound track and its associated resources
  133401. */
  133402. dispose(): void;
  133403. /**
  133404. * Adds a sound to this sound track
  133405. * @param sound define the cound to add
  133406. * @ignoreNaming
  133407. */
  133408. addSound(sound: Sound): void;
  133409. /**
  133410. * Removes a sound to this sound track
  133411. * @param sound define the cound to remove
  133412. * @ignoreNaming
  133413. */
  133414. removeSound(sound: Sound): void;
  133415. /**
  133416. * Set a global volume for the full sound track.
  133417. * @param newVolume Define the new volume of the sound track
  133418. */
  133419. setVolume(newVolume: number): void;
  133420. /**
  133421. * Switch the panning model to HRTF:
  133422. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  133423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133424. */
  133425. switchPanningModelToHRTF(): void;
  133426. /**
  133427. * Switch the panning model to Equal Power:
  133428. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  133429. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133430. */
  133431. switchPanningModelToEqualPower(): void;
  133432. /**
  133433. * Connect the sound track to an audio analyser allowing some amazing
  133434. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  133435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  133436. * @param analyser The analyser to connect to the engine
  133437. */
  133438. connectToAnalyser(analyser: Analyser): void;
  133439. }
  133440. }
  133441. declare module BABYLON {
  133442. interface AbstractScene {
  133443. /**
  133444. * The list of sounds used in the scene.
  133445. */
  133446. sounds: Nullable<Array<Sound>>;
  133447. }
  133448. interface Scene {
  133449. /**
  133450. * @hidden
  133451. * Backing field
  133452. */
  133453. _mainSoundTrack: SoundTrack;
  133454. /**
  133455. * The main sound track played by the scene.
  133456. * It cotains your primary collection of sounds.
  133457. */
  133458. mainSoundTrack: SoundTrack;
  133459. /**
  133460. * The list of sound tracks added to the scene
  133461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133462. */
  133463. soundTracks: Nullable<Array<SoundTrack>>;
  133464. /**
  133465. * Gets a sound using a given name
  133466. * @param name defines the name to search for
  133467. * @return the found sound or null if not found at all.
  133468. */
  133469. getSoundByName(name: string): Nullable<Sound>;
  133470. /**
  133471. * Gets or sets if audio support is enabled
  133472. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133473. */
  133474. audioEnabled: boolean;
  133475. /**
  133476. * Gets or sets if audio will be output to headphones
  133477. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133478. */
  133479. headphone: boolean;
  133480. /**
  133481. * Gets or sets custom audio listener position provider
  133482. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133483. */
  133484. audioListenerPositionProvider: Nullable<() => Vector3>;
  133485. /**
  133486. * Gets or sets a refresh rate when using 3D audio positioning
  133487. */
  133488. audioPositioningRefreshRate: number;
  133489. }
  133490. /**
  133491. * Defines the sound scene component responsible to manage any sounds
  133492. * in a given scene.
  133493. */
  133494. export class AudioSceneComponent implements ISceneSerializableComponent {
  133495. private static _CameraDirectionLH;
  133496. private static _CameraDirectionRH;
  133497. /**
  133498. * The component name helpfull to identify the component in the list of scene components.
  133499. */
  133500. readonly name: string;
  133501. /**
  133502. * The scene the component belongs to.
  133503. */
  133504. scene: Scene;
  133505. private _audioEnabled;
  133506. /**
  133507. * Gets whether audio is enabled or not.
  133508. * Please use related enable/disable method to switch state.
  133509. */
  133510. get audioEnabled(): boolean;
  133511. private _headphone;
  133512. /**
  133513. * Gets whether audio is outputing to headphone or not.
  133514. * Please use the according Switch methods to change output.
  133515. */
  133516. get headphone(): boolean;
  133517. /**
  133518. * Gets or sets a refresh rate when using 3D audio positioning
  133519. */
  133520. audioPositioningRefreshRate: number;
  133521. private _audioListenerPositionProvider;
  133522. /**
  133523. * Gets the current audio listener position provider
  133524. */
  133525. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  133526. /**
  133527. * Sets a custom listener position for all sounds in the scene
  133528. * By default, this is the position of the first active camera
  133529. */
  133530. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  133531. /**
  133532. * Creates a new instance of the component for the given scene
  133533. * @param scene Defines the scene to register the component in
  133534. */
  133535. constructor(scene: Scene);
  133536. /**
  133537. * Registers the component in a given scene
  133538. */
  133539. register(): void;
  133540. /**
  133541. * Rebuilds the elements related to this component in case of
  133542. * context lost for instance.
  133543. */
  133544. rebuild(): void;
  133545. /**
  133546. * Serializes the component data to the specified json object
  133547. * @param serializationObject The object to serialize to
  133548. */
  133549. serialize(serializationObject: any): void;
  133550. /**
  133551. * Adds all the elements from the container to the scene
  133552. * @param container the container holding the elements
  133553. */
  133554. addFromContainer(container: AbstractScene): void;
  133555. /**
  133556. * Removes all the elements in the container from the scene
  133557. * @param container contains the elements to remove
  133558. * @param dispose if the removed element should be disposed (default: false)
  133559. */
  133560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133561. /**
  133562. * Disposes the component and the associated ressources.
  133563. */
  133564. dispose(): void;
  133565. /**
  133566. * Disables audio in the associated scene.
  133567. */
  133568. disableAudio(): void;
  133569. /**
  133570. * Enables audio in the associated scene.
  133571. */
  133572. enableAudio(): void;
  133573. /**
  133574. * Switch audio to headphone output.
  133575. */
  133576. switchAudioModeForHeadphones(): void;
  133577. /**
  133578. * Switch audio to normal speakers.
  133579. */
  133580. switchAudioModeForNormalSpeakers(): void;
  133581. private _cachedCameraDirection;
  133582. private _cachedCameraPosition;
  133583. private _lastCheck;
  133584. private _afterRender;
  133585. }
  133586. }
  133587. declare module BABYLON {
  133588. /**
  133589. * Wraps one or more Sound objects and selects one with random weight for playback.
  133590. */
  133591. export class WeightedSound {
  133592. /** When true a Sound will be selected and played when the current playing Sound completes. */
  133593. loop: boolean;
  133594. private _coneInnerAngle;
  133595. private _coneOuterAngle;
  133596. private _volume;
  133597. /** A Sound is currently playing. */
  133598. isPlaying: boolean;
  133599. /** A Sound is currently paused. */
  133600. isPaused: boolean;
  133601. private _sounds;
  133602. private _weights;
  133603. private _currentIndex?;
  133604. /**
  133605. * Creates a new WeightedSound from the list of sounds given.
  133606. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  133607. * @param sounds Array of Sounds that will be selected from.
  133608. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  133609. */
  133610. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  133611. /**
  133612. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  133613. */
  133614. get directionalConeInnerAngle(): number;
  133615. /**
  133616. * The size of cone in degress for a directional sound in which there will be no attenuation.
  133617. */
  133618. set directionalConeInnerAngle(value: number);
  133619. /**
  133620. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133621. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133622. */
  133623. get directionalConeOuterAngle(): number;
  133624. /**
  133625. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133626. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133627. */
  133628. set directionalConeOuterAngle(value: number);
  133629. /**
  133630. * Playback volume.
  133631. */
  133632. get volume(): number;
  133633. /**
  133634. * Playback volume.
  133635. */
  133636. set volume(value: number);
  133637. private _onended;
  133638. /**
  133639. * Suspend playback
  133640. */
  133641. pause(): void;
  133642. /**
  133643. * Stop playback
  133644. */
  133645. stop(): void;
  133646. /**
  133647. * Start playback.
  133648. * @param startOffset Position the clip head at a specific time in seconds.
  133649. */
  133650. play(startOffset?: number): void;
  133651. }
  133652. }
  133653. declare module BABYLON {
  133654. /**
  133655. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  133656. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133657. */
  133658. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  133659. /**
  133660. * Gets the name of the behavior.
  133661. */
  133662. get name(): string;
  133663. /**
  133664. * The easing function used by animations
  133665. */
  133666. static EasingFunction: BackEase;
  133667. /**
  133668. * The easing mode used by animations
  133669. */
  133670. static EasingMode: number;
  133671. /**
  133672. * The duration of the animation, in milliseconds
  133673. */
  133674. transitionDuration: number;
  133675. /**
  133676. * Length of the distance animated by the transition when lower radius is reached
  133677. */
  133678. lowerRadiusTransitionRange: number;
  133679. /**
  133680. * Length of the distance animated by the transition when upper radius is reached
  133681. */
  133682. upperRadiusTransitionRange: number;
  133683. private _autoTransitionRange;
  133684. /**
  133685. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133686. */
  133687. get autoTransitionRange(): boolean;
  133688. /**
  133689. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133690. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  133691. */
  133692. set autoTransitionRange(value: boolean);
  133693. private _attachedCamera;
  133694. private _onAfterCheckInputsObserver;
  133695. private _onMeshTargetChangedObserver;
  133696. /**
  133697. * Initializes the behavior.
  133698. */
  133699. init(): void;
  133700. /**
  133701. * Attaches the behavior to its arc rotate camera.
  133702. * @param camera Defines the camera to attach the behavior to
  133703. */
  133704. attach(camera: ArcRotateCamera): void;
  133705. /**
  133706. * Detaches the behavior from its current arc rotate camera.
  133707. */
  133708. detach(): void;
  133709. private _radiusIsAnimating;
  133710. private _radiusBounceTransition;
  133711. private _animatables;
  133712. private _cachedWheelPrecision;
  133713. /**
  133714. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  133715. * @param radiusLimit The limit to check against.
  133716. * @return Bool to indicate if at limit.
  133717. */
  133718. private _isRadiusAtLimit;
  133719. /**
  133720. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  133721. * @param radiusDelta The delta by which to animate to. Can be negative.
  133722. */
  133723. private _applyBoundRadiusAnimation;
  133724. /**
  133725. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  133726. */
  133727. protected _clearAnimationLocks(): void;
  133728. /**
  133729. * Stops and removes all animations that have been applied to the camera
  133730. */
  133731. stopAllAnimations(): void;
  133732. }
  133733. }
  133734. declare module BABYLON {
  133735. /**
  133736. * 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.
  133737. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133738. */
  133739. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  133740. /**
  133741. * Gets the name of the behavior.
  133742. */
  133743. get name(): string;
  133744. private _mode;
  133745. private _radiusScale;
  133746. private _positionScale;
  133747. private _defaultElevation;
  133748. private _elevationReturnTime;
  133749. private _elevationReturnWaitTime;
  133750. private _zoomStopsAnimation;
  133751. private _framingTime;
  133752. /**
  133753. * The easing function used by animations
  133754. */
  133755. static EasingFunction: ExponentialEase;
  133756. /**
  133757. * The easing mode used by animations
  133758. */
  133759. static EasingMode: number;
  133760. /**
  133761. * Sets the current mode used by the behavior
  133762. */
  133763. set mode(mode: number);
  133764. /**
  133765. * Gets current mode used by the behavior.
  133766. */
  133767. get mode(): number;
  133768. /**
  133769. * Sets the scale applied to the radius (1 by default)
  133770. */
  133771. set radiusScale(radius: number);
  133772. /**
  133773. * Gets the scale applied to the radius
  133774. */
  133775. get radiusScale(): number;
  133776. /**
  133777. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133778. */
  133779. set positionScale(scale: number);
  133780. /**
  133781. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133782. */
  133783. get positionScale(): number;
  133784. /**
  133785. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133786. * behaviour is triggered, in radians.
  133787. */
  133788. set defaultElevation(elevation: number);
  133789. /**
  133790. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133791. * behaviour is triggered, in radians.
  133792. */
  133793. get defaultElevation(): number;
  133794. /**
  133795. * Sets the time (in milliseconds) taken to return to the default beta position.
  133796. * Negative value indicates camera should not return to default.
  133797. */
  133798. set elevationReturnTime(speed: number);
  133799. /**
  133800. * Gets the time (in milliseconds) taken to return to the default beta position.
  133801. * Negative value indicates camera should not return to default.
  133802. */
  133803. get elevationReturnTime(): number;
  133804. /**
  133805. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133806. */
  133807. set elevationReturnWaitTime(time: number);
  133808. /**
  133809. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133810. */
  133811. get elevationReturnWaitTime(): number;
  133812. /**
  133813. * Sets the flag that indicates if user zooming should stop animation.
  133814. */
  133815. set zoomStopsAnimation(flag: boolean);
  133816. /**
  133817. * Gets the flag that indicates if user zooming should stop animation.
  133818. */
  133819. get zoomStopsAnimation(): boolean;
  133820. /**
  133821. * Sets the transition time when framing the mesh, in milliseconds
  133822. */
  133823. set framingTime(time: number);
  133824. /**
  133825. * Gets the transition time when framing the mesh, in milliseconds
  133826. */
  133827. get framingTime(): number;
  133828. /**
  133829. * Define if the behavior should automatically change the configured
  133830. * camera limits and sensibilities.
  133831. */
  133832. autoCorrectCameraLimitsAndSensibility: boolean;
  133833. private _onPrePointerObservableObserver;
  133834. private _onAfterCheckInputsObserver;
  133835. private _onMeshTargetChangedObserver;
  133836. private _attachedCamera;
  133837. private _isPointerDown;
  133838. private _lastInteractionTime;
  133839. /**
  133840. * Initializes the behavior.
  133841. */
  133842. init(): void;
  133843. /**
  133844. * Attaches the behavior to its arc rotate camera.
  133845. * @param camera Defines the camera to attach the behavior to
  133846. */
  133847. attach(camera: ArcRotateCamera): void;
  133848. /**
  133849. * Detaches the behavior from its current arc rotate camera.
  133850. */
  133851. detach(): void;
  133852. private _animatables;
  133853. private _betaIsAnimating;
  133854. private _betaTransition;
  133855. private _radiusTransition;
  133856. private _vectorTransition;
  133857. /**
  133858. * Targets the given mesh and updates zoom level accordingly.
  133859. * @param mesh The mesh to target.
  133860. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133861. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133862. */
  133863. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133864. /**
  133865. * Targets the given mesh with its children and updates zoom level accordingly.
  133866. * @param mesh The mesh to target.
  133867. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133868. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133869. */
  133870. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133871. /**
  133872. * Targets the given meshes with their children and updates zoom level accordingly.
  133873. * @param meshes The mesh to target.
  133874. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133875. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133876. */
  133877. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133878. /**
  133879. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  133880. * @param minimumWorld Determines the smaller position of the bounding box extend
  133881. * @param maximumWorld Determines the bigger position of the bounding box extend
  133882. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133883. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133884. */
  133885. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133886. /**
  133887. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  133888. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  133889. * frustum width.
  133890. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  133891. * to fully enclose the mesh in the viewing frustum.
  133892. */
  133893. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  133894. /**
  133895. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  133896. * is automatically returned to its default position (expected to be above ground plane).
  133897. */
  133898. private _maintainCameraAboveGround;
  133899. /**
  133900. * Returns the frustum slope based on the canvas ratio and camera FOV
  133901. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  133902. */
  133903. private _getFrustumSlope;
  133904. /**
  133905. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  133906. */
  133907. private _clearAnimationLocks;
  133908. /**
  133909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  133910. */
  133911. private _applyUserInteraction;
  133912. /**
  133913. * Stops and removes all animations that have been applied to the camera
  133914. */
  133915. stopAllAnimations(): void;
  133916. /**
  133917. * Gets a value indicating if the user is moving the camera
  133918. */
  133919. get isUserIsMoving(): boolean;
  133920. /**
  133921. * The camera can move all the way towards the mesh.
  133922. */
  133923. static IgnoreBoundsSizeMode: number;
  133924. /**
  133925. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  133926. */
  133927. static FitFrustumSidesMode: number;
  133928. }
  133929. }
  133930. declare module BABYLON {
  133931. /**
  133932. * Base class for Camera Pointer Inputs.
  133933. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  133934. * for example usage.
  133935. */
  133936. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  133937. /**
  133938. * Defines the camera the input is attached to.
  133939. */
  133940. abstract camera: Camera;
  133941. /**
  133942. * Whether keyboard modifier keys are pressed at time of last mouse event.
  133943. */
  133944. protected _altKey: boolean;
  133945. protected _ctrlKey: boolean;
  133946. protected _metaKey: boolean;
  133947. protected _shiftKey: boolean;
  133948. /**
  133949. * Which mouse buttons were pressed at time of last mouse event.
  133950. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  133951. */
  133952. protected _buttonsPressed: number;
  133953. /**
  133954. * Defines the buttons associated with the input to handle camera move.
  133955. */
  133956. buttons: number[];
  133957. /**
  133958. * Attach the input controls to a specific dom element to get the input from.
  133959. * @param element Defines the element the controls should be listened from
  133960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133961. */
  133962. attachControl(noPreventDefault?: boolean): void;
  133963. /**
  133964. * Detach the current controls from the specified dom element.
  133965. */
  133966. detachControl(): void;
  133967. /**
  133968. * Gets the class name of the current input.
  133969. * @returns the class name
  133970. */
  133971. getClassName(): string;
  133972. /**
  133973. * Get the friendly name associated with the input class.
  133974. * @returns the input friendly name
  133975. */
  133976. getSimpleName(): string;
  133977. /**
  133978. * Called on pointer POINTERDOUBLETAP event.
  133979. * Override this method to provide functionality on POINTERDOUBLETAP event.
  133980. */
  133981. protected onDoubleTap(type: string): void;
  133982. /**
  133983. * Called on pointer POINTERMOVE event if only a single touch is active.
  133984. * Override this method to provide functionality.
  133985. */
  133986. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  133987. /**
  133988. * Called on pointer POINTERMOVE event if multiple touches are active.
  133989. * Override this method to provide functionality.
  133990. */
  133991. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  133992. /**
  133993. * Called on JS contextmenu event.
  133994. * Override this method to provide functionality.
  133995. */
  133996. protected onContextMenu(evt: PointerEvent): void;
  133997. /**
  133998. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  133999. * press.
  134000. * Override this method to provide functionality.
  134001. */
  134002. protected onButtonDown(evt: PointerEvent): void;
  134003. /**
  134004. * Called each time a new POINTERUP event occurs. Ie, for each button
  134005. * release.
  134006. * Override this method to provide functionality.
  134007. */
  134008. protected onButtonUp(evt: PointerEvent): void;
  134009. /**
  134010. * Called when window becomes inactive.
  134011. * Override this method to provide functionality.
  134012. */
  134013. protected onLostFocus(): void;
  134014. private _pointerInput;
  134015. private _observer;
  134016. private _onLostFocus;
  134017. private pointA;
  134018. private pointB;
  134019. }
  134020. }
  134021. declare module BABYLON {
  134022. /**
  134023. * Manage the pointers inputs to control an arc rotate camera.
  134024. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134025. */
  134026. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  134027. /**
  134028. * Defines the camera the input is attached to.
  134029. */
  134030. camera: ArcRotateCamera;
  134031. /**
  134032. * Gets the class name of the current input.
  134033. * @returns the class name
  134034. */
  134035. getClassName(): string;
  134036. /**
  134037. * Defines the buttons associated with the input to handle camera move.
  134038. */
  134039. buttons: number[];
  134040. /**
  134041. * Defines the pointer angular sensibility along the X axis or how fast is
  134042. * the camera rotating.
  134043. */
  134044. angularSensibilityX: number;
  134045. /**
  134046. * Defines the pointer angular sensibility along the Y axis or how fast is
  134047. * the camera rotating.
  134048. */
  134049. angularSensibilityY: number;
  134050. /**
  134051. * Defines the pointer pinch precision or how fast is the camera zooming.
  134052. */
  134053. pinchPrecision: number;
  134054. /**
  134055. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  134056. * from 0.
  134057. * It defines the percentage of current camera.radius to use as delta when
  134058. * pinch zoom is used.
  134059. */
  134060. pinchDeltaPercentage: number;
  134061. /**
  134062. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  134063. * that any object in the plane at the camera's target point will scale
  134064. * perfectly with finger motion.
  134065. * Overrides pinchDeltaPercentage and pinchPrecision.
  134066. */
  134067. useNaturalPinchZoom: boolean;
  134068. /**
  134069. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  134070. */
  134071. pinchZoom: boolean;
  134072. /**
  134073. * Defines the pointer panning sensibility or how fast is the camera moving.
  134074. */
  134075. panningSensibility: number;
  134076. /**
  134077. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  134078. */
  134079. multiTouchPanning: boolean;
  134080. /**
  134081. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  134082. * zoom (pinch) through multitouch.
  134083. */
  134084. multiTouchPanAndZoom: boolean;
  134085. /**
  134086. * Revers pinch action direction.
  134087. */
  134088. pinchInwards: boolean;
  134089. private _isPanClick;
  134090. private _twoFingerActivityCount;
  134091. private _isPinching;
  134092. /**
  134093. * Move camera from multi touch panning positions.
  134094. */
  134095. private _computeMultiTouchPanning;
  134096. /**
  134097. * Move camera from pinch zoom distances.
  134098. */
  134099. private _computePinchZoom;
  134100. /**
  134101. * Called on pointer POINTERMOVE event if only a single touch is active.
  134102. */
  134103. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  134104. /**
  134105. * Called on pointer POINTERDOUBLETAP event.
  134106. */
  134107. protected onDoubleTap(type: string): void;
  134108. /**
  134109. * Called on pointer POINTERMOVE event if multiple touches are active.
  134110. */
  134111. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  134112. /**
  134113. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  134114. * press.
  134115. */
  134116. protected onButtonDown(evt: PointerEvent): void;
  134117. /**
  134118. * Called each time a new POINTERUP event occurs. Ie, for each button
  134119. * release.
  134120. */
  134121. protected onButtonUp(evt: PointerEvent): void;
  134122. /**
  134123. * Called when window becomes inactive.
  134124. */
  134125. protected onLostFocus(): void;
  134126. }
  134127. }
  134128. declare module BABYLON {
  134129. /**
  134130. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  134131. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134132. */
  134133. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  134134. /**
  134135. * Defines the camera the input is attached to.
  134136. */
  134137. camera: ArcRotateCamera;
  134138. /**
  134139. * Defines the list of key codes associated with the up action (increase alpha)
  134140. */
  134141. keysUp: number[];
  134142. /**
  134143. * Defines the list of key codes associated with the down action (decrease alpha)
  134144. */
  134145. keysDown: number[];
  134146. /**
  134147. * Defines the list of key codes associated with the left action (increase beta)
  134148. */
  134149. keysLeft: number[];
  134150. /**
  134151. * Defines the list of key codes associated with the right action (decrease beta)
  134152. */
  134153. keysRight: number[];
  134154. /**
  134155. * Defines the list of key codes associated with the reset action.
  134156. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  134157. */
  134158. keysReset: number[];
  134159. /**
  134160. * Defines the panning sensibility of the inputs.
  134161. * (How fast is the camera panning)
  134162. */
  134163. panningSensibility: number;
  134164. /**
  134165. * Defines the zooming sensibility of the inputs.
  134166. * (How fast is the camera zooming)
  134167. */
  134168. zoomingSensibility: number;
  134169. /**
  134170. * Defines whether maintaining the alt key down switch the movement mode from
  134171. * orientation to zoom.
  134172. */
  134173. useAltToZoom: boolean;
  134174. /**
  134175. * Rotation speed of the camera
  134176. */
  134177. angularSpeed: number;
  134178. private _keys;
  134179. private _ctrlPressed;
  134180. private _altPressed;
  134181. private _onCanvasBlurObserver;
  134182. private _onKeyboardObserver;
  134183. private _engine;
  134184. private _scene;
  134185. /**
  134186. * Attach the input controls to a specific dom element to get the input from.
  134187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134188. */
  134189. attachControl(noPreventDefault?: boolean): void;
  134190. /**
  134191. * Detach the current controls from the specified dom element.
  134192. */
  134193. detachControl(): void;
  134194. /**
  134195. * Update the current camera state depending on the inputs that have been used this frame.
  134196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134197. */
  134198. checkInputs(): void;
  134199. /**
  134200. * Gets the class name of the current intput.
  134201. * @returns the class name
  134202. */
  134203. getClassName(): string;
  134204. /**
  134205. * Get the friendly name associated with the input class.
  134206. * @returns the input friendly name
  134207. */
  134208. getSimpleName(): string;
  134209. }
  134210. }
  134211. declare module BABYLON {
  134212. /**
  134213. * Manage the mouse wheel inputs to control an arc rotate camera.
  134214. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134215. */
  134216. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  134217. /**
  134218. * Defines the camera the input is attached to.
  134219. */
  134220. camera: ArcRotateCamera;
  134221. /**
  134222. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  134223. */
  134224. wheelPrecision: number;
  134225. /**
  134226. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  134227. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  134228. */
  134229. wheelDeltaPercentage: number;
  134230. private _wheel;
  134231. private _observer;
  134232. private computeDeltaFromMouseWheelLegacyEvent;
  134233. /**
  134234. * Attach the input controls to a specific dom element to get the input from.
  134235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134236. */
  134237. attachControl(noPreventDefault?: boolean): void;
  134238. /**
  134239. * Detach the current controls from the specified dom element.
  134240. */
  134241. detachControl(): void;
  134242. /**
  134243. * Gets the class name of the current intput.
  134244. * @returns the class name
  134245. */
  134246. getClassName(): string;
  134247. /**
  134248. * Get the friendly name associated with the input class.
  134249. * @returns the input friendly name
  134250. */
  134251. getSimpleName(): string;
  134252. }
  134253. }
  134254. declare module BABYLON {
  134255. /**
  134256. * Default Inputs manager for the ArcRotateCamera.
  134257. * It groups all the default supported inputs for ease of use.
  134258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134259. */
  134260. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  134261. /**
  134262. * Instantiates a new ArcRotateCameraInputsManager.
  134263. * @param camera Defines the camera the inputs belong to
  134264. */
  134265. constructor(camera: ArcRotateCamera);
  134266. /**
  134267. * Add mouse wheel input support to the input manager.
  134268. * @returns the current input manager
  134269. */
  134270. addMouseWheel(): ArcRotateCameraInputsManager;
  134271. /**
  134272. * Add pointers input support to the input manager.
  134273. * @returns the current input manager
  134274. */
  134275. addPointers(): ArcRotateCameraInputsManager;
  134276. /**
  134277. * Add keyboard input support to the input manager.
  134278. * @returns the current input manager
  134279. */
  134280. addKeyboard(): ArcRotateCameraInputsManager;
  134281. }
  134282. }
  134283. declare module BABYLON {
  134284. /**
  134285. * This represents an orbital type of camera.
  134286. *
  134287. * 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.
  134288. * 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.
  134289. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  134290. */
  134291. export class ArcRotateCamera extends TargetCamera {
  134292. /**
  134293. * Defines the rotation angle of the camera along the longitudinal axis.
  134294. */
  134295. alpha: number;
  134296. /**
  134297. * Defines the rotation angle of the camera along the latitudinal axis.
  134298. */
  134299. beta: number;
  134300. /**
  134301. * Defines the radius of the camera from it s target point.
  134302. */
  134303. radius: number;
  134304. protected _target: Vector3;
  134305. protected _targetHost: Nullable<AbstractMesh>;
  134306. /**
  134307. * Defines the target point of the camera.
  134308. * The camera looks towards it form the radius distance.
  134309. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  134310. */
  134311. get target(): Vector3;
  134312. set target(value: Vector3);
  134313. /**
  134314. * Define the current local position of the camera in the scene
  134315. */
  134316. get position(): Vector3;
  134317. set position(newPosition: Vector3);
  134318. protected _upToYMatrix: Matrix;
  134319. protected _YToUpMatrix: Matrix;
  134320. /**
  134321. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  134322. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  134323. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  134324. */
  134325. set upVector(vec: Vector3);
  134326. get upVector(): Vector3;
  134327. /**
  134328. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  134329. */
  134330. setMatUp(): void;
  134331. /**
  134332. * Current inertia value on the longitudinal axis.
  134333. * The bigger this number the longer it will take for the camera to stop.
  134334. */
  134335. inertialAlphaOffset: number;
  134336. /**
  134337. * Current inertia value on the latitudinal axis.
  134338. * The bigger this number the longer it will take for the camera to stop.
  134339. */
  134340. inertialBetaOffset: number;
  134341. /**
  134342. * Current inertia value on the radius axis.
  134343. * The bigger this number the longer it will take for the camera to stop.
  134344. */
  134345. inertialRadiusOffset: number;
  134346. /**
  134347. * Minimum allowed angle on the longitudinal axis.
  134348. * This can help limiting how the Camera is able to move in the scene.
  134349. */
  134350. lowerAlphaLimit: Nullable<number>;
  134351. /**
  134352. * Maximum allowed angle on the longitudinal axis.
  134353. * This can help limiting how the Camera is able to move in the scene.
  134354. */
  134355. upperAlphaLimit: Nullable<number>;
  134356. /**
  134357. * Minimum allowed angle on the latitudinal axis.
  134358. * This can help limiting how the Camera is able to move in the scene.
  134359. */
  134360. lowerBetaLimit: number;
  134361. /**
  134362. * Maximum allowed angle on the latitudinal axis.
  134363. * This can help limiting how the Camera is able to move in the scene.
  134364. */
  134365. upperBetaLimit: number;
  134366. /**
  134367. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  134368. * This can help limiting how the Camera is able to move in the scene.
  134369. */
  134370. lowerRadiusLimit: Nullable<number>;
  134371. /**
  134372. * Maximum allowed distance of the camera to the target (The camera can not get further).
  134373. * This can help limiting how the Camera is able to move in the scene.
  134374. */
  134375. upperRadiusLimit: Nullable<number>;
  134376. /**
  134377. * Defines the current inertia value used during panning of the camera along the X axis.
  134378. */
  134379. inertialPanningX: number;
  134380. /**
  134381. * Defines the current inertia value used during panning of the camera along the Y axis.
  134382. */
  134383. inertialPanningY: number;
  134384. /**
  134385. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  134386. * Basically if your fingers moves away from more than this distance you will be considered
  134387. * in pinch mode.
  134388. */
  134389. pinchToPanMaxDistance: number;
  134390. /**
  134391. * Defines the maximum distance the camera can pan.
  134392. * This could help keeping the cammera always in your scene.
  134393. */
  134394. panningDistanceLimit: Nullable<number>;
  134395. /**
  134396. * Defines the target of the camera before paning.
  134397. */
  134398. panningOriginTarget: Vector3;
  134399. /**
  134400. * Defines the value of the inertia used during panning.
  134401. * 0 would mean stop inertia and one would mean no decelleration at all.
  134402. */
  134403. panningInertia: number;
  134404. /**
  134405. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  134406. */
  134407. get angularSensibilityX(): number;
  134408. set angularSensibilityX(value: number);
  134409. /**
  134410. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  134411. */
  134412. get angularSensibilityY(): number;
  134413. set angularSensibilityY(value: number);
  134414. /**
  134415. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  134416. */
  134417. get pinchPrecision(): number;
  134418. set pinchPrecision(value: number);
  134419. /**
  134420. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  134421. * It will be used instead of pinchDeltaPrecision if different from 0.
  134422. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  134423. */
  134424. get pinchDeltaPercentage(): number;
  134425. set pinchDeltaPercentage(value: number);
  134426. /**
  134427. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  134428. * and pinch delta percentage.
  134429. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  134430. * that any object in the plane at the camera's target point will scale
  134431. * perfectly with finger motion.
  134432. */
  134433. get useNaturalPinchZoom(): boolean;
  134434. set useNaturalPinchZoom(value: boolean);
  134435. /**
  134436. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  134437. */
  134438. get panningSensibility(): number;
  134439. set panningSensibility(value: number);
  134440. /**
  134441. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  134442. */
  134443. get keysUp(): number[];
  134444. set keysUp(value: number[]);
  134445. /**
  134446. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  134447. */
  134448. get keysDown(): number[];
  134449. set keysDown(value: number[]);
  134450. /**
  134451. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  134452. */
  134453. get keysLeft(): number[];
  134454. set keysLeft(value: number[]);
  134455. /**
  134456. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  134457. */
  134458. get keysRight(): number[];
  134459. set keysRight(value: number[]);
  134460. /**
  134461. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  134462. */
  134463. get wheelPrecision(): number;
  134464. set wheelPrecision(value: number);
  134465. /**
  134466. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  134467. * It will be used instead of pinchDeltaPrecision if different from 0.
  134468. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  134469. */
  134470. get wheelDeltaPercentage(): number;
  134471. set wheelDeltaPercentage(value: number);
  134472. /**
  134473. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  134474. */
  134475. zoomOnFactor: number;
  134476. /**
  134477. * Defines a screen offset for the camera position.
  134478. */
  134479. targetScreenOffset: Vector2;
  134480. /**
  134481. * Allows the camera to be completely reversed.
  134482. * If false the camera can not arrive upside down.
  134483. */
  134484. allowUpsideDown: boolean;
  134485. /**
  134486. * Define if double tap/click is used to restore the previously saved state of the camera.
  134487. */
  134488. useInputToRestoreState: boolean;
  134489. /** @hidden */
  134490. _viewMatrix: Matrix;
  134491. /** @hidden */
  134492. _useCtrlForPanning: boolean;
  134493. /** @hidden */
  134494. _panningMouseButton: number;
  134495. /**
  134496. * Defines the input associated to the camera.
  134497. */
  134498. inputs: ArcRotateCameraInputsManager;
  134499. /** @hidden */
  134500. _reset: () => void;
  134501. /**
  134502. * Defines the allowed panning axis.
  134503. */
  134504. panningAxis: Vector3;
  134505. protected _transformedDirection: Vector3;
  134506. private _bouncingBehavior;
  134507. /**
  134508. * Gets the bouncing behavior of the camera if it has been enabled.
  134509. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  134510. */
  134511. get bouncingBehavior(): Nullable<BouncingBehavior>;
  134512. /**
  134513. * Defines if the bouncing behavior of the camera is enabled on the camera.
  134514. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  134515. */
  134516. get useBouncingBehavior(): boolean;
  134517. set useBouncingBehavior(value: boolean);
  134518. private _framingBehavior;
  134519. /**
  134520. * Gets the framing behavior of the camera if it has been enabled.
  134521. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  134522. */
  134523. get framingBehavior(): Nullable<FramingBehavior>;
  134524. /**
  134525. * Defines if the framing behavior of the camera is enabled on the camera.
  134526. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  134527. */
  134528. get useFramingBehavior(): boolean;
  134529. set useFramingBehavior(value: boolean);
  134530. private _autoRotationBehavior;
  134531. /**
  134532. * Gets the auto rotation behavior of the camera if it has been enabled.
  134533. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134534. */
  134535. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  134536. /**
  134537. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  134538. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134539. */
  134540. get useAutoRotationBehavior(): boolean;
  134541. set useAutoRotationBehavior(value: boolean);
  134542. /**
  134543. * Observable triggered when the mesh target has been changed on the camera.
  134544. */
  134545. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  134546. /**
  134547. * Event raised when the camera is colliding with a mesh.
  134548. */
  134549. onCollide: (collidedMesh: AbstractMesh) => void;
  134550. /**
  134551. * Defines whether the camera should check collision with the objects oh the scene.
  134552. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  134553. */
  134554. checkCollisions: boolean;
  134555. /**
  134556. * Defines the collision radius of the camera.
  134557. * This simulates a sphere around the camera.
  134558. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  134559. */
  134560. collisionRadius: Vector3;
  134561. protected _collider: Collider;
  134562. protected _previousPosition: Vector3;
  134563. protected _collisionVelocity: Vector3;
  134564. protected _newPosition: Vector3;
  134565. protected _previousAlpha: number;
  134566. protected _previousBeta: number;
  134567. protected _previousRadius: number;
  134568. protected _collisionTriggered: boolean;
  134569. protected _targetBoundingCenter: Nullable<Vector3>;
  134570. private _computationVector;
  134571. /**
  134572. * Instantiates a new ArcRotateCamera in a given scene
  134573. * @param name Defines the name of the camera
  134574. * @param alpha Defines the camera rotation along the logitudinal axis
  134575. * @param beta Defines the camera rotation along the latitudinal axis
  134576. * @param radius Defines the camera distance from its target
  134577. * @param target Defines the camera target
  134578. * @param scene Defines the scene the camera belongs to
  134579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  134580. */
  134581. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  134582. /** @hidden */
  134583. _initCache(): void;
  134584. /** @hidden */
  134585. _updateCache(ignoreParentClass?: boolean): void;
  134586. protected _getTargetPosition(): Vector3;
  134587. private _storedAlpha;
  134588. private _storedBeta;
  134589. private _storedRadius;
  134590. private _storedTarget;
  134591. private _storedTargetScreenOffset;
  134592. /**
  134593. * Stores the current state of the camera (alpha, beta, radius and target)
  134594. * @returns the camera itself
  134595. */
  134596. storeState(): Camera;
  134597. /**
  134598. * @hidden
  134599. * Restored camera state. You must call storeState() first
  134600. */
  134601. _restoreStateValues(): boolean;
  134602. /** @hidden */
  134603. _isSynchronizedViewMatrix(): boolean;
  134604. /**
  134605. * Attach the input controls to a specific dom element to get the input from.
  134606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134607. */
  134608. attachControl(noPreventDefault?: boolean): void;
  134609. /**
  134610. * Attach the input controls to a specific dom element to get the input from.
  134611. * @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
  134612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134613. */
  134614. attachControl(ignored: any, noPreventDefault?: boolean): void;
  134615. /**
  134616. * Attached controls to the current camera.
  134617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134618. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134619. */
  134620. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134621. /**
  134622. * Attached controls to the current camera.
  134623. * @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
  134624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134625. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134626. */
  134627. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134628. /**
  134629. * Attached controls to the current camera.
  134630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134631. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134632. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  134633. */
  134634. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  134635. /**
  134636. * Detach the current controls from the specified dom element.
  134637. */
  134638. detachControl(): void;
  134639. /**
  134640. * Detach the current controls from the specified dom element.
  134641. * @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
  134642. */
  134643. detachControl(ignored: any): void;
  134644. /** @hidden */
  134645. _checkInputs(): void;
  134646. protected _checkLimits(): void;
  134647. /**
  134648. * Rebuilds angles (alpha, beta) and radius from the give position and target
  134649. */
  134650. rebuildAnglesAndRadius(): void;
  134651. /**
  134652. * Use a position to define the current camera related information like alpha, beta and radius
  134653. * @param position Defines the position to set the camera at
  134654. */
  134655. setPosition(position: Vector3): void;
  134656. /**
  134657. * Defines the target the camera should look at.
  134658. * This will automatically adapt alpha beta and radius to fit within the new target.
  134659. * @param target Defines the new target as a Vector or a mesh
  134660. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  134661. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  134662. */
  134663. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  134664. /** @hidden */
  134665. _getViewMatrix(): Matrix;
  134666. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  134667. /**
  134668. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  134669. * @param meshes Defines the mesh to zoom on
  134670. * @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)
  134671. */
  134672. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  134673. /**
  134674. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  134675. * The target will be changed but the radius
  134676. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  134677. * @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)
  134678. */
  134679. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  134680. min: Vector3;
  134681. max: Vector3;
  134682. distance: number;
  134683. }, doNotUpdateMaxZ?: boolean): void;
  134684. /**
  134685. * @override
  134686. * Override Camera.createRigCamera
  134687. */
  134688. createRigCamera(name: string, cameraIndex: number): Camera;
  134689. /**
  134690. * @hidden
  134691. * @override
  134692. * Override Camera._updateRigCameras
  134693. */
  134694. _updateRigCameras(): void;
  134695. /**
  134696. * Destroy the camera and release the current resources hold by it.
  134697. */
  134698. dispose(): void;
  134699. /**
  134700. * Gets the current object class name.
  134701. * @return the class name
  134702. */
  134703. getClassName(): string;
  134704. }
  134705. }
  134706. declare module BABYLON {
  134707. /**
  134708. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  134709. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134710. */
  134711. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  134712. /**
  134713. * Gets the name of the behavior.
  134714. */
  134715. get name(): string;
  134716. private _zoomStopsAnimation;
  134717. private _idleRotationSpeed;
  134718. private _idleRotationWaitTime;
  134719. private _idleRotationSpinupTime;
  134720. /**
  134721. * Sets the flag that indicates if user zooming should stop animation.
  134722. */
  134723. set zoomStopsAnimation(flag: boolean);
  134724. /**
  134725. * Gets the flag that indicates if user zooming should stop animation.
  134726. */
  134727. get zoomStopsAnimation(): boolean;
  134728. /**
  134729. * Sets the default speed at which the camera rotates around the model.
  134730. */
  134731. set idleRotationSpeed(speed: number);
  134732. /**
  134733. * Gets the default speed at which the camera rotates around the model.
  134734. */
  134735. get idleRotationSpeed(): number;
  134736. /**
  134737. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  134738. */
  134739. set idleRotationWaitTime(time: number);
  134740. /**
  134741. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  134742. */
  134743. get idleRotationWaitTime(): number;
  134744. /**
  134745. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134746. */
  134747. set idleRotationSpinupTime(time: number);
  134748. /**
  134749. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134750. */
  134751. get idleRotationSpinupTime(): number;
  134752. /**
  134753. * Gets a value indicating if the camera is currently rotating because of this behavior
  134754. */
  134755. get rotationInProgress(): boolean;
  134756. private _onPrePointerObservableObserver;
  134757. private _onAfterCheckInputsObserver;
  134758. private _attachedCamera;
  134759. private _isPointerDown;
  134760. private _lastFrameTime;
  134761. private _lastInteractionTime;
  134762. private _cameraRotationSpeed;
  134763. /**
  134764. * Initializes the behavior.
  134765. */
  134766. init(): void;
  134767. /**
  134768. * Attaches the behavior to its arc rotate camera.
  134769. * @param camera Defines the camera to attach the behavior to
  134770. */
  134771. attach(camera: ArcRotateCamera): void;
  134772. /**
  134773. * Detaches the behavior from its current arc rotate camera.
  134774. */
  134775. detach(): void;
  134776. /**
  134777. * Returns true if user is scrolling.
  134778. * @return true if user is scrolling.
  134779. */
  134780. private _userIsZooming;
  134781. private _lastFrameRadius;
  134782. private _shouldAnimationStopForInteraction;
  134783. /**
  134784. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  134785. */
  134786. private _applyUserInteraction;
  134787. private _userIsMoving;
  134788. }
  134789. }
  134790. declare module BABYLON {
  134791. /**
  134792. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  134793. */
  134794. export class AttachToBoxBehavior implements Behavior<Mesh> {
  134795. private ui;
  134796. /**
  134797. * The name of the behavior
  134798. */
  134799. name: string;
  134800. /**
  134801. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  134802. */
  134803. distanceAwayFromFace: number;
  134804. /**
  134805. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  134806. */
  134807. distanceAwayFromBottomOfFace: number;
  134808. private _faceVectors;
  134809. private _target;
  134810. private _scene;
  134811. private _onRenderObserver;
  134812. private _tmpMatrix;
  134813. private _tmpVector;
  134814. /**
  134815. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  134816. * @param ui The transform node that should be attched to the mesh
  134817. */
  134818. constructor(ui: TransformNode);
  134819. /**
  134820. * Initializes the behavior
  134821. */
  134822. init(): void;
  134823. private _closestFace;
  134824. private _zeroVector;
  134825. private _lookAtTmpMatrix;
  134826. private _lookAtToRef;
  134827. /**
  134828. * Attaches the AttachToBoxBehavior to the passed in mesh
  134829. * @param target The mesh that the specified node will be attached to
  134830. */
  134831. attach(target: Mesh): void;
  134832. /**
  134833. * Detaches the behavior from the mesh
  134834. */
  134835. detach(): void;
  134836. }
  134837. }
  134838. declare module BABYLON {
  134839. /**
  134840. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  134841. */
  134842. export class FadeInOutBehavior implements Behavior<Mesh> {
  134843. /**
  134844. * Time in milliseconds to delay before fading in (Default: 0)
  134845. */
  134846. delay: number;
  134847. /**
  134848. * Time in milliseconds for the mesh to fade in (Default: 300)
  134849. */
  134850. fadeInTime: number;
  134851. private _millisecondsPerFrame;
  134852. private _hovered;
  134853. private _hoverValue;
  134854. private _ownerNode;
  134855. /**
  134856. * Instatiates the FadeInOutBehavior
  134857. */
  134858. constructor();
  134859. /**
  134860. * The name of the behavior
  134861. */
  134862. get name(): string;
  134863. /**
  134864. * Initializes the behavior
  134865. */
  134866. init(): void;
  134867. /**
  134868. * Attaches the fade behavior on the passed in mesh
  134869. * @param ownerNode The mesh that will be faded in/out once attached
  134870. */
  134871. attach(ownerNode: Mesh): void;
  134872. /**
  134873. * Detaches the behavior from the mesh
  134874. */
  134875. detach(): void;
  134876. /**
  134877. * Triggers the mesh to begin fading in or out
  134878. * @param value if the object should fade in or out (true to fade in)
  134879. */
  134880. fadeIn(value: boolean): void;
  134881. private _update;
  134882. private _setAllVisibility;
  134883. }
  134884. }
  134885. declare module BABYLON {
  134886. /**
  134887. * Class containing a set of static utilities functions for managing Pivots
  134888. * @hidden
  134889. */
  134890. export class PivotTools {
  134891. private static _PivotCached;
  134892. private static _OldPivotPoint;
  134893. private static _PivotTranslation;
  134894. private static _PivotTmpVector;
  134895. private static _PivotPostMultiplyPivotMatrix;
  134896. /** @hidden */
  134897. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  134898. /** @hidden */
  134899. static _RestorePivotPoint(mesh: AbstractMesh): void;
  134900. }
  134901. }
  134902. declare module BABYLON {
  134903. /**
  134904. * Class containing static functions to help procedurally build meshes
  134905. */
  134906. export class PlaneBuilder {
  134907. /**
  134908. * Creates a plane mesh
  134909. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134910. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134911. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134915. * @param name defines the name of the mesh
  134916. * @param options defines the options used to create the mesh
  134917. * @param scene defines the hosting scene
  134918. * @returns the plane mesh
  134919. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134920. */
  134921. static CreatePlane(name: string, options: {
  134922. size?: number;
  134923. width?: number;
  134924. height?: number;
  134925. sideOrientation?: number;
  134926. frontUVs?: Vector4;
  134927. backUVs?: Vector4;
  134928. updatable?: boolean;
  134929. sourcePlane?: Plane;
  134930. }, scene?: Nullable<Scene>): Mesh;
  134931. }
  134932. }
  134933. declare module BABYLON {
  134934. /**
  134935. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  134936. */
  134937. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  134938. private static _AnyMouseID;
  134939. /**
  134940. * Abstract mesh the behavior is set on
  134941. */
  134942. attachedNode: AbstractMesh;
  134943. private _dragPlane;
  134944. private _scene;
  134945. private _pointerObserver;
  134946. private _beforeRenderObserver;
  134947. private static _planeScene;
  134948. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  134949. /**
  134950. * 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)
  134951. */
  134952. maxDragAngle: number;
  134953. /**
  134954. * @hidden
  134955. */
  134956. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  134957. /**
  134958. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  134959. */
  134960. currentDraggingPointerID: number;
  134961. /**
  134962. * The last position where the pointer hit the drag plane in world space
  134963. */
  134964. lastDragPosition: Vector3;
  134965. /**
  134966. * If the behavior is currently in a dragging state
  134967. */
  134968. dragging: boolean;
  134969. /**
  134970. * 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)
  134971. */
  134972. dragDeltaRatio: number;
  134973. /**
  134974. * If the drag plane orientation should be updated during the dragging (Default: true)
  134975. */
  134976. updateDragPlane: boolean;
  134977. private _debugMode;
  134978. private _moving;
  134979. /**
  134980. * Fires each time the attached mesh is dragged with the pointer
  134981. * * delta between last drag position and current drag position in world space
  134982. * * dragDistance along the drag axis
  134983. * * dragPlaneNormal normal of the current drag plane used during the drag
  134984. * * dragPlanePoint in world space where the drag intersects the drag plane
  134985. */
  134986. onDragObservable: Observable<{
  134987. delta: Vector3;
  134988. dragPlanePoint: Vector3;
  134989. dragPlaneNormal: Vector3;
  134990. dragDistance: number;
  134991. pointerId: number;
  134992. }>;
  134993. /**
  134994. * Fires each time a drag begins (eg. mouse down on mesh)
  134995. */
  134996. onDragStartObservable: Observable<{
  134997. dragPlanePoint: Vector3;
  134998. pointerId: number;
  134999. }>;
  135000. /**
  135001. * Fires each time a drag ends (eg. mouse release after drag)
  135002. */
  135003. onDragEndObservable: Observable<{
  135004. dragPlanePoint: Vector3;
  135005. pointerId: number;
  135006. }>;
  135007. /**
  135008. * If the attached mesh should be moved when dragged
  135009. */
  135010. moveAttached: boolean;
  135011. /**
  135012. * If the drag behavior will react to drag events (Default: true)
  135013. */
  135014. enabled: boolean;
  135015. /**
  135016. * If pointer events should start and release the drag (Default: true)
  135017. */
  135018. startAndReleaseDragOnPointerEvents: boolean;
  135019. /**
  135020. * If camera controls should be detached during the drag
  135021. */
  135022. detachCameraControls: boolean;
  135023. /**
  135024. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  135025. */
  135026. useObjectOrientationForDragging: boolean;
  135027. private _options;
  135028. /**
  135029. * Gets the options used by the behavior
  135030. */
  135031. get options(): {
  135032. dragAxis?: Vector3;
  135033. dragPlaneNormal?: Vector3;
  135034. };
  135035. /**
  135036. * Sets the options used by the behavior
  135037. */
  135038. set options(options: {
  135039. dragAxis?: Vector3;
  135040. dragPlaneNormal?: Vector3;
  135041. });
  135042. /**
  135043. * Creates a pointer drag behavior that can be attached to a mesh
  135044. * @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)
  135045. */
  135046. constructor(options?: {
  135047. dragAxis?: Vector3;
  135048. dragPlaneNormal?: Vector3;
  135049. });
  135050. /**
  135051. * Predicate to determine if it is valid to move the object to a new position when it is moved
  135052. */
  135053. validateDrag: (targetPosition: Vector3) => boolean;
  135054. /**
  135055. * The name of the behavior
  135056. */
  135057. get name(): string;
  135058. /**
  135059. * Initializes the behavior
  135060. */
  135061. init(): void;
  135062. private _tmpVector;
  135063. private _alternatePickedPoint;
  135064. private _worldDragAxis;
  135065. private _targetPosition;
  135066. private _attachedToElement;
  135067. /**
  135068. * Attaches the drag behavior the passed in mesh
  135069. * @param ownerNode The mesh that will be dragged around once attached
  135070. * @param predicate Predicate to use for pick filtering
  135071. */
  135072. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  135073. /**
  135074. * Force relase the drag action by code.
  135075. */
  135076. releaseDrag(): void;
  135077. private _startDragRay;
  135078. private _lastPointerRay;
  135079. /**
  135080. * Simulates the start of a pointer drag event on the behavior
  135081. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  135082. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  135083. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  135084. */
  135085. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  135086. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  135087. private _dragDelta;
  135088. protected _moveDrag(ray: Ray): void;
  135089. private _pickWithRayOnDragPlane;
  135090. private _pointA;
  135091. private _pointC;
  135092. private _localAxis;
  135093. private _lookAt;
  135094. private _updateDragPlanePosition;
  135095. /**
  135096. * Detaches the behavior from the mesh
  135097. */
  135098. detach(): void;
  135099. }
  135100. }
  135101. declare module BABYLON {
  135102. /**
  135103. * A behavior that when attached to a mesh will allow the mesh to be scaled
  135104. */
  135105. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  135106. private _dragBehaviorA;
  135107. private _dragBehaviorB;
  135108. private _startDistance;
  135109. private _initialScale;
  135110. private _targetScale;
  135111. private _ownerNode;
  135112. private _sceneRenderObserver;
  135113. /**
  135114. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  135115. */
  135116. constructor();
  135117. /**
  135118. * The name of the behavior
  135119. */
  135120. get name(): string;
  135121. /**
  135122. * Initializes the behavior
  135123. */
  135124. init(): void;
  135125. private _getCurrentDistance;
  135126. /**
  135127. * Attaches the scale behavior the passed in mesh
  135128. * @param ownerNode The mesh that will be scaled around once attached
  135129. */
  135130. attach(ownerNode: Mesh): void;
  135131. /**
  135132. * Detaches the behavior from the mesh
  135133. */
  135134. detach(): void;
  135135. }
  135136. }
  135137. declare module BABYLON {
  135138. /**
  135139. * 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
  135140. */
  135141. export class SixDofDragBehavior implements Behavior<Mesh> {
  135142. private static _virtualScene;
  135143. private _ownerNode;
  135144. private _sceneRenderObserver;
  135145. private _scene;
  135146. private _targetPosition;
  135147. private _virtualOriginMesh;
  135148. private _virtualDragMesh;
  135149. private _pointerObserver;
  135150. private _moving;
  135151. private _startingOrientation;
  135152. private _attachedToElement;
  135153. /**
  135154. * 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)
  135155. */
  135156. private zDragFactor;
  135157. /**
  135158. * If the object should rotate to face the drag origin
  135159. */
  135160. rotateDraggedObject: boolean;
  135161. /**
  135162. * If the behavior is currently in a dragging state
  135163. */
  135164. dragging: boolean;
  135165. /**
  135166. * 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)
  135167. */
  135168. dragDeltaRatio: number;
  135169. /**
  135170. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  135171. */
  135172. currentDraggingPointerID: number;
  135173. /**
  135174. * If camera controls should be detached during the drag
  135175. */
  135176. detachCameraControls: boolean;
  135177. /**
  135178. * Fires each time a drag starts
  135179. */
  135180. onDragStartObservable: Observable<{}>;
  135181. /**
  135182. * Fires each time a drag happens
  135183. */
  135184. onDragObservable: Observable<void>;
  135185. /**
  135186. * Fires each time a drag ends (eg. mouse release after drag)
  135187. */
  135188. onDragEndObservable: Observable<{}>;
  135189. /**
  135190. * 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
  135191. */
  135192. constructor();
  135193. /**
  135194. * The name of the behavior
  135195. */
  135196. get name(): string;
  135197. /**
  135198. * Initializes the behavior
  135199. */
  135200. init(): void;
  135201. /**
  135202. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  135203. */
  135204. private get _pointerCamera();
  135205. /**
  135206. * Attaches the scale behavior the passed in mesh
  135207. * @param ownerNode The mesh that will be scaled around once attached
  135208. */
  135209. attach(ownerNode: Mesh): void;
  135210. /**
  135211. * Detaches the behavior from the mesh
  135212. */
  135213. detach(): void;
  135214. }
  135215. }
  135216. declare module BABYLON {
  135217. /**
  135218. * Class used to apply inverse kinematics to bones
  135219. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  135220. */
  135221. export class BoneIKController {
  135222. private static _tmpVecs;
  135223. private static _tmpQuat;
  135224. private static _tmpMats;
  135225. /**
  135226. * Gets or sets the target mesh
  135227. */
  135228. targetMesh: AbstractMesh;
  135229. /** Gets or sets the mesh used as pole */
  135230. poleTargetMesh: AbstractMesh;
  135231. /**
  135232. * Gets or sets the bone used as pole
  135233. */
  135234. poleTargetBone: Nullable<Bone>;
  135235. /**
  135236. * Gets or sets the target position
  135237. */
  135238. targetPosition: Vector3;
  135239. /**
  135240. * Gets or sets the pole target position
  135241. */
  135242. poleTargetPosition: Vector3;
  135243. /**
  135244. * Gets or sets the pole target local offset
  135245. */
  135246. poleTargetLocalOffset: Vector3;
  135247. /**
  135248. * Gets or sets the pole angle
  135249. */
  135250. poleAngle: number;
  135251. /**
  135252. * Gets or sets the mesh associated with the controller
  135253. */
  135254. mesh: AbstractMesh;
  135255. /**
  135256. * 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)
  135257. */
  135258. slerpAmount: number;
  135259. private _bone1Quat;
  135260. private _bone1Mat;
  135261. private _bone2Ang;
  135262. private _bone1;
  135263. private _bone2;
  135264. private _bone1Length;
  135265. private _bone2Length;
  135266. private _maxAngle;
  135267. private _maxReach;
  135268. private _rightHandedSystem;
  135269. private _bendAxis;
  135270. private _slerping;
  135271. private _adjustRoll;
  135272. /**
  135273. * Gets or sets maximum allowed angle
  135274. */
  135275. get maxAngle(): number;
  135276. set maxAngle(value: number);
  135277. /**
  135278. * Creates a new BoneIKController
  135279. * @param mesh defines the mesh to control
  135280. * @param bone defines the bone to control
  135281. * @param options defines options to set up the controller
  135282. */
  135283. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  135284. targetMesh?: AbstractMesh;
  135285. poleTargetMesh?: AbstractMesh;
  135286. poleTargetBone?: Bone;
  135287. poleTargetLocalOffset?: Vector3;
  135288. poleAngle?: number;
  135289. bendAxis?: Vector3;
  135290. maxAngle?: number;
  135291. slerpAmount?: number;
  135292. });
  135293. private _setMaxAngle;
  135294. /**
  135295. * Force the controller to update the bones
  135296. */
  135297. update(): void;
  135298. }
  135299. }
  135300. declare module BABYLON {
  135301. /**
  135302. * Class used to make a bone look toward a point in space
  135303. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  135304. */
  135305. export class BoneLookController {
  135306. private static _tmpVecs;
  135307. private static _tmpQuat;
  135308. private static _tmpMats;
  135309. /**
  135310. * The target Vector3 that the bone will look at
  135311. */
  135312. target: Vector3;
  135313. /**
  135314. * The mesh that the bone is attached to
  135315. */
  135316. mesh: AbstractMesh;
  135317. /**
  135318. * The bone that will be looking to the target
  135319. */
  135320. bone: Bone;
  135321. /**
  135322. * The up axis of the coordinate system that is used when the bone is rotated
  135323. */
  135324. upAxis: Vector3;
  135325. /**
  135326. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  135327. */
  135328. upAxisSpace: Space;
  135329. /**
  135330. * Used to make an adjustment to the yaw of the bone
  135331. */
  135332. adjustYaw: number;
  135333. /**
  135334. * Used to make an adjustment to the pitch of the bone
  135335. */
  135336. adjustPitch: number;
  135337. /**
  135338. * Used to make an adjustment to the roll of the bone
  135339. */
  135340. adjustRoll: number;
  135341. /**
  135342. * 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)
  135343. */
  135344. slerpAmount: number;
  135345. private _minYaw;
  135346. private _maxYaw;
  135347. private _minPitch;
  135348. private _maxPitch;
  135349. private _minYawSin;
  135350. private _minYawCos;
  135351. private _maxYawSin;
  135352. private _maxYawCos;
  135353. private _midYawConstraint;
  135354. private _minPitchTan;
  135355. private _maxPitchTan;
  135356. private _boneQuat;
  135357. private _slerping;
  135358. private _transformYawPitch;
  135359. private _transformYawPitchInv;
  135360. private _firstFrameSkipped;
  135361. private _yawRange;
  135362. private _fowardAxis;
  135363. /**
  135364. * Gets or sets the minimum yaw angle that the bone can look to
  135365. */
  135366. get minYaw(): number;
  135367. set minYaw(value: number);
  135368. /**
  135369. * Gets or sets the maximum yaw angle that the bone can look to
  135370. */
  135371. get maxYaw(): number;
  135372. set maxYaw(value: number);
  135373. /**
  135374. * Gets or sets the minimum pitch angle that the bone can look to
  135375. */
  135376. get minPitch(): number;
  135377. set minPitch(value: number);
  135378. /**
  135379. * Gets or sets the maximum pitch angle that the bone can look to
  135380. */
  135381. get maxPitch(): number;
  135382. set maxPitch(value: number);
  135383. /**
  135384. * Create a BoneLookController
  135385. * @param mesh the mesh that the bone belongs to
  135386. * @param bone the bone that will be looking to the target
  135387. * @param target the target Vector3 to look at
  135388. * @param options optional settings:
  135389. * * maxYaw: the maximum angle the bone will yaw to
  135390. * * minYaw: the minimum angle the bone will yaw to
  135391. * * maxPitch: the maximum angle the bone will pitch to
  135392. * * minPitch: the minimum angle the bone will yaw to
  135393. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  135394. * * upAxis: the up axis of the coordinate system
  135395. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  135396. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  135397. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  135398. * * adjustYaw: used to make an adjustment to the yaw of the bone
  135399. * * adjustPitch: used to make an adjustment to the pitch of the bone
  135400. * * adjustRoll: used to make an adjustment to the roll of the bone
  135401. **/
  135402. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  135403. maxYaw?: number;
  135404. minYaw?: number;
  135405. maxPitch?: number;
  135406. minPitch?: number;
  135407. slerpAmount?: number;
  135408. upAxis?: Vector3;
  135409. upAxisSpace?: Space;
  135410. yawAxis?: Vector3;
  135411. pitchAxis?: Vector3;
  135412. adjustYaw?: number;
  135413. adjustPitch?: number;
  135414. adjustRoll?: number;
  135415. });
  135416. /**
  135417. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  135418. */
  135419. update(): void;
  135420. private _getAngleDiff;
  135421. private _getAngleBetween;
  135422. private _isAngleBetween;
  135423. }
  135424. }
  135425. declare module BABYLON {
  135426. /**
  135427. * Manage the gamepad inputs to control an arc rotate camera.
  135428. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135429. */
  135430. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  135431. /**
  135432. * Defines the camera the input is attached to.
  135433. */
  135434. camera: ArcRotateCamera;
  135435. /**
  135436. * Defines the gamepad the input is gathering event from.
  135437. */
  135438. gamepad: Nullable<Gamepad>;
  135439. /**
  135440. * Defines the gamepad rotation sensiblity.
  135441. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  135442. */
  135443. gamepadRotationSensibility: number;
  135444. /**
  135445. * Defines the gamepad move sensiblity.
  135446. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  135447. */
  135448. gamepadMoveSensibility: number;
  135449. private _yAxisScale;
  135450. /**
  135451. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  135452. */
  135453. get invertYAxis(): boolean;
  135454. set invertYAxis(value: boolean);
  135455. private _onGamepadConnectedObserver;
  135456. private _onGamepadDisconnectedObserver;
  135457. /**
  135458. * Attach the input controls to a specific dom element to get the input from.
  135459. */
  135460. attachControl(): void;
  135461. /**
  135462. * Detach the current controls from the specified dom element.
  135463. */
  135464. detachControl(): void;
  135465. /**
  135466. * Update the current camera state depending on the inputs that have been used this frame.
  135467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135468. */
  135469. checkInputs(): void;
  135470. /**
  135471. * Gets the class name of the current intput.
  135472. * @returns the class name
  135473. */
  135474. getClassName(): string;
  135475. /**
  135476. * Get the friendly name associated with the input class.
  135477. * @returns the input friendly name
  135478. */
  135479. getSimpleName(): string;
  135480. }
  135481. }
  135482. declare module BABYLON {
  135483. interface ArcRotateCameraInputsManager {
  135484. /**
  135485. * Add orientation input support to the input manager.
  135486. * @returns the current input manager
  135487. */
  135488. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  135489. }
  135490. /**
  135491. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  135492. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135493. */
  135494. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  135495. /**
  135496. * Defines the camera the input is attached to.
  135497. */
  135498. camera: ArcRotateCamera;
  135499. /**
  135500. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  135501. */
  135502. alphaCorrection: number;
  135503. /**
  135504. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  135505. */
  135506. gammaCorrection: number;
  135507. private _alpha;
  135508. private _gamma;
  135509. private _dirty;
  135510. private _deviceOrientationHandler;
  135511. /**
  135512. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  135513. */
  135514. constructor();
  135515. /**
  135516. * Attach the input controls to a specific dom element to get the input from.
  135517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135518. */
  135519. attachControl(noPreventDefault?: boolean): void;
  135520. /** @hidden */
  135521. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  135522. /**
  135523. * Update the current camera state depending on the inputs that have been used this frame.
  135524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135525. */
  135526. checkInputs(): void;
  135527. /**
  135528. * Detach the current controls from the specified dom element.
  135529. */
  135530. detachControl(): void;
  135531. /**
  135532. * Gets the class name of the current intput.
  135533. * @returns the class name
  135534. */
  135535. getClassName(): string;
  135536. /**
  135537. * Get the friendly name associated with the input class.
  135538. * @returns the input friendly name
  135539. */
  135540. getSimpleName(): string;
  135541. }
  135542. }
  135543. declare module BABYLON {
  135544. /**
  135545. * Listen to mouse events to control the camera.
  135546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135547. */
  135548. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  135549. /**
  135550. * Defines the camera the input is attached to.
  135551. */
  135552. camera: FlyCamera;
  135553. /**
  135554. * Defines if touch is enabled. (Default is true.)
  135555. */
  135556. touchEnabled: boolean;
  135557. /**
  135558. * Defines the buttons associated with the input to handle camera rotation.
  135559. */
  135560. buttons: number[];
  135561. /**
  135562. * Assign buttons for Yaw control.
  135563. */
  135564. buttonsYaw: number[];
  135565. /**
  135566. * Assign buttons for Pitch control.
  135567. */
  135568. buttonsPitch: number[];
  135569. /**
  135570. * Assign buttons for Roll control.
  135571. */
  135572. buttonsRoll: number[];
  135573. /**
  135574. * Detect if any button is being pressed while mouse is moved.
  135575. * -1 = Mouse locked.
  135576. * 0 = Left button.
  135577. * 1 = Middle Button.
  135578. * 2 = Right Button.
  135579. */
  135580. activeButton: number;
  135581. /**
  135582. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  135583. * Higher values reduce its sensitivity.
  135584. */
  135585. angularSensibility: number;
  135586. private _observer;
  135587. private _rollObserver;
  135588. private previousPosition;
  135589. private noPreventDefault;
  135590. private element;
  135591. /**
  135592. * Listen to mouse events to control the camera.
  135593. * @param touchEnabled Define if touch is enabled. (Default is true.)
  135594. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135595. */
  135596. constructor(touchEnabled?: boolean);
  135597. /**
  135598. * Attach the mouse control to the HTML DOM element.
  135599. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  135600. */
  135601. attachControl(noPreventDefault?: boolean): void;
  135602. /**
  135603. * Detach the current controls from the specified dom element.
  135604. */
  135605. detachControl(): void;
  135606. /**
  135607. * Gets the class name of the current input.
  135608. * @returns the class name.
  135609. */
  135610. getClassName(): string;
  135611. /**
  135612. * Get the friendly name associated with the input class.
  135613. * @returns the input's friendly name.
  135614. */
  135615. getSimpleName(): string;
  135616. private _pointerInput;
  135617. private _onMouseMove;
  135618. /**
  135619. * Rotate camera by mouse offset.
  135620. */
  135621. private rotateCamera;
  135622. }
  135623. }
  135624. declare module BABYLON {
  135625. /**
  135626. * Default Inputs manager for the FlyCamera.
  135627. * It groups all the default supported inputs for ease of use.
  135628. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135629. */
  135630. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  135631. /**
  135632. * Instantiates a new FlyCameraInputsManager.
  135633. * @param camera Defines the camera the inputs belong to.
  135634. */
  135635. constructor(camera: FlyCamera);
  135636. /**
  135637. * Add keyboard input support to the input manager.
  135638. * @returns the new FlyCameraKeyboardMoveInput().
  135639. */
  135640. addKeyboard(): FlyCameraInputsManager;
  135641. /**
  135642. * Add mouse input support to the input manager.
  135643. * @param touchEnabled Enable touch screen support.
  135644. * @returns the new FlyCameraMouseInput().
  135645. */
  135646. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  135647. }
  135648. }
  135649. declare module BABYLON {
  135650. /**
  135651. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135652. * such as in a 3D Space Shooter or a Flight Simulator.
  135653. */
  135654. export class FlyCamera extends TargetCamera {
  135655. /**
  135656. * Define the collision ellipsoid of the camera.
  135657. * This is helpful for simulating a camera body, like a player's body.
  135658. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  135659. */
  135660. ellipsoid: Vector3;
  135661. /**
  135662. * Define an offset for the position of the ellipsoid around the camera.
  135663. * This can be helpful if the camera is attached away from the player's body center,
  135664. * such as at its head.
  135665. */
  135666. ellipsoidOffset: Vector3;
  135667. /**
  135668. * Enable or disable collisions of the camera with the rest of the scene objects.
  135669. */
  135670. checkCollisions: boolean;
  135671. /**
  135672. * Enable or disable gravity on the camera.
  135673. */
  135674. applyGravity: boolean;
  135675. /**
  135676. * Define the current direction the camera is moving to.
  135677. */
  135678. cameraDirection: Vector3;
  135679. /**
  135680. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  135681. * This overrides and empties cameraRotation.
  135682. */
  135683. rotationQuaternion: Quaternion;
  135684. /**
  135685. * Track Roll to maintain the wanted Rolling when looking around.
  135686. */
  135687. _trackRoll: number;
  135688. /**
  135689. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  135690. */
  135691. rollCorrect: number;
  135692. /**
  135693. * Mimic a banked turn, Rolling the camera when Yawing.
  135694. * It's recommended to use rollCorrect = 10 for faster banking correction.
  135695. */
  135696. bankedTurn: boolean;
  135697. /**
  135698. * Limit in radians for how much Roll banking will add. (Default: 90°)
  135699. */
  135700. bankedTurnLimit: number;
  135701. /**
  135702. * Value of 0 disables the banked Roll.
  135703. * Value of 1 is equal to the Yaw angle in radians.
  135704. */
  135705. bankedTurnMultiplier: number;
  135706. /**
  135707. * The inputs manager loads all the input sources, such as keyboard and mouse.
  135708. */
  135709. inputs: FlyCameraInputsManager;
  135710. /**
  135711. * Gets the input sensibility for mouse input.
  135712. * Higher values reduce sensitivity.
  135713. */
  135714. get angularSensibility(): number;
  135715. /**
  135716. * Sets the input sensibility for a mouse input.
  135717. * Higher values reduce sensitivity.
  135718. */
  135719. set angularSensibility(value: number);
  135720. /**
  135721. * Get the keys for camera movement forward.
  135722. */
  135723. get keysForward(): number[];
  135724. /**
  135725. * Set the keys for camera movement forward.
  135726. */
  135727. set keysForward(value: number[]);
  135728. /**
  135729. * Get the keys for camera movement backward.
  135730. */
  135731. get keysBackward(): number[];
  135732. set keysBackward(value: number[]);
  135733. /**
  135734. * Get the keys for camera movement up.
  135735. */
  135736. get keysUp(): number[];
  135737. /**
  135738. * Set the keys for camera movement up.
  135739. */
  135740. set keysUp(value: number[]);
  135741. /**
  135742. * Get the keys for camera movement down.
  135743. */
  135744. get keysDown(): number[];
  135745. /**
  135746. * Set the keys for camera movement down.
  135747. */
  135748. set keysDown(value: number[]);
  135749. /**
  135750. * Get the keys for camera movement left.
  135751. */
  135752. get keysLeft(): number[];
  135753. /**
  135754. * Set the keys for camera movement left.
  135755. */
  135756. set keysLeft(value: number[]);
  135757. /**
  135758. * Set the keys for camera movement right.
  135759. */
  135760. get keysRight(): number[];
  135761. /**
  135762. * Set the keys for camera movement right.
  135763. */
  135764. set keysRight(value: number[]);
  135765. /**
  135766. * Event raised when the camera collides with a mesh in the scene.
  135767. */
  135768. onCollide: (collidedMesh: AbstractMesh) => void;
  135769. private _collider;
  135770. private _needMoveForGravity;
  135771. private _oldPosition;
  135772. private _diffPosition;
  135773. private _newPosition;
  135774. /** @hidden */
  135775. _localDirection: Vector3;
  135776. /** @hidden */
  135777. _transformedDirection: Vector3;
  135778. /**
  135779. * Instantiates a FlyCamera.
  135780. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135781. * such as in a 3D Space Shooter or a Flight Simulator.
  135782. * @param name Define the name of the camera in the scene.
  135783. * @param position Define the starting position of the camera in the scene.
  135784. * @param scene Define the scene the camera belongs to.
  135785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  135786. */
  135787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  135788. /**
  135789. * Attach the input controls to a specific dom element to get the input from.
  135790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135791. */
  135792. attachControl(noPreventDefault?: boolean): void;
  135793. /**
  135794. * Detach a control from the HTML DOM element.
  135795. * The camera will stop reacting to that input.
  135796. */
  135797. detachControl(): void;
  135798. private _collisionMask;
  135799. /**
  135800. * Get the mask that the camera ignores in collision events.
  135801. */
  135802. get collisionMask(): number;
  135803. /**
  135804. * Set the mask that the camera ignores in collision events.
  135805. */
  135806. set collisionMask(mask: number);
  135807. /** @hidden */
  135808. _collideWithWorld(displacement: Vector3): void;
  135809. /** @hidden */
  135810. private _onCollisionPositionChange;
  135811. /** @hidden */
  135812. _checkInputs(): void;
  135813. /** @hidden */
  135814. _decideIfNeedsToMove(): boolean;
  135815. /** @hidden */
  135816. _updatePosition(): void;
  135817. /**
  135818. * Restore the Roll to its target value at the rate specified.
  135819. * @param rate - Higher means slower restoring.
  135820. * @hidden
  135821. */
  135822. restoreRoll(rate: number): void;
  135823. /**
  135824. * Destroy the camera and release the current resources held by it.
  135825. */
  135826. dispose(): void;
  135827. /**
  135828. * Get the current object class name.
  135829. * @returns the class name.
  135830. */
  135831. getClassName(): string;
  135832. }
  135833. }
  135834. declare module BABYLON {
  135835. /**
  135836. * Listen to keyboard events to control the camera.
  135837. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135838. */
  135839. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  135840. /**
  135841. * Defines the camera the input is attached to.
  135842. */
  135843. camera: FlyCamera;
  135844. /**
  135845. * The list of keyboard keys used to control the forward move of the camera.
  135846. */
  135847. keysForward: number[];
  135848. /**
  135849. * The list of keyboard keys used to control the backward move of the camera.
  135850. */
  135851. keysBackward: number[];
  135852. /**
  135853. * The list of keyboard keys used to control the forward move of the camera.
  135854. */
  135855. keysUp: number[];
  135856. /**
  135857. * The list of keyboard keys used to control the backward move of the camera.
  135858. */
  135859. keysDown: number[];
  135860. /**
  135861. * The list of keyboard keys used to control the right strafe move of the camera.
  135862. */
  135863. keysRight: number[];
  135864. /**
  135865. * The list of keyboard keys used to control the left strafe move of the camera.
  135866. */
  135867. keysLeft: number[];
  135868. private _keys;
  135869. private _onCanvasBlurObserver;
  135870. private _onKeyboardObserver;
  135871. private _engine;
  135872. private _scene;
  135873. /**
  135874. * Attach the input controls to a specific dom element to get the input from.
  135875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135876. */
  135877. attachControl(noPreventDefault?: boolean): void;
  135878. /**
  135879. * Detach the current controls from the specified dom element.
  135880. */
  135881. detachControl(): void;
  135882. /**
  135883. * Gets the class name of the current intput.
  135884. * @returns the class name
  135885. */
  135886. getClassName(): string;
  135887. /** @hidden */
  135888. _onLostFocus(e: FocusEvent): void;
  135889. /**
  135890. * Get the friendly name associated with the input class.
  135891. * @returns the input friendly name
  135892. */
  135893. getSimpleName(): string;
  135894. /**
  135895. * Update the current camera state depending on the inputs that have been used this frame.
  135896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135897. */
  135898. checkInputs(): void;
  135899. }
  135900. }
  135901. declare module BABYLON {
  135902. /**
  135903. * Manage the mouse wheel inputs to control a follow camera.
  135904. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135905. */
  135906. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  135907. /**
  135908. * Defines the camera the input is attached to.
  135909. */
  135910. camera: FollowCamera;
  135911. /**
  135912. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  135913. */
  135914. axisControlRadius: boolean;
  135915. /**
  135916. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  135917. */
  135918. axisControlHeight: boolean;
  135919. /**
  135920. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  135921. */
  135922. axisControlRotation: boolean;
  135923. /**
  135924. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  135925. * relation to mouseWheel events.
  135926. */
  135927. wheelPrecision: number;
  135928. /**
  135929. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  135930. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  135931. */
  135932. wheelDeltaPercentage: number;
  135933. private _wheel;
  135934. private _observer;
  135935. /**
  135936. * Attach the input controls to a specific dom element to get the input from.
  135937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135938. */
  135939. attachControl(noPreventDefault?: boolean): void;
  135940. /**
  135941. * Detach the current controls from the specified dom element.
  135942. */
  135943. detachControl(): void;
  135944. /**
  135945. * Gets the class name of the current intput.
  135946. * @returns the class name
  135947. */
  135948. getClassName(): string;
  135949. /**
  135950. * Get the friendly name associated with the input class.
  135951. * @returns the input friendly name
  135952. */
  135953. getSimpleName(): string;
  135954. }
  135955. }
  135956. declare module BABYLON {
  135957. /**
  135958. * Manage the pointers inputs to control an follow camera.
  135959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135960. */
  135961. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  135962. /**
  135963. * Defines the camera the input is attached to.
  135964. */
  135965. camera: FollowCamera;
  135966. /**
  135967. * Gets the class name of the current input.
  135968. * @returns the class name
  135969. */
  135970. getClassName(): string;
  135971. /**
  135972. * Defines the pointer angular sensibility along the X axis or how fast is
  135973. * the camera rotating.
  135974. * A negative number will reverse the axis direction.
  135975. */
  135976. angularSensibilityX: number;
  135977. /**
  135978. * Defines the pointer angular sensibility along the Y axis or how fast is
  135979. * the camera rotating.
  135980. * A negative number will reverse the axis direction.
  135981. */
  135982. angularSensibilityY: number;
  135983. /**
  135984. * Defines the pointer pinch precision or how fast is the camera zooming.
  135985. * A negative number will reverse the axis direction.
  135986. */
  135987. pinchPrecision: number;
  135988. /**
  135989. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  135990. * from 0.
  135991. * It defines the percentage of current camera.radius to use as delta when
  135992. * pinch zoom is used.
  135993. */
  135994. pinchDeltaPercentage: number;
  135995. /**
  135996. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  135997. */
  135998. axisXControlRadius: boolean;
  135999. /**
  136000. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  136001. */
  136002. axisXControlHeight: boolean;
  136003. /**
  136004. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  136005. */
  136006. axisXControlRotation: boolean;
  136007. /**
  136008. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  136009. */
  136010. axisYControlRadius: boolean;
  136011. /**
  136012. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  136013. */
  136014. axisYControlHeight: boolean;
  136015. /**
  136016. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  136017. */
  136018. axisYControlRotation: boolean;
  136019. /**
  136020. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  136021. */
  136022. axisPinchControlRadius: boolean;
  136023. /**
  136024. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  136025. */
  136026. axisPinchControlHeight: boolean;
  136027. /**
  136028. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  136029. */
  136030. axisPinchControlRotation: boolean;
  136031. /**
  136032. * Log error messages if basic misconfiguration has occurred.
  136033. */
  136034. warningEnable: boolean;
  136035. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  136036. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  136037. private _warningCounter;
  136038. private _warning;
  136039. }
  136040. }
  136041. declare module BABYLON {
  136042. /**
  136043. * Default Inputs manager for the FollowCamera.
  136044. * It groups all the default supported inputs for ease of use.
  136045. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136046. */
  136047. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  136048. /**
  136049. * Instantiates a new FollowCameraInputsManager.
  136050. * @param camera Defines the camera the inputs belong to
  136051. */
  136052. constructor(camera: FollowCamera);
  136053. /**
  136054. * Add keyboard input support to the input manager.
  136055. * @returns the current input manager
  136056. */
  136057. addKeyboard(): FollowCameraInputsManager;
  136058. /**
  136059. * Add mouse wheel input support to the input manager.
  136060. * @returns the current input manager
  136061. */
  136062. addMouseWheel(): FollowCameraInputsManager;
  136063. /**
  136064. * Add pointers input support to the input manager.
  136065. * @returns the current input manager
  136066. */
  136067. addPointers(): FollowCameraInputsManager;
  136068. /**
  136069. * Add orientation input support to the input manager.
  136070. * @returns the current input manager
  136071. */
  136072. addVRDeviceOrientation(): FollowCameraInputsManager;
  136073. }
  136074. }
  136075. declare module BABYLON {
  136076. /**
  136077. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  136078. * an arc rotate version arcFollowCamera are available.
  136079. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136080. */
  136081. export class FollowCamera extends TargetCamera {
  136082. /**
  136083. * Distance the follow camera should follow an object at
  136084. */
  136085. radius: number;
  136086. /**
  136087. * Minimum allowed distance of the camera to the axis of rotation
  136088. * (The camera can not get closer).
  136089. * This can help limiting how the Camera is able to move in the scene.
  136090. */
  136091. lowerRadiusLimit: Nullable<number>;
  136092. /**
  136093. * Maximum allowed distance of the camera to the axis of rotation
  136094. * (The camera can not get further).
  136095. * This can help limiting how the Camera is able to move in the scene.
  136096. */
  136097. upperRadiusLimit: Nullable<number>;
  136098. /**
  136099. * Define a rotation offset between the camera and the object it follows
  136100. */
  136101. rotationOffset: number;
  136102. /**
  136103. * Minimum allowed angle to camera position relative to target object.
  136104. * This can help limiting how the Camera is able to move in the scene.
  136105. */
  136106. lowerRotationOffsetLimit: Nullable<number>;
  136107. /**
  136108. * Maximum allowed angle to camera position relative to target object.
  136109. * This can help limiting how the Camera is able to move in the scene.
  136110. */
  136111. upperRotationOffsetLimit: Nullable<number>;
  136112. /**
  136113. * Define a height offset between the camera and the object it follows.
  136114. * It can help following an object from the top (like a car chaing a plane)
  136115. */
  136116. heightOffset: number;
  136117. /**
  136118. * Minimum allowed height of camera position relative to target object.
  136119. * This can help limiting how the Camera is able to move in the scene.
  136120. */
  136121. lowerHeightOffsetLimit: Nullable<number>;
  136122. /**
  136123. * Maximum allowed height of camera position relative to target object.
  136124. * This can help limiting how the Camera is able to move in the scene.
  136125. */
  136126. upperHeightOffsetLimit: Nullable<number>;
  136127. /**
  136128. * Define how fast the camera can accelerate to follow it s target.
  136129. */
  136130. cameraAcceleration: number;
  136131. /**
  136132. * Define the speed limit of the camera following an object.
  136133. */
  136134. maxCameraSpeed: number;
  136135. /**
  136136. * Define the target of the camera.
  136137. */
  136138. lockedTarget: Nullable<AbstractMesh>;
  136139. /**
  136140. * Defines the input associated with the camera.
  136141. */
  136142. inputs: FollowCameraInputsManager;
  136143. /**
  136144. * Instantiates the follow camera.
  136145. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136146. * @param name Define the name of the camera in the scene
  136147. * @param position Define the position of the camera
  136148. * @param scene Define the scene the camera belong to
  136149. * @param lockedTarget Define the target of the camera
  136150. */
  136151. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  136152. private _follow;
  136153. /**
  136154. * Attach the input controls to a specific dom element to get the input from.
  136155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136156. */
  136157. attachControl(noPreventDefault?: boolean): void;
  136158. /**
  136159. * Detach the current controls from the specified dom element.
  136160. */
  136161. detachControl(): void;
  136162. /** @hidden */
  136163. _checkInputs(): void;
  136164. private _checkLimits;
  136165. /**
  136166. * Gets the camera class name.
  136167. * @returns the class name
  136168. */
  136169. getClassName(): string;
  136170. }
  136171. /**
  136172. * Arc Rotate version of the follow camera.
  136173. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  136174. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136175. */
  136176. export class ArcFollowCamera extends TargetCamera {
  136177. /** The longitudinal angle of the camera */
  136178. alpha: number;
  136179. /** The latitudinal angle of the camera */
  136180. beta: number;
  136181. /** The radius of the camera from its target */
  136182. radius: number;
  136183. private _cartesianCoordinates;
  136184. /** Define the camera target (the mesh it should follow) */
  136185. private _meshTarget;
  136186. /**
  136187. * Instantiates a new ArcFollowCamera
  136188. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136189. * @param name Define the name of the camera
  136190. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  136191. * @param beta Define the rotation angle of the camera around the elevation axis
  136192. * @param radius Define the radius of the camera from its target point
  136193. * @param target Define the target of the camera
  136194. * @param scene Define the scene the camera belongs to
  136195. */
  136196. constructor(name: string,
  136197. /** The longitudinal angle of the camera */
  136198. alpha: number,
  136199. /** The latitudinal angle of the camera */
  136200. beta: number,
  136201. /** The radius of the camera from its target */
  136202. radius: number,
  136203. /** Define the camera target (the mesh it should follow) */
  136204. target: Nullable<AbstractMesh>, scene: Scene);
  136205. private _follow;
  136206. /** @hidden */
  136207. _checkInputs(): void;
  136208. /**
  136209. * Returns the class name of the object.
  136210. * It is mostly used internally for serialization purposes.
  136211. */
  136212. getClassName(): string;
  136213. }
  136214. }
  136215. declare module BABYLON {
  136216. /**
  136217. * Manage the keyboard inputs to control the movement of a follow camera.
  136218. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136219. */
  136220. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  136221. /**
  136222. * Defines the camera the input is attached to.
  136223. */
  136224. camera: FollowCamera;
  136225. /**
  136226. * Defines the list of key codes associated with the up action (increase heightOffset)
  136227. */
  136228. keysHeightOffsetIncr: number[];
  136229. /**
  136230. * Defines the list of key codes associated with the down action (decrease heightOffset)
  136231. */
  136232. keysHeightOffsetDecr: number[];
  136233. /**
  136234. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  136235. */
  136236. keysHeightOffsetModifierAlt: boolean;
  136237. /**
  136238. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  136239. */
  136240. keysHeightOffsetModifierCtrl: boolean;
  136241. /**
  136242. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  136243. */
  136244. keysHeightOffsetModifierShift: boolean;
  136245. /**
  136246. * Defines the list of key codes associated with the left action (increase rotationOffset)
  136247. */
  136248. keysRotationOffsetIncr: number[];
  136249. /**
  136250. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  136251. */
  136252. keysRotationOffsetDecr: number[];
  136253. /**
  136254. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  136255. */
  136256. keysRotationOffsetModifierAlt: boolean;
  136257. /**
  136258. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  136259. */
  136260. keysRotationOffsetModifierCtrl: boolean;
  136261. /**
  136262. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  136263. */
  136264. keysRotationOffsetModifierShift: boolean;
  136265. /**
  136266. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  136267. */
  136268. keysRadiusIncr: number[];
  136269. /**
  136270. * Defines the list of key codes associated with the zoom-out action (increase radius)
  136271. */
  136272. keysRadiusDecr: number[];
  136273. /**
  136274. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  136275. */
  136276. keysRadiusModifierAlt: boolean;
  136277. /**
  136278. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  136279. */
  136280. keysRadiusModifierCtrl: boolean;
  136281. /**
  136282. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  136283. */
  136284. keysRadiusModifierShift: boolean;
  136285. /**
  136286. * Defines the rate of change of heightOffset.
  136287. */
  136288. heightSensibility: number;
  136289. /**
  136290. * Defines the rate of change of rotationOffset.
  136291. */
  136292. rotationSensibility: number;
  136293. /**
  136294. * Defines the rate of change of radius.
  136295. */
  136296. radiusSensibility: number;
  136297. private _keys;
  136298. private _ctrlPressed;
  136299. private _altPressed;
  136300. private _shiftPressed;
  136301. private _onCanvasBlurObserver;
  136302. private _onKeyboardObserver;
  136303. private _engine;
  136304. private _scene;
  136305. /**
  136306. * Attach the input controls to a specific dom element to get the input from.
  136307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136308. */
  136309. attachControl(noPreventDefault?: boolean): void;
  136310. /**
  136311. * Detach the current controls from the specified dom element.
  136312. */
  136313. detachControl(): void;
  136314. /**
  136315. * Update the current camera state depending on the inputs that have been used this frame.
  136316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136317. */
  136318. checkInputs(): void;
  136319. /**
  136320. * Gets the class name of the current input.
  136321. * @returns the class name
  136322. */
  136323. getClassName(): string;
  136324. /**
  136325. * Get the friendly name associated with the input class.
  136326. * @returns the input friendly name
  136327. */
  136328. getSimpleName(): string;
  136329. /**
  136330. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136331. * allow modification of the heightOffset value.
  136332. */
  136333. private _modifierHeightOffset;
  136334. /**
  136335. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136336. * allow modification of the rotationOffset value.
  136337. */
  136338. private _modifierRotationOffset;
  136339. /**
  136340. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136341. * allow modification of the radius value.
  136342. */
  136343. private _modifierRadius;
  136344. }
  136345. }
  136346. declare module BABYLON {
  136347. interface FreeCameraInputsManager {
  136348. /**
  136349. * @hidden
  136350. */
  136351. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  136352. /**
  136353. * Add orientation input support to the input manager.
  136354. * @returns the current input manager
  136355. */
  136356. addDeviceOrientation(): FreeCameraInputsManager;
  136357. }
  136358. /**
  136359. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  136360. * Screen rotation is taken into account.
  136361. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136362. */
  136363. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  136364. private _camera;
  136365. private _screenOrientationAngle;
  136366. private _constantTranform;
  136367. private _screenQuaternion;
  136368. private _alpha;
  136369. private _beta;
  136370. private _gamma;
  136371. /**
  136372. * Can be used to detect if a device orientation sensor is available on a device
  136373. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  136374. * @returns a promise that will resolve on orientation change
  136375. */
  136376. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  136377. /**
  136378. * @hidden
  136379. */
  136380. _onDeviceOrientationChangedObservable: Observable<void>;
  136381. /**
  136382. * Instantiates a new input
  136383. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136384. */
  136385. constructor();
  136386. /**
  136387. * Define the camera controlled by the input.
  136388. */
  136389. get camera(): FreeCamera;
  136390. set camera(camera: FreeCamera);
  136391. /**
  136392. * Attach the input controls to a specific dom element to get the input from.
  136393. */
  136394. attachControl(): void;
  136395. private _orientationChanged;
  136396. private _deviceOrientation;
  136397. /**
  136398. * Detach the current controls from the specified dom element.
  136399. */
  136400. detachControl(): void;
  136401. /**
  136402. * Update the current camera state depending on the inputs that have been used this frame.
  136403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136404. */
  136405. checkInputs(): void;
  136406. /**
  136407. * Gets the class name of the current intput.
  136408. * @returns the class name
  136409. */
  136410. getClassName(): string;
  136411. /**
  136412. * Get the friendly name associated with the input class.
  136413. * @returns the input friendly name
  136414. */
  136415. getSimpleName(): string;
  136416. }
  136417. }
  136418. declare module BABYLON {
  136419. /**
  136420. * Manage the gamepad inputs to control a free camera.
  136421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136422. */
  136423. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  136424. /**
  136425. * Define the camera the input is attached to.
  136426. */
  136427. camera: FreeCamera;
  136428. /**
  136429. * Define the Gamepad controlling the input
  136430. */
  136431. gamepad: Nullable<Gamepad>;
  136432. /**
  136433. * Defines the gamepad rotation sensiblity.
  136434. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  136435. */
  136436. gamepadAngularSensibility: number;
  136437. /**
  136438. * Defines the gamepad move sensiblity.
  136439. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  136440. */
  136441. gamepadMoveSensibility: number;
  136442. private _yAxisScale;
  136443. /**
  136444. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  136445. */
  136446. get invertYAxis(): boolean;
  136447. set invertYAxis(value: boolean);
  136448. private _onGamepadConnectedObserver;
  136449. private _onGamepadDisconnectedObserver;
  136450. private _cameraTransform;
  136451. private _deltaTransform;
  136452. private _vector3;
  136453. private _vector2;
  136454. /**
  136455. * Attach the input controls to a specific dom element to get the input from.
  136456. */
  136457. attachControl(): void;
  136458. /**
  136459. * Detach the current controls from the specified dom element.
  136460. */
  136461. detachControl(): void;
  136462. /**
  136463. * Update the current camera state depending on the inputs that have been used this frame.
  136464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136465. */
  136466. checkInputs(): void;
  136467. /**
  136468. * Gets the class name of the current intput.
  136469. * @returns the class name
  136470. */
  136471. getClassName(): string;
  136472. /**
  136473. * Get the friendly name associated with the input class.
  136474. * @returns the input friendly name
  136475. */
  136476. getSimpleName(): string;
  136477. }
  136478. }
  136479. declare module BABYLON {
  136480. /**
  136481. * Defines the potential axis of a Joystick
  136482. */
  136483. export enum JoystickAxis {
  136484. /** X axis */
  136485. X = 0,
  136486. /** Y axis */
  136487. Y = 1,
  136488. /** Z axis */
  136489. Z = 2
  136490. }
  136491. /**
  136492. * Represents the different customization options available
  136493. * for VirtualJoystick
  136494. */
  136495. interface VirtualJoystickCustomizations {
  136496. /**
  136497. * Size of the joystick's puck
  136498. */
  136499. puckSize: number;
  136500. /**
  136501. * Size of the joystick's container
  136502. */
  136503. containerSize: number;
  136504. /**
  136505. * Color of the joystick && puck
  136506. */
  136507. color: string;
  136508. /**
  136509. * Image URL for the joystick's puck
  136510. */
  136511. puckImage?: string;
  136512. /**
  136513. * Image URL for the joystick's container
  136514. */
  136515. containerImage?: string;
  136516. /**
  136517. * Defines the unmoving position of the joystick container
  136518. */
  136519. position?: {
  136520. x: number;
  136521. y: number;
  136522. };
  136523. /**
  136524. * Defines whether or not the joystick container is always visible
  136525. */
  136526. alwaysVisible: boolean;
  136527. /**
  136528. * Defines whether or not to limit the movement of the puck to the joystick's container
  136529. */
  136530. limitToContainer: boolean;
  136531. }
  136532. /**
  136533. * Class used to define virtual joystick (used in touch mode)
  136534. */
  136535. export class VirtualJoystick {
  136536. /**
  136537. * Gets or sets a boolean indicating that left and right values must be inverted
  136538. */
  136539. reverseLeftRight: boolean;
  136540. /**
  136541. * Gets or sets a boolean indicating that up and down values must be inverted
  136542. */
  136543. reverseUpDown: boolean;
  136544. /**
  136545. * Gets the offset value for the position (ie. the change of the position value)
  136546. */
  136547. deltaPosition: Vector3;
  136548. /**
  136549. * Gets a boolean indicating if the virtual joystick was pressed
  136550. */
  136551. pressed: boolean;
  136552. /**
  136553. * Canvas the virtual joystick will render onto, default z-index of this is 5
  136554. */
  136555. static Canvas: Nullable<HTMLCanvasElement>;
  136556. /**
  136557. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  136558. */
  136559. limitToContainer: boolean;
  136560. private static _globalJoystickIndex;
  136561. private static _alwaysVisibleSticks;
  136562. private static vjCanvasContext;
  136563. private static vjCanvasWidth;
  136564. private static vjCanvasHeight;
  136565. private static halfWidth;
  136566. private static _GetDefaultOptions;
  136567. private _action;
  136568. private _axisTargetedByLeftAndRight;
  136569. private _axisTargetedByUpAndDown;
  136570. private _joystickSensibility;
  136571. private _inversedSensibility;
  136572. private _joystickPointerID;
  136573. private _joystickColor;
  136574. private _joystickPointerPos;
  136575. private _joystickPreviousPointerPos;
  136576. private _joystickPointerStartPos;
  136577. private _deltaJoystickVector;
  136578. private _leftJoystick;
  136579. private _touches;
  136580. private _joystickPosition;
  136581. private _alwaysVisible;
  136582. private _puckImage;
  136583. private _containerImage;
  136584. private _joystickPuckSize;
  136585. private _joystickContainerSize;
  136586. private _clearPuckSize;
  136587. private _clearContainerSize;
  136588. private _clearPuckSizeOffset;
  136589. private _clearContainerSizeOffset;
  136590. private _onPointerDownHandlerRef;
  136591. private _onPointerMoveHandlerRef;
  136592. private _onPointerUpHandlerRef;
  136593. private _onResize;
  136594. /**
  136595. * Creates a new virtual joystick
  136596. * @param leftJoystick defines that the joystick is for left hand (false by default)
  136597. * @param customizations Defines the options we want to customize the VirtualJoystick
  136598. */
  136599. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  136600. /**
  136601. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  136602. * @param newJoystickSensibility defines the new sensibility
  136603. */
  136604. setJoystickSensibility(newJoystickSensibility: number): void;
  136605. private _onPointerDown;
  136606. private _onPointerMove;
  136607. private _onPointerUp;
  136608. /**
  136609. * Change the color of the virtual joystick
  136610. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  136611. */
  136612. setJoystickColor(newColor: string): void;
  136613. /**
  136614. * Size of the joystick's container
  136615. */
  136616. set containerSize(newSize: number);
  136617. get containerSize(): number;
  136618. /**
  136619. * Size of the joystick's puck
  136620. */
  136621. set puckSize(newSize: number);
  136622. get puckSize(): number;
  136623. /**
  136624. * Clears the set position of the joystick
  136625. */
  136626. clearPosition(): void;
  136627. /**
  136628. * Defines whether or not the joystick container is always visible
  136629. */
  136630. set alwaysVisible(value: boolean);
  136631. get alwaysVisible(): boolean;
  136632. /**
  136633. * Sets the constant position of the Joystick container
  136634. * @param x X axis coordinate
  136635. * @param y Y axis coordinate
  136636. */
  136637. setPosition(x: number, y: number): void;
  136638. /**
  136639. * Defines a callback to call when the joystick is touched
  136640. * @param action defines the callback
  136641. */
  136642. setActionOnTouch(action: () => any): void;
  136643. /**
  136644. * Defines which axis you'd like to control for left & right
  136645. * @param axis defines the axis to use
  136646. */
  136647. setAxisForLeftRight(axis: JoystickAxis): void;
  136648. /**
  136649. * Defines which axis you'd like to control for up & down
  136650. * @param axis defines the axis to use
  136651. */
  136652. setAxisForUpDown(axis: JoystickAxis): void;
  136653. /**
  136654. * Clears the canvas from the previous puck / container draw
  136655. */
  136656. private _clearPreviousDraw;
  136657. /**
  136658. * Loads `urlPath` to be used for the container's image
  136659. * @param urlPath defines the urlPath of an image to use
  136660. */
  136661. setContainerImage(urlPath: string): void;
  136662. /**
  136663. * Loads `urlPath` to be used for the puck's image
  136664. * @param urlPath defines the urlPath of an image to use
  136665. */
  136666. setPuckImage(urlPath: string): void;
  136667. /**
  136668. * Draws the Virtual Joystick's container
  136669. */
  136670. private _drawContainer;
  136671. /**
  136672. * Draws the Virtual Joystick's puck
  136673. */
  136674. private _drawPuck;
  136675. private _drawVirtualJoystick;
  136676. /**
  136677. * Release internal HTML canvas
  136678. */
  136679. releaseCanvas(): void;
  136680. }
  136681. }
  136682. declare module BABYLON {
  136683. interface FreeCameraInputsManager {
  136684. /**
  136685. * Add virtual joystick input support to the input manager.
  136686. * @returns the current input manager
  136687. */
  136688. addVirtualJoystick(): FreeCameraInputsManager;
  136689. }
  136690. /**
  136691. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  136692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136693. */
  136694. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  136695. /**
  136696. * Defines the camera the input is attached to.
  136697. */
  136698. camera: FreeCamera;
  136699. private _leftjoystick;
  136700. private _rightjoystick;
  136701. /**
  136702. * Gets the left stick of the virtual joystick.
  136703. * @returns The virtual Joystick
  136704. */
  136705. getLeftJoystick(): VirtualJoystick;
  136706. /**
  136707. * Gets the right stick of the virtual joystick.
  136708. * @returns The virtual Joystick
  136709. */
  136710. getRightJoystick(): VirtualJoystick;
  136711. /**
  136712. * Update the current camera state depending on the inputs that have been used this frame.
  136713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136714. */
  136715. checkInputs(): void;
  136716. /**
  136717. * Attach the input controls to a specific dom element to get the input from.
  136718. */
  136719. attachControl(): void;
  136720. /**
  136721. * Detach the current controls from the specified dom element.
  136722. */
  136723. detachControl(): void;
  136724. /**
  136725. * Gets the class name of the current intput.
  136726. * @returns the class name
  136727. */
  136728. getClassName(): string;
  136729. /**
  136730. * Get the friendly name associated with the input class.
  136731. * @returns the input friendly name
  136732. */
  136733. getSimpleName(): string;
  136734. }
  136735. }
  136736. declare module BABYLON {
  136737. /**
  136738. * This represents a FPS type of camera controlled by touch.
  136739. * This is like a universal camera minus the Gamepad controls.
  136740. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136741. */
  136742. export class TouchCamera extends FreeCamera {
  136743. /**
  136744. * Defines the touch sensibility for rotation.
  136745. * The higher the faster.
  136746. */
  136747. get touchAngularSensibility(): number;
  136748. set touchAngularSensibility(value: number);
  136749. /**
  136750. * Defines the touch sensibility for move.
  136751. * The higher the faster.
  136752. */
  136753. get touchMoveSensibility(): number;
  136754. set touchMoveSensibility(value: number);
  136755. /**
  136756. * Instantiates a new touch camera.
  136757. * This represents a FPS type of camera controlled by touch.
  136758. * This is like a universal camera minus the Gamepad controls.
  136759. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136760. * @param name Define the name of the camera in the scene
  136761. * @param position Define the start position of the camera in the scene
  136762. * @param scene Define the scene the camera belongs to
  136763. */
  136764. constructor(name: string, position: Vector3, scene: Scene);
  136765. /**
  136766. * Gets the current object class name.
  136767. * @return the class name
  136768. */
  136769. getClassName(): string;
  136770. /** @hidden */
  136771. _setupInputs(): void;
  136772. }
  136773. }
  136774. declare module BABYLON {
  136775. /**
  136776. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  136777. * being tilted forward or back and left or right.
  136778. */
  136779. export class DeviceOrientationCamera extends FreeCamera {
  136780. private _initialQuaternion;
  136781. private _quaternionCache;
  136782. private _tmpDragQuaternion;
  136783. private _disablePointerInputWhenUsingDeviceOrientation;
  136784. /**
  136785. * Creates a new device orientation camera
  136786. * @param name The name of the camera
  136787. * @param position The start position camera
  136788. * @param scene The scene the camera belongs to
  136789. */
  136790. constructor(name: string, position: Vector3, scene: Scene);
  136791. /**
  136792. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  136793. */
  136794. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  136795. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  136796. private _dragFactor;
  136797. /**
  136798. * Enabled turning on the y axis when the orientation sensor is active
  136799. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  136800. */
  136801. enableHorizontalDragging(dragFactor?: number): void;
  136802. /**
  136803. * Gets the current instance class name ("DeviceOrientationCamera").
  136804. * This helps avoiding instanceof at run time.
  136805. * @returns the class name
  136806. */
  136807. getClassName(): string;
  136808. /**
  136809. * @hidden
  136810. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  136811. */
  136812. _checkInputs(): void;
  136813. /**
  136814. * Reset the camera to its default orientation on the specified axis only.
  136815. * @param axis The axis to reset
  136816. */
  136817. resetToCurrentRotation(axis?: Axis): void;
  136818. }
  136819. }
  136820. declare module BABYLON {
  136821. /**
  136822. * Defines supported buttons for XBox360 compatible gamepads
  136823. */
  136824. export enum Xbox360Button {
  136825. /** A */
  136826. A = 0,
  136827. /** B */
  136828. B = 1,
  136829. /** X */
  136830. X = 2,
  136831. /** Y */
  136832. Y = 3,
  136833. /** Left button */
  136834. LB = 4,
  136835. /** Right button */
  136836. RB = 5,
  136837. /** Back */
  136838. Back = 8,
  136839. /** Start */
  136840. Start = 9,
  136841. /** Left stick */
  136842. LeftStick = 10,
  136843. /** Right stick */
  136844. RightStick = 11
  136845. }
  136846. /** Defines values for XBox360 DPad */
  136847. export enum Xbox360Dpad {
  136848. /** Up */
  136849. Up = 12,
  136850. /** Down */
  136851. Down = 13,
  136852. /** Left */
  136853. Left = 14,
  136854. /** Right */
  136855. Right = 15
  136856. }
  136857. /**
  136858. * Defines a XBox360 gamepad
  136859. */
  136860. export class Xbox360Pad extends Gamepad {
  136861. private _leftTrigger;
  136862. private _rightTrigger;
  136863. private _onlefttriggerchanged;
  136864. private _onrighttriggerchanged;
  136865. private _onbuttondown;
  136866. private _onbuttonup;
  136867. private _ondpaddown;
  136868. private _ondpadup;
  136869. /** Observable raised when a button is pressed */
  136870. onButtonDownObservable: Observable<Xbox360Button>;
  136871. /** Observable raised when a button is released */
  136872. onButtonUpObservable: Observable<Xbox360Button>;
  136873. /** Observable raised when a pad is pressed */
  136874. onPadDownObservable: Observable<Xbox360Dpad>;
  136875. /** Observable raised when a pad is released */
  136876. onPadUpObservable: Observable<Xbox360Dpad>;
  136877. private _buttonA;
  136878. private _buttonB;
  136879. private _buttonX;
  136880. private _buttonY;
  136881. private _buttonBack;
  136882. private _buttonStart;
  136883. private _buttonLB;
  136884. private _buttonRB;
  136885. private _buttonLeftStick;
  136886. private _buttonRightStick;
  136887. private _dPadUp;
  136888. private _dPadDown;
  136889. private _dPadLeft;
  136890. private _dPadRight;
  136891. private _isXboxOnePad;
  136892. /**
  136893. * Creates a new XBox360 gamepad object
  136894. * @param id defines the id of this gamepad
  136895. * @param index defines its index
  136896. * @param gamepad defines the internal HTML gamepad object
  136897. * @param xboxOne defines if it is a XBox One gamepad
  136898. */
  136899. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  136900. /**
  136901. * Defines the callback to call when left trigger is pressed
  136902. * @param callback defines the callback to use
  136903. */
  136904. onlefttriggerchanged(callback: (value: number) => void): void;
  136905. /**
  136906. * Defines the callback to call when right trigger is pressed
  136907. * @param callback defines the callback to use
  136908. */
  136909. onrighttriggerchanged(callback: (value: number) => void): void;
  136910. /**
  136911. * Gets the left trigger value
  136912. */
  136913. get leftTrigger(): number;
  136914. /**
  136915. * Sets the left trigger value
  136916. */
  136917. set leftTrigger(newValue: number);
  136918. /**
  136919. * Gets the right trigger value
  136920. */
  136921. get rightTrigger(): number;
  136922. /**
  136923. * Sets the right trigger value
  136924. */
  136925. set rightTrigger(newValue: number);
  136926. /**
  136927. * Defines the callback to call when a button is pressed
  136928. * @param callback defines the callback to use
  136929. */
  136930. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  136931. /**
  136932. * Defines the callback to call when a button is released
  136933. * @param callback defines the callback to use
  136934. */
  136935. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  136936. /**
  136937. * Defines the callback to call when a pad is pressed
  136938. * @param callback defines the callback to use
  136939. */
  136940. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  136941. /**
  136942. * Defines the callback to call when a pad is released
  136943. * @param callback defines the callback to use
  136944. */
  136945. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  136946. private _setButtonValue;
  136947. private _setDPadValue;
  136948. /**
  136949. * Gets the value of the `A` button
  136950. */
  136951. get buttonA(): number;
  136952. /**
  136953. * Sets the value of the `A` button
  136954. */
  136955. set buttonA(value: number);
  136956. /**
  136957. * Gets the value of the `B` button
  136958. */
  136959. get buttonB(): number;
  136960. /**
  136961. * Sets the value of the `B` button
  136962. */
  136963. set buttonB(value: number);
  136964. /**
  136965. * Gets the value of the `X` button
  136966. */
  136967. get buttonX(): number;
  136968. /**
  136969. * Sets the value of the `X` button
  136970. */
  136971. set buttonX(value: number);
  136972. /**
  136973. * Gets the value of the `Y` button
  136974. */
  136975. get buttonY(): number;
  136976. /**
  136977. * Sets the value of the `Y` button
  136978. */
  136979. set buttonY(value: number);
  136980. /**
  136981. * Gets the value of the `Start` button
  136982. */
  136983. get buttonStart(): number;
  136984. /**
  136985. * Sets the value of the `Start` button
  136986. */
  136987. set buttonStart(value: number);
  136988. /**
  136989. * Gets the value of the `Back` button
  136990. */
  136991. get buttonBack(): number;
  136992. /**
  136993. * Sets the value of the `Back` button
  136994. */
  136995. set buttonBack(value: number);
  136996. /**
  136997. * Gets the value of the `Left` button
  136998. */
  136999. get buttonLB(): number;
  137000. /**
  137001. * Sets the value of the `Left` button
  137002. */
  137003. set buttonLB(value: number);
  137004. /**
  137005. * Gets the value of the `Right` button
  137006. */
  137007. get buttonRB(): number;
  137008. /**
  137009. * Sets the value of the `Right` button
  137010. */
  137011. set buttonRB(value: number);
  137012. /**
  137013. * Gets the value of the Left joystick
  137014. */
  137015. get buttonLeftStick(): number;
  137016. /**
  137017. * Sets the value of the Left joystick
  137018. */
  137019. set buttonLeftStick(value: number);
  137020. /**
  137021. * Gets the value of the Right joystick
  137022. */
  137023. get buttonRightStick(): number;
  137024. /**
  137025. * Sets the value of the Right joystick
  137026. */
  137027. set buttonRightStick(value: number);
  137028. /**
  137029. * Gets the value of D-pad up
  137030. */
  137031. get dPadUp(): number;
  137032. /**
  137033. * Sets the value of D-pad up
  137034. */
  137035. set dPadUp(value: number);
  137036. /**
  137037. * Gets the value of D-pad down
  137038. */
  137039. get dPadDown(): number;
  137040. /**
  137041. * Sets the value of D-pad down
  137042. */
  137043. set dPadDown(value: number);
  137044. /**
  137045. * Gets the value of D-pad left
  137046. */
  137047. get dPadLeft(): number;
  137048. /**
  137049. * Sets the value of D-pad left
  137050. */
  137051. set dPadLeft(value: number);
  137052. /**
  137053. * Gets the value of D-pad right
  137054. */
  137055. get dPadRight(): number;
  137056. /**
  137057. * Sets the value of D-pad right
  137058. */
  137059. set dPadRight(value: number);
  137060. /**
  137061. * Force the gamepad to synchronize with device values
  137062. */
  137063. update(): void;
  137064. /**
  137065. * Disposes the gamepad
  137066. */
  137067. dispose(): void;
  137068. }
  137069. }
  137070. declare module BABYLON {
  137071. /**
  137072. * Defines supported buttons for DualShock compatible gamepads
  137073. */
  137074. export enum DualShockButton {
  137075. /** Cross */
  137076. Cross = 0,
  137077. /** Circle */
  137078. Circle = 1,
  137079. /** Square */
  137080. Square = 2,
  137081. /** Triangle */
  137082. Triangle = 3,
  137083. /** L1 */
  137084. L1 = 4,
  137085. /** R1 */
  137086. R1 = 5,
  137087. /** Share */
  137088. Share = 8,
  137089. /** Options */
  137090. Options = 9,
  137091. /** Left stick */
  137092. LeftStick = 10,
  137093. /** Right stick */
  137094. RightStick = 11
  137095. }
  137096. /** Defines values for DualShock DPad */
  137097. export enum DualShockDpad {
  137098. /** Up */
  137099. Up = 12,
  137100. /** Down */
  137101. Down = 13,
  137102. /** Left */
  137103. Left = 14,
  137104. /** Right */
  137105. Right = 15
  137106. }
  137107. /**
  137108. * Defines a DualShock gamepad
  137109. */
  137110. export class DualShockPad extends Gamepad {
  137111. private _leftTrigger;
  137112. private _rightTrigger;
  137113. private _onlefttriggerchanged;
  137114. private _onrighttriggerchanged;
  137115. private _onbuttondown;
  137116. private _onbuttonup;
  137117. private _ondpaddown;
  137118. private _ondpadup;
  137119. /** Observable raised when a button is pressed */
  137120. onButtonDownObservable: Observable<DualShockButton>;
  137121. /** Observable raised when a button is released */
  137122. onButtonUpObservable: Observable<DualShockButton>;
  137123. /** Observable raised when a pad is pressed */
  137124. onPadDownObservable: Observable<DualShockDpad>;
  137125. /** Observable raised when a pad is released */
  137126. onPadUpObservable: Observable<DualShockDpad>;
  137127. private _buttonCross;
  137128. private _buttonCircle;
  137129. private _buttonSquare;
  137130. private _buttonTriangle;
  137131. private _buttonShare;
  137132. private _buttonOptions;
  137133. private _buttonL1;
  137134. private _buttonR1;
  137135. private _buttonLeftStick;
  137136. private _buttonRightStick;
  137137. private _dPadUp;
  137138. private _dPadDown;
  137139. private _dPadLeft;
  137140. private _dPadRight;
  137141. /**
  137142. * Creates a new DualShock gamepad object
  137143. * @param id defines the id of this gamepad
  137144. * @param index defines its index
  137145. * @param gamepad defines the internal HTML gamepad object
  137146. */
  137147. constructor(id: string, index: number, gamepad: any);
  137148. /**
  137149. * Defines the callback to call when left trigger is pressed
  137150. * @param callback defines the callback to use
  137151. */
  137152. onlefttriggerchanged(callback: (value: number) => void): void;
  137153. /**
  137154. * Defines the callback to call when right trigger is pressed
  137155. * @param callback defines the callback to use
  137156. */
  137157. onrighttriggerchanged(callback: (value: number) => void): void;
  137158. /**
  137159. * Gets the left trigger value
  137160. */
  137161. get leftTrigger(): number;
  137162. /**
  137163. * Sets the left trigger value
  137164. */
  137165. set leftTrigger(newValue: number);
  137166. /**
  137167. * Gets the right trigger value
  137168. */
  137169. get rightTrigger(): number;
  137170. /**
  137171. * Sets the right trigger value
  137172. */
  137173. set rightTrigger(newValue: number);
  137174. /**
  137175. * Defines the callback to call when a button is pressed
  137176. * @param callback defines the callback to use
  137177. */
  137178. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  137179. /**
  137180. * Defines the callback to call when a button is released
  137181. * @param callback defines the callback to use
  137182. */
  137183. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  137184. /**
  137185. * Defines the callback to call when a pad is pressed
  137186. * @param callback defines the callback to use
  137187. */
  137188. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  137189. /**
  137190. * Defines the callback to call when a pad is released
  137191. * @param callback defines the callback to use
  137192. */
  137193. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  137194. private _setButtonValue;
  137195. private _setDPadValue;
  137196. /**
  137197. * Gets the value of the `Cross` button
  137198. */
  137199. get buttonCross(): number;
  137200. /**
  137201. * Sets the value of the `Cross` button
  137202. */
  137203. set buttonCross(value: number);
  137204. /**
  137205. * Gets the value of the `Circle` button
  137206. */
  137207. get buttonCircle(): number;
  137208. /**
  137209. * Sets the value of the `Circle` button
  137210. */
  137211. set buttonCircle(value: number);
  137212. /**
  137213. * Gets the value of the `Square` button
  137214. */
  137215. get buttonSquare(): number;
  137216. /**
  137217. * Sets the value of the `Square` button
  137218. */
  137219. set buttonSquare(value: number);
  137220. /**
  137221. * Gets the value of the `Triangle` button
  137222. */
  137223. get buttonTriangle(): number;
  137224. /**
  137225. * Sets the value of the `Triangle` button
  137226. */
  137227. set buttonTriangle(value: number);
  137228. /**
  137229. * Gets the value of the `Options` button
  137230. */
  137231. get buttonOptions(): number;
  137232. /**
  137233. * Sets the value of the `Options` button
  137234. */
  137235. set buttonOptions(value: number);
  137236. /**
  137237. * Gets the value of the `Share` button
  137238. */
  137239. get buttonShare(): number;
  137240. /**
  137241. * Sets the value of the `Share` button
  137242. */
  137243. set buttonShare(value: number);
  137244. /**
  137245. * Gets the value of the `L1` button
  137246. */
  137247. get buttonL1(): number;
  137248. /**
  137249. * Sets the value of the `L1` button
  137250. */
  137251. set buttonL1(value: number);
  137252. /**
  137253. * Gets the value of the `R1` button
  137254. */
  137255. get buttonR1(): number;
  137256. /**
  137257. * Sets the value of the `R1` button
  137258. */
  137259. set buttonR1(value: number);
  137260. /**
  137261. * Gets the value of the Left joystick
  137262. */
  137263. get buttonLeftStick(): number;
  137264. /**
  137265. * Sets the value of the Left joystick
  137266. */
  137267. set buttonLeftStick(value: number);
  137268. /**
  137269. * Gets the value of the Right joystick
  137270. */
  137271. get buttonRightStick(): number;
  137272. /**
  137273. * Sets the value of the Right joystick
  137274. */
  137275. set buttonRightStick(value: number);
  137276. /**
  137277. * Gets the value of D-pad up
  137278. */
  137279. get dPadUp(): number;
  137280. /**
  137281. * Sets the value of D-pad up
  137282. */
  137283. set dPadUp(value: number);
  137284. /**
  137285. * Gets the value of D-pad down
  137286. */
  137287. get dPadDown(): number;
  137288. /**
  137289. * Sets the value of D-pad down
  137290. */
  137291. set dPadDown(value: number);
  137292. /**
  137293. * Gets the value of D-pad left
  137294. */
  137295. get dPadLeft(): number;
  137296. /**
  137297. * Sets the value of D-pad left
  137298. */
  137299. set dPadLeft(value: number);
  137300. /**
  137301. * Gets the value of D-pad right
  137302. */
  137303. get dPadRight(): number;
  137304. /**
  137305. * Sets the value of D-pad right
  137306. */
  137307. set dPadRight(value: number);
  137308. /**
  137309. * Force the gamepad to synchronize with device values
  137310. */
  137311. update(): void;
  137312. /**
  137313. * Disposes the gamepad
  137314. */
  137315. dispose(): void;
  137316. }
  137317. }
  137318. declare module BABYLON {
  137319. /**
  137320. * Manager for handling gamepads
  137321. */
  137322. export class GamepadManager {
  137323. private _scene?;
  137324. private _babylonGamepads;
  137325. private _oneGamepadConnected;
  137326. /** @hidden */
  137327. _isMonitoring: boolean;
  137328. private _gamepadEventSupported;
  137329. private _gamepadSupport?;
  137330. /**
  137331. * observable to be triggered when the gamepad controller has been connected
  137332. */
  137333. onGamepadConnectedObservable: Observable<Gamepad>;
  137334. /**
  137335. * observable to be triggered when the gamepad controller has been disconnected
  137336. */
  137337. onGamepadDisconnectedObservable: Observable<Gamepad>;
  137338. private _onGamepadConnectedEvent;
  137339. private _onGamepadDisconnectedEvent;
  137340. /**
  137341. * Initializes the gamepad manager
  137342. * @param _scene BabylonJS scene
  137343. */
  137344. constructor(_scene?: Scene | undefined);
  137345. /**
  137346. * The gamepads in the game pad manager
  137347. */
  137348. get gamepads(): Gamepad[];
  137349. /**
  137350. * Get the gamepad controllers based on type
  137351. * @param type The type of gamepad controller
  137352. * @returns Nullable gamepad
  137353. */
  137354. getGamepadByType(type?: number): Nullable<Gamepad>;
  137355. /**
  137356. * Disposes the gamepad manager
  137357. */
  137358. dispose(): void;
  137359. private _addNewGamepad;
  137360. private _startMonitoringGamepads;
  137361. private _stopMonitoringGamepads;
  137362. /** @hidden */
  137363. _checkGamepadsStatus(): void;
  137364. private _updateGamepadObjects;
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. interface Scene {
  137369. /** @hidden */
  137370. _gamepadManager: Nullable<GamepadManager>;
  137371. /**
  137372. * Gets the gamepad manager associated with the scene
  137373. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  137374. */
  137375. gamepadManager: GamepadManager;
  137376. }
  137377. /**
  137378. * Interface representing a free camera inputs manager
  137379. */
  137380. interface FreeCameraInputsManager {
  137381. /**
  137382. * Adds gamepad input support to the FreeCameraInputsManager.
  137383. * @returns the FreeCameraInputsManager
  137384. */
  137385. addGamepad(): FreeCameraInputsManager;
  137386. }
  137387. /**
  137388. * Interface representing an arc rotate camera inputs manager
  137389. */
  137390. interface ArcRotateCameraInputsManager {
  137391. /**
  137392. * Adds gamepad input support to the ArcRotateCamera InputManager.
  137393. * @returns the camera inputs manager
  137394. */
  137395. addGamepad(): ArcRotateCameraInputsManager;
  137396. }
  137397. /**
  137398. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  137399. */
  137400. export class GamepadSystemSceneComponent implements ISceneComponent {
  137401. /**
  137402. * The component name helpfull to identify the component in the list of scene components.
  137403. */
  137404. readonly name: string;
  137405. /**
  137406. * The scene the component belongs to.
  137407. */
  137408. scene: Scene;
  137409. /**
  137410. * Creates a new instance of the component for the given scene
  137411. * @param scene Defines the scene to register the component in
  137412. */
  137413. constructor(scene: Scene);
  137414. /**
  137415. * Registers the component in a given scene
  137416. */
  137417. register(): void;
  137418. /**
  137419. * Rebuilds the elements related to this component in case of
  137420. * context lost for instance.
  137421. */
  137422. rebuild(): void;
  137423. /**
  137424. * Disposes the component and the associated ressources
  137425. */
  137426. dispose(): void;
  137427. private _beforeCameraUpdate;
  137428. }
  137429. }
  137430. declare module BABYLON {
  137431. /**
  137432. * 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,
  137433. * which still works and will still be found in many Playgrounds.
  137434. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137435. */
  137436. export class UniversalCamera extends TouchCamera {
  137437. /**
  137438. * Defines the gamepad rotation sensiblity.
  137439. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  137440. */
  137441. get gamepadAngularSensibility(): number;
  137442. set gamepadAngularSensibility(value: number);
  137443. /**
  137444. * Defines the gamepad move sensiblity.
  137445. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  137446. */
  137447. get gamepadMoveSensibility(): number;
  137448. set gamepadMoveSensibility(value: number);
  137449. /**
  137450. * 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,
  137451. * which still works and will still be found in many Playgrounds.
  137452. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137453. * @param name Define the name of the camera in the scene
  137454. * @param position Define the start position of the camera in the scene
  137455. * @param scene Define the scene the camera belongs to
  137456. */
  137457. constructor(name: string, position: Vector3, scene: Scene);
  137458. /**
  137459. * Gets the current object class name.
  137460. * @return the class name
  137461. */
  137462. getClassName(): string;
  137463. }
  137464. }
  137465. declare module BABYLON {
  137466. /**
  137467. * This represents a FPS type of camera. This is only here for back compat purpose.
  137468. * Please use the UniversalCamera instead as both are identical.
  137469. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137470. */
  137471. export class GamepadCamera extends UniversalCamera {
  137472. /**
  137473. * Instantiates a new Gamepad Camera
  137474. * This represents a FPS type of camera. This is only here for back compat purpose.
  137475. * Please use the UniversalCamera instead as both are identical.
  137476. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137477. * @param name Define the name of the camera in the scene
  137478. * @param position Define the start position of the camera in the scene
  137479. * @param scene Define the scene the camera belongs to
  137480. */
  137481. constructor(name: string, position: Vector3, scene: Scene);
  137482. /**
  137483. * Gets the current object class name.
  137484. * @return the class name
  137485. */
  137486. getClassName(): string;
  137487. }
  137488. }
  137489. declare module BABYLON {
  137490. /** @hidden */
  137491. export var anaglyphPixelShader: {
  137492. name: string;
  137493. shader: string;
  137494. };
  137495. }
  137496. declare module BABYLON {
  137497. /**
  137498. * Postprocess used to generate anaglyphic rendering
  137499. */
  137500. export class AnaglyphPostProcess extends PostProcess {
  137501. private _passedProcess;
  137502. /**
  137503. * Gets a string identifying the name of the class
  137504. * @returns "AnaglyphPostProcess" string
  137505. */
  137506. getClassName(): string;
  137507. /**
  137508. * Creates a new AnaglyphPostProcess
  137509. * @param name defines postprocess name
  137510. * @param options defines creation options or target ratio scale
  137511. * @param rigCameras defines cameras using this postprocess
  137512. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  137513. * @param engine defines hosting engine
  137514. * @param reusable defines if the postprocess will be reused multiple times per frame
  137515. */
  137516. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  137517. }
  137518. }
  137519. declare module BABYLON {
  137520. /**
  137521. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  137522. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137523. */
  137524. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  137525. /**
  137526. * Creates a new AnaglyphArcRotateCamera
  137527. * @param name defines camera name
  137528. * @param alpha defines alpha angle (in radians)
  137529. * @param beta defines beta angle (in radians)
  137530. * @param radius defines radius
  137531. * @param target defines camera target
  137532. * @param interaxialDistance defines distance between each color axis
  137533. * @param scene defines the hosting scene
  137534. */
  137535. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  137536. /**
  137537. * Gets camera class name
  137538. * @returns AnaglyphArcRotateCamera
  137539. */
  137540. getClassName(): string;
  137541. }
  137542. }
  137543. declare module BABYLON {
  137544. /**
  137545. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  137546. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137547. */
  137548. export class AnaglyphFreeCamera extends FreeCamera {
  137549. /**
  137550. * Creates a new AnaglyphFreeCamera
  137551. * @param name defines camera name
  137552. * @param position defines initial position
  137553. * @param interaxialDistance defines distance between each color axis
  137554. * @param scene defines the hosting scene
  137555. */
  137556. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137557. /**
  137558. * Gets camera class name
  137559. * @returns AnaglyphFreeCamera
  137560. */
  137561. getClassName(): string;
  137562. }
  137563. }
  137564. declare module BABYLON {
  137565. /**
  137566. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  137567. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137568. */
  137569. export class AnaglyphGamepadCamera extends GamepadCamera {
  137570. /**
  137571. * Creates a new AnaglyphGamepadCamera
  137572. * @param name defines camera name
  137573. * @param position defines initial position
  137574. * @param interaxialDistance defines distance between each color axis
  137575. * @param scene defines the hosting scene
  137576. */
  137577. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137578. /**
  137579. * Gets camera class name
  137580. * @returns AnaglyphGamepadCamera
  137581. */
  137582. getClassName(): string;
  137583. }
  137584. }
  137585. declare module BABYLON {
  137586. /**
  137587. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  137588. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137589. */
  137590. export class AnaglyphUniversalCamera extends UniversalCamera {
  137591. /**
  137592. * Creates a new AnaglyphUniversalCamera
  137593. * @param name defines camera name
  137594. * @param position defines initial position
  137595. * @param interaxialDistance defines distance between each color axis
  137596. * @param scene defines the hosting scene
  137597. */
  137598. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137599. /**
  137600. * Gets camera class name
  137601. * @returns AnaglyphUniversalCamera
  137602. */
  137603. getClassName(): string;
  137604. }
  137605. }
  137606. declare module BABYLON {
  137607. /** @hidden */
  137608. export var stereoscopicInterlacePixelShader: {
  137609. name: string;
  137610. shader: string;
  137611. };
  137612. }
  137613. declare module BABYLON {
  137614. /**
  137615. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  137616. */
  137617. export class StereoscopicInterlacePostProcessI extends PostProcess {
  137618. private _stepSize;
  137619. private _passedProcess;
  137620. /**
  137621. * Gets a string identifying the name of the class
  137622. * @returns "StereoscopicInterlacePostProcessI" string
  137623. */
  137624. getClassName(): string;
  137625. /**
  137626. * Initializes a StereoscopicInterlacePostProcessI
  137627. * @param name The name of the effect.
  137628. * @param rigCameras The rig cameras to be appled to the post process
  137629. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  137630. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  137631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137632. * @param engine The engine which the post process will be applied. (default: current engine)
  137633. * @param reusable If the post process can be reused on the same frame. (default: false)
  137634. */
  137635. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137636. }
  137637. /**
  137638. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  137639. */
  137640. export class StereoscopicInterlacePostProcess extends PostProcess {
  137641. private _stepSize;
  137642. private _passedProcess;
  137643. /**
  137644. * Gets a string identifying the name of the class
  137645. * @returns "StereoscopicInterlacePostProcess" string
  137646. */
  137647. getClassName(): string;
  137648. /**
  137649. * Initializes a StereoscopicInterlacePostProcess
  137650. * @param name The name of the effect.
  137651. * @param rigCameras The rig cameras to be appled to the post process
  137652. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  137653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137654. * @param engine The engine which the post process will be applied. (default: current engine)
  137655. * @param reusable If the post process can be reused on the same frame. (default: false)
  137656. */
  137657. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137658. }
  137659. }
  137660. declare module BABYLON {
  137661. /**
  137662. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  137663. * @see https://doc.babylonjs.com/features/cameras
  137664. */
  137665. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  137666. /**
  137667. * Creates a new StereoscopicArcRotateCamera
  137668. * @param name defines camera name
  137669. * @param alpha defines alpha angle (in radians)
  137670. * @param beta defines beta angle (in radians)
  137671. * @param radius defines radius
  137672. * @param target defines camera target
  137673. * @param interaxialDistance defines distance between each color axis
  137674. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137675. * @param scene defines the hosting scene
  137676. */
  137677. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137678. /**
  137679. * Gets camera class name
  137680. * @returns StereoscopicArcRotateCamera
  137681. */
  137682. getClassName(): string;
  137683. }
  137684. }
  137685. declare module BABYLON {
  137686. /**
  137687. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  137688. * @see https://doc.babylonjs.com/features/cameras
  137689. */
  137690. export class StereoscopicFreeCamera extends FreeCamera {
  137691. /**
  137692. * Creates a new StereoscopicFreeCamera
  137693. * @param name defines camera name
  137694. * @param position defines initial position
  137695. * @param interaxialDistance defines distance between each color axis
  137696. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137697. * @param scene defines the hosting scene
  137698. */
  137699. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137700. /**
  137701. * Gets camera class name
  137702. * @returns StereoscopicFreeCamera
  137703. */
  137704. getClassName(): string;
  137705. }
  137706. }
  137707. declare module BABYLON {
  137708. /**
  137709. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  137710. * @see https://doc.babylonjs.com/features/cameras
  137711. */
  137712. export class StereoscopicGamepadCamera extends GamepadCamera {
  137713. /**
  137714. * Creates a new StereoscopicGamepadCamera
  137715. * @param name defines camera name
  137716. * @param position defines initial position
  137717. * @param interaxialDistance defines distance between each color axis
  137718. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137719. * @param scene defines the hosting scene
  137720. */
  137721. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137722. /**
  137723. * Gets camera class name
  137724. * @returns StereoscopicGamepadCamera
  137725. */
  137726. getClassName(): string;
  137727. }
  137728. }
  137729. declare module BABYLON {
  137730. /**
  137731. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  137732. * @see https://doc.babylonjs.com/features/cameras
  137733. */
  137734. export class StereoscopicUniversalCamera extends UniversalCamera {
  137735. /**
  137736. * Creates a new StereoscopicUniversalCamera
  137737. * @param name defines camera name
  137738. * @param position defines initial position
  137739. * @param interaxialDistance defines distance between each color axis
  137740. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137741. * @param scene defines the hosting scene
  137742. */
  137743. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137744. /**
  137745. * Gets camera class name
  137746. * @returns StereoscopicUniversalCamera
  137747. */
  137748. getClassName(): string;
  137749. }
  137750. }
  137751. declare module BABYLON {
  137752. /**
  137753. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  137754. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137755. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137756. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137757. */
  137758. export class VirtualJoysticksCamera extends FreeCamera {
  137759. /**
  137760. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  137761. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137762. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137763. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137764. * @param name Define the name of the camera in the scene
  137765. * @param position Define the start position of the camera in the scene
  137766. * @param scene Define the scene the camera belongs to
  137767. */
  137768. constructor(name: string, position: Vector3, scene: Scene);
  137769. /**
  137770. * Gets the current object class name.
  137771. * @return the class name
  137772. */
  137773. getClassName(): string;
  137774. }
  137775. }
  137776. declare module BABYLON {
  137777. /**
  137778. * This represents all the required metrics to create a VR camera.
  137779. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  137780. */
  137781. export class VRCameraMetrics {
  137782. /**
  137783. * Define the horizontal resolution off the screen.
  137784. */
  137785. hResolution: number;
  137786. /**
  137787. * Define the vertical resolution off the screen.
  137788. */
  137789. vResolution: number;
  137790. /**
  137791. * Define the horizontal screen size.
  137792. */
  137793. hScreenSize: number;
  137794. /**
  137795. * Define the vertical screen size.
  137796. */
  137797. vScreenSize: number;
  137798. /**
  137799. * Define the vertical screen center position.
  137800. */
  137801. vScreenCenter: number;
  137802. /**
  137803. * Define the distance of the eyes to the screen.
  137804. */
  137805. eyeToScreenDistance: number;
  137806. /**
  137807. * Define the distance between both lenses
  137808. */
  137809. lensSeparationDistance: number;
  137810. /**
  137811. * Define the distance between both viewer's eyes.
  137812. */
  137813. interpupillaryDistance: number;
  137814. /**
  137815. * Define the distortion factor of the VR postprocess.
  137816. * Please, touch with care.
  137817. */
  137818. distortionK: number[];
  137819. /**
  137820. * Define the chromatic aberration correction factors for the VR post process.
  137821. */
  137822. chromaAbCorrection: number[];
  137823. /**
  137824. * Define the scale factor of the post process.
  137825. * The smaller the better but the slower.
  137826. */
  137827. postProcessScaleFactor: number;
  137828. /**
  137829. * Define an offset for the lens center.
  137830. */
  137831. lensCenterOffset: number;
  137832. /**
  137833. * Define if the current vr camera should compensate the distortion of the lense or not.
  137834. */
  137835. compensateDistortion: boolean;
  137836. /**
  137837. * Defines if multiview should be enabled when rendering (Default: false)
  137838. */
  137839. multiviewEnabled: boolean;
  137840. /**
  137841. * Gets the rendering aspect ratio based on the provided resolutions.
  137842. */
  137843. get aspectRatio(): number;
  137844. /**
  137845. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  137846. */
  137847. get aspectRatioFov(): number;
  137848. /**
  137849. * @hidden
  137850. */
  137851. get leftHMatrix(): Matrix;
  137852. /**
  137853. * @hidden
  137854. */
  137855. get rightHMatrix(): Matrix;
  137856. /**
  137857. * @hidden
  137858. */
  137859. get leftPreViewMatrix(): Matrix;
  137860. /**
  137861. * @hidden
  137862. */
  137863. get rightPreViewMatrix(): Matrix;
  137864. /**
  137865. * Get the default VRMetrics based on the most generic setup.
  137866. * @returns the default vr metrics
  137867. */
  137868. static GetDefault(): VRCameraMetrics;
  137869. }
  137870. }
  137871. declare module BABYLON {
  137872. /** @hidden */
  137873. export var vrDistortionCorrectionPixelShader: {
  137874. name: string;
  137875. shader: string;
  137876. };
  137877. }
  137878. declare module BABYLON {
  137879. /**
  137880. * VRDistortionCorrectionPostProcess used for mobile VR
  137881. */
  137882. export class VRDistortionCorrectionPostProcess extends PostProcess {
  137883. private _isRightEye;
  137884. private _distortionFactors;
  137885. private _postProcessScaleFactor;
  137886. private _lensCenterOffset;
  137887. private _scaleIn;
  137888. private _scaleFactor;
  137889. private _lensCenter;
  137890. /**
  137891. * Gets a string identifying the name of the class
  137892. * @returns "VRDistortionCorrectionPostProcess" string
  137893. */
  137894. getClassName(): string;
  137895. /**
  137896. * Initializes the VRDistortionCorrectionPostProcess
  137897. * @param name The name of the effect.
  137898. * @param camera The camera to apply the render pass to.
  137899. * @param isRightEye If this is for the right eye distortion
  137900. * @param vrMetrics All the required metrics for the VR camera
  137901. */
  137902. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  137903. }
  137904. }
  137905. declare module BABYLON {
  137906. /**
  137907. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  137908. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137909. */
  137910. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  137911. /**
  137912. * Creates a new VRDeviceOrientationArcRotateCamera
  137913. * @param name defines camera name
  137914. * @param alpha defines the camera rotation along the logitudinal axis
  137915. * @param beta defines the camera rotation along the latitudinal axis
  137916. * @param radius defines the camera distance from its target
  137917. * @param target defines the camera target
  137918. * @param scene defines the scene the camera belongs to
  137919. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137920. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137921. */
  137922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137923. /**
  137924. * Gets camera class name
  137925. * @returns VRDeviceOrientationArcRotateCamera
  137926. */
  137927. getClassName(): string;
  137928. }
  137929. }
  137930. declare module BABYLON {
  137931. /**
  137932. * Camera used to simulate VR rendering (based on FreeCamera)
  137933. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137934. */
  137935. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  137936. /**
  137937. * Creates a new VRDeviceOrientationFreeCamera
  137938. * @param name defines camera name
  137939. * @param position defines the start position of the camera
  137940. * @param scene defines the scene the camera belongs to
  137941. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137942. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137943. */
  137944. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137945. /**
  137946. * Gets camera class name
  137947. * @returns VRDeviceOrientationFreeCamera
  137948. */
  137949. getClassName(): string;
  137950. }
  137951. }
  137952. declare module BABYLON {
  137953. /**
  137954. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  137955. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137956. */
  137957. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  137958. /**
  137959. * Creates a new VRDeviceOrientationGamepadCamera
  137960. * @param name defines camera name
  137961. * @param position defines the start position of the camera
  137962. * @param scene defines the scene the camera belongs to
  137963. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137964. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137965. */
  137966. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137967. /**
  137968. * Gets camera class name
  137969. * @returns VRDeviceOrientationGamepadCamera
  137970. */
  137971. getClassName(): string;
  137972. }
  137973. }
  137974. declare module BABYLON {
  137975. /**
  137976. * A class extending Texture allowing drawing on a texture
  137977. * @see https://doc.babylonjs.com/how_to/dynamictexture
  137978. */
  137979. export class DynamicTexture extends Texture {
  137980. private _generateMipMaps;
  137981. private _canvas;
  137982. private _context;
  137983. /**
  137984. * Creates a DynamicTexture
  137985. * @param name defines the name of the texture
  137986. * @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
  137987. * @param scene defines the scene where you want the texture
  137988. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  137989. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137990. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  137991. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  137992. */
  137993. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  137994. /**
  137995. * Get the current class name of the texture useful for serialization or dynamic coding.
  137996. * @returns "DynamicTexture"
  137997. */
  137998. getClassName(): string;
  137999. /**
  138000. * Gets the current state of canRescale
  138001. */
  138002. get canRescale(): boolean;
  138003. private _recreate;
  138004. /**
  138005. * Scales the texture
  138006. * @param ratio the scale factor to apply to both width and height
  138007. */
  138008. scale(ratio: number): void;
  138009. /**
  138010. * Resizes the texture
  138011. * @param width the new width
  138012. * @param height the new height
  138013. */
  138014. scaleTo(width: number, height: number): void;
  138015. /**
  138016. * Gets the context of the canvas used by the texture
  138017. * @returns the canvas context of the dynamic texture
  138018. */
  138019. getContext(): CanvasRenderingContext2D;
  138020. /**
  138021. * Clears the texture
  138022. */
  138023. clear(): void;
  138024. /**
  138025. * Updates the texture
  138026. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  138027. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  138028. */
  138029. update(invertY?: boolean, premulAlpha?: boolean): void;
  138030. /**
  138031. * Draws text onto the texture
  138032. * @param text defines the text to be drawn
  138033. * @param x defines the placement of the text from the left
  138034. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  138035. * @param font defines the font to be used with font-style, font-size, font-name
  138036. * @param color defines the color used for the text
  138037. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  138038. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  138039. * @param update defines whether texture is immediately update (default is true)
  138040. */
  138041. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  138042. /**
  138043. * Clones the texture
  138044. * @returns the clone of the texture.
  138045. */
  138046. clone(): DynamicTexture;
  138047. /**
  138048. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  138049. * @returns a serialized dynamic texture object
  138050. */
  138051. serialize(): any;
  138052. private _IsCanvasElement;
  138053. /** @hidden */
  138054. _rebuild(): void;
  138055. }
  138056. }
  138057. declare module BABYLON {
  138058. /**
  138059. * Class containing static functions to help procedurally build meshes
  138060. */
  138061. export class GroundBuilder {
  138062. /**
  138063. * Creates a ground mesh
  138064. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  138065. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  138066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138067. * @param name defines the name of the mesh
  138068. * @param options defines the options used to create the mesh
  138069. * @param scene defines the hosting scene
  138070. * @returns the ground mesh
  138071. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  138072. */
  138073. static CreateGround(name: string, options: {
  138074. width?: number;
  138075. height?: number;
  138076. subdivisions?: number;
  138077. subdivisionsX?: number;
  138078. subdivisionsY?: number;
  138079. updatable?: boolean;
  138080. }, scene: any): Mesh;
  138081. /**
  138082. * Creates a tiled ground mesh
  138083. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  138084. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  138085. * * 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
  138086. * * 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
  138087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138088. * @param name defines the name of the mesh
  138089. * @param options defines the options used to create the mesh
  138090. * @param scene defines the hosting scene
  138091. * @returns the tiled ground mesh
  138092. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  138093. */
  138094. static CreateTiledGround(name: string, options: {
  138095. xmin: number;
  138096. zmin: number;
  138097. xmax: number;
  138098. zmax: number;
  138099. subdivisions?: {
  138100. w: number;
  138101. h: number;
  138102. };
  138103. precision?: {
  138104. w: number;
  138105. h: number;
  138106. };
  138107. updatable?: boolean;
  138108. }, scene?: Nullable<Scene>): Mesh;
  138109. /**
  138110. * Creates a ground mesh from a height map
  138111. * * The parameter `url` sets the URL of the height map image resource.
  138112. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  138113. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  138114. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  138115. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  138116. * * 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.
  138117. * * 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).
  138118. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  138119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138120. * @param name defines the name of the mesh
  138121. * @param url defines the url to the height map
  138122. * @param options defines the options used to create the mesh
  138123. * @param scene defines the hosting scene
  138124. * @returns the ground mesh
  138125. * @see https://doc.babylonjs.com/babylon101/height_map
  138126. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  138127. */
  138128. static CreateGroundFromHeightMap(name: string, url: string, options: {
  138129. width?: number;
  138130. height?: number;
  138131. subdivisions?: number;
  138132. minHeight?: number;
  138133. maxHeight?: number;
  138134. colorFilter?: Color3;
  138135. alphaFilter?: number;
  138136. updatable?: boolean;
  138137. onReady?: (mesh: GroundMesh) => void;
  138138. }, scene?: Nullable<Scene>): GroundMesh;
  138139. }
  138140. }
  138141. declare module BABYLON {
  138142. /**
  138143. * Class containing static functions to help procedurally build meshes
  138144. */
  138145. export class TorusBuilder {
  138146. /**
  138147. * Creates a torus mesh
  138148. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  138149. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  138150. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  138151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138154. * @param name defines the name of the mesh
  138155. * @param options defines the options used to create the mesh
  138156. * @param scene defines the hosting scene
  138157. * @returns the torus mesh
  138158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  138159. */
  138160. static CreateTorus(name: string, options: {
  138161. diameter?: number;
  138162. thickness?: number;
  138163. tessellation?: number;
  138164. updatable?: boolean;
  138165. sideOrientation?: number;
  138166. frontUVs?: Vector4;
  138167. backUVs?: Vector4;
  138168. }, scene: any): Mesh;
  138169. }
  138170. }
  138171. declare module BABYLON {
  138172. /**
  138173. * Class containing static functions to help procedurally build meshes
  138174. */
  138175. export class CylinderBuilder {
  138176. /**
  138177. * Creates a cylinder or a cone mesh
  138178. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  138179. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  138180. * * 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.
  138181. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  138182. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  138183. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  138184. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  138185. * * 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).
  138186. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  138187. * * 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).
  138188. * * 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
  138189. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  138190. * * 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
  138191. * * 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.
  138192. * * If `enclose` is false, a ring surface is one element.
  138193. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  138194. * * 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
  138195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138198. * @param name defines the name of the mesh
  138199. * @param options defines the options used to create the mesh
  138200. * @param scene defines the hosting scene
  138201. * @returns the cylinder mesh
  138202. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  138203. */
  138204. static CreateCylinder(name: string, options: {
  138205. height?: number;
  138206. diameterTop?: number;
  138207. diameterBottom?: number;
  138208. diameter?: number;
  138209. tessellation?: number;
  138210. subdivisions?: number;
  138211. arc?: number;
  138212. faceColors?: Color4[];
  138213. faceUV?: Vector4[];
  138214. updatable?: boolean;
  138215. hasRings?: boolean;
  138216. enclose?: boolean;
  138217. cap?: number;
  138218. sideOrientation?: number;
  138219. frontUVs?: Vector4;
  138220. backUVs?: Vector4;
  138221. }, scene: any): Mesh;
  138222. }
  138223. }
  138224. declare module BABYLON {
  138225. /**
  138226. * States of the webXR experience
  138227. */
  138228. export enum WebXRState {
  138229. /**
  138230. * Transitioning to being in XR mode
  138231. */
  138232. ENTERING_XR = 0,
  138233. /**
  138234. * Transitioning to non XR mode
  138235. */
  138236. EXITING_XR = 1,
  138237. /**
  138238. * In XR mode and presenting
  138239. */
  138240. IN_XR = 2,
  138241. /**
  138242. * Not entered XR mode
  138243. */
  138244. NOT_IN_XR = 3
  138245. }
  138246. /**
  138247. * The state of the XR camera's tracking
  138248. */
  138249. export enum WebXRTrackingState {
  138250. /**
  138251. * No transformation received, device is not being tracked
  138252. */
  138253. NOT_TRACKING = 0,
  138254. /**
  138255. * Tracking lost - using emulated position
  138256. */
  138257. TRACKING_LOST = 1,
  138258. /**
  138259. * Transformation tracking works normally
  138260. */
  138261. TRACKING = 2
  138262. }
  138263. /**
  138264. * Abstraction of the XR render target
  138265. */
  138266. export interface WebXRRenderTarget extends IDisposable {
  138267. /**
  138268. * xrpresent context of the canvas which can be used to display/mirror xr content
  138269. */
  138270. canvasContext: WebGLRenderingContext;
  138271. /**
  138272. * xr layer for the canvas
  138273. */
  138274. xrLayer: Nullable<XRWebGLLayer>;
  138275. /**
  138276. * Initializes the xr layer for the session
  138277. * @param xrSession xr session
  138278. * @returns a promise that will resolve once the XR Layer has been created
  138279. */
  138280. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  138281. }
  138282. }
  138283. declare module BABYLON {
  138284. /**
  138285. * COnfiguration object for WebXR output canvas
  138286. */
  138287. export class WebXRManagedOutputCanvasOptions {
  138288. /**
  138289. * An optional canvas in case you wish to create it yourself and provide it here.
  138290. * If not provided, a new canvas will be created
  138291. */
  138292. canvasElement?: HTMLCanvasElement;
  138293. /**
  138294. * Options for this XR Layer output
  138295. */
  138296. canvasOptions?: XRWebGLLayerInit;
  138297. /**
  138298. * CSS styling for a newly created canvas (if not provided)
  138299. */
  138300. newCanvasCssStyle?: string;
  138301. /**
  138302. * Get the default values of the configuration object
  138303. * @param engine defines the engine to use (can be null)
  138304. * @returns default values of this configuration object
  138305. */
  138306. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  138307. }
  138308. /**
  138309. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  138310. */
  138311. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  138312. private _options;
  138313. private _canvas;
  138314. private _engine;
  138315. private _originalCanvasSize;
  138316. /**
  138317. * Rendering context of the canvas which can be used to display/mirror xr content
  138318. */
  138319. canvasContext: WebGLRenderingContext;
  138320. /**
  138321. * xr layer for the canvas
  138322. */
  138323. xrLayer: Nullable<XRWebGLLayer>;
  138324. /**
  138325. * Obseervers registered here will be triggered when the xr layer was initialized
  138326. */
  138327. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  138328. /**
  138329. * Initializes the canvas to be added/removed upon entering/exiting xr
  138330. * @param _xrSessionManager The XR Session manager
  138331. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  138332. */
  138333. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  138334. /**
  138335. * Disposes of the object
  138336. */
  138337. dispose(): void;
  138338. /**
  138339. * Initializes the xr layer for the session
  138340. * @param xrSession xr session
  138341. * @returns a promise that will resolve once the XR Layer has been created
  138342. */
  138343. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  138344. private _addCanvas;
  138345. private _removeCanvas;
  138346. private _setCanvasSize;
  138347. private _setManagedOutputCanvas;
  138348. }
  138349. }
  138350. declare module BABYLON {
  138351. /**
  138352. * Manages an XRSession to work with Babylon's engine
  138353. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  138354. */
  138355. export class WebXRSessionManager implements IDisposable {
  138356. /** The scene which the session should be created for */
  138357. scene: Scene;
  138358. private _referenceSpace;
  138359. private _rttProvider;
  138360. private _sessionEnded;
  138361. private _xrNavigator;
  138362. private baseLayer;
  138363. /**
  138364. * The base reference space from which the session started. good if you want to reset your
  138365. * reference space
  138366. */
  138367. baseReferenceSpace: XRReferenceSpace;
  138368. /**
  138369. * Current XR frame
  138370. */
  138371. currentFrame: Nullable<XRFrame>;
  138372. /** WebXR timestamp updated every frame */
  138373. currentTimestamp: number;
  138374. /**
  138375. * Used just in case of a failure to initialize an immersive session.
  138376. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  138377. */
  138378. defaultHeightCompensation: number;
  138379. /**
  138380. * Fires every time a new xrFrame arrives which can be used to update the camera
  138381. */
  138382. onXRFrameObservable: Observable<XRFrame>;
  138383. /**
  138384. * Fires when the reference space changed
  138385. */
  138386. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  138387. /**
  138388. * Fires when the xr session is ended either by the device or manually done
  138389. */
  138390. onXRSessionEnded: Observable<any>;
  138391. /**
  138392. * Fires when the xr session is ended either by the device or manually done
  138393. */
  138394. onXRSessionInit: Observable<XRSession>;
  138395. /**
  138396. * Underlying xr session
  138397. */
  138398. session: XRSession;
  138399. /**
  138400. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  138401. * or get the offset the player is currently at.
  138402. */
  138403. viewerReferenceSpace: XRReferenceSpace;
  138404. /**
  138405. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  138406. * @param scene The scene which the session should be created for
  138407. */
  138408. constructor(
  138409. /** The scene which the session should be created for */
  138410. scene: Scene);
  138411. /**
  138412. * The current reference space used in this session. This reference space can constantly change!
  138413. * It is mainly used to offset the camera's position.
  138414. */
  138415. get referenceSpace(): XRReferenceSpace;
  138416. /**
  138417. * Set a new reference space and triggers the observable
  138418. */
  138419. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  138420. /**
  138421. * Disposes of the session manager
  138422. */
  138423. dispose(): void;
  138424. /**
  138425. * Stops the xrSession and restores the render loop
  138426. * @returns Promise which resolves after it exits XR
  138427. */
  138428. exitXRAsync(): Promise<void>;
  138429. /**
  138430. * Gets the correct render target texture to be rendered this frame for this eye
  138431. * @param eye the eye for which to get the render target
  138432. * @returns the render target for the specified eye
  138433. */
  138434. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  138435. /**
  138436. * Creates a WebXRRenderTarget object for the XR session
  138437. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  138438. * @param options optional options to provide when creating a new render target
  138439. * @returns a WebXR render target to which the session can render
  138440. */
  138441. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  138442. /**
  138443. * Initializes the manager
  138444. * After initialization enterXR can be called to start an XR session
  138445. * @returns Promise which resolves after it is initialized
  138446. */
  138447. initializeAsync(): Promise<void>;
  138448. /**
  138449. * Initializes an xr session
  138450. * @param xrSessionMode mode to initialize
  138451. * @param xrSessionInit defines optional and required values to pass to the session builder
  138452. * @returns a promise which will resolve once the session has been initialized
  138453. */
  138454. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  138455. /**
  138456. * Checks if a session would be supported for the creation options specified
  138457. * @param sessionMode session mode to check if supported eg. immersive-vr
  138458. * @returns A Promise that resolves to true if supported and false if not
  138459. */
  138460. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  138461. /**
  138462. * Resets the reference space to the one started the session
  138463. */
  138464. resetReferenceSpace(): void;
  138465. /**
  138466. * Starts rendering to the xr layer
  138467. */
  138468. runXRRenderLoop(): void;
  138469. /**
  138470. * Sets the reference space on the xr session
  138471. * @param referenceSpaceType space to set
  138472. * @returns a promise that will resolve once the reference space has been set
  138473. */
  138474. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138475. /**
  138476. * Updates the render state of the session
  138477. * @param state state to set
  138478. * @returns a promise that resolves once the render state has been updated
  138479. */
  138480. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  138481. /**
  138482. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  138483. * @param sessionMode defines the session to test
  138484. * @returns a promise with boolean as final value
  138485. */
  138486. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  138487. /**
  138488. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  138489. */
  138490. get isNative(): boolean;
  138491. private _createRenderTargetTexture;
  138492. }
  138493. }
  138494. declare module BABYLON {
  138495. /**
  138496. * WebXR Camera which holds the views for the xrSession
  138497. * @see https://doc.babylonjs.com/how_to/webxr_camera
  138498. */
  138499. export class WebXRCamera extends FreeCamera {
  138500. private _xrSessionManager;
  138501. private _firstFrame;
  138502. private _referenceQuaternion;
  138503. private _referencedPosition;
  138504. private _xrInvPositionCache;
  138505. private _xrInvQuaternionCache;
  138506. private _trackingState;
  138507. /**
  138508. * Observable raised before camera teleportation
  138509. */
  138510. onBeforeCameraTeleport: Observable<Vector3>;
  138511. /**
  138512. * Observable raised after camera teleportation
  138513. */
  138514. onAfterCameraTeleport: Observable<Vector3>;
  138515. /**
  138516. * Notifies when the camera's tracking state has changed.
  138517. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  138518. */
  138519. onTrackingStateChanged: Observable<WebXRTrackingState>;
  138520. /**
  138521. * Should position compensation execute on first frame.
  138522. * This is used when copying the position from a native (non XR) camera
  138523. */
  138524. compensateOnFirstFrame: boolean;
  138525. /**
  138526. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  138527. * @param name the name of the camera
  138528. * @param scene the scene to add the camera to
  138529. * @param _xrSessionManager a constructed xr session manager
  138530. */
  138531. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  138532. /**
  138533. * Get the current XR tracking state of the camera
  138534. */
  138535. get trackingState(): WebXRTrackingState;
  138536. private _setTrackingState;
  138537. /**
  138538. * Return the user's height, unrelated to the current ground.
  138539. * This will be the y position of this camera, when ground level is 0.
  138540. */
  138541. get realWorldHeight(): number;
  138542. /** @hidden */
  138543. _updateForDualEyeDebugging(): void;
  138544. /**
  138545. * Sets this camera's transformation based on a non-vr camera
  138546. * @param otherCamera the non-vr camera to copy the transformation from
  138547. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  138548. */
  138549. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  138550. /**
  138551. * Gets the current instance class name ("WebXRCamera").
  138552. * @returns the class name
  138553. */
  138554. getClassName(): string;
  138555. private _rotate180;
  138556. private _updateFromXRSession;
  138557. private _updateNumberOfRigCameras;
  138558. private _updateReferenceSpace;
  138559. private _updateReferenceSpaceOffset;
  138560. }
  138561. }
  138562. declare module BABYLON {
  138563. /**
  138564. * Defining the interface required for a (webxr) feature
  138565. */
  138566. export interface IWebXRFeature extends IDisposable {
  138567. /**
  138568. * Is this feature attached
  138569. */
  138570. attached: boolean;
  138571. /**
  138572. * Should auto-attach be disabled?
  138573. */
  138574. disableAutoAttach: boolean;
  138575. /**
  138576. * Attach the feature to the session
  138577. * Will usually be called by the features manager
  138578. *
  138579. * @param force should attachment be forced (even when already attached)
  138580. * @returns true if successful.
  138581. */
  138582. attach(force?: boolean): boolean;
  138583. /**
  138584. * Detach the feature from the session
  138585. * Will usually be called by the features manager
  138586. *
  138587. * @returns true if successful.
  138588. */
  138589. detach(): boolean;
  138590. /**
  138591. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  138592. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  138593. *
  138594. * @returns whether or not the feature is compatible in this environment
  138595. */
  138596. isCompatible(): boolean;
  138597. /**
  138598. * Was this feature disposed;
  138599. */
  138600. isDisposed: boolean;
  138601. /**
  138602. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  138603. */
  138604. xrNativeFeatureName?: string;
  138605. /**
  138606. * A list of (Babylon WebXR) features this feature depends on
  138607. */
  138608. dependsOn?: string[];
  138609. /**
  138610. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  138611. */
  138612. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  138613. }
  138614. /**
  138615. * A list of the currently available features without referencing them
  138616. */
  138617. export class WebXRFeatureName {
  138618. /**
  138619. * The name of the anchor system feature
  138620. */
  138621. static readonly ANCHOR_SYSTEM: string;
  138622. /**
  138623. * The name of the background remover feature
  138624. */
  138625. static readonly BACKGROUND_REMOVER: string;
  138626. /**
  138627. * The name of the hit test feature
  138628. */
  138629. static readonly HIT_TEST: string;
  138630. /**
  138631. * The name of the mesh detection feature
  138632. */
  138633. static readonly MESH_DETECTION: string;
  138634. /**
  138635. * physics impostors for xr controllers feature
  138636. */
  138637. static readonly PHYSICS_CONTROLLERS: string;
  138638. /**
  138639. * The name of the plane detection feature
  138640. */
  138641. static readonly PLANE_DETECTION: string;
  138642. /**
  138643. * The name of the pointer selection feature
  138644. */
  138645. static readonly POINTER_SELECTION: string;
  138646. /**
  138647. * The name of the teleportation feature
  138648. */
  138649. static readonly TELEPORTATION: string;
  138650. /**
  138651. * The name of the feature points feature.
  138652. */
  138653. static readonly FEATURE_POINTS: string;
  138654. /**
  138655. * The name of the hand tracking feature.
  138656. */
  138657. static readonly HAND_TRACKING: string;
  138658. /**
  138659. * The name of the image tracking feature
  138660. */
  138661. static readonly IMAGE_TRACKING: string;
  138662. }
  138663. /**
  138664. * Defining the constructor of a feature. Used to register the modules.
  138665. */
  138666. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  138667. /**
  138668. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  138669. * It is mainly used in AR sessions.
  138670. *
  138671. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  138672. */
  138673. export class WebXRFeaturesManager implements IDisposable {
  138674. private _xrSessionManager;
  138675. private static readonly _AvailableFeatures;
  138676. private _features;
  138677. /**
  138678. * constructs a new features manages.
  138679. *
  138680. * @param _xrSessionManager an instance of WebXRSessionManager
  138681. */
  138682. constructor(_xrSessionManager: WebXRSessionManager);
  138683. /**
  138684. * Used to register a module. After calling this function a developer can use this feature in the scene.
  138685. * Mainly used internally.
  138686. *
  138687. * @param featureName the name of the feature to register
  138688. * @param constructorFunction the function used to construct the module
  138689. * @param version the (babylon) version of the module
  138690. * @param stable is that a stable version of this module
  138691. */
  138692. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  138693. /**
  138694. * Returns a constructor of a specific feature.
  138695. *
  138696. * @param featureName the name of the feature to construct
  138697. * @param version the version of the feature to load
  138698. * @param xrSessionManager the xrSessionManager. Used to construct the module
  138699. * @param options optional options provided to the module.
  138700. * @returns a function that, when called, will return a new instance of this feature
  138701. */
  138702. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  138703. /**
  138704. * Can be used to return the list of features currently registered
  138705. *
  138706. * @returns an Array of available features
  138707. */
  138708. static GetAvailableFeatures(): string[];
  138709. /**
  138710. * Gets the versions available for a specific feature
  138711. * @param featureName the name of the feature
  138712. * @returns an array with the available versions
  138713. */
  138714. static GetAvailableVersions(featureName: string): string[];
  138715. /**
  138716. * Return the latest unstable version of this feature
  138717. * @param featureName the name of the feature to search
  138718. * @returns the version number. if not found will return -1
  138719. */
  138720. static GetLatestVersionOfFeature(featureName: string): number;
  138721. /**
  138722. * Return the latest stable version of this feature
  138723. * @param featureName the name of the feature to search
  138724. * @returns the version number. if not found will return -1
  138725. */
  138726. static GetStableVersionOfFeature(featureName: string): number;
  138727. /**
  138728. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  138729. * Can be used during a session to start a feature
  138730. * @param featureName the name of feature to attach
  138731. */
  138732. attachFeature(featureName: string): void;
  138733. /**
  138734. * Can be used inside a session or when the session ends to detach a specific feature
  138735. * @param featureName the name of the feature to detach
  138736. */
  138737. detachFeature(featureName: string): void;
  138738. /**
  138739. * Used to disable an already-enabled feature
  138740. * The feature will be disposed and will be recreated once enabled.
  138741. * @param featureName the feature to disable
  138742. * @returns true if disable was successful
  138743. */
  138744. disableFeature(featureName: string | {
  138745. Name: string;
  138746. }): boolean;
  138747. /**
  138748. * dispose this features manager
  138749. */
  138750. dispose(): void;
  138751. /**
  138752. * 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.
  138753. * 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.
  138754. *
  138755. * @param featureName the name of the feature to load or the class of the feature
  138756. * @param version optional version to load. if not provided the latest version will be enabled
  138757. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  138758. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  138759. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  138760. * @returns a new constructed feature or throws an error if feature not found.
  138761. */
  138762. enableFeature(featureName: string | {
  138763. Name: string;
  138764. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  138765. /**
  138766. * get the implementation of an enabled feature.
  138767. * @param featureName the name of the feature to load
  138768. * @returns the feature class, if found
  138769. */
  138770. getEnabledFeature(featureName: string): IWebXRFeature;
  138771. /**
  138772. * Get the list of enabled features
  138773. * @returns an array of enabled features
  138774. */
  138775. getEnabledFeatures(): string[];
  138776. /**
  138777. * This function will extend the session creation configuration object with enabled features.
  138778. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  138779. * according to the defined "required" variable, provided during enableFeature call
  138780. * @param xrSessionInit the xr Session init object to extend
  138781. *
  138782. * @returns an extended XRSessionInit object
  138783. */
  138784. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  138785. }
  138786. }
  138787. declare module BABYLON {
  138788. /**
  138789. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  138790. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  138791. */
  138792. export class WebXRExperienceHelper implements IDisposable {
  138793. private scene;
  138794. private _nonVRCamera;
  138795. private _originalSceneAutoClear;
  138796. private _supported;
  138797. /**
  138798. * Camera used to render xr content
  138799. */
  138800. camera: WebXRCamera;
  138801. /** A features manager for this xr session */
  138802. featuresManager: WebXRFeaturesManager;
  138803. /**
  138804. * Observers registered here will be triggered after the camera's initial transformation is set
  138805. * This can be used to set a different ground level or an extra rotation.
  138806. *
  138807. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  138808. * to the position set after this observable is done executing.
  138809. */
  138810. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  138811. /**
  138812. * Fires when the state of the experience helper has changed
  138813. */
  138814. onStateChangedObservable: Observable<WebXRState>;
  138815. /** Session manager used to keep track of xr session */
  138816. sessionManager: WebXRSessionManager;
  138817. /**
  138818. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  138819. */
  138820. state: WebXRState;
  138821. /**
  138822. * Creates a WebXRExperienceHelper
  138823. * @param scene The scene the helper should be created in
  138824. */
  138825. private constructor();
  138826. /**
  138827. * Creates the experience helper
  138828. * @param scene the scene to attach the experience helper to
  138829. * @returns a promise for the experience helper
  138830. */
  138831. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  138832. /**
  138833. * Disposes of the experience helper
  138834. */
  138835. dispose(): void;
  138836. /**
  138837. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  138838. * @param sessionMode options for the XR session
  138839. * @param referenceSpaceType frame of reference of the XR session
  138840. * @param renderTarget the output canvas that will be used to enter XR mode
  138841. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  138842. * @returns promise that resolves after xr mode has entered
  138843. */
  138844. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  138845. /**
  138846. * Exits XR mode and returns the scene to its original state
  138847. * @returns promise that resolves after xr mode has exited
  138848. */
  138849. exitXRAsync(): Promise<void>;
  138850. private _nonXRToXRCamera;
  138851. private _setState;
  138852. }
  138853. }
  138854. declare module BABYLON {
  138855. /**
  138856. * X-Y values for axes in WebXR
  138857. */
  138858. export interface IWebXRMotionControllerAxesValue {
  138859. /**
  138860. * The value of the x axis
  138861. */
  138862. x: number;
  138863. /**
  138864. * The value of the y-axis
  138865. */
  138866. y: number;
  138867. }
  138868. /**
  138869. * changed / previous values for the values of this component
  138870. */
  138871. export interface IWebXRMotionControllerComponentChangesValues<T> {
  138872. /**
  138873. * current (this frame) value
  138874. */
  138875. current: T;
  138876. /**
  138877. * previous (last change) value
  138878. */
  138879. previous: T;
  138880. }
  138881. /**
  138882. * Represents changes in the component between current frame and last values recorded
  138883. */
  138884. export interface IWebXRMotionControllerComponentChanges {
  138885. /**
  138886. * will be populated with previous and current values if axes changed
  138887. */
  138888. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  138889. /**
  138890. * will be populated with previous and current values if pressed changed
  138891. */
  138892. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138893. /**
  138894. * will be populated with previous and current values if touched changed
  138895. */
  138896. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138897. /**
  138898. * will be populated with previous and current values if value changed
  138899. */
  138900. value?: IWebXRMotionControllerComponentChangesValues<number>;
  138901. }
  138902. /**
  138903. * This class represents a single component (for example button or thumbstick) of a motion controller
  138904. */
  138905. export class WebXRControllerComponent implements IDisposable {
  138906. /**
  138907. * the id of this component
  138908. */
  138909. id: string;
  138910. /**
  138911. * the type of the component
  138912. */
  138913. type: MotionControllerComponentType;
  138914. private _buttonIndex;
  138915. private _axesIndices;
  138916. private _axes;
  138917. private _changes;
  138918. private _currentValue;
  138919. private _hasChanges;
  138920. private _pressed;
  138921. private _touched;
  138922. /**
  138923. * button component type
  138924. */
  138925. static BUTTON_TYPE: MotionControllerComponentType;
  138926. /**
  138927. * squeeze component type
  138928. */
  138929. static SQUEEZE_TYPE: MotionControllerComponentType;
  138930. /**
  138931. * Thumbstick component type
  138932. */
  138933. static THUMBSTICK_TYPE: MotionControllerComponentType;
  138934. /**
  138935. * Touchpad component type
  138936. */
  138937. static TOUCHPAD_TYPE: MotionControllerComponentType;
  138938. /**
  138939. * trigger component type
  138940. */
  138941. static TRIGGER_TYPE: MotionControllerComponentType;
  138942. /**
  138943. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  138944. * the axes data changes
  138945. */
  138946. onAxisValueChangedObservable: Observable<{
  138947. x: number;
  138948. y: number;
  138949. }>;
  138950. /**
  138951. * Observers registered here will be triggered when the state of a button changes
  138952. * State change is either pressed / touched / value
  138953. */
  138954. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  138955. /**
  138956. * Creates a new component for a motion controller.
  138957. * It is created by the motion controller itself
  138958. *
  138959. * @param id the id of this component
  138960. * @param type the type of the component
  138961. * @param _buttonIndex index in the buttons array of the gamepad
  138962. * @param _axesIndices indices of the values in the axes array of the gamepad
  138963. */
  138964. constructor(
  138965. /**
  138966. * the id of this component
  138967. */
  138968. id: string,
  138969. /**
  138970. * the type of the component
  138971. */
  138972. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  138973. /**
  138974. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  138975. */
  138976. get axes(): IWebXRMotionControllerAxesValue;
  138977. /**
  138978. * Get the changes. Elements will be populated only if they changed with their previous and current value
  138979. */
  138980. get changes(): IWebXRMotionControllerComponentChanges;
  138981. /**
  138982. * Return whether or not the component changed the last frame
  138983. */
  138984. get hasChanges(): boolean;
  138985. /**
  138986. * is the button currently pressed
  138987. */
  138988. get pressed(): boolean;
  138989. /**
  138990. * is the button currently touched
  138991. */
  138992. get touched(): boolean;
  138993. /**
  138994. * Get the current value of this component
  138995. */
  138996. get value(): number;
  138997. /**
  138998. * Dispose this component
  138999. */
  139000. dispose(): void;
  139001. /**
  139002. * Are there axes correlating to this component
  139003. * @return true is axes data is available
  139004. */
  139005. isAxes(): boolean;
  139006. /**
  139007. * Is this component a button (hence - pressable)
  139008. * @returns true if can be pressed
  139009. */
  139010. isButton(): boolean;
  139011. /**
  139012. * update this component using the gamepad object it is in. Called on every frame
  139013. * @param nativeController the native gamepad controller object
  139014. */
  139015. update(nativeController: IMinimalMotionControllerObject): void;
  139016. }
  139017. }
  139018. declare module BABYLON {
  139019. /**
  139020. * Type used for the success callback of ImportMesh
  139021. */
  139022. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  139023. /**
  139024. * Interface used for the result of ImportMeshAsync
  139025. */
  139026. export interface ISceneLoaderAsyncResult {
  139027. /**
  139028. * The array of loaded meshes
  139029. */
  139030. readonly meshes: AbstractMesh[];
  139031. /**
  139032. * The array of loaded particle systems
  139033. */
  139034. readonly particleSystems: IParticleSystem[];
  139035. /**
  139036. * The array of loaded skeletons
  139037. */
  139038. readonly skeletons: Skeleton[];
  139039. /**
  139040. * The array of loaded animation groups
  139041. */
  139042. readonly animationGroups: AnimationGroup[];
  139043. /**
  139044. * The array of loaded transform nodes
  139045. */
  139046. readonly transformNodes: TransformNode[];
  139047. /**
  139048. * The array of loaded geometries
  139049. */
  139050. readonly geometries: Geometry[];
  139051. /**
  139052. * The array of loaded lights
  139053. */
  139054. readonly lights: Light[];
  139055. }
  139056. /**
  139057. * Interface used to represent data loading progression
  139058. */
  139059. export interface ISceneLoaderProgressEvent {
  139060. /**
  139061. * Defines if data length to load can be evaluated
  139062. */
  139063. readonly lengthComputable: boolean;
  139064. /**
  139065. * Defines the loaded data length
  139066. */
  139067. readonly loaded: number;
  139068. /**
  139069. * Defines the data length to load
  139070. */
  139071. readonly total: number;
  139072. }
  139073. /**
  139074. * Interface used by SceneLoader plugins to define supported file extensions
  139075. */
  139076. export interface ISceneLoaderPluginExtensions {
  139077. /**
  139078. * Defines the list of supported extensions
  139079. */
  139080. [extension: string]: {
  139081. isBinary: boolean;
  139082. };
  139083. }
  139084. /**
  139085. * Interface used by SceneLoader plugin factory
  139086. */
  139087. export interface ISceneLoaderPluginFactory {
  139088. /**
  139089. * Defines the name of the factory
  139090. */
  139091. name: string;
  139092. /**
  139093. * Function called to create a new plugin
  139094. * @return the new plugin
  139095. */
  139096. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  139097. /**
  139098. * The callback that returns true if the data can be directly loaded.
  139099. * @param data string containing the file data
  139100. * @returns if the data can be loaded directly
  139101. */
  139102. canDirectLoad?(data: string): boolean;
  139103. }
  139104. /**
  139105. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  139106. */
  139107. export interface ISceneLoaderPluginBase {
  139108. /**
  139109. * The friendly name of this plugin.
  139110. */
  139111. name: string;
  139112. /**
  139113. * The file extensions supported by this plugin.
  139114. */
  139115. extensions: string | ISceneLoaderPluginExtensions;
  139116. /**
  139117. * The callback called when loading from a url.
  139118. * @param scene scene loading this url
  139119. * @param url url to load
  139120. * @param onSuccess callback called when the file successfully loads
  139121. * @param onProgress callback called while file is loading (if the server supports this mode)
  139122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  139123. * @param onError callback called when the file fails to load
  139124. * @returns a file request object
  139125. */
  139126. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  139127. /**
  139128. * The callback called when loading from a file object.
  139129. * @param scene scene loading this file
  139130. * @param file defines the file to load
  139131. * @param onSuccess defines the callback to call when data is loaded
  139132. * @param onProgress defines the callback to call during loading process
  139133. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  139134. * @param onError defines the callback to call when an error occurs
  139135. * @returns a file request object
  139136. */
  139137. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  139138. /**
  139139. * The callback that returns true if the data can be directly loaded.
  139140. * @param data string containing the file data
  139141. * @returns if the data can be loaded directly
  139142. */
  139143. canDirectLoad?(data: string): boolean;
  139144. /**
  139145. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  139146. * @param scene scene loading this data
  139147. * @param data string containing the data
  139148. * @returns data to pass to the plugin
  139149. */
  139150. directLoad?(scene: Scene, data: string): any;
  139151. /**
  139152. * The callback that allows custom handling of the root url based on the response url.
  139153. * @param rootUrl the original root url
  139154. * @param responseURL the response url if available
  139155. * @returns the new root url
  139156. */
  139157. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  139158. }
  139159. /**
  139160. * Interface used to define a SceneLoader plugin
  139161. */
  139162. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  139163. /**
  139164. * Import meshes into a scene.
  139165. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139166. * @param scene The scene to import into
  139167. * @param data The data to import
  139168. * @param rootUrl The root url for scene and resources
  139169. * @param meshes The meshes array to import into
  139170. * @param particleSystems The particle systems array to import into
  139171. * @param skeletons The skeletons array to import into
  139172. * @param onError The callback when import fails
  139173. * @returns True if successful or false otherwise
  139174. */
  139175. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  139176. /**
  139177. * Load into a scene.
  139178. * @param scene The scene to load into
  139179. * @param data The data to import
  139180. * @param rootUrl The root url for scene and resources
  139181. * @param onError The callback when import fails
  139182. * @returns True if successful or false otherwise
  139183. */
  139184. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  139185. /**
  139186. * Load into an asset container.
  139187. * @param scene The scene to load into
  139188. * @param data The data to import
  139189. * @param rootUrl The root url for scene and resources
  139190. * @param onError The callback when import fails
  139191. * @returns The loaded asset container
  139192. */
  139193. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  139194. }
  139195. /**
  139196. * Interface used to define an async SceneLoader plugin
  139197. */
  139198. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  139199. /**
  139200. * Import meshes into a scene.
  139201. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139202. * @param scene The scene to import into
  139203. * @param data The data to import
  139204. * @param rootUrl The root url for scene and resources
  139205. * @param onProgress The callback when the load progresses
  139206. * @param fileName Defines the name of the file to load
  139207. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  139208. */
  139209. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  139210. /**
  139211. * Load into a scene.
  139212. * @param scene The scene to load into
  139213. * @param data The data to import
  139214. * @param rootUrl The root url for scene and resources
  139215. * @param onProgress The callback when the load progresses
  139216. * @param fileName Defines the name of the file to load
  139217. * @returns Nothing
  139218. */
  139219. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  139220. /**
  139221. * Load into an asset container.
  139222. * @param scene The scene to load into
  139223. * @param data The data to import
  139224. * @param rootUrl The root url for scene and resources
  139225. * @param onProgress The callback when the load progresses
  139226. * @param fileName Defines the name of the file to load
  139227. * @returns The loaded asset container
  139228. */
  139229. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  139230. }
  139231. /**
  139232. * Mode that determines how to handle old animation groups before loading new ones.
  139233. */
  139234. export enum SceneLoaderAnimationGroupLoadingMode {
  139235. /**
  139236. * Reset all old animations to initial state then dispose them.
  139237. */
  139238. Clean = 0,
  139239. /**
  139240. * Stop all old animations.
  139241. */
  139242. Stop = 1,
  139243. /**
  139244. * Restart old animations from first frame.
  139245. */
  139246. Sync = 2,
  139247. /**
  139248. * Old animations remains untouched.
  139249. */
  139250. NoSync = 3
  139251. }
  139252. /**
  139253. * Defines a plugin registered by the SceneLoader
  139254. */
  139255. interface IRegisteredPlugin {
  139256. /**
  139257. * Defines the plugin to use
  139258. */
  139259. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  139260. /**
  139261. * Defines if the plugin supports binary data
  139262. */
  139263. isBinary: boolean;
  139264. }
  139265. /**
  139266. * Class used to load scene from various file formats using registered plugins
  139267. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  139268. */
  139269. export class SceneLoader {
  139270. /**
  139271. * No logging while loading
  139272. */
  139273. static readonly NO_LOGGING: number;
  139274. /**
  139275. * Minimal logging while loading
  139276. */
  139277. static readonly MINIMAL_LOGGING: number;
  139278. /**
  139279. * Summary logging while loading
  139280. */
  139281. static readonly SUMMARY_LOGGING: number;
  139282. /**
  139283. * Detailled logging while loading
  139284. */
  139285. static readonly DETAILED_LOGGING: number;
  139286. /**
  139287. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  139288. */
  139289. static get ForceFullSceneLoadingForIncremental(): boolean;
  139290. static set ForceFullSceneLoadingForIncremental(value: boolean);
  139291. /**
  139292. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  139293. */
  139294. static get ShowLoadingScreen(): boolean;
  139295. static set ShowLoadingScreen(value: boolean);
  139296. /**
  139297. * Defines the current logging level (while loading the scene)
  139298. * @ignorenaming
  139299. */
  139300. static get loggingLevel(): number;
  139301. static set loggingLevel(value: number);
  139302. /**
  139303. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  139304. */
  139305. static get CleanBoneMatrixWeights(): boolean;
  139306. static set CleanBoneMatrixWeights(value: boolean);
  139307. /**
  139308. * Event raised when a plugin is used to load a scene
  139309. */
  139310. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139311. private static _registeredPlugins;
  139312. private static _showingLoadingScreen;
  139313. /**
  139314. * Gets the default plugin (used to load Babylon files)
  139315. * @returns the .babylon plugin
  139316. */
  139317. static GetDefaultPlugin(): IRegisteredPlugin;
  139318. private static _GetPluginForExtension;
  139319. private static _GetPluginForDirectLoad;
  139320. private static _GetPluginForFilename;
  139321. private static _GetDirectLoad;
  139322. private static _LoadData;
  139323. private static _GetFileInfo;
  139324. /**
  139325. * Gets a plugin that can load the given extension
  139326. * @param extension defines the extension to load
  139327. * @returns a plugin or null if none works
  139328. */
  139329. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  139330. /**
  139331. * Gets a boolean indicating that the given extension can be loaded
  139332. * @param extension defines the extension to load
  139333. * @returns true if the extension is supported
  139334. */
  139335. static IsPluginForExtensionAvailable(extension: string): boolean;
  139336. /**
  139337. * Adds a new plugin to the list of registered plugins
  139338. * @param plugin defines the plugin to add
  139339. */
  139340. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  139341. /**
  139342. * Import meshes into a scene
  139343. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139344. * @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)
  139345. * @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)
  139346. * @param scene the instance of BABYLON.Scene to append to
  139347. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  139348. * @param onProgress a callback with a progress event for each file being loaded
  139349. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139350. * @param pluginExtension the extension used to determine the plugin
  139351. * @returns The loaded plugin
  139352. */
  139353. 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>;
  139354. /**
  139355. * Import meshes into a scene
  139356. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139357. * @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)
  139358. * @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)
  139359. * @param scene the instance of BABYLON.Scene to append to
  139360. * @param onProgress a callback with a progress event for each file being loaded
  139361. * @param pluginExtension the extension used to determine the plugin
  139362. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  139363. */
  139364. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  139365. /**
  139366. * Load a scene
  139367. * @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)
  139368. * @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)
  139369. * @param engine is the instance of BABYLON.Engine to use to create the scene
  139370. * @param onSuccess a callback with the scene when import succeeds
  139371. * @param onProgress a callback with a progress event for each file being loaded
  139372. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139373. * @param pluginExtension the extension used to determine the plugin
  139374. * @returns The loaded plugin
  139375. */
  139376. 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>;
  139377. /**
  139378. * Load a scene
  139379. * @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)
  139380. * @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)
  139381. * @param engine is the instance of BABYLON.Engine to use to create the scene
  139382. * @param onProgress a callback with a progress event for each file being loaded
  139383. * @param pluginExtension the extension used to determine the plugin
  139384. * @returns The loaded scene
  139385. */
  139386. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  139387. /**
  139388. * Append a scene
  139389. * @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)
  139390. * @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)
  139391. * @param scene is the instance of BABYLON.Scene to append to
  139392. * @param onSuccess a callback with the scene when import succeeds
  139393. * @param onProgress a callback with a progress event for each file being loaded
  139394. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139395. * @param pluginExtension the extension used to determine the plugin
  139396. * @returns The loaded plugin
  139397. */
  139398. 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>;
  139399. /**
  139400. * Append a scene
  139401. * @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)
  139402. * @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)
  139403. * @param scene is the instance of BABYLON.Scene to append to
  139404. * @param onProgress a callback with a progress event for each file being loaded
  139405. * @param pluginExtension the extension used to determine the plugin
  139406. * @returns The given scene
  139407. */
  139408. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  139409. /**
  139410. * Load a scene into an asset container
  139411. * @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)
  139412. * @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)
  139413. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139414. * @param onSuccess a callback with the scene when import succeeds
  139415. * @param onProgress a callback with a progress event for each file being loaded
  139416. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139417. * @param pluginExtension the extension used to determine the plugin
  139418. * @returns The loaded plugin
  139419. */
  139420. 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>;
  139421. /**
  139422. * Load a scene into an asset container
  139423. * @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)
  139424. * @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)
  139425. * @param scene is the instance of Scene to append to
  139426. * @param onProgress a callback with a progress event for each file being loaded
  139427. * @param pluginExtension the extension used to determine the plugin
  139428. * @returns The loaded asset container
  139429. */
  139430. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  139431. /**
  139432. * Import animations from a file into a scene
  139433. * @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)
  139434. * @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)
  139435. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139436. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  139437. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  139438. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  139439. * @param onSuccess a callback with the scene when import succeeds
  139440. * @param onProgress a callback with a progress event for each file being loaded
  139441. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139442. * @param pluginExtension the extension used to determine the plugin
  139443. */
  139444. 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;
  139445. /**
  139446. * Import animations from a file into a scene
  139447. * @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)
  139448. * @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)
  139449. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139450. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  139451. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  139452. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  139453. * @param onSuccess a callback with the scene when import succeeds
  139454. * @param onProgress a callback with a progress event for each file being loaded
  139455. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139456. * @param pluginExtension the extension used to determine the plugin
  139457. * @returns the updated scene with imported animations
  139458. */
  139459. 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>;
  139460. }
  139461. }
  139462. declare module BABYLON {
  139463. /**
  139464. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  139465. */
  139466. export type MotionControllerHandedness = "none" | "left" | "right";
  139467. /**
  139468. * The type of components available in motion controllers.
  139469. * This is not the name of the component.
  139470. */
  139471. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  139472. /**
  139473. * The state of a controller component
  139474. */
  139475. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  139476. /**
  139477. * The schema of motion controller layout.
  139478. * No object will be initialized using this interface
  139479. * This is used just to define the profile.
  139480. */
  139481. export interface IMotionControllerLayout {
  139482. /**
  139483. * Path to load the assets. Usually relative to the base path
  139484. */
  139485. assetPath: string;
  139486. /**
  139487. * Available components (unsorted)
  139488. */
  139489. components: {
  139490. /**
  139491. * A map of component Ids
  139492. */
  139493. [componentId: string]: {
  139494. /**
  139495. * The type of input the component outputs
  139496. */
  139497. type: MotionControllerComponentType;
  139498. /**
  139499. * The indices of this component in the gamepad object
  139500. */
  139501. gamepadIndices: {
  139502. /**
  139503. * Index of button
  139504. */
  139505. button?: number;
  139506. /**
  139507. * If available, index of x-axis
  139508. */
  139509. xAxis?: number;
  139510. /**
  139511. * If available, index of y-axis
  139512. */
  139513. yAxis?: number;
  139514. };
  139515. /**
  139516. * The mesh's root node name
  139517. */
  139518. rootNodeName: string;
  139519. /**
  139520. * Animation definitions for this model
  139521. */
  139522. visualResponses: {
  139523. [stateKey: string]: {
  139524. /**
  139525. * What property will be animated
  139526. */
  139527. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  139528. /**
  139529. * What states influence this visual response
  139530. */
  139531. states: MotionControllerComponentStateType[];
  139532. /**
  139533. * Type of animation - movement or visibility
  139534. */
  139535. valueNodeProperty: "transform" | "visibility";
  139536. /**
  139537. * Base node name to move. Its position will be calculated according to the min and max nodes
  139538. */
  139539. valueNodeName?: string;
  139540. /**
  139541. * Minimum movement node
  139542. */
  139543. minNodeName?: string;
  139544. /**
  139545. * Max movement node
  139546. */
  139547. maxNodeName?: string;
  139548. };
  139549. };
  139550. /**
  139551. * If touch enabled, what is the name of node to display user feedback
  139552. */
  139553. touchPointNodeName?: string;
  139554. };
  139555. };
  139556. /**
  139557. * Is it xr standard mapping or not
  139558. */
  139559. gamepadMapping: "" | "xr-standard";
  139560. /**
  139561. * Base root node of this entire model
  139562. */
  139563. rootNodeName: string;
  139564. /**
  139565. * Defines the main button component id
  139566. */
  139567. selectComponentId: string;
  139568. }
  139569. /**
  139570. * A definition for the layout map in the input profile
  139571. */
  139572. export interface IMotionControllerLayoutMap {
  139573. /**
  139574. * Layouts with handedness type as a key
  139575. */
  139576. [handedness: string]: IMotionControllerLayout;
  139577. }
  139578. /**
  139579. * The XR Input profile schema
  139580. * Profiles can be found here:
  139581. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  139582. */
  139583. export interface IMotionControllerProfile {
  139584. /**
  139585. * fallback profiles for this profileId
  139586. */
  139587. fallbackProfileIds: string[];
  139588. /**
  139589. * The layout map, with handedness as key
  139590. */
  139591. layouts: IMotionControllerLayoutMap;
  139592. /**
  139593. * The id of this profile
  139594. * correlates to the profile(s) in the xrInput.profiles array
  139595. */
  139596. profileId: string;
  139597. }
  139598. /**
  139599. * A helper-interface for the 3 meshes needed for controller button animation
  139600. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  139601. */
  139602. export interface IMotionControllerButtonMeshMap {
  139603. /**
  139604. * the mesh that defines the pressed value mesh position.
  139605. * This is used to find the max-position of this button
  139606. */
  139607. pressedMesh: AbstractMesh;
  139608. /**
  139609. * the mesh that defines the unpressed value mesh position.
  139610. * This is used to find the min (or initial) position of this button
  139611. */
  139612. unpressedMesh: AbstractMesh;
  139613. /**
  139614. * The mesh that will be changed when value changes
  139615. */
  139616. valueMesh: AbstractMesh;
  139617. }
  139618. /**
  139619. * A helper-interface for the 3 meshes needed for controller axis animation.
  139620. * This will be expanded when touchpad animations are fully supported
  139621. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  139622. */
  139623. export interface IMotionControllerMeshMap {
  139624. /**
  139625. * the mesh that defines the maximum value mesh position.
  139626. */
  139627. maxMesh?: AbstractMesh;
  139628. /**
  139629. * the mesh that defines the minimum value mesh position.
  139630. */
  139631. minMesh?: AbstractMesh;
  139632. /**
  139633. * The mesh that will be changed when axis value changes
  139634. */
  139635. valueMesh?: AbstractMesh;
  139636. }
  139637. /**
  139638. * The elements needed for change-detection of the gamepad objects in motion controllers
  139639. */
  139640. export interface IMinimalMotionControllerObject {
  139641. /**
  139642. * Available axes of this controller
  139643. */
  139644. axes: number[];
  139645. /**
  139646. * An array of available buttons
  139647. */
  139648. buttons: Array<{
  139649. /**
  139650. * Value of the button/trigger
  139651. */
  139652. value: number;
  139653. /**
  139654. * If the button/trigger is currently touched
  139655. */
  139656. touched: boolean;
  139657. /**
  139658. * If the button/trigger is currently pressed
  139659. */
  139660. pressed: boolean;
  139661. }>;
  139662. /**
  139663. * EXPERIMENTAL haptic support.
  139664. */
  139665. hapticActuators?: Array<{
  139666. pulse: (value: number, duration: number) => Promise<boolean>;
  139667. }>;
  139668. }
  139669. /**
  139670. * An Abstract Motion controller
  139671. * This class receives an xrInput and a profile layout and uses those to initialize the components
  139672. * Each component has an observable to check for changes in value and state
  139673. */
  139674. export abstract class WebXRAbstractMotionController implements IDisposable {
  139675. protected scene: Scene;
  139676. protected layout: IMotionControllerLayout;
  139677. /**
  139678. * The gamepad object correlating to this controller
  139679. */
  139680. gamepadObject: IMinimalMotionControllerObject;
  139681. /**
  139682. * handedness (left/right/none) of this controller
  139683. */
  139684. handedness: MotionControllerHandedness;
  139685. private _initComponent;
  139686. private _modelReady;
  139687. /**
  139688. * A map of components (WebXRControllerComponent) in this motion controller
  139689. * Components have a ComponentType and can also have both button and axis definitions
  139690. */
  139691. readonly components: {
  139692. [id: string]: WebXRControllerComponent;
  139693. };
  139694. /**
  139695. * Disable the model's animation. Can be set at any time.
  139696. */
  139697. disableAnimation: boolean;
  139698. /**
  139699. * Observers registered here will be triggered when the model of this controller is done loading
  139700. */
  139701. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  139702. /**
  139703. * The profile id of this motion controller
  139704. */
  139705. abstract profileId: string;
  139706. /**
  139707. * The root mesh of the model. It is null if the model was not yet initialized
  139708. */
  139709. rootMesh: Nullable<AbstractMesh>;
  139710. /**
  139711. * constructs a new abstract motion controller
  139712. * @param scene the scene to which the model of the controller will be added
  139713. * @param layout The profile layout to load
  139714. * @param gamepadObject The gamepad object correlating to this controller
  139715. * @param handedness handedness (left/right/none) of this controller
  139716. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  139717. */
  139718. constructor(scene: Scene, layout: IMotionControllerLayout,
  139719. /**
  139720. * The gamepad object correlating to this controller
  139721. */
  139722. gamepadObject: IMinimalMotionControllerObject,
  139723. /**
  139724. * handedness (left/right/none) of this controller
  139725. */
  139726. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  139727. /**
  139728. * Dispose this controller, the model mesh and all its components
  139729. */
  139730. dispose(): void;
  139731. /**
  139732. * Returns all components of specific type
  139733. * @param type the type to search for
  139734. * @return an array of components with this type
  139735. */
  139736. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  139737. /**
  139738. * get a component based an its component id as defined in layout.components
  139739. * @param id the id of the component
  139740. * @returns the component correlates to the id or undefined if not found
  139741. */
  139742. getComponent(id: string): WebXRControllerComponent;
  139743. /**
  139744. * Get the list of components available in this motion controller
  139745. * @returns an array of strings correlating to available components
  139746. */
  139747. getComponentIds(): string[];
  139748. /**
  139749. * Get the first component of specific type
  139750. * @param type type of component to find
  139751. * @return a controller component or null if not found
  139752. */
  139753. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  139754. /**
  139755. * Get the main (Select) component of this controller as defined in the layout
  139756. * @returns the main component of this controller
  139757. */
  139758. getMainComponent(): WebXRControllerComponent;
  139759. /**
  139760. * Loads the model correlating to this controller
  139761. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  139762. * @returns A promise fulfilled with the result of the model loading
  139763. */
  139764. loadModel(): Promise<boolean>;
  139765. /**
  139766. * Update this model using the current XRFrame
  139767. * @param xrFrame the current xr frame to use and update the model
  139768. */
  139769. updateFromXRFrame(xrFrame: XRFrame): void;
  139770. /**
  139771. * Backwards compatibility due to a deeply-integrated typo
  139772. */
  139773. get handness(): XREye;
  139774. /**
  139775. * Pulse (vibrate) this controller
  139776. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  139777. * Consecutive calls to this function will cancel the last pulse call
  139778. *
  139779. * @param value the strength of the pulse in 0.0...1.0 range
  139780. * @param duration Duration of the pulse in milliseconds
  139781. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  139782. * @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
  139783. */
  139784. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  139785. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139786. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139787. /**
  139788. * Moves the axis on the controller mesh based on its current state
  139789. * @param axis the index of the axis
  139790. * @param axisValue the value of the axis which determines the meshes new position
  139791. * @hidden
  139792. */
  139793. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  139794. /**
  139795. * Update the model itself with the current frame data
  139796. * @param xrFrame the frame to use for updating the model mesh
  139797. */
  139798. protected updateModel(xrFrame: XRFrame): void;
  139799. /**
  139800. * Get the filename and path for this controller's model
  139801. * @returns a map of filename and path
  139802. */
  139803. protected abstract _getFilenameAndPath(): {
  139804. filename: string;
  139805. path: string;
  139806. };
  139807. /**
  139808. * This function is called before the mesh is loaded. It checks for loading constraints.
  139809. * For example, this function can check if the GLB loader is available
  139810. * If this function returns false, the generic controller will be loaded instead
  139811. * @returns Is the client ready to load the mesh
  139812. */
  139813. protected abstract _getModelLoadingConstraints(): boolean;
  139814. /**
  139815. * This function will be called after the model was successfully loaded and can be used
  139816. * for mesh transformations before it is available for the user
  139817. * @param meshes the loaded meshes
  139818. */
  139819. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  139820. /**
  139821. * Set the root mesh for this controller. Important for the WebXR controller class
  139822. * @param meshes the loaded meshes
  139823. */
  139824. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  139825. /**
  139826. * A function executed each frame that updates the mesh (if needed)
  139827. * @param xrFrame the current xrFrame
  139828. */
  139829. protected abstract _updateModel(xrFrame: XRFrame): void;
  139830. private _getGenericFilenameAndPath;
  139831. private _getGenericParentMesh;
  139832. }
  139833. }
  139834. declare module BABYLON {
  139835. /**
  139836. * A generic trigger-only motion controller for WebXR
  139837. */
  139838. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  139839. /**
  139840. * Static version of the profile id of this controller
  139841. */
  139842. static ProfileId: string;
  139843. profileId: string;
  139844. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  139845. protected _getFilenameAndPath(): {
  139846. filename: string;
  139847. path: string;
  139848. };
  139849. protected _getModelLoadingConstraints(): boolean;
  139850. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  139851. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139852. protected _updateModel(): void;
  139853. }
  139854. }
  139855. declare module BABYLON {
  139856. /**
  139857. * Class containing static functions to help procedurally build meshes
  139858. */
  139859. export class SphereBuilder {
  139860. /**
  139861. * Creates a sphere mesh
  139862. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139863. * * 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`)
  139864. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139865. * * 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
  139866. * * 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)
  139867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139870. * @param name defines the name of the mesh
  139871. * @param options defines the options used to create the mesh
  139872. * @param scene defines the hosting scene
  139873. * @returns the sphere mesh
  139874. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139875. */
  139876. static CreateSphere(name: string, options: {
  139877. segments?: number;
  139878. diameter?: number;
  139879. diameterX?: number;
  139880. diameterY?: number;
  139881. diameterZ?: number;
  139882. arc?: number;
  139883. slice?: number;
  139884. sideOrientation?: number;
  139885. frontUVs?: Vector4;
  139886. backUVs?: Vector4;
  139887. updatable?: boolean;
  139888. }, scene?: Nullable<Scene>): Mesh;
  139889. }
  139890. }
  139891. declare module BABYLON {
  139892. /**
  139893. * A profiled motion controller has its profile loaded from an online repository.
  139894. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  139895. */
  139896. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  139897. private _repositoryUrl;
  139898. private _buttonMeshMapping;
  139899. private _touchDots;
  139900. /**
  139901. * The profile ID of this controller. Will be populated when the controller initializes.
  139902. */
  139903. profileId: string;
  139904. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  139905. dispose(): void;
  139906. protected _getFilenameAndPath(): {
  139907. filename: string;
  139908. path: string;
  139909. };
  139910. protected _getModelLoadingConstraints(): boolean;
  139911. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  139912. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139913. protected _updateModel(_xrFrame: XRFrame): void;
  139914. }
  139915. }
  139916. declare module BABYLON {
  139917. /**
  139918. * A construction function type to create a new controller based on an xrInput object
  139919. */
  139920. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  139921. /**
  139922. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  139923. *
  139924. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  139925. * it should be replaced with auto-loaded controllers.
  139926. *
  139927. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  139928. */
  139929. export class WebXRMotionControllerManager {
  139930. private static _AvailableControllers;
  139931. private static _Fallbacks;
  139932. private static _ProfileLoadingPromises;
  139933. private static _ProfilesList;
  139934. /**
  139935. * The base URL of the online controller repository. Can be changed at any time.
  139936. */
  139937. static BaseRepositoryUrl: string;
  139938. /**
  139939. * Which repository gets priority - local or online
  139940. */
  139941. static PrioritizeOnlineRepository: boolean;
  139942. /**
  139943. * Use the online repository, or use only locally-defined controllers
  139944. */
  139945. static UseOnlineRepository: boolean;
  139946. /**
  139947. * Clear the cache used for profile loading and reload when requested again
  139948. */
  139949. static ClearProfilesCache(): void;
  139950. /**
  139951. * Register the default fallbacks.
  139952. * This function is called automatically when this file is imported.
  139953. */
  139954. static DefaultFallbacks(): void;
  139955. /**
  139956. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  139957. * @param profileId the profile to which a fallback needs to be found
  139958. * @return an array with corresponding fallback profiles
  139959. */
  139960. static FindFallbackWithProfileId(profileId: string): string[];
  139961. /**
  139962. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  139963. * The order of search:
  139964. *
  139965. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  139966. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  139967. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  139968. * 4) return the generic trigger controller if none were found
  139969. *
  139970. * @param xrInput the xrInput to which a new controller is initialized
  139971. * @param scene the scene to which the model will be added
  139972. * @param forceProfile force a certain profile for this controller
  139973. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  139974. */
  139975. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  139976. /**
  139977. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  139978. *
  139979. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  139980. *
  139981. * @param type the profile type to register
  139982. * @param constructFunction the function to be called when loading this profile
  139983. */
  139984. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  139985. /**
  139986. * Register a fallback to a specific profile.
  139987. * @param profileId the profileId that will receive the fallbacks
  139988. * @param fallbacks A list of fallback profiles
  139989. */
  139990. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  139991. /**
  139992. * Will update the list of profiles available in the repository
  139993. * @return a promise that resolves to a map of profiles available online
  139994. */
  139995. static UpdateProfilesList(): Promise<{
  139996. [profile: string]: string;
  139997. }>;
  139998. private static _LoadProfileFromRepository;
  139999. private static _LoadProfilesFromAvailableControllers;
  140000. }
  140001. }
  140002. declare module BABYLON {
  140003. /**
  140004. * Configuration options for the WebXR controller creation
  140005. */
  140006. export interface IWebXRControllerOptions {
  140007. /**
  140008. * Should the controller mesh be animated when a user interacts with it
  140009. * The pressed buttons / thumbstick and touchpad animations will be disabled
  140010. */
  140011. disableMotionControllerAnimation?: boolean;
  140012. /**
  140013. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  140014. */
  140015. doNotLoadControllerMesh?: boolean;
  140016. /**
  140017. * Force a specific controller type for this controller.
  140018. * This can be used when creating your own profile or when testing different controllers
  140019. */
  140020. forceControllerProfile?: string;
  140021. /**
  140022. * Defines a rendering group ID for meshes that will be loaded.
  140023. * This is for the default controllers only.
  140024. */
  140025. renderingGroupId?: number;
  140026. }
  140027. /**
  140028. * Represents an XR controller
  140029. */
  140030. export class WebXRInputSource {
  140031. private _scene;
  140032. /** The underlying input source for the controller */
  140033. inputSource: XRInputSource;
  140034. private _options;
  140035. private _tmpVector;
  140036. private _uniqueId;
  140037. private _disposed;
  140038. /**
  140039. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  140040. */
  140041. grip?: AbstractMesh;
  140042. /**
  140043. * If available, this is the gamepad object related to this controller.
  140044. * Using this object it is possible to get click events and trackpad changes of the
  140045. * webxr controller that is currently being used.
  140046. */
  140047. motionController?: WebXRAbstractMotionController;
  140048. /**
  140049. * Event that fires when the controller is removed/disposed.
  140050. * The object provided as event data is this controller, after associated assets were disposed.
  140051. * uniqueId is still available.
  140052. */
  140053. onDisposeObservable: Observable<WebXRInputSource>;
  140054. /**
  140055. * Will be triggered when the mesh associated with the motion controller is done loading.
  140056. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  140057. * A shortened version of controller -> motion controller -> on mesh loaded.
  140058. */
  140059. onMeshLoadedObservable: Observable<AbstractMesh>;
  140060. /**
  140061. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  140062. */
  140063. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  140064. /**
  140065. * Pointer which can be used to select objects or attach a visible laser to
  140066. */
  140067. pointer: AbstractMesh;
  140068. /**
  140069. * Creates the input source object
  140070. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  140071. * @param _scene the scene which the controller should be associated to
  140072. * @param inputSource the underlying input source for the controller
  140073. * @param _options options for this controller creation
  140074. */
  140075. constructor(_scene: Scene,
  140076. /** The underlying input source for the controller */
  140077. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  140078. /**
  140079. * Get this controllers unique id
  140080. */
  140081. get uniqueId(): string;
  140082. /**
  140083. * Disposes of the object
  140084. */
  140085. dispose(): void;
  140086. /**
  140087. * Gets a world space ray coming from the pointer or grip
  140088. * @param result the resulting ray
  140089. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  140090. */
  140091. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  140092. /**
  140093. * Updates the controller pose based on the given XRFrame
  140094. * @param xrFrame xr frame to update the pose with
  140095. * @param referenceSpace reference space to use
  140096. */
  140097. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  140098. }
  140099. }
  140100. declare module BABYLON {
  140101. /**
  140102. * The schema for initialization options of the XR Input class
  140103. */
  140104. export interface IWebXRInputOptions {
  140105. /**
  140106. * If set to true no model will be automatically loaded
  140107. */
  140108. doNotLoadControllerMeshes?: boolean;
  140109. /**
  140110. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  140111. * If not found, the xr input profile data will be used.
  140112. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  140113. */
  140114. forceInputProfile?: string;
  140115. /**
  140116. * Do not send a request to the controller repository to load the profile.
  140117. *
  140118. * Instead, use the controllers available in babylon itself.
  140119. */
  140120. disableOnlineControllerRepository?: boolean;
  140121. /**
  140122. * A custom URL for the controllers repository
  140123. */
  140124. customControllersRepositoryURL?: string;
  140125. /**
  140126. * Should the controller model's components not move according to the user input
  140127. */
  140128. disableControllerAnimation?: boolean;
  140129. /**
  140130. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  140131. */
  140132. controllerOptions?: IWebXRControllerOptions;
  140133. }
  140134. /**
  140135. * XR input used to track XR inputs such as controllers/rays
  140136. */
  140137. export class WebXRInput implements IDisposable {
  140138. /**
  140139. * the xr session manager for this session
  140140. */
  140141. xrSessionManager: WebXRSessionManager;
  140142. /**
  140143. * the WebXR camera for this session. Mainly used for teleportation
  140144. */
  140145. xrCamera: WebXRCamera;
  140146. private readonly options;
  140147. /**
  140148. * XR controllers being tracked
  140149. */
  140150. controllers: Array<WebXRInputSource>;
  140151. private _frameObserver;
  140152. private _sessionEndedObserver;
  140153. private _sessionInitObserver;
  140154. /**
  140155. * Event when a controller has been connected/added
  140156. */
  140157. onControllerAddedObservable: Observable<WebXRInputSource>;
  140158. /**
  140159. * Event when a controller has been removed/disconnected
  140160. */
  140161. onControllerRemovedObservable: Observable<WebXRInputSource>;
  140162. /**
  140163. * Initializes the WebXRInput
  140164. * @param xrSessionManager the xr session manager for this session
  140165. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  140166. * @param options = initialization options for this xr input
  140167. */
  140168. constructor(
  140169. /**
  140170. * the xr session manager for this session
  140171. */
  140172. xrSessionManager: WebXRSessionManager,
  140173. /**
  140174. * the WebXR camera for this session. Mainly used for teleportation
  140175. */
  140176. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  140177. private _onInputSourcesChange;
  140178. private _addAndRemoveControllers;
  140179. /**
  140180. * Disposes of the object
  140181. */
  140182. dispose(): void;
  140183. }
  140184. }
  140185. declare module BABYLON {
  140186. /**
  140187. * This is the base class for all WebXR features.
  140188. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  140189. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  140190. */
  140191. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  140192. protected _xrSessionManager: WebXRSessionManager;
  140193. private _attached;
  140194. private _removeOnDetach;
  140195. /**
  140196. * Is this feature disposed?
  140197. */
  140198. isDisposed: boolean;
  140199. /**
  140200. * Should auto-attach be disabled?
  140201. */
  140202. disableAutoAttach: boolean;
  140203. /**
  140204. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  140205. */
  140206. xrNativeFeatureName: string;
  140207. /**
  140208. * Construct a new (abstract) WebXR feature
  140209. * @param _xrSessionManager the xr session manager for this feature
  140210. */
  140211. constructor(_xrSessionManager: WebXRSessionManager);
  140212. /**
  140213. * Is this feature attached
  140214. */
  140215. get attached(): boolean;
  140216. /**
  140217. * attach this feature
  140218. *
  140219. * @param force should attachment be forced (even when already attached)
  140220. * @returns true if successful, false is failed or already attached
  140221. */
  140222. attach(force?: boolean): boolean;
  140223. /**
  140224. * detach this feature.
  140225. *
  140226. * @returns true if successful, false if failed or already detached
  140227. */
  140228. detach(): boolean;
  140229. /**
  140230. * Dispose this feature and all of the resources attached
  140231. */
  140232. dispose(): void;
  140233. /**
  140234. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  140235. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  140236. *
  140237. * @returns whether or not the feature is compatible in this environment
  140238. */
  140239. isCompatible(): boolean;
  140240. /**
  140241. * This is used to register callbacks that will automatically be removed when detach is called.
  140242. * @param observable the observable to which the observer will be attached
  140243. * @param callback the callback to register
  140244. */
  140245. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  140246. /**
  140247. * Code in this function will be executed on each xrFrame received from the browser.
  140248. * This function will not execute after the feature is detached.
  140249. * @param _xrFrame the current frame
  140250. */
  140251. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  140252. }
  140253. }
  140254. declare module BABYLON {
  140255. /**
  140256. * Renders a layer on top of an existing scene
  140257. */
  140258. export class UtilityLayerRenderer implements IDisposable {
  140259. /** the original scene that will be rendered on top of */
  140260. originalScene: Scene;
  140261. private _pointerCaptures;
  140262. private _lastPointerEvents;
  140263. private static _DefaultUtilityLayer;
  140264. private static _DefaultKeepDepthUtilityLayer;
  140265. private _sharedGizmoLight;
  140266. private _renderCamera;
  140267. /**
  140268. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  140269. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  140270. * @returns the camera that is used when rendering the utility layer
  140271. */
  140272. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  140273. /**
  140274. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  140275. * @param cam the camera that should be used when rendering the utility layer
  140276. */
  140277. setRenderCamera(cam: Nullable<Camera>): void;
  140278. /**
  140279. * @hidden
  140280. * Light which used by gizmos to get light shading
  140281. */
  140282. _getSharedGizmoLight(): HemisphericLight;
  140283. /**
  140284. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  140285. */
  140286. pickUtilitySceneFirst: boolean;
  140287. /**
  140288. * 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)
  140289. */
  140290. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  140291. /**
  140292. * 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)
  140293. */
  140294. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  140295. /**
  140296. * The scene that is rendered on top of the original scene
  140297. */
  140298. utilityLayerScene: Scene;
  140299. /**
  140300. * If the utility layer should automatically be rendered on top of existing scene
  140301. */
  140302. shouldRender: boolean;
  140303. /**
  140304. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  140305. */
  140306. onlyCheckPointerDownEvents: boolean;
  140307. /**
  140308. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  140309. */
  140310. processAllEvents: boolean;
  140311. /**
  140312. * Observable raised when the pointer move from the utility layer scene to the main scene
  140313. */
  140314. onPointerOutObservable: Observable<number>;
  140315. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  140316. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  140317. private _afterRenderObserver;
  140318. private _sceneDisposeObserver;
  140319. private _originalPointerObserver;
  140320. /**
  140321. * Instantiates a UtilityLayerRenderer
  140322. * @param originalScene the original scene that will be rendered on top of
  140323. * @param handleEvents boolean indicating if the utility layer should handle events
  140324. */
  140325. constructor(
  140326. /** the original scene that will be rendered on top of */
  140327. originalScene: Scene, handleEvents?: boolean);
  140328. private _notifyObservers;
  140329. /**
  140330. * Renders the utility layers scene on top of the original scene
  140331. */
  140332. render(): void;
  140333. /**
  140334. * Disposes of the renderer
  140335. */
  140336. dispose(): void;
  140337. private _updateCamera;
  140338. }
  140339. }
  140340. declare module BABYLON {
  140341. /**
  140342. * Options interface for the pointer selection module
  140343. */
  140344. export interface IWebXRControllerPointerSelectionOptions {
  140345. /**
  140346. * if provided, this scene will be used to render meshes.
  140347. */
  140348. customUtilityLayerScene?: Scene;
  140349. /**
  140350. * 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)
  140351. * If not disabled, the last picked point will be used to execute a pointer up event
  140352. * If disabled, pointer up event will be triggered right after the pointer down event.
  140353. * Used in screen and gaze target ray mode only
  140354. */
  140355. disablePointerUpOnTouchOut: boolean;
  140356. /**
  140357. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  140358. */
  140359. forceGazeMode: boolean;
  140360. /**
  140361. * 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
  140362. * to start a new countdown to the pointer down event.
  140363. * Defaults to 1.
  140364. */
  140365. gazeModePointerMovedFactor?: number;
  140366. /**
  140367. * Different button type to use instead of the main component
  140368. */
  140369. overrideButtonId?: string;
  140370. /**
  140371. * use this rendering group id for the meshes (optional)
  140372. */
  140373. renderingGroupId?: number;
  140374. /**
  140375. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  140376. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  140377. * 3000 means 3 seconds between pointing at something and selecting it
  140378. */
  140379. timeToSelect?: number;
  140380. /**
  140381. * Should meshes created here be added to a utility layer or the main scene
  140382. */
  140383. useUtilityLayer?: boolean;
  140384. /**
  140385. * Optional WebXR camera to be used for gaze selection
  140386. */
  140387. gazeCamera?: WebXRCamera;
  140388. /**
  140389. * the xr input to use with this pointer selection
  140390. */
  140391. xrInput: WebXRInput;
  140392. /**
  140393. * Should the scene pointerX and pointerY update be disabled
  140394. * This is required for fullscreen AR GUI, but might slow down other experiences.
  140395. * Disable in VR, if not needed.
  140396. * The first rig camera (left eye) will be used to calculate the projection
  140397. */
  140398. disableScenePointerVectorUpdate: boolean;
  140399. /**
  140400. * Enable pointer selection on all controllers instead of switching between them
  140401. */
  140402. enablePointerSelectionOnAllControllers?: boolean;
  140403. /**
  140404. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  140405. * If switch is enabled, it will still allow the user to switch between the different controllers
  140406. */
  140407. preferredHandedness?: XRHandedness;
  140408. /**
  140409. * Disable switching the pointer selection from one controller to the other.
  140410. * 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
  140411. */
  140412. disableSwitchOnClick?: boolean;
  140413. /**
  140414. * The maximum distance of the pointer selection feature. Defaults to 100.
  140415. */
  140416. maxPointerDistance?: number;
  140417. }
  140418. /**
  140419. * A module that will enable pointer selection for motion controllers of XR Input Sources
  140420. */
  140421. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  140422. private readonly _options;
  140423. private static _idCounter;
  140424. private _attachController;
  140425. private _controllers;
  140426. private _scene;
  140427. private _tmpVectorForPickCompare;
  140428. private _attachedController;
  140429. /**
  140430. * The module's name
  140431. */
  140432. static readonly Name: string;
  140433. /**
  140434. * The (Babylon) version of this module.
  140435. * This is an integer representing the implementation version.
  140436. * This number does not correspond to the WebXR specs version
  140437. */
  140438. static readonly Version: number;
  140439. /**
  140440. * Disable lighting on the laser pointer (so it will always be visible)
  140441. */
  140442. disablePointerLighting: boolean;
  140443. /**
  140444. * Disable lighting on the selection mesh (so it will always be visible)
  140445. */
  140446. disableSelectionMeshLighting: boolean;
  140447. /**
  140448. * Should the laser pointer be displayed
  140449. */
  140450. displayLaserPointer: boolean;
  140451. /**
  140452. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  140453. */
  140454. displaySelectionMesh: boolean;
  140455. /**
  140456. * This color will be set to the laser pointer when selection is triggered
  140457. */
  140458. laserPointerPickedColor: Color3;
  140459. /**
  140460. * Default color of the laser pointer
  140461. */
  140462. laserPointerDefaultColor: Color3;
  140463. /**
  140464. * default color of the selection ring
  140465. */
  140466. selectionMeshDefaultColor: Color3;
  140467. /**
  140468. * This color will be applied to the selection ring when selection is triggered
  140469. */
  140470. selectionMeshPickedColor: Color3;
  140471. /**
  140472. * Optional filter to be used for ray selection. This predicate shares behavior with
  140473. * scene.pointerMovePredicate which takes priority if it is also assigned.
  140474. */
  140475. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  140476. /**
  140477. * constructs a new background remover module
  140478. * @param _xrSessionManager the session manager for this module
  140479. * @param _options read-only options to be used in this module
  140480. */
  140481. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  140482. /**
  140483. * attach this feature
  140484. * Will usually be called by the features manager
  140485. *
  140486. * @returns true if successful.
  140487. */
  140488. attach(): boolean;
  140489. /**
  140490. * detach this feature.
  140491. * Will usually be called by the features manager
  140492. *
  140493. * @returns true if successful.
  140494. */
  140495. detach(): boolean;
  140496. /**
  140497. * Will get the mesh under a specific pointer.
  140498. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  140499. * @param controllerId the controllerId to check
  140500. * @returns The mesh under pointer or null if no mesh is under the pointer
  140501. */
  140502. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  140503. /**
  140504. * Get the xr controller that correlates to the pointer id in the pointer event
  140505. *
  140506. * @param id the pointer id to search for
  140507. * @returns the controller that correlates to this id or null if not found
  140508. */
  140509. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  140510. private _identityMatrix;
  140511. private _screenCoordinatesRef;
  140512. private _viewportRef;
  140513. protected _onXRFrame(_xrFrame: XRFrame): void;
  140514. private _attachGazeMode;
  140515. private _attachScreenRayMode;
  140516. private _attachTrackedPointerRayMode;
  140517. private _convertNormalToDirectionOfRay;
  140518. private _detachController;
  140519. private _generateNewMeshPair;
  140520. private _pickingMoved;
  140521. private _updatePointerDistance;
  140522. /** @hidden */
  140523. get lasterPointerDefaultColor(): Color3;
  140524. }
  140525. }
  140526. declare module BABYLON {
  140527. /**
  140528. * Button which can be used to enter a different mode of XR
  140529. */
  140530. export class WebXREnterExitUIButton {
  140531. /** button element */
  140532. element: HTMLElement;
  140533. /** XR initialization options for the button */
  140534. sessionMode: XRSessionMode;
  140535. /** Reference space type */
  140536. referenceSpaceType: XRReferenceSpaceType;
  140537. /**
  140538. * Creates a WebXREnterExitUIButton
  140539. * @param element button element
  140540. * @param sessionMode XR initialization session mode
  140541. * @param referenceSpaceType the type of reference space to be used
  140542. */
  140543. constructor(
  140544. /** button element */
  140545. element: HTMLElement,
  140546. /** XR initialization options for the button */
  140547. sessionMode: XRSessionMode,
  140548. /** Reference space type */
  140549. referenceSpaceType: XRReferenceSpaceType);
  140550. /**
  140551. * Extendable function which can be used to update the button's visuals when the state changes
  140552. * @param activeButton the current active button in the UI
  140553. */
  140554. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  140555. }
  140556. /**
  140557. * Options to create the webXR UI
  140558. */
  140559. export class WebXREnterExitUIOptions {
  140560. /**
  140561. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  140562. */
  140563. customButtons?: Array<WebXREnterExitUIButton>;
  140564. /**
  140565. * A reference space type to use when creating the default button.
  140566. * Default is local-floor
  140567. */
  140568. referenceSpaceType?: XRReferenceSpaceType;
  140569. /**
  140570. * Context to enter xr with
  140571. */
  140572. renderTarget?: Nullable<WebXRRenderTarget>;
  140573. /**
  140574. * A session mode to use when creating the default button.
  140575. * Default is immersive-vr
  140576. */
  140577. sessionMode?: XRSessionMode;
  140578. /**
  140579. * A list of optional features to init the session with
  140580. */
  140581. optionalFeatures?: string[];
  140582. /**
  140583. * A list of optional features to init the session with
  140584. */
  140585. requiredFeatures?: string[];
  140586. /**
  140587. * If defined, this function will be executed if the UI encounters an error when entering XR
  140588. */
  140589. onError?: (error: any) => void;
  140590. }
  140591. /**
  140592. * UI to allow the user to enter/exit XR mode
  140593. */
  140594. export class WebXREnterExitUI implements IDisposable {
  140595. private scene;
  140596. /** version of the options passed to this UI */
  140597. options: WebXREnterExitUIOptions;
  140598. private _activeButton;
  140599. private _buttons;
  140600. /**
  140601. * The HTML Div Element to which buttons are added.
  140602. */
  140603. readonly overlay: HTMLDivElement;
  140604. /**
  140605. * Fired every time the active button is changed.
  140606. *
  140607. * When xr is entered via a button that launches xr that button will be the callback parameter
  140608. *
  140609. * When exiting xr the callback parameter will be null)
  140610. */
  140611. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  140612. /**
  140613. *
  140614. * @param scene babylon scene object to use
  140615. * @param options (read-only) version of the options passed to this UI
  140616. */
  140617. private constructor();
  140618. /**
  140619. * Creates UI to allow the user to enter/exit XR mode
  140620. * @param scene the scene to add the ui to
  140621. * @param helper the xr experience helper to enter/exit xr with
  140622. * @param options options to configure the UI
  140623. * @returns the created ui
  140624. */
  140625. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  140626. /**
  140627. * Disposes of the XR UI component
  140628. */
  140629. dispose(): void;
  140630. private _updateButtons;
  140631. }
  140632. }
  140633. declare module BABYLON {
  140634. /**
  140635. * Class containing static functions to help procedurally build meshes
  140636. */
  140637. export class LinesBuilder {
  140638. /**
  140639. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  140640. * * 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
  140641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  140642. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  140643. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  140644. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  140645. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140646. * * 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
  140647. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  140648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  140650. * @param name defines the name of the new line system
  140651. * @param options defines the options used to create the line system
  140652. * @param scene defines the hosting scene
  140653. * @returns a new line system mesh
  140654. */
  140655. static CreateLineSystem(name: string, options: {
  140656. lines: Vector3[][];
  140657. updatable?: boolean;
  140658. instance?: Nullable<LinesMesh>;
  140659. colors?: Nullable<Color4[][]>;
  140660. useVertexAlpha?: boolean;
  140661. }, scene: Nullable<Scene>): LinesMesh;
  140662. /**
  140663. * Creates a line mesh
  140664. * 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
  140665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140666. * * The parameter `points` is an array successive Vector3
  140667. * * 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
  140668. * * The optional parameter `colors` is an array of successive Color4, one per line point
  140669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  140670. * * When updating an instance, remember that only point positions can change, not the number of points
  140671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  140673. * @param name defines the name of the new line system
  140674. * @param options defines the options used to create the line system
  140675. * @param scene defines the hosting scene
  140676. * @returns a new line mesh
  140677. */
  140678. static CreateLines(name: string, options: {
  140679. points: Vector3[];
  140680. updatable?: boolean;
  140681. instance?: Nullable<LinesMesh>;
  140682. colors?: Color4[];
  140683. useVertexAlpha?: boolean;
  140684. }, scene?: Nullable<Scene>): LinesMesh;
  140685. /**
  140686. * Creates a dashed line mesh
  140687. * * 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
  140688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140689. * * The parameter `points` is an array successive Vector3
  140690. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  140691. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  140692. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  140693. * * 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
  140694. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140695. * * When updating an instance, remember that only point positions can change, not the number of points
  140696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140697. * @param name defines the name of the mesh
  140698. * @param options defines the options used to create the mesh
  140699. * @param scene defines the hosting scene
  140700. * @returns the dashed line mesh
  140701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  140702. */
  140703. static CreateDashedLines(name: string, options: {
  140704. points: Vector3[];
  140705. dashSize?: number;
  140706. gapSize?: number;
  140707. dashNb?: number;
  140708. updatable?: boolean;
  140709. instance?: LinesMesh;
  140710. useVertexAlpha?: boolean;
  140711. }, scene?: Nullable<Scene>): LinesMesh;
  140712. }
  140713. }
  140714. declare module BABYLON {
  140715. /**
  140716. * Construction options for a timer
  140717. */
  140718. export interface ITimerOptions<T> {
  140719. /**
  140720. * Time-to-end
  140721. */
  140722. timeout: number;
  140723. /**
  140724. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  140725. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  140726. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  140727. */
  140728. contextObservable: Observable<T>;
  140729. /**
  140730. * Optional parameters when adding an observer to the observable
  140731. */
  140732. observableParameters?: {
  140733. mask?: number;
  140734. insertFirst?: boolean;
  140735. scope?: any;
  140736. };
  140737. /**
  140738. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  140739. */
  140740. breakCondition?: (data?: ITimerData<T>) => boolean;
  140741. /**
  140742. * Will be triggered when the time condition has met
  140743. */
  140744. onEnded?: (data: ITimerData<any>) => void;
  140745. /**
  140746. * Will be triggered when the break condition has met (prematurely ended)
  140747. */
  140748. onAborted?: (data: ITimerData<any>) => void;
  140749. /**
  140750. * Optional function to execute on each tick (or count)
  140751. */
  140752. onTick?: (data: ITimerData<any>) => void;
  140753. }
  140754. /**
  140755. * An interface defining the data sent by the timer
  140756. */
  140757. export interface ITimerData<T> {
  140758. /**
  140759. * When did it start
  140760. */
  140761. startTime: number;
  140762. /**
  140763. * Time now
  140764. */
  140765. currentTime: number;
  140766. /**
  140767. * Time passed since started
  140768. */
  140769. deltaTime: number;
  140770. /**
  140771. * How much is completed, in [0.0...1.0].
  140772. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  140773. */
  140774. completeRate: number;
  140775. /**
  140776. * What the registered observable sent in the last count
  140777. */
  140778. payload: T;
  140779. }
  140780. /**
  140781. * The current state of the timer
  140782. */
  140783. export enum TimerState {
  140784. /**
  140785. * Timer initialized, not yet started
  140786. */
  140787. INIT = 0,
  140788. /**
  140789. * Timer started and counting
  140790. */
  140791. STARTED = 1,
  140792. /**
  140793. * Timer ended (whether aborted or time reached)
  140794. */
  140795. ENDED = 2
  140796. }
  140797. /**
  140798. * A simple version of the timer. Will take options and start the timer immediately after calling it
  140799. *
  140800. * @param options options with which to initialize this timer
  140801. */
  140802. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  140803. /**
  140804. * An advanced implementation of a timer class
  140805. */
  140806. export class AdvancedTimer<T = any> implements IDisposable {
  140807. /**
  140808. * Will notify each time the timer calculates the remaining time
  140809. */
  140810. onEachCountObservable: Observable<ITimerData<T>>;
  140811. /**
  140812. * Will trigger when the timer was aborted due to the break condition
  140813. */
  140814. onTimerAbortedObservable: Observable<ITimerData<T>>;
  140815. /**
  140816. * Will trigger when the timer ended successfully
  140817. */
  140818. onTimerEndedObservable: Observable<ITimerData<T>>;
  140819. /**
  140820. * Will trigger when the timer state has changed
  140821. */
  140822. onStateChangedObservable: Observable<TimerState>;
  140823. private _observer;
  140824. private _contextObservable;
  140825. private _observableParameters;
  140826. private _startTime;
  140827. private _timer;
  140828. private _state;
  140829. private _breakCondition;
  140830. private _timeToEnd;
  140831. private _breakOnNextTick;
  140832. /**
  140833. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  140834. * @param options construction options for this advanced timer
  140835. */
  140836. constructor(options: ITimerOptions<T>);
  140837. /**
  140838. * set a breaking condition for this timer. Default is to never break during count
  140839. * @param predicate the new break condition. Returns true to break, false otherwise
  140840. */
  140841. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  140842. /**
  140843. * Reset ALL associated observables in this advanced timer
  140844. */
  140845. clearObservables(): void;
  140846. /**
  140847. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  140848. *
  140849. * @param timeToEnd how much time to measure until timer ended
  140850. */
  140851. start(timeToEnd?: number): void;
  140852. /**
  140853. * Will force a stop on the next tick.
  140854. */
  140855. stop(): void;
  140856. /**
  140857. * Dispose this timer, clearing all resources
  140858. */
  140859. dispose(): void;
  140860. private _setState;
  140861. private _tick;
  140862. private _stop;
  140863. }
  140864. }
  140865. declare module BABYLON {
  140866. /**
  140867. * The options container for the teleportation module
  140868. */
  140869. export interface IWebXRTeleportationOptions {
  140870. /**
  140871. * if provided, this scene will be used to render meshes.
  140872. */
  140873. customUtilityLayerScene?: Scene;
  140874. /**
  140875. * Values to configure the default target mesh
  140876. */
  140877. defaultTargetMeshOptions?: {
  140878. /**
  140879. * Fill color of the teleportation area
  140880. */
  140881. teleportationFillColor?: string;
  140882. /**
  140883. * Border color for the teleportation area
  140884. */
  140885. teleportationBorderColor?: string;
  140886. /**
  140887. * Disable the mesh's animation sequence
  140888. */
  140889. disableAnimation?: boolean;
  140890. /**
  140891. * Disable lighting on the material or the ring and arrow
  140892. */
  140893. disableLighting?: boolean;
  140894. /**
  140895. * Override the default material of the torus and arrow
  140896. */
  140897. torusArrowMaterial?: Material;
  140898. };
  140899. /**
  140900. * A list of meshes to use as floor meshes.
  140901. * Meshes can be added and removed after initializing the feature using the
  140902. * addFloorMesh and removeFloorMesh functions
  140903. * If empty, rotation will still work
  140904. */
  140905. floorMeshes?: AbstractMesh[];
  140906. /**
  140907. * use this rendering group id for the meshes (optional)
  140908. */
  140909. renderingGroupId?: number;
  140910. /**
  140911. * Should teleportation move only to snap points
  140912. */
  140913. snapPointsOnly?: boolean;
  140914. /**
  140915. * An array of points to which the teleportation will snap to.
  140916. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  140917. */
  140918. snapPositions?: Vector3[];
  140919. /**
  140920. * How close should the teleportation ray be in order to snap to position.
  140921. * Default to 0.8 units (meters)
  140922. */
  140923. snapToPositionRadius?: number;
  140924. /**
  140925. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  140926. * If you want to support rotation, make sure your mesh has a direction indicator.
  140927. *
  140928. * When left untouched, the default mesh will be initialized.
  140929. */
  140930. teleportationTargetMesh?: AbstractMesh;
  140931. /**
  140932. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  140933. */
  140934. timeToTeleport?: number;
  140935. /**
  140936. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  140937. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  140938. */
  140939. useMainComponentOnly?: boolean;
  140940. /**
  140941. * Should meshes created here be added to a utility layer or the main scene
  140942. */
  140943. useUtilityLayer?: boolean;
  140944. /**
  140945. * Babylon XR Input class for controller
  140946. */
  140947. xrInput: WebXRInput;
  140948. /**
  140949. * Meshes that the teleportation ray cannot go through
  140950. */
  140951. pickBlockerMeshes?: AbstractMesh[];
  140952. /**
  140953. * Should teleport work only on a specific hand?
  140954. */
  140955. forceHandedness?: XRHandedness;
  140956. /**
  140957. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  140958. */
  140959. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  140960. }
  140961. /**
  140962. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  140963. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  140964. * the input of the attached controllers.
  140965. */
  140966. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  140967. private _options;
  140968. private _controllers;
  140969. private _currentTeleportationControllerId;
  140970. private _floorMeshes;
  140971. private _quadraticBezierCurve;
  140972. private _selectionFeature;
  140973. private _snapToPositions;
  140974. private _snappedToPoint;
  140975. private _teleportationRingMaterial?;
  140976. private _tmpRay;
  140977. private _tmpVector;
  140978. private _tmpQuaternion;
  140979. /**
  140980. * The module's name
  140981. */
  140982. static readonly Name: string;
  140983. /**
  140984. * The (Babylon) version of this module.
  140985. * This is an integer representing the implementation version.
  140986. * This number does not correspond to the webxr specs version
  140987. */
  140988. static readonly Version: number;
  140989. /**
  140990. * Is movement backwards enabled
  140991. */
  140992. backwardsMovementEnabled: boolean;
  140993. /**
  140994. * Distance to travel when moving backwards
  140995. */
  140996. backwardsTeleportationDistance: number;
  140997. /**
  140998. * The distance from the user to the inspection point in the direction of the controller
  140999. * A higher number will allow the user to move further
  141000. * defaults to 5 (meters, in xr units)
  141001. */
  141002. parabolicCheckRadius: number;
  141003. /**
  141004. * Should the module support parabolic ray on top of direct ray
  141005. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  141006. * Very helpful when moving between floors / different heights
  141007. */
  141008. parabolicRayEnabled: boolean;
  141009. /**
  141010. * The second type of ray - straight line.
  141011. * Should it be enabled or should the parabolic line be the only one.
  141012. */
  141013. straightRayEnabled: boolean;
  141014. /**
  141015. * How much rotation should be applied when rotating right and left
  141016. */
  141017. rotationAngle: number;
  141018. private _rotationEnabled;
  141019. /**
  141020. * Is rotation enabled when moving forward?
  141021. * Disabling this feature will prevent the user from deciding the direction when teleporting
  141022. */
  141023. get rotationEnabled(): boolean;
  141024. /**
  141025. * Sets wether rotation is enabled or not
  141026. * @param enabled is rotation enabled when teleportation is shown
  141027. */
  141028. set rotationEnabled(enabled: boolean);
  141029. /**
  141030. * Exposes the currently set teleportation target mesh.
  141031. */
  141032. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  141033. /**
  141034. * constructs a new anchor system
  141035. * @param _xrSessionManager an instance of WebXRSessionManager
  141036. * @param _options configuration object for this feature
  141037. */
  141038. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  141039. /**
  141040. * Get the snapPointsOnly flag
  141041. */
  141042. get snapPointsOnly(): boolean;
  141043. /**
  141044. * Sets the snapPointsOnly flag
  141045. * @param snapToPoints should teleportation be exclusively to snap points
  141046. */
  141047. set snapPointsOnly(snapToPoints: boolean);
  141048. /**
  141049. * Add a new mesh to the floor meshes array
  141050. * @param mesh the mesh to use as floor mesh
  141051. */
  141052. addFloorMesh(mesh: AbstractMesh): void;
  141053. /**
  141054. * Add a new snap-to point to fix teleportation to this position
  141055. * @param newSnapPoint The new Snap-To point
  141056. */
  141057. addSnapPoint(newSnapPoint: Vector3): void;
  141058. attach(): boolean;
  141059. detach(): boolean;
  141060. dispose(): void;
  141061. /**
  141062. * Remove a mesh from the floor meshes array
  141063. * @param mesh the mesh to remove
  141064. */
  141065. removeFloorMesh(mesh: AbstractMesh): void;
  141066. /**
  141067. * Remove a mesh from the floor meshes array using its name
  141068. * @param name the mesh name to remove
  141069. */
  141070. removeFloorMeshByName(name: string): void;
  141071. /**
  141072. * 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
  141073. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  141074. * @returns was the point found and removed or not
  141075. */
  141076. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  141077. /**
  141078. * This function sets a selection feature that will be disabled when
  141079. * the forward ray is shown and will be reattached when hidden.
  141080. * This is used to remove the selection rays when moving.
  141081. * @param selectionFeature the feature to disable when forward movement is enabled
  141082. */
  141083. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  141084. protected _onXRFrame(_xrFrame: XRFrame): void;
  141085. private _attachController;
  141086. private _createDefaultTargetMesh;
  141087. private _detachController;
  141088. private _findClosestSnapPointWithRadius;
  141089. private _setTargetMeshPosition;
  141090. private _setTargetMeshVisibility;
  141091. private _showParabolicPath;
  141092. private _teleportForward;
  141093. }
  141094. }
  141095. declare module BABYLON {
  141096. /**
  141097. * Options for the default xr helper
  141098. */
  141099. export class WebXRDefaultExperienceOptions {
  141100. /**
  141101. * Enable or disable default UI to enter XR
  141102. */
  141103. disableDefaultUI?: boolean;
  141104. /**
  141105. * Should teleportation not initialize. defaults to false.
  141106. */
  141107. disableTeleportation?: boolean;
  141108. /**
  141109. * Floor meshes that will be used for teleport
  141110. */
  141111. floorMeshes?: Array<AbstractMesh>;
  141112. /**
  141113. * If set to true, the first frame will not be used to reset position
  141114. * The first frame is mainly used when copying transformation from the old camera
  141115. * Mainly used in AR
  141116. */
  141117. ignoreNativeCameraTransformation?: boolean;
  141118. /**
  141119. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  141120. */
  141121. inputOptions?: IWebXRInputOptions;
  141122. /**
  141123. * optional configuration for the output canvas
  141124. */
  141125. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  141126. /**
  141127. * optional UI options. This can be used among other to change session mode and reference space type
  141128. */
  141129. uiOptions?: WebXREnterExitUIOptions;
  141130. /**
  141131. * When loading teleportation and pointer select, use stable versions instead of latest.
  141132. */
  141133. useStablePlugins?: boolean;
  141134. /**
  141135. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  141136. */
  141137. renderingGroupId?: number;
  141138. /**
  141139. * A list of optional features to init the session with
  141140. * If set to true, all features we support will be added
  141141. */
  141142. optionalFeatures?: boolean | string[];
  141143. }
  141144. /**
  141145. * Default experience which provides a similar setup to the previous webVRExperience
  141146. */
  141147. export class WebXRDefaultExperience {
  141148. /**
  141149. * Base experience
  141150. */
  141151. baseExperience: WebXRExperienceHelper;
  141152. /**
  141153. * Enables ui for entering/exiting xr
  141154. */
  141155. enterExitUI: WebXREnterExitUI;
  141156. /**
  141157. * Input experience extension
  141158. */
  141159. input: WebXRInput;
  141160. /**
  141161. * Enables laser pointer and selection
  141162. */
  141163. pointerSelection: WebXRControllerPointerSelection;
  141164. /**
  141165. * Default target xr should render to
  141166. */
  141167. renderTarget: WebXRRenderTarget;
  141168. /**
  141169. * Enables teleportation
  141170. */
  141171. teleportation: WebXRMotionControllerTeleportation;
  141172. private constructor();
  141173. /**
  141174. * Creates the default xr experience
  141175. * @param scene scene
  141176. * @param options options for basic configuration
  141177. * @returns resulting WebXRDefaultExperience
  141178. */
  141179. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  141180. /**
  141181. * DIsposes of the experience helper
  141182. */
  141183. dispose(): void;
  141184. }
  141185. }
  141186. declare module BABYLON {
  141187. /**
  141188. * Options to modify the vr teleportation behavior.
  141189. */
  141190. export interface VRTeleportationOptions {
  141191. /**
  141192. * The name of the mesh which should be used as the teleportation floor. (default: null)
  141193. */
  141194. floorMeshName?: string;
  141195. /**
  141196. * A list of meshes to be used as the teleportation floor. (default: empty)
  141197. */
  141198. floorMeshes?: Mesh[];
  141199. /**
  141200. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  141201. */
  141202. teleportationMode?: number;
  141203. /**
  141204. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  141205. */
  141206. teleportationTime?: number;
  141207. /**
  141208. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  141209. */
  141210. teleportationSpeed?: number;
  141211. /**
  141212. * The easing function used in the animation or null for Linear. (default CircleEase)
  141213. */
  141214. easingFunction?: EasingFunction;
  141215. }
  141216. /**
  141217. * Options to modify the vr experience helper's behavior.
  141218. */
  141219. export interface VRExperienceHelperOptions extends WebVROptions {
  141220. /**
  141221. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  141222. */
  141223. createDeviceOrientationCamera?: boolean;
  141224. /**
  141225. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  141226. */
  141227. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  141228. /**
  141229. * Uses the main button on the controller to toggle the laser casted. (default: true)
  141230. */
  141231. laserToggle?: boolean;
  141232. /**
  141233. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  141234. */
  141235. floorMeshes?: Mesh[];
  141236. /**
  141237. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  141238. */
  141239. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  141240. /**
  141241. * Defines if WebXR should be used instead of WebVR (if available)
  141242. */
  141243. useXR?: boolean;
  141244. }
  141245. /**
  141246. * Event containing information after VR has been entered
  141247. */
  141248. export class OnAfterEnteringVRObservableEvent {
  141249. /**
  141250. * If entering vr was successful
  141251. */
  141252. success: boolean;
  141253. }
  141254. /**
  141255. * Helps to quickly add VR support to an existing scene.
  141256. * See https://doc.babylonjs.com/how_to/webvr_helper
  141257. */
  141258. export class VRExperienceHelper {
  141259. /** Options to modify the vr experience helper's behavior. */
  141260. webVROptions: VRExperienceHelperOptions;
  141261. private _scene;
  141262. private _position;
  141263. private _btnVR;
  141264. private _btnVRDisplayed;
  141265. private _webVRsupported;
  141266. private _webVRready;
  141267. private _webVRrequesting;
  141268. private _webVRpresenting;
  141269. private _hasEnteredVR;
  141270. private _fullscreenVRpresenting;
  141271. private _inputElement;
  141272. private _webVRCamera;
  141273. private _vrDeviceOrientationCamera;
  141274. private _deviceOrientationCamera;
  141275. private _existingCamera;
  141276. private _onKeyDown;
  141277. private _onVrDisplayPresentChange;
  141278. private _onVRDisplayChanged;
  141279. private _onVRRequestPresentStart;
  141280. private _onVRRequestPresentComplete;
  141281. /**
  141282. * 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)
  141283. */
  141284. enableGazeEvenWhenNoPointerLock: boolean;
  141285. /**
  141286. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  141287. */
  141288. exitVROnDoubleTap: boolean;
  141289. /**
  141290. * Observable raised right before entering VR.
  141291. */
  141292. onEnteringVRObservable: Observable<VRExperienceHelper>;
  141293. /**
  141294. * Observable raised when entering VR has completed.
  141295. */
  141296. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  141297. /**
  141298. * Observable raised when exiting VR.
  141299. */
  141300. onExitingVRObservable: Observable<VRExperienceHelper>;
  141301. /**
  141302. * Observable raised when controller mesh is loaded.
  141303. */
  141304. onControllerMeshLoadedObservable: Observable<WebVRController>;
  141305. /** Return this.onEnteringVRObservable
  141306. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  141307. */
  141308. get onEnteringVR(): Observable<VRExperienceHelper>;
  141309. /** Return this.onExitingVRObservable
  141310. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  141311. */
  141312. get onExitingVR(): Observable<VRExperienceHelper>;
  141313. /** Return this.onControllerMeshLoadedObservable
  141314. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  141315. */
  141316. get onControllerMeshLoaded(): Observable<WebVRController>;
  141317. private _rayLength;
  141318. private _useCustomVRButton;
  141319. private _teleportationRequested;
  141320. private _teleportActive;
  141321. private _floorMeshName;
  141322. private _floorMeshesCollection;
  141323. private _teleportationMode;
  141324. private _teleportationTime;
  141325. private _teleportationSpeed;
  141326. private _teleportationEasing;
  141327. private _rotationAllowed;
  141328. private _teleportBackwardsVector;
  141329. private _teleportationTarget;
  141330. private _isDefaultTeleportationTarget;
  141331. private _postProcessMove;
  141332. private _teleportationFillColor;
  141333. private _teleportationBorderColor;
  141334. private _rotationAngle;
  141335. private _haloCenter;
  141336. private _cameraGazer;
  141337. private _padSensibilityUp;
  141338. private _padSensibilityDown;
  141339. private _leftController;
  141340. private _rightController;
  141341. private _gazeColor;
  141342. private _laserColor;
  141343. private _pickedLaserColor;
  141344. private _pickedGazeColor;
  141345. /**
  141346. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  141347. */
  141348. onNewMeshSelected: Observable<AbstractMesh>;
  141349. /**
  141350. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  141351. * This observable will provide the mesh and the controller used to select the mesh
  141352. */
  141353. onMeshSelectedWithController: Observable<{
  141354. mesh: AbstractMesh;
  141355. controller: WebVRController;
  141356. }>;
  141357. /**
  141358. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  141359. */
  141360. onNewMeshPicked: Observable<PickingInfo>;
  141361. private _circleEase;
  141362. /**
  141363. * Observable raised before camera teleportation
  141364. */
  141365. onBeforeCameraTeleport: Observable<Vector3>;
  141366. /**
  141367. * Observable raised after camera teleportation
  141368. */
  141369. onAfterCameraTeleport: Observable<Vector3>;
  141370. /**
  141371. * Observable raised when current selected mesh gets unselected
  141372. */
  141373. onSelectedMeshUnselected: Observable<AbstractMesh>;
  141374. private _raySelectionPredicate;
  141375. /**
  141376. * To be optionaly changed by user to define custom ray selection
  141377. */
  141378. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  141379. /**
  141380. * To be optionaly changed by user to define custom selection logic (after ray selection)
  141381. */
  141382. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141383. /**
  141384. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  141385. */
  141386. teleportationEnabled: boolean;
  141387. private _defaultHeight;
  141388. private _teleportationInitialized;
  141389. private _interactionsEnabled;
  141390. private _interactionsRequested;
  141391. private _displayGaze;
  141392. private _displayLaserPointer;
  141393. /**
  141394. * The mesh used to display where the user is going to teleport.
  141395. */
  141396. get teleportationTarget(): Mesh;
  141397. /**
  141398. * Sets the mesh to be used to display where the user is going to teleport.
  141399. */
  141400. set teleportationTarget(value: Mesh);
  141401. /**
  141402. * 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
  141403. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  141404. * See https://doc.babylonjs.com/resources/baking_transformations
  141405. */
  141406. get gazeTrackerMesh(): Mesh;
  141407. set gazeTrackerMesh(value: Mesh);
  141408. /**
  141409. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  141410. */
  141411. updateGazeTrackerScale: boolean;
  141412. /**
  141413. * If the gaze trackers color should be updated when selecting meshes
  141414. */
  141415. updateGazeTrackerColor: boolean;
  141416. /**
  141417. * If the controller laser color should be updated when selecting meshes
  141418. */
  141419. updateControllerLaserColor: boolean;
  141420. /**
  141421. * The gaze tracking mesh corresponding to the left controller
  141422. */
  141423. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  141424. /**
  141425. * The gaze tracking mesh corresponding to the right controller
  141426. */
  141427. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  141428. /**
  141429. * If the ray of the gaze should be displayed.
  141430. */
  141431. get displayGaze(): boolean;
  141432. /**
  141433. * Sets if the ray of the gaze should be displayed.
  141434. */
  141435. set displayGaze(value: boolean);
  141436. /**
  141437. * If the ray of the LaserPointer should be displayed.
  141438. */
  141439. get displayLaserPointer(): boolean;
  141440. /**
  141441. * Sets if the ray of the LaserPointer should be displayed.
  141442. */
  141443. set displayLaserPointer(value: boolean);
  141444. /**
  141445. * The deviceOrientationCamera used as the camera when not in VR.
  141446. */
  141447. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  141448. /**
  141449. * Based on the current WebVR support, returns the current VR camera used.
  141450. */
  141451. get currentVRCamera(): Nullable<Camera>;
  141452. /**
  141453. * The webVRCamera which is used when in VR.
  141454. */
  141455. get webVRCamera(): WebVRFreeCamera;
  141456. /**
  141457. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  141458. */
  141459. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  141460. /**
  141461. * The html button that is used to trigger entering into VR.
  141462. */
  141463. get vrButton(): Nullable<HTMLButtonElement>;
  141464. private get _teleportationRequestInitiated();
  141465. /**
  141466. * Defines whether or not Pointer lock should be requested when switching to
  141467. * full screen.
  141468. */
  141469. requestPointerLockOnFullScreen: boolean;
  141470. /**
  141471. * If asking to force XR, this will be populated with the default xr experience
  141472. */
  141473. xr: WebXRDefaultExperience;
  141474. /**
  141475. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  141476. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  141477. */
  141478. xrTestDone: boolean;
  141479. /**
  141480. * Instantiates a VRExperienceHelper.
  141481. * Helps to quickly add VR support to an existing scene.
  141482. * @param scene The scene the VRExperienceHelper belongs to.
  141483. * @param webVROptions Options to modify the vr experience helper's behavior.
  141484. */
  141485. constructor(scene: Scene,
  141486. /** Options to modify the vr experience helper's behavior. */
  141487. webVROptions?: VRExperienceHelperOptions);
  141488. private completeVRInit;
  141489. private _onDefaultMeshLoaded;
  141490. private _onResize;
  141491. private _onFullscreenChange;
  141492. /**
  141493. * Gets a value indicating if we are currently in VR mode.
  141494. */
  141495. get isInVRMode(): boolean;
  141496. private onVrDisplayPresentChange;
  141497. private onVRDisplayChanged;
  141498. private moveButtonToBottomRight;
  141499. private displayVRButton;
  141500. private updateButtonVisibility;
  141501. private _cachedAngularSensibility;
  141502. /**
  141503. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  141504. * Otherwise, will use the fullscreen API.
  141505. */
  141506. enterVR(): void;
  141507. /**
  141508. * Attempt to exit VR, or fullscreen.
  141509. */
  141510. exitVR(): void;
  141511. /**
  141512. * The position of the vr experience helper.
  141513. */
  141514. get position(): Vector3;
  141515. /**
  141516. * Sets the position of the vr experience helper.
  141517. */
  141518. set position(value: Vector3);
  141519. /**
  141520. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  141521. */
  141522. enableInteractions(): void;
  141523. private get _noControllerIsActive();
  141524. private beforeRender;
  141525. private _isTeleportationFloor;
  141526. /**
  141527. * Adds a floor mesh to be used for teleportation.
  141528. * @param floorMesh the mesh to be used for teleportation.
  141529. */
  141530. addFloorMesh(floorMesh: Mesh): void;
  141531. /**
  141532. * Removes a floor mesh from being used for teleportation.
  141533. * @param floorMesh the mesh to be removed.
  141534. */
  141535. removeFloorMesh(floorMesh: Mesh): void;
  141536. /**
  141537. * Enables interactions and teleportation using the VR controllers and gaze.
  141538. * @param vrTeleportationOptions options to modify teleportation behavior.
  141539. */
  141540. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  141541. private _onNewGamepadConnected;
  141542. private _tryEnableInteractionOnController;
  141543. private _onNewGamepadDisconnected;
  141544. private _enableInteractionOnController;
  141545. private _checkTeleportWithRay;
  141546. private _checkRotate;
  141547. private _checkTeleportBackwards;
  141548. private _enableTeleportationOnController;
  141549. private _createTeleportationCircles;
  141550. private _displayTeleportationTarget;
  141551. private _hideTeleportationTarget;
  141552. private _rotateCamera;
  141553. private _moveTeleportationSelectorTo;
  141554. private _workingVector;
  141555. private _workingQuaternion;
  141556. private _workingMatrix;
  141557. /**
  141558. * Time Constant Teleportation Mode
  141559. */
  141560. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  141561. /**
  141562. * Speed Constant Teleportation Mode
  141563. */
  141564. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  141565. /**
  141566. * Teleports the users feet to the desired location
  141567. * @param location The location where the user's feet should be placed
  141568. */
  141569. teleportCamera(location: Vector3): void;
  141570. private _convertNormalToDirectionOfRay;
  141571. private _castRayAndSelectObject;
  141572. private _notifySelectedMeshUnselected;
  141573. /**
  141574. * Permanently set new colors for the laser pointer
  141575. * @param color the new laser color
  141576. * @param pickedColor the new laser color when picked mesh detected
  141577. */
  141578. setLaserColor(color: Color3, pickedColor?: Color3): void;
  141579. /**
  141580. * Set lighting enabled / disabled on the laser pointer of both controllers
  141581. * @param enabled should the lighting be enabled on the laser pointer
  141582. */
  141583. setLaserLightingState(enabled?: boolean): void;
  141584. /**
  141585. * Permanently set new colors for the gaze pointer
  141586. * @param color the new gaze color
  141587. * @param pickedColor the new gaze color when picked mesh detected
  141588. */
  141589. setGazeColor(color: Color3, pickedColor?: Color3): void;
  141590. /**
  141591. * Sets the color of the laser ray from the vr controllers.
  141592. * @param color new color for the ray.
  141593. */
  141594. changeLaserColor(color: Color3): void;
  141595. /**
  141596. * Sets the color of the ray from the vr headsets gaze.
  141597. * @param color new color for the ray.
  141598. */
  141599. changeGazeColor(color: Color3): void;
  141600. /**
  141601. * Exits VR and disposes of the vr experience helper
  141602. */
  141603. dispose(): void;
  141604. /**
  141605. * Gets the name of the VRExperienceHelper class
  141606. * @returns "VRExperienceHelper"
  141607. */
  141608. getClassName(): string;
  141609. }
  141610. }
  141611. declare module BABYLON {
  141612. /**
  141613. * Contains an array of blocks representing the octree
  141614. */
  141615. export interface IOctreeContainer<T> {
  141616. /**
  141617. * Blocks within the octree
  141618. */
  141619. blocks: Array<OctreeBlock<T>>;
  141620. }
  141621. /**
  141622. * Class used to store a cell in an octree
  141623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141624. */
  141625. export class OctreeBlock<T> {
  141626. /**
  141627. * Gets the content of the current block
  141628. */
  141629. entries: T[];
  141630. /**
  141631. * Gets the list of block children
  141632. */
  141633. blocks: Array<OctreeBlock<T>>;
  141634. private _depth;
  141635. private _maxDepth;
  141636. private _capacity;
  141637. private _minPoint;
  141638. private _maxPoint;
  141639. private _boundingVectors;
  141640. private _creationFunc;
  141641. /**
  141642. * Creates a new block
  141643. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  141644. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  141645. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141646. * @param depth defines the current depth of this block in the octree
  141647. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  141648. * @param creationFunc defines a callback to call when an element is added to the block
  141649. */
  141650. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  141651. /**
  141652. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141653. */
  141654. get capacity(): number;
  141655. /**
  141656. * Gets the minimum vector (in world space) of the block's bounding box
  141657. */
  141658. get minPoint(): Vector3;
  141659. /**
  141660. * Gets the maximum vector (in world space) of the block's bounding box
  141661. */
  141662. get maxPoint(): Vector3;
  141663. /**
  141664. * Add a new element to this block
  141665. * @param entry defines the element to add
  141666. */
  141667. addEntry(entry: T): void;
  141668. /**
  141669. * Remove an element from this block
  141670. * @param entry defines the element to remove
  141671. */
  141672. removeEntry(entry: T): void;
  141673. /**
  141674. * Add an array of elements to this block
  141675. * @param entries defines the array of elements to add
  141676. */
  141677. addEntries(entries: T[]): void;
  141678. /**
  141679. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  141680. * @param frustumPlanes defines the frustum planes to test
  141681. * @param selection defines the array to store current content if selection is positive
  141682. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141683. */
  141684. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141685. /**
  141686. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  141687. * @param sphereCenter defines the bounding sphere center
  141688. * @param sphereRadius defines the bounding sphere radius
  141689. * @param selection defines the array to store current content if selection is positive
  141690. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141691. */
  141692. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141693. /**
  141694. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  141695. * @param ray defines the ray to test with
  141696. * @param selection defines the array to store current content if selection is positive
  141697. */
  141698. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  141699. /**
  141700. * Subdivide the content into child blocks (this block will then be empty)
  141701. */
  141702. createInnerBlocks(): void;
  141703. /**
  141704. * @hidden
  141705. */
  141706. 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;
  141707. }
  141708. }
  141709. declare module BABYLON {
  141710. /**
  141711. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  141712. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141713. */
  141714. export class Octree<T> {
  141715. /** 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.) */
  141716. maxDepth: number;
  141717. /**
  141718. * Blocks within the octree containing objects
  141719. */
  141720. blocks: Array<OctreeBlock<T>>;
  141721. /**
  141722. * Content stored in the octree
  141723. */
  141724. dynamicContent: T[];
  141725. private _maxBlockCapacity;
  141726. private _selectionContent;
  141727. private _creationFunc;
  141728. /**
  141729. * Creates a octree
  141730. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141731. * @param creationFunc function to be used to instatiate the octree
  141732. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  141733. * @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.)
  141734. */
  141735. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  141736. /** 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.) */
  141737. maxDepth?: number);
  141738. /**
  141739. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  141740. * @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);
  141741. * @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);
  141742. * @param entries meshes to be added to the octree blocks
  141743. */
  141744. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  141745. /**
  141746. * Adds a mesh to the octree
  141747. * @param entry Mesh to add to the octree
  141748. */
  141749. addMesh(entry: T): void;
  141750. /**
  141751. * Remove an element from the octree
  141752. * @param entry defines the element to remove
  141753. */
  141754. removeMesh(entry: T): void;
  141755. /**
  141756. * Selects an array of meshes within the frustum
  141757. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  141758. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  141759. * @returns array of meshes within the frustum
  141760. */
  141761. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  141762. /**
  141763. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  141764. * @param sphereCenter defines the bounding sphere center
  141765. * @param sphereRadius defines the bounding sphere radius
  141766. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141767. * @returns an array of objects that intersect the sphere
  141768. */
  141769. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  141770. /**
  141771. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  141772. * @param ray defines the ray to test with
  141773. * @returns array of intersected objects
  141774. */
  141775. intersectsRay(ray: Ray): SmartArray<T>;
  141776. /**
  141777. * Adds a mesh into the octree block if it intersects the block
  141778. */
  141779. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  141780. /**
  141781. * Adds a submesh into the octree block if it intersects the block
  141782. */
  141783. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  141784. }
  141785. }
  141786. declare module BABYLON {
  141787. interface Scene {
  141788. /**
  141789. * @hidden
  141790. * Backing Filed
  141791. */
  141792. _selectionOctree: Octree<AbstractMesh>;
  141793. /**
  141794. * Gets the octree used to boost mesh selection (picking)
  141795. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141796. */
  141797. selectionOctree: Octree<AbstractMesh>;
  141798. /**
  141799. * Creates or updates the octree used to boost selection (picking)
  141800. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141801. * @param maxCapacity defines the maximum capacity per leaf
  141802. * @param maxDepth defines the maximum depth of the octree
  141803. * @returns an octree of AbstractMesh
  141804. */
  141805. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  141806. }
  141807. interface AbstractMesh {
  141808. /**
  141809. * @hidden
  141810. * Backing Field
  141811. */
  141812. _submeshesOctree: Octree<SubMesh>;
  141813. /**
  141814. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  141815. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  141816. * @param maxCapacity defines the maximum size of each block (64 by default)
  141817. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  141818. * @returns the new octree
  141819. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  141820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141821. */
  141822. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  141823. }
  141824. /**
  141825. * Defines the octree scene component responsible to manage any octrees
  141826. * in a given scene.
  141827. */
  141828. export class OctreeSceneComponent {
  141829. /**
  141830. * The component name help to identify the component in the list of scene components.
  141831. */
  141832. readonly name: string;
  141833. /**
  141834. * The scene the component belongs to.
  141835. */
  141836. scene: Scene;
  141837. /**
  141838. * Indicates if the meshes have been checked to make sure they are isEnabled()
  141839. */
  141840. readonly checksIsEnabled: boolean;
  141841. /**
  141842. * Creates a new instance of the component for the given scene
  141843. * @param scene Defines the scene to register the component in
  141844. */
  141845. constructor(scene: Scene);
  141846. /**
  141847. * Registers the component in a given scene
  141848. */
  141849. register(): void;
  141850. /**
  141851. * Return the list of active meshes
  141852. * @returns the list of active meshes
  141853. */
  141854. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  141855. /**
  141856. * Return the list of active sub meshes
  141857. * @param mesh The mesh to get the candidates sub meshes from
  141858. * @returns the list of active sub meshes
  141859. */
  141860. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  141861. private _tempRay;
  141862. /**
  141863. * Return the list of sub meshes intersecting with a given local ray
  141864. * @param mesh defines the mesh to find the submesh for
  141865. * @param localRay defines the ray in local space
  141866. * @returns the list of intersecting sub meshes
  141867. */
  141868. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  141869. /**
  141870. * Return the list of sub meshes colliding with a collider
  141871. * @param mesh defines the mesh to find the submesh for
  141872. * @param collider defines the collider to evaluate the collision against
  141873. * @returns the list of colliding sub meshes
  141874. */
  141875. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  141876. /**
  141877. * Rebuilds the elements related to this component in case of
  141878. * context lost for instance.
  141879. */
  141880. rebuild(): void;
  141881. /**
  141882. * Disposes the component and the associated ressources.
  141883. */
  141884. dispose(): void;
  141885. }
  141886. }
  141887. declare module BABYLON {
  141888. /**
  141889. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  141890. */
  141891. export interface GizmoAxisCache {
  141892. /** Mesh used to runder the Gizmo */
  141893. gizmoMeshes: Mesh[];
  141894. /** Mesh used to detect user interaction with Gizmo */
  141895. colliderMeshes: Mesh[];
  141896. /** Material used to inicate color of gizmo mesh */
  141897. material: StandardMaterial;
  141898. /** Material used to inicate hover state of the Gizmo */
  141899. hoverMaterial: StandardMaterial;
  141900. /** Material used to inicate disabled state of the Gizmo */
  141901. disableMaterial: StandardMaterial;
  141902. /** Used to indicate Active state of the Gizmo */
  141903. active: boolean;
  141904. }
  141905. /**
  141906. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  141907. */
  141908. export class Gizmo implements IDisposable {
  141909. /** The utility layer the gizmo will be added to */
  141910. gizmoLayer: UtilityLayerRenderer;
  141911. /**
  141912. * The root mesh of the gizmo
  141913. */
  141914. _rootMesh: Mesh;
  141915. private _attachedMesh;
  141916. private _attachedNode;
  141917. /**
  141918. * Ratio for the scale of the gizmo (Default: 1)
  141919. */
  141920. protected _scaleRatio: number;
  141921. /**
  141922. * boolean updated by pointermove when a gizmo mesh is hovered
  141923. */
  141924. protected _isHovered: boolean;
  141925. /**
  141926. * Ratio for the scale of the gizmo (Default: 1)
  141927. */
  141928. set scaleRatio(value: number);
  141929. get scaleRatio(): number;
  141930. /**
  141931. * True when the mouse pointer is hovered a gizmo mesh
  141932. */
  141933. get isHovered(): boolean;
  141934. /**
  141935. * If a custom mesh has been set (Default: false)
  141936. */
  141937. protected _customMeshSet: boolean;
  141938. /**
  141939. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  141940. * * When set, interactions will be enabled
  141941. */
  141942. get attachedMesh(): Nullable<AbstractMesh>;
  141943. set attachedMesh(value: Nullable<AbstractMesh>);
  141944. /**
  141945. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  141946. * * When set, interactions will be enabled
  141947. */
  141948. get attachedNode(): Nullable<Node>;
  141949. set attachedNode(value: Nullable<Node>);
  141950. /**
  141951. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  141952. * @param mesh The mesh to replace the default mesh of the gizmo
  141953. */
  141954. setCustomMesh(mesh: Mesh): void;
  141955. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  141956. /**
  141957. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  141958. */
  141959. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141960. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141961. /**
  141962. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  141963. */
  141964. updateGizmoPositionToMatchAttachedMesh: boolean;
  141965. /**
  141966. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  141967. */
  141968. updateScale: boolean;
  141969. protected _interactionsEnabled: boolean;
  141970. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141971. private _beforeRenderObserver;
  141972. private _tempQuaternion;
  141973. private _tempVector;
  141974. private _tempVector2;
  141975. private _tempMatrix1;
  141976. private _tempMatrix2;
  141977. private _rightHandtoLeftHandMatrix;
  141978. /**
  141979. * Creates a gizmo
  141980. * @param gizmoLayer The utility layer the gizmo will be added to
  141981. */
  141982. constructor(
  141983. /** The utility layer the gizmo will be added to */
  141984. gizmoLayer?: UtilityLayerRenderer);
  141985. /**
  141986. * Updates the gizmo to match the attached mesh's position/rotation
  141987. */
  141988. protected _update(): void;
  141989. /**
  141990. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  141991. * @param value Node, TransformNode or mesh
  141992. */
  141993. protected _matrixChanged(): void;
  141994. /**
  141995. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  141996. * @param gizmoLayer The utility layer the gizmo will be added to
  141997. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  141998. * @returns {Observer<PointerInfo>} pointerObserver
  141999. */
  142000. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  142001. /**
  142002. * Disposes of the gizmo
  142003. */
  142004. dispose(): void;
  142005. }
  142006. }
  142007. declare module BABYLON {
  142008. /**
  142009. * Single plane drag gizmo
  142010. */
  142011. export class PlaneDragGizmo extends Gizmo {
  142012. /**
  142013. * Drag behavior responsible for the gizmos dragging interactions
  142014. */
  142015. dragBehavior: PointerDragBehavior;
  142016. private _pointerObserver;
  142017. /**
  142018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142019. */
  142020. snapDistance: number;
  142021. /**
  142022. * Event that fires each time the gizmo snaps to a new location.
  142023. * * snapDistance is the the change in distance
  142024. */
  142025. onSnapObservable: Observable<{
  142026. snapDistance: number;
  142027. }>;
  142028. private _gizmoMesh;
  142029. private _coloredMaterial;
  142030. private _hoverMaterial;
  142031. private _disableMaterial;
  142032. private _isEnabled;
  142033. private _parent;
  142034. private _dragging;
  142035. /** @hidden */
  142036. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  142037. /**
  142038. * Creates a PlaneDragGizmo
  142039. * @param gizmoLayer The utility layer the gizmo will be added to
  142040. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  142041. * @param color The color of the gizmo
  142042. */
  142043. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  142044. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142045. /**
  142046. * If the gizmo is enabled
  142047. */
  142048. set isEnabled(value: boolean);
  142049. get isEnabled(): boolean;
  142050. /**
  142051. * Disposes of the gizmo
  142052. */
  142053. dispose(): void;
  142054. }
  142055. }
  142056. declare module BABYLON {
  142057. /**
  142058. * Single plane rotation gizmo
  142059. */
  142060. export class PlaneRotationGizmo extends Gizmo {
  142061. /**
  142062. * Drag behavior responsible for the gizmos dragging interactions
  142063. */
  142064. dragBehavior: PointerDragBehavior;
  142065. private _pointerObserver;
  142066. /**
  142067. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  142068. */
  142069. snapDistance: number;
  142070. /**
  142071. * Event that fires each time the gizmo snaps to a new location.
  142072. * * snapDistance is the the change in distance
  142073. */
  142074. onSnapObservable: Observable<{
  142075. snapDistance: number;
  142076. }>;
  142077. private _isEnabled;
  142078. private _parent;
  142079. private _coloredMaterial;
  142080. private _hoverMaterial;
  142081. private _disableMaterial;
  142082. private _gizmoMesh;
  142083. private _rotationCircle;
  142084. private _dragging;
  142085. private static _CircleConstants;
  142086. /**
  142087. * Creates a PlaneRotationGizmo
  142088. * @param gizmoLayer The utility layer the gizmo will be added to
  142089. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  142090. * @param color The color of the gizmo
  142091. * @param tessellation Amount of tessellation to be used when creating rotation circles
  142092. * @param useEulerRotation Use and update Euler angle instead of quaternion
  142093. * @param thickness display gizmo axis thickness
  142094. */
  142095. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  142096. /** Create Geometry for Gizmo */
  142097. private _createGizmoMesh;
  142098. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142099. private setupRotationCircle;
  142100. private updateRotationPath;
  142101. private updateRotationCircle;
  142102. /**
  142103. * If the gizmo is enabled
  142104. */
  142105. set isEnabled(value: boolean);
  142106. get isEnabled(): boolean;
  142107. /**
  142108. * Disposes of the gizmo
  142109. */
  142110. dispose(): void;
  142111. }
  142112. }
  142113. declare module BABYLON {
  142114. /**
  142115. * Gizmo that enables rotating a mesh along 3 axis
  142116. */
  142117. export class RotationGizmo extends Gizmo {
  142118. /**
  142119. * Internal gizmo used for interactions on the x axis
  142120. */
  142121. xGizmo: PlaneRotationGizmo;
  142122. /**
  142123. * Internal gizmo used for interactions on the y axis
  142124. */
  142125. yGizmo: PlaneRotationGizmo;
  142126. /**
  142127. * Internal gizmo used for interactions on the z axis
  142128. */
  142129. zGizmo: PlaneRotationGizmo;
  142130. /** Fires an event when any of it's sub gizmos are dragged */
  142131. onDragStartObservable: Observable<unknown>;
  142132. /** Fires an event when any of it's sub gizmos are released from dragging */
  142133. onDragEndObservable: Observable<unknown>;
  142134. private _meshAttached;
  142135. private _nodeAttached;
  142136. private _observables;
  142137. /** Node Caching for quick lookup */
  142138. private _gizmoAxisCache;
  142139. get attachedMesh(): Nullable<AbstractMesh>;
  142140. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142141. get attachedNode(): Nullable<Node>;
  142142. set attachedNode(node: Nullable<Node>);
  142143. protected _checkBillboardTransform(): void;
  142144. /**
  142145. * True when the mouse pointer is hovering a gizmo mesh
  142146. */
  142147. get isHovered(): boolean;
  142148. /**
  142149. * Creates a RotationGizmo
  142150. * @param gizmoLayer The utility layer the gizmo will be added to
  142151. * @param tessellation Amount of tessellation to be used when creating rotation circles
  142152. * @param useEulerRotation Use and update Euler angle instead of quaternion
  142153. * @param thickness display gizmo axis thickness
  142154. */
  142155. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  142156. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142157. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142158. /**
  142159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142160. */
  142161. set snapDistance(value: number);
  142162. get snapDistance(): number;
  142163. /**
  142164. * Ratio for the scale of the gizmo (Default: 1)
  142165. */
  142166. set scaleRatio(value: number);
  142167. get scaleRatio(): number;
  142168. /**
  142169. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142170. * @param mesh Axis gizmo mesh
  142171. * @param cache Gizmo axis definition used for reactive gizmo UI
  142172. */
  142173. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142174. /**
  142175. * Disposes of the gizmo
  142176. */
  142177. dispose(): void;
  142178. /**
  142179. * CustomMeshes are not supported by this gizmo
  142180. * @param mesh The mesh to replace the default mesh of the gizmo
  142181. */
  142182. setCustomMesh(mesh: Mesh): void;
  142183. }
  142184. }
  142185. declare module BABYLON {
  142186. /**
  142187. * Class containing static functions to help procedurally build meshes
  142188. */
  142189. export class PolyhedronBuilder {
  142190. /**
  142191. * Creates a polyhedron mesh
  142192. * * 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
  142193. * * The parameter `size` (positive float, default 1) sets the polygon size
  142194. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142195. * * 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`
  142196. * * 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
  142197. * * 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)`)
  142198. * * 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
  142199. * * 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
  142200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142203. * @param name defines the name of the mesh
  142204. * @param options defines the options used to create the mesh
  142205. * @param scene defines the hosting scene
  142206. * @returns the polyhedron mesh
  142207. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142208. */
  142209. static CreatePolyhedron(name: string, options: {
  142210. type?: number;
  142211. size?: number;
  142212. sizeX?: number;
  142213. sizeY?: number;
  142214. sizeZ?: number;
  142215. custom?: any;
  142216. faceUV?: Vector4[];
  142217. faceColors?: Color4[];
  142218. flat?: boolean;
  142219. updatable?: boolean;
  142220. sideOrientation?: number;
  142221. frontUVs?: Vector4;
  142222. backUVs?: Vector4;
  142223. }, scene?: Nullable<Scene>): Mesh;
  142224. }
  142225. }
  142226. declare module BABYLON {
  142227. /**
  142228. * Class containing static functions to help procedurally build meshes
  142229. */
  142230. export class BoxBuilder {
  142231. /**
  142232. * Creates a box mesh
  142233. * * The parameter `size` sets the size (float) of each box side (default 1)
  142234. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142235. * * 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)
  142236. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142240. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142241. * @param name defines the name of the mesh
  142242. * @param options defines the options used to create the mesh
  142243. * @param scene defines the hosting scene
  142244. * @returns the box mesh
  142245. */
  142246. static CreateBox(name: string, options: {
  142247. size?: number;
  142248. width?: number;
  142249. height?: number;
  142250. depth?: number;
  142251. faceUV?: Vector4[];
  142252. faceColors?: Color4[];
  142253. sideOrientation?: number;
  142254. frontUVs?: Vector4;
  142255. backUVs?: Vector4;
  142256. wrap?: boolean;
  142257. topBaseAt?: number;
  142258. bottomBaseAt?: number;
  142259. updatable?: boolean;
  142260. }, scene?: Nullable<Scene>): Mesh;
  142261. }
  142262. }
  142263. declare module BABYLON {
  142264. /**
  142265. * Single axis scale gizmo
  142266. */
  142267. export class AxisScaleGizmo extends Gizmo {
  142268. /**
  142269. * Drag behavior responsible for the gizmos dragging interactions
  142270. */
  142271. dragBehavior: PointerDragBehavior;
  142272. private _pointerObserver;
  142273. /**
  142274. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142275. */
  142276. snapDistance: number;
  142277. /**
  142278. * Event that fires each time the gizmo snaps to a new location.
  142279. * * snapDistance is the the change in distance
  142280. */
  142281. onSnapObservable: Observable<{
  142282. snapDistance: number;
  142283. }>;
  142284. /**
  142285. * If the scaling operation should be done on all axis (default: false)
  142286. */
  142287. uniformScaling: boolean;
  142288. /**
  142289. * Custom sensitivity value for the drag strength
  142290. */
  142291. sensitivity: number;
  142292. private _isEnabled;
  142293. private _parent;
  142294. private _gizmoMesh;
  142295. private _coloredMaterial;
  142296. private _hoverMaterial;
  142297. private _disableMaterial;
  142298. private _dragging;
  142299. private _tmpVector;
  142300. private _tmpMatrix;
  142301. private _tmpMatrix2;
  142302. /**
  142303. * Creates an AxisScaleGizmo
  142304. * @param gizmoLayer The utility layer the gizmo will be added to
  142305. * @param dragAxis The axis which the gizmo will be able to scale on
  142306. * @param color The color of the gizmo
  142307. * @param thickness display gizmo axis thickness
  142308. */
  142309. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  142310. /** Create Geometry for Gizmo */
  142311. private _createGizmoMesh;
  142312. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142313. /**
  142314. * If the gizmo is enabled
  142315. */
  142316. set isEnabled(value: boolean);
  142317. get isEnabled(): boolean;
  142318. /**
  142319. * Disposes of the gizmo
  142320. */
  142321. dispose(): void;
  142322. /**
  142323. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  142324. * @param mesh The mesh to replace the default mesh of the gizmo
  142325. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  142326. */
  142327. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  142328. }
  142329. }
  142330. declare module BABYLON {
  142331. /**
  142332. * Gizmo that enables scaling a mesh along 3 axis
  142333. */
  142334. export class ScaleGizmo extends Gizmo {
  142335. /**
  142336. * Internal gizmo used for interactions on the x axis
  142337. */
  142338. xGizmo: AxisScaleGizmo;
  142339. /**
  142340. * Internal gizmo used for interactions on the y axis
  142341. */
  142342. yGizmo: AxisScaleGizmo;
  142343. /**
  142344. * Internal gizmo used for interactions on the z axis
  142345. */
  142346. zGizmo: AxisScaleGizmo;
  142347. /**
  142348. * Internal gizmo used to scale all axis equally
  142349. */
  142350. uniformScaleGizmo: AxisScaleGizmo;
  142351. private _meshAttached;
  142352. private _nodeAttached;
  142353. private _snapDistance;
  142354. private _uniformScalingMesh;
  142355. private _octahedron;
  142356. private _sensitivity;
  142357. private _coloredMaterial;
  142358. private _hoverMaterial;
  142359. private _disableMaterial;
  142360. private _observables;
  142361. /** Node Caching for quick lookup */
  142362. private _gizmoAxisCache;
  142363. /** Fires an event when any of it's sub gizmos are dragged */
  142364. onDragStartObservable: Observable<unknown>;
  142365. /** Fires an event when any of it's sub gizmos are released from dragging */
  142366. onDragEndObservable: Observable<unknown>;
  142367. get attachedMesh(): Nullable<AbstractMesh>;
  142368. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142369. get attachedNode(): Nullable<Node>;
  142370. set attachedNode(node: Nullable<Node>);
  142371. /**
  142372. * True when the mouse pointer is hovering a gizmo mesh
  142373. */
  142374. get isHovered(): boolean;
  142375. /**
  142376. * Creates a ScaleGizmo
  142377. * @param gizmoLayer The utility layer the gizmo will be added to
  142378. * @param thickness display gizmo axis thickness
  142379. */
  142380. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142381. /** Create Geometry for Gizmo */
  142382. private _createUniformScaleMesh;
  142383. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142384. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142385. /**
  142386. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142387. */
  142388. set snapDistance(value: number);
  142389. get snapDistance(): number;
  142390. /**
  142391. * Ratio for the scale of the gizmo (Default: 1)
  142392. */
  142393. set scaleRatio(value: number);
  142394. get scaleRatio(): number;
  142395. /**
  142396. * Sensitivity factor for dragging (Default: 1)
  142397. */
  142398. set sensitivity(value: number);
  142399. get sensitivity(): number;
  142400. /**
  142401. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142402. * @param mesh Axis gizmo mesh
  142403. * @param cache Gizmo axis definition used for reactive gizmo UI
  142404. */
  142405. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142406. /**
  142407. * Disposes of the gizmo
  142408. */
  142409. dispose(): void;
  142410. }
  142411. }
  142412. declare module BABYLON {
  142413. /**
  142414. * Bounding box gizmo
  142415. */
  142416. export class BoundingBoxGizmo extends Gizmo {
  142417. private _lineBoundingBox;
  142418. private _rotateSpheresParent;
  142419. private _scaleBoxesParent;
  142420. private _boundingDimensions;
  142421. private _renderObserver;
  142422. private _pointerObserver;
  142423. private _scaleDragSpeed;
  142424. private _tmpQuaternion;
  142425. private _tmpVector;
  142426. private _tmpRotationMatrix;
  142427. /**
  142428. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  142429. */
  142430. ignoreChildren: boolean;
  142431. /**
  142432. * 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)
  142433. */
  142434. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  142435. /**
  142436. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  142437. */
  142438. rotationSphereSize: number;
  142439. /**
  142440. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  142441. */
  142442. scaleBoxSize: number;
  142443. /**
  142444. * 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)
  142445. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  142446. */
  142447. fixedDragMeshScreenSize: boolean;
  142448. /**
  142449. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  142450. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  142451. */
  142452. fixedDragMeshBoundsSize: boolean;
  142453. /**
  142454. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  142455. */
  142456. fixedDragMeshScreenSizeDistanceFactor: number;
  142457. /**
  142458. * Fired when a rotation sphere or scale box is dragged
  142459. */
  142460. onDragStartObservable: Observable<{}>;
  142461. /**
  142462. * Fired when a scale box is dragged
  142463. */
  142464. onScaleBoxDragObservable: Observable<{}>;
  142465. /**
  142466. * Fired when a scale box drag is ended
  142467. */
  142468. onScaleBoxDragEndObservable: Observable<{}>;
  142469. /**
  142470. * Fired when a rotation sphere is dragged
  142471. */
  142472. onRotationSphereDragObservable: Observable<{}>;
  142473. /**
  142474. * Fired when a rotation sphere drag is ended
  142475. */
  142476. onRotationSphereDragEndObservable: Observable<{}>;
  142477. /**
  142478. * 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)
  142479. */
  142480. scalePivot: Nullable<Vector3>;
  142481. /**
  142482. * Mesh used as a pivot to rotate the attached node
  142483. */
  142484. private _anchorMesh;
  142485. private _existingMeshScale;
  142486. private _dragMesh;
  142487. private pointerDragBehavior;
  142488. private coloredMaterial;
  142489. private hoverColoredMaterial;
  142490. /**
  142491. * Sets the color of the bounding box gizmo
  142492. * @param color the color to set
  142493. */
  142494. setColor(color: Color3): void;
  142495. /**
  142496. * Creates an BoundingBoxGizmo
  142497. * @param gizmoLayer The utility layer the gizmo will be added to
  142498. * @param color The color of the gizmo
  142499. */
  142500. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  142501. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  142502. private _selectNode;
  142503. /**
  142504. * Updates the bounding box information for the Gizmo
  142505. */
  142506. updateBoundingBox(): void;
  142507. private _updateRotationSpheres;
  142508. private _updateScaleBoxes;
  142509. /**
  142510. * Enables rotation on the specified axis and disables rotation on the others
  142511. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  142512. */
  142513. setEnabledRotationAxis(axis: string): void;
  142514. /**
  142515. * Enables/disables scaling
  142516. * @param enable if scaling should be enabled
  142517. * @param homogeneousScaling defines if scaling should only be homogeneous
  142518. */
  142519. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  142520. private _updateDummy;
  142521. /**
  142522. * Enables a pointer drag behavior on the bounding box of the gizmo
  142523. */
  142524. enableDragBehavior(): void;
  142525. /**
  142526. * Disposes of the gizmo
  142527. */
  142528. dispose(): void;
  142529. /**
  142530. * 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)
  142531. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  142532. * @returns the bounding box mesh with the passed in mesh as a child
  142533. */
  142534. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  142535. /**
  142536. * CustomMeshes are not supported by this gizmo
  142537. * @param mesh The mesh to replace the default mesh of the gizmo
  142538. */
  142539. setCustomMesh(mesh: Mesh): void;
  142540. }
  142541. }
  142542. declare module BABYLON {
  142543. /**
  142544. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  142545. */
  142546. export class GizmoManager implements IDisposable {
  142547. private scene;
  142548. /**
  142549. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  142550. */
  142551. gizmos: {
  142552. positionGizmo: Nullable<PositionGizmo>;
  142553. rotationGizmo: Nullable<RotationGizmo>;
  142554. scaleGizmo: Nullable<ScaleGizmo>;
  142555. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  142556. };
  142557. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  142558. clearGizmoOnEmptyPointerEvent: boolean;
  142559. /** Fires an event when the manager is attached to a mesh */
  142560. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  142561. /** Fires an event when the manager is attached to a node */
  142562. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  142563. private _gizmosEnabled;
  142564. private _pointerObservers;
  142565. private _attachedMesh;
  142566. private _attachedNode;
  142567. private _boundingBoxColor;
  142568. private _defaultUtilityLayer;
  142569. private _defaultKeepDepthUtilityLayer;
  142570. private _thickness;
  142571. /** Node Caching for quick lookup */
  142572. private _gizmoAxisCache;
  142573. /**
  142574. * When bounding box gizmo is enabled, this can be used to track drag/end events
  142575. */
  142576. boundingBoxDragBehavior: SixDofDragBehavior;
  142577. /**
  142578. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  142579. */
  142580. attachableMeshes: Nullable<Array<AbstractMesh>>;
  142581. /**
  142582. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  142583. */
  142584. attachableNodes: Nullable<Array<Node>>;
  142585. /**
  142586. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  142587. */
  142588. usePointerToAttachGizmos: boolean;
  142589. /**
  142590. * Utility layer that the bounding box gizmo belongs to
  142591. */
  142592. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  142593. /**
  142594. * Utility layer that all gizmos besides bounding box belong to
  142595. */
  142596. get utilityLayer(): UtilityLayerRenderer;
  142597. /**
  142598. * True when the mouse pointer is hovering a gizmo mesh
  142599. */
  142600. get isHovered(): boolean;
  142601. /**
  142602. * Instatiates a gizmo manager
  142603. * @param scene the scene to overlay the gizmos on top of
  142604. * @param thickness display gizmo axis thickness
  142605. * @param utilityLayer the layer where gizmos are rendered
  142606. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  142607. */
  142608. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  142609. /**
  142610. * Subscribes to pointer down events, for attaching and detaching mesh
  142611. * @param scene The sceme layer the observer will be added to
  142612. */
  142613. private _attachToMeshPointerObserver;
  142614. /**
  142615. * Attaches a set of gizmos to the specified mesh
  142616. * @param mesh The mesh the gizmo's should be attached to
  142617. */
  142618. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142619. /**
  142620. * Attaches a set of gizmos to the specified node
  142621. * @param node The node the gizmo's should be attached to
  142622. */
  142623. attachToNode(node: Nullable<Node>): void;
  142624. /**
  142625. * If the position gizmo is enabled
  142626. */
  142627. set positionGizmoEnabled(value: boolean);
  142628. get positionGizmoEnabled(): boolean;
  142629. /**
  142630. * If the rotation gizmo is enabled
  142631. */
  142632. set rotationGizmoEnabled(value: boolean);
  142633. get rotationGizmoEnabled(): boolean;
  142634. /**
  142635. * If the scale gizmo is enabled
  142636. */
  142637. set scaleGizmoEnabled(value: boolean);
  142638. get scaleGizmoEnabled(): boolean;
  142639. /**
  142640. * If the boundingBox gizmo is enabled
  142641. */
  142642. set boundingBoxGizmoEnabled(value: boolean);
  142643. get boundingBoxGizmoEnabled(): boolean;
  142644. /**
  142645. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142646. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  142647. */
  142648. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  142649. /**
  142650. * Disposes of the gizmo manager
  142651. */
  142652. dispose(): void;
  142653. }
  142654. }
  142655. declare module BABYLON {
  142656. /**
  142657. * Gizmo that enables dragging a mesh along 3 axis
  142658. */
  142659. export class PositionGizmo extends Gizmo {
  142660. /**
  142661. * Internal gizmo used for interactions on the x axis
  142662. */
  142663. xGizmo: AxisDragGizmo;
  142664. /**
  142665. * Internal gizmo used for interactions on the y axis
  142666. */
  142667. yGizmo: AxisDragGizmo;
  142668. /**
  142669. * Internal gizmo used for interactions on the z axis
  142670. */
  142671. zGizmo: AxisDragGizmo;
  142672. /**
  142673. * Internal gizmo used for interactions on the yz plane
  142674. */
  142675. xPlaneGizmo: PlaneDragGizmo;
  142676. /**
  142677. * Internal gizmo used for interactions on the xz plane
  142678. */
  142679. yPlaneGizmo: PlaneDragGizmo;
  142680. /**
  142681. * Internal gizmo used for interactions on the xy plane
  142682. */
  142683. zPlaneGizmo: PlaneDragGizmo;
  142684. /**
  142685. * private variables
  142686. */
  142687. private _meshAttached;
  142688. private _nodeAttached;
  142689. private _snapDistance;
  142690. private _observables;
  142691. /** Node Caching for quick lookup */
  142692. private _gizmoAxisCache;
  142693. /** Fires an event when any of it's sub gizmos are dragged */
  142694. onDragStartObservable: Observable<unknown>;
  142695. /** Fires an event when any of it's sub gizmos are released from dragging */
  142696. onDragEndObservable: Observable<unknown>;
  142697. /**
  142698. * If set to true, planar drag is enabled
  142699. */
  142700. private _planarGizmoEnabled;
  142701. get attachedMesh(): Nullable<AbstractMesh>;
  142702. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142703. get attachedNode(): Nullable<Node>;
  142704. set attachedNode(node: Nullable<Node>);
  142705. /**
  142706. * True when the mouse pointer is hovering a gizmo mesh
  142707. */
  142708. get isHovered(): boolean;
  142709. /**
  142710. * Creates a PositionGizmo
  142711. * @param gizmoLayer The utility layer the gizmo will be added to
  142712. @param thickness display gizmo axis thickness
  142713. */
  142714. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142715. /**
  142716. * If the planar drag gizmo is enabled
  142717. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  142718. */
  142719. set planarGizmoEnabled(value: boolean);
  142720. get planarGizmoEnabled(): boolean;
  142721. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142722. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142723. /**
  142724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142725. */
  142726. set snapDistance(value: number);
  142727. get snapDistance(): number;
  142728. /**
  142729. * Ratio for the scale of the gizmo (Default: 1)
  142730. */
  142731. set scaleRatio(value: number);
  142732. get scaleRatio(): number;
  142733. /**
  142734. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142735. * @param mesh Axis gizmo mesh
  142736. * @param cache Gizmo axis definition used for reactive gizmo UI
  142737. */
  142738. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142739. /**
  142740. * Disposes of the gizmo
  142741. */
  142742. dispose(): void;
  142743. /**
  142744. * CustomMeshes are not supported by this gizmo
  142745. * @param mesh The mesh to replace the default mesh of the gizmo
  142746. */
  142747. setCustomMesh(mesh: Mesh): void;
  142748. }
  142749. }
  142750. declare module BABYLON {
  142751. /**
  142752. * Single axis drag gizmo
  142753. */
  142754. export class AxisDragGizmo extends Gizmo {
  142755. /**
  142756. * Drag behavior responsible for the gizmos dragging interactions
  142757. */
  142758. dragBehavior: PointerDragBehavior;
  142759. private _pointerObserver;
  142760. /**
  142761. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142762. */
  142763. snapDistance: number;
  142764. /**
  142765. * Event that fires each time the gizmo snaps to a new location.
  142766. * * snapDistance is the the change in distance
  142767. */
  142768. onSnapObservable: Observable<{
  142769. snapDistance: number;
  142770. }>;
  142771. private _isEnabled;
  142772. private _parent;
  142773. private _gizmoMesh;
  142774. private _coloredMaterial;
  142775. private _hoverMaterial;
  142776. private _disableMaterial;
  142777. private _dragging;
  142778. /** @hidden */
  142779. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  142780. /** @hidden */
  142781. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  142782. /**
  142783. * Creates an AxisDragGizmo
  142784. * @param gizmoLayer The utility layer the gizmo will be added to
  142785. * @param dragAxis The axis which the gizmo will be able to drag on
  142786. * @param color The color of the gizmo
  142787. * @param thickness display gizmo axis thickness
  142788. */
  142789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  142790. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142791. /**
  142792. * If the gizmo is enabled
  142793. */
  142794. set isEnabled(value: boolean);
  142795. get isEnabled(): boolean;
  142796. /**
  142797. * Disposes of the gizmo
  142798. */
  142799. dispose(): void;
  142800. }
  142801. }
  142802. declare module BABYLON.Debug {
  142803. /**
  142804. * The Axes viewer will show 3 axes in a specific point in space
  142805. */
  142806. export class AxesViewer {
  142807. private _xAxis;
  142808. private _yAxis;
  142809. private _zAxis;
  142810. private _scaleLinesFactor;
  142811. private _instanced;
  142812. /**
  142813. * Gets the hosting scene
  142814. */
  142815. scene: Nullable<Scene>;
  142816. /**
  142817. * Gets or sets a number used to scale line length
  142818. */
  142819. scaleLines: number;
  142820. /** Gets the node hierarchy used to render x-axis */
  142821. get xAxis(): TransformNode;
  142822. /** Gets the node hierarchy used to render y-axis */
  142823. get yAxis(): TransformNode;
  142824. /** Gets the node hierarchy used to render z-axis */
  142825. get zAxis(): TransformNode;
  142826. /**
  142827. * Creates a new AxesViewer
  142828. * @param scene defines the hosting scene
  142829. * @param scaleLines defines a number used to scale line length (1 by default)
  142830. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  142831. * @param xAxis defines the node hierarchy used to render the x-axis
  142832. * @param yAxis defines the node hierarchy used to render the y-axis
  142833. * @param zAxis defines the node hierarchy used to render the z-axis
  142834. */
  142835. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  142836. /**
  142837. * Force the viewer to update
  142838. * @param position defines the position of the viewer
  142839. * @param xaxis defines the x axis of the viewer
  142840. * @param yaxis defines the y axis of the viewer
  142841. * @param zaxis defines the z axis of the viewer
  142842. */
  142843. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  142844. /**
  142845. * Creates an instance of this axes viewer.
  142846. * @returns a new axes viewer with instanced meshes
  142847. */
  142848. createInstance(): AxesViewer;
  142849. /** Releases resources */
  142850. dispose(): void;
  142851. private static _SetRenderingGroupId;
  142852. }
  142853. }
  142854. declare module BABYLON.Debug {
  142855. /**
  142856. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  142857. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  142858. */
  142859. export class BoneAxesViewer extends AxesViewer {
  142860. /**
  142861. * Gets or sets the target mesh where to display the axes viewer
  142862. */
  142863. mesh: Nullable<Mesh>;
  142864. /**
  142865. * Gets or sets the target bone where to display the axes viewer
  142866. */
  142867. bone: Nullable<Bone>;
  142868. /** Gets current position */
  142869. pos: Vector3;
  142870. /** Gets direction of X axis */
  142871. xaxis: Vector3;
  142872. /** Gets direction of Y axis */
  142873. yaxis: Vector3;
  142874. /** Gets direction of Z axis */
  142875. zaxis: Vector3;
  142876. /**
  142877. * Creates a new BoneAxesViewer
  142878. * @param scene defines the hosting scene
  142879. * @param bone defines the target bone
  142880. * @param mesh defines the target mesh
  142881. * @param scaleLines defines a scaling factor for line length (1 by default)
  142882. */
  142883. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  142884. /**
  142885. * Force the viewer to update
  142886. */
  142887. update(): void;
  142888. /** Releases resources */
  142889. dispose(): void;
  142890. }
  142891. }
  142892. declare module BABYLON {
  142893. /**
  142894. * Interface used to define scene explorer extensibility option
  142895. */
  142896. export interface IExplorerExtensibilityOption {
  142897. /**
  142898. * Define the option label
  142899. */
  142900. label: string;
  142901. /**
  142902. * Defines the action to execute on click
  142903. */
  142904. action: (entity: any) => void;
  142905. }
  142906. /**
  142907. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  142908. */
  142909. export interface IExplorerExtensibilityGroup {
  142910. /**
  142911. * Defines a predicate to test if a given type mut be extended
  142912. */
  142913. predicate: (entity: any) => boolean;
  142914. /**
  142915. * Gets the list of options added to a type
  142916. */
  142917. entries: IExplorerExtensibilityOption[];
  142918. }
  142919. /**
  142920. * Interface used to define the options to use to create the Inspector
  142921. */
  142922. export interface IInspectorOptions {
  142923. /**
  142924. * Display in overlay mode (default: false)
  142925. */
  142926. overlay?: boolean;
  142927. /**
  142928. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  142929. */
  142930. globalRoot?: HTMLElement;
  142931. /**
  142932. * Display the Scene explorer
  142933. */
  142934. showExplorer?: boolean;
  142935. /**
  142936. * Display the property inspector
  142937. */
  142938. showInspector?: boolean;
  142939. /**
  142940. * Display in embed mode (both panes on the right)
  142941. */
  142942. embedMode?: boolean;
  142943. /**
  142944. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  142945. */
  142946. handleResize?: boolean;
  142947. /**
  142948. * Allow the panes to popup (default: true)
  142949. */
  142950. enablePopup?: boolean;
  142951. /**
  142952. * Allow the panes to be closed by users (default: true)
  142953. */
  142954. enableClose?: boolean;
  142955. /**
  142956. * Optional list of extensibility entries
  142957. */
  142958. explorerExtensibility?: IExplorerExtensibilityGroup[];
  142959. /**
  142960. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  142961. */
  142962. inspectorURL?: string;
  142963. /**
  142964. * Optional initial tab (default to DebugLayerTab.Properties)
  142965. */
  142966. initialTab?: DebugLayerTab;
  142967. }
  142968. interface Scene {
  142969. /**
  142970. * @hidden
  142971. * Backing field
  142972. */
  142973. _debugLayer: DebugLayer;
  142974. /**
  142975. * Gets the debug layer (aka Inspector) associated with the scene
  142976. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142977. */
  142978. debugLayer: DebugLayer;
  142979. }
  142980. /**
  142981. * Enum of inspector action tab
  142982. */
  142983. export enum DebugLayerTab {
  142984. /**
  142985. * Properties tag (default)
  142986. */
  142987. Properties = 0,
  142988. /**
  142989. * Debug tab
  142990. */
  142991. Debug = 1,
  142992. /**
  142993. * Statistics tab
  142994. */
  142995. Statistics = 2,
  142996. /**
  142997. * Tools tab
  142998. */
  142999. Tools = 3,
  143000. /**
  143001. * Settings tab
  143002. */
  143003. Settings = 4
  143004. }
  143005. /**
  143006. * The debug layer (aka Inspector) is the go to tool in order to better understand
  143007. * what is happening in your scene
  143008. * @see https://doc.babylonjs.com/features/playground_debuglayer
  143009. */
  143010. export class DebugLayer {
  143011. /**
  143012. * Define the url to get the inspector script from.
  143013. * By default it uses the babylonjs CDN.
  143014. * @ignoreNaming
  143015. */
  143016. static InspectorURL: string;
  143017. private _scene;
  143018. private BJSINSPECTOR;
  143019. private _onPropertyChangedObservable?;
  143020. /**
  143021. * Observable triggered when a property is changed through the inspector.
  143022. */
  143023. get onPropertyChangedObservable(): any;
  143024. /**
  143025. * Instantiates a new debug layer.
  143026. * The debug layer (aka Inspector) is the go to tool in order to better understand
  143027. * what is happening in your scene
  143028. * @see https://doc.babylonjs.com/features/playground_debuglayer
  143029. * @param scene Defines the scene to inspect
  143030. */
  143031. constructor(scene: Scene);
  143032. /** Creates the inspector window. */
  143033. private _createInspector;
  143034. /**
  143035. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  143036. * @param entity defines the entity to select
  143037. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  143038. */
  143039. select(entity: any, lineContainerTitles?: string | string[]): void;
  143040. /** Get the inspector from bundle or global */
  143041. private _getGlobalInspector;
  143042. /**
  143043. * Get if the inspector is visible or not.
  143044. * @returns true if visible otherwise, false
  143045. */
  143046. isVisible(): boolean;
  143047. /**
  143048. * Hide the inspector and close its window.
  143049. */
  143050. hide(): void;
  143051. /**
  143052. * Update the scene in the inspector
  143053. */
  143054. setAsActiveScene(): void;
  143055. /**
  143056. * Launch the debugLayer.
  143057. * @param config Define the configuration of the inspector
  143058. * @return a promise fulfilled when the debug layer is visible
  143059. */
  143060. show(config?: IInspectorOptions): Promise<DebugLayer>;
  143061. }
  143062. }
  143063. declare module BABYLON.Debug {
  143064. /**
  143065. * Used to show the physics impostor around the specific mesh
  143066. */
  143067. export class PhysicsViewer {
  143068. /** @hidden */
  143069. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  143070. /** @hidden */
  143071. protected _meshes: Array<Nullable<AbstractMesh>>;
  143072. /** @hidden */
  143073. protected _scene: Nullable<Scene>;
  143074. /** @hidden */
  143075. protected _numMeshes: number;
  143076. /** @hidden */
  143077. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  143078. private _renderFunction;
  143079. private _utilityLayer;
  143080. private _debugBoxMesh;
  143081. private _debugSphereMesh;
  143082. private _debugCylinderMesh;
  143083. private _debugMaterial;
  143084. private _debugMeshMeshes;
  143085. /**
  143086. * Creates a new PhysicsViewer
  143087. * @param scene defines the hosting scene
  143088. */
  143089. constructor(scene: Scene);
  143090. /** @hidden */
  143091. protected _updateDebugMeshes(): void;
  143092. /**
  143093. * Renders a specified physic impostor
  143094. * @param impostor defines the impostor to render
  143095. * @param targetMesh defines the mesh represented by the impostor
  143096. * @returns the new debug mesh used to render the impostor
  143097. */
  143098. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  143099. /**
  143100. * Hides a specified physic impostor
  143101. * @param impostor defines the impostor to hide
  143102. */
  143103. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  143104. private _getDebugMaterial;
  143105. private _getDebugBoxMesh;
  143106. private _getDebugSphereMesh;
  143107. private _getDebugCylinderMesh;
  143108. private _getDebugMeshMesh;
  143109. private _getDebugMesh;
  143110. /** Releases all resources */
  143111. dispose(): void;
  143112. }
  143113. }
  143114. declare module BABYLON {
  143115. /**
  143116. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  143117. * in order to better appreciate the issue one might have.
  143118. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  143119. */
  143120. export class RayHelper {
  143121. /**
  143122. * Defines the ray we are currently tryin to visualize.
  143123. */
  143124. ray: Nullable<Ray>;
  143125. private _renderPoints;
  143126. private _renderLine;
  143127. private _renderFunction;
  143128. private _scene;
  143129. private _onAfterRenderObserver;
  143130. private _onAfterStepObserver;
  143131. private _attachedToMesh;
  143132. private _meshSpaceDirection;
  143133. private _meshSpaceOrigin;
  143134. /**
  143135. * Helper function to create a colored helper in a scene in one line.
  143136. * @param ray Defines the ray we are currently tryin to visualize
  143137. * @param scene Defines the scene the ray is used in
  143138. * @param color Defines the color we want to see the ray in
  143139. * @returns The newly created ray helper.
  143140. */
  143141. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  143142. /**
  143143. * Instantiate a new ray helper.
  143144. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  143145. * in order to better appreciate the issue one might have.
  143146. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  143147. * @param ray Defines the ray we are currently tryin to visualize
  143148. */
  143149. constructor(ray: Ray);
  143150. /**
  143151. * Shows the ray we are willing to debug.
  143152. * @param scene Defines the scene the ray needs to be rendered in
  143153. * @param color Defines the color the ray needs to be rendered in
  143154. */
  143155. show(scene: Scene, color?: Color3): void;
  143156. /**
  143157. * Hides the ray we are debugging.
  143158. */
  143159. hide(): void;
  143160. private _render;
  143161. /**
  143162. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  143163. * @param mesh Defines the mesh we want the helper attached to
  143164. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  143165. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  143166. * @param length Defines the length of the ray
  143167. */
  143168. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  143169. /**
  143170. * Detach the ray helper from the mesh it has previously been attached to.
  143171. */
  143172. detachFromMesh(): void;
  143173. private _updateToMesh;
  143174. /**
  143175. * Dispose the helper and release its associated resources.
  143176. */
  143177. dispose(): void;
  143178. }
  143179. }
  143180. declare module BABYLON {
  143181. /**
  143182. * Defines the options associated with the creation of a SkeletonViewer.
  143183. */
  143184. export interface ISkeletonViewerOptions {
  143185. /** Should the system pause animations before building the Viewer? */
  143186. pauseAnimations: boolean;
  143187. /** Should the system return the skeleton to rest before building? */
  143188. returnToRest: boolean;
  143189. /** public Display Mode of the Viewer */
  143190. displayMode: number;
  143191. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  143192. displayOptions: ISkeletonViewerDisplayOptions;
  143193. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  143194. computeBonesUsingShaders: boolean;
  143195. /** Flag ignore non weighted bones */
  143196. useAllBones: boolean;
  143197. }
  143198. /**
  143199. * Defines how to display the various bone meshes for the viewer.
  143200. */
  143201. export interface ISkeletonViewerDisplayOptions {
  143202. /** How far down to start tapering the bone spurs */
  143203. midStep?: number;
  143204. /** How big is the midStep? */
  143205. midStepFactor?: number;
  143206. /** Base for the Sphere Size */
  143207. sphereBaseSize?: number;
  143208. /** The ratio of the sphere to the longest bone in units */
  143209. sphereScaleUnit?: number;
  143210. /** Ratio for the Sphere Size */
  143211. sphereFactor?: number;
  143212. /** Whether a spur should attach its far end to the child bone position */
  143213. spurFollowsChild?: boolean;
  143214. /** Whether to show local axes or not */
  143215. showLocalAxes?: boolean;
  143216. /** Length of each local axis */
  143217. localAxesSize?: number;
  143218. }
  143219. /**
  143220. * Defines the constructor options for the BoneWeight Shader.
  143221. */
  143222. export interface IBoneWeightShaderOptions {
  143223. /** Skeleton to Map */
  143224. skeleton: Skeleton;
  143225. /** Colors for Uninfluenced bones */
  143226. colorBase?: Color3;
  143227. /** Colors for 0.0-0.25 Weight bones */
  143228. colorZero?: Color3;
  143229. /** Color for 0.25-0.5 Weight Influence */
  143230. colorQuarter?: Color3;
  143231. /** Color for 0.5-0.75 Weight Influence */
  143232. colorHalf?: Color3;
  143233. /** Color for 0.75-1 Weight Influence */
  143234. colorFull?: Color3;
  143235. /** Color for Zero Weight Influence */
  143236. targetBoneIndex?: number;
  143237. }
  143238. /**
  143239. * Simple structure of the gradient steps for the Color Map.
  143240. */
  143241. export interface ISkeletonMapShaderColorMapKnot {
  143242. /** Color of the Knot */
  143243. color: Color3;
  143244. /** Location of the Knot */
  143245. location: number;
  143246. }
  143247. /**
  143248. * Defines the constructor options for the SkeletonMap Shader.
  143249. */
  143250. export interface ISkeletonMapShaderOptions {
  143251. /** Skeleton to Map */
  143252. skeleton: Skeleton;
  143253. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  143254. colorMap?: ISkeletonMapShaderColorMapKnot[];
  143255. }
  143256. }
  143257. declare module BABYLON {
  143258. /**
  143259. * Class containing static functions to help procedurally build meshes
  143260. */
  143261. export class RibbonBuilder {
  143262. /**
  143263. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143264. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143265. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143266. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143267. * * 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
  143268. * * 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
  143269. * * 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
  143270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143273. * * 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
  143274. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143275. * * 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
  143276. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143278. * @param name defines the name of the mesh
  143279. * @param options defines the options used to create the mesh
  143280. * @param scene defines the hosting scene
  143281. * @returns the ribbon mesh
  143282. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143284. */
  143285. static CreateRibbon(name: string, options: {
  143286. pathArray: Vector3[][];
  143287. closeArray?: boolean;
  143288. closePath?: boolean;
  143289. offset?: number;
  143290. updatable?: boolean;
  143291. sideOrientation?: number;
  143292. frontUVs?: Vector4;
  143293. backUVs?: Vector4;
  143294. instance?: Mesh;
  143295. invertUV?: boolean;
  143296. uvs?: Vector2[];
  143297. colors?: Color4[];
  143298. }, scene?: Nullable<Scene>): Mesh;
  143299. }
  143300. }
  143301. declare module BABYLON {
  143302. /**
  143303. * Class containing static functions to help procedurally build meshes
  143304. */
  143305. export class ShapeBuilder {
  143306. /**
  143307. * 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.
  143308. * * 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.
  143309. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143310. * * 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.
  143311. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143312. * * 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
  143313. * * 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
  143314. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143319. * @param name defines the name of the mesh
  143320. * @param options defines the options used to create the mesh
  143321. * @param scene defines the hosting scene
  143322. * @returns the extruded shape mesh
  143323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143325. */
  143326. static ExtrudeShape(name: string, options: {
  143327. shape: Vector3[];
  143328. path: Vector3[];
  143329. scale?: number;
  143330. rotation?: number;
  143331. cap?: number;
  143332. updatable?: boolean;
  143333. sideOrientation?: number;
  143334. frontUVs?: Vector4;
  143335. backUVs?: Vector4;
  143336. instance?: Mesh;
  143337. invertUV?: boolean;
  143338. }, scene?: Nullable<Scene>): Mesh;
  143339. /**
  143340. * Creates an custom extruded shape mesh.
  143341. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143342. * * 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.
  143343. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143344. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  143345. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143346. * * 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
  143347. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143348. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143349. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143350. * * 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
  143351. * * 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
  143352. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143357. * @param name defines the name of the mesh
  143358. * @param options defines the options used to create the mesh
  143359. * @param scene defines the hosting scene
  143360. * @returns the custom extruded shape mesh
  143361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143364. */
  143365. static ExtrudeShapeCustom(name: string, options: {
  143366. shape: Vector3[];
  143367. path: Vector3[];
  143368. scaleFunction?: any;
  143369. rotationFunction?: any;
  143370. ribbonCloseArray?: boolean;
  143371. ribbonClosePath?: boolean;
  143372. cap?: number;
  143373. updatable?: boolean;
  143374. sideOrientation?: number;
  143375. frontUVs?: Vector4;
  143376. backUVs?: Vector4;
  143377. instance?: Mesh;
  143378. invertUV?: boolean;
  143379. }, scene?: Nullable<Scene>): Mesh;
  143380. private static _ExtrudeShapeGeneric;
  143381. }
  143382. }
  143383. declare module BABYLON.Debug {
  143384. /**
  143385. * Class used to render a debug view of a given skeleton
  143386. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  143387. */
  143388. export class SkeletonViewer {
  143389. /** defines the skeleton to render */
  143390. skeleton: Skeleton;
  143391. /** defines the mesh attached to the skeleton */
  143392. mesh: AbstractMesh;
  143393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  143394. autoUpdateBonesMatrices: boolean;
  143395. /** defines the rendering group id to use with the viewer */
  143396. renderingGroupId: number;
  143397. /** is the options for the viewer */
  143398. options: Partial<ISkeletonViewerOptions>;
  143399. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  143400. static readonly DISPLAY_LINES: number;
  143401. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  143402. static readonly DISPLAY_SPHERES: number;
  143403. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  143404. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  143405. /** public static method to create a BoneWeight Shader
  143406. * @param options The constructor options
  143407. * @param scene The scene that the shader is scoped to
  143408. * @returns The created ShaderMaterial
  143409. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  143410. */
  143411. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  143412. /** public static method to create a BoneWeight Shader
  143413. * @param options The constructor options
  143414. * @param scene The scene that the shader is scoped to
  143415. * @returns The created ShaderMaterial
  143416. */
  143417. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  143418. /** private static method to create a BoneWeight Shader
  143419. * @param size The size of the buffer to create (usually the bone count)
  143420. * @param colorMap The gradient data to generate
  143421. * @param scene The scene that the shader is scoped to
  143422. * @returns an Array of floats from the color gradient values
  143423. */
  143424. private static _CreateBoneMapColorBuffer;
  143425. /** If SkeletonViewer scene scope. */
  143426. private _scene;
  143427. /** Gets or sets the color used to render the skeleton */
  143428. color: Color3;
  143429. /** Array of the points of the skeleton fo the line view. */
  143430. private _debugLines;
  143431. /** The SkeletonViewers Mesh. */
  143432. private _debugMesh;
  143433. /** The local axes Meshes. */
  143434. private _localAxes;
  143435. /** If SkeletonViewer is enabled. */
  143436. private _isEnabled;
  143437. /** If SkeletonViewer is ready. */
  143438. private _ready;
  143439. /** SkeletonViewer render observable. */
  143440. private _obs;
  143441. /** The Utility Layer to render the gizmos in. */
  143442. private _utilityLayer;
  143443. private _boneIndices;
  143444. /** Gets the Scene. */
  143445. get scene(): Scene;
  143446. /** Gets the utilityLayer. */
  143447. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  143448. /** Checks Ready Status. */
  143449. get isReady(): Boolean;
  143450. /** Sets Ready Status. */
  143451. set ready(value: boolean);
  143452. /** Gets the debugMesh */
  143453. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  143454. /** Sets the debugMesh */
  143455. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  143456. /** Gets the displayMode */
  143457. get displayMode(): number;
  143458. /** Sets the displayMode */
  143459. set displayMode(value: number);
  143460. /**
  143461. * Creates a new SkeletonViewer
  143462. * @param skeleton defines the skeleton to render
  143463. * @param mesh defines the mesh attached to the skeleton
  143464. * @param scene defines the hosting scene
  143465. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  143466. * @param renderingGroupId defines the rendering group id to use with the viewer
  143467. * @param options All of the extra constructor options for the SkeletonViewer
  143468. */
  143469. constructor(
  143470. /** defines the skeleton to render */
  143471. skeleton: Skeleton,
  143472. /** defines the mesh attached to the skeleton */
  143473. mesh: AbstractMesh,
  143474. /** The Scene scope*/
  143475. scene: Scene,
  143476. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  143477. autoUpdateBonesMatrices?: boolean,
  143478. /** defines the rendering group id to use with the viewer */
  143479. renderingGroupId?: number,
  143480. /** is the options for the viewer */
  143481. options?: Partial<ISkeletonViewerOptions>);
  143482. /** The Dynamic bindings for the update functions */
  143483. private _bindObs;
  143484. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  143485. update(): void;
  143486. /** Gets or sets a boolean indicating if the viewer is enabled */
  143487. set isEnabled(value: boolean);
  143488. get isEnabled(): boolean;
  143489. private _getBonePosition;
  143490. private _getLinesForBonesWithLength;
  143491. private _getLinesForBonesNoLength;
  143492. /** function to revert the mesh and scene back to the initial state. */
  143493. private _revert;
  143494. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  143495. private _getAbsoluteBindPoseToRef;
  143496. /** function to build and bind sphere joint points and spur bone representations. */
  143497. private _buildSpheresAndSpurs;
  143498. private _buildLocalAxes;
  143499. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  143500. private _displayLinesUpdate;
  143501. /** Changes the displayMode of the skeleton viewer
  143502. * @param mode The displayMode numerical value
  143503. */
  143504. changeDisplayMode(mode: number): void;
  143505. /** Sets a display option of the skeleton viewer
  143506. *
  143507. * | Option | Type | Default | Description |
  143508. * | ---------------- | ------- | ------- | ----------- |
  143509. * | 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`. |
  143510. * | 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`. |
  143511. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  143512. * | 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`. |
  143513. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  143514. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  143515. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  143516. *
  143517. * @param option String of the option name
  143518. * @param value The numerical option value
  143519. */
  143520. changeDisplayOptions(option: string, value: number): void;
  143521. /** Release associated resources */
  143522. dispose(): void;
  143523. }
  143524. }
  143525. declare module BABYLON {
  143526. /**
  143527. * Enum for Device Types
  143528. */
  143529. export enum DeviceType {
  143530. /** Generic */
  143531. Generic = 0,
  143532. /** Keyboard */
  143533. Keyboard = 1,
  143534. /** Mouse */
  143535. Mouse = 2,
  143536. /** Touch Pointers */
  143537. Touch = 3,
  143538. /** PS4 Dual Shock */
  143539. DualShock = 4,
  143540. /** Xbox */
  143541. Xbox = 5,
  143542. /** Switch Controller */
  143543. Switch = 6
  143544. }
  143545. /**
  143546. * Enum for All Pointers (Touch/Mouse)
  143547. */
  143548. export enum PointerInput {
  143549. /** Horizontal Axis */
  143550. Horizontal = 0,
  143551. /** Vertical Axis */
  143552. Vertical = 1,
  143553. /** Left Click or Touch */
  143554. LeftClick = 2,
  143555. /** Middle Click */
  143556. MiddleClick = 3,
  143557. /** Right Click */
  143558. RightClick = 4,
  143559. /** Browser Back */
  143560. BrowserBack = 5,
  143561. /** Browser Forward */
  143562. BrowserForward = 6
  143563. }
  143564. /**
  143565. * Enum for Dual Shock Gamepad
  143566. */
  143567. export enum DualShockInput {
  143568. /** Cross */
  143569. Cross = 0,
  143570. /** Circle */
  143571. Circle = 1,
  143572. /** Square */
  143573. Square = 2,
  143574. /** Triangle */
  143575. Triangle = 3,
  143576. /** L1 */
  143577. L1 = 4,
  143578. /** R1 */
  143579. R1 = 5,
  143580. /** L2 */
  143581. L2 = 6,
  143582. /** R2 */
  143583. R2 = 7,
  143584. /** Share */
  143585. Share = 8,
  143586. /** Options */
  143587. Options = 9,
  143588. /** L3 */
  143589. L3 = 10,
  143590. /** R3 */
  143591. R3 = 11,
  143592. /** DPadUp */
  143593. DPadUp = 12,
  143594. /** DPadDown */
  143595. DPadDown = 13,
  143596. /** DPadLeft */
  143597. DPadLeft = 14,
  143598. /** DRight */
  143599. DPadRight = 15,
  143600. /** Home */
  143601. Home = 16,
  143602. /** TouchPad */
  143603. TouchPad = 17,
  143604. /** LStickXAxis */
  143605. LStickXAxis = 18,
  143606. /** LStickYAxis */
  143607. LStickYAxis = 19,
  143608. /** RStickXAxis */
  143609. RStickXAxis = 20,
  143610. /** RStickYAxis */
  143611. RStickYAxis = 21
  143612. }
  143613. /**
  143614. * Enum for Xbox Gamepad
  143615. */
  143616. export enum XboxInput {
  143617. /** A */
  143618. A = 0,
  143619. /** B */
  143620. B = 1,
  143621. /** X */
  143622. X = 2,
  143623. /** Y */
  143624. Y = 3,
  143625. /** LB */
  143626. LB = 4,
  143627. /** RB */
  143628. RB = 5,
  143629. /** LT */
  143630. LT = 6,
  143631. /** RT */
  143632. RT = 7,
  143633. /** Back */
  143634. Back = 8,
  143635. /** Start */
  143636. Start = 9,
  143637. /** LS */
  143638. LS = 10,
  143639. /** RS */
  143640. RS = 11,
  143641. /** DPadUp */
  143642. DPadUp = 12,
  143643. /** DPadDown */
  143644. DPadDown = 13,
  143645. /** DPadLeft */
  143646. DPadLeft = 14,
  143647. /** DRight */
  143648. DPadRight = 15,
  143649. /** Home */
  143650. Home = 16,
  143651. /** LStickXAxis */
  143652. LStickXAxis = 17,
  143653. /** LStickYAxis */
  143654. LStickYAxis = 18,
  143655. /** RStickXAxis */
  143656. RStickXAxis = 19,
  143657. /** RStickYAxis */
  143658. RStickYAxis = 20
  143659. }
  143660. /**
  143661. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  143662. */
  143663. export enum SwitchInput {
  143664. /** B */
  143665. B = 0,
  143666. /** A */
  143667. A = 1,
  143668. /** Y */
  143669. Y = 2,
  143670. /** X */
  143671. X = 3,
  143672. /** L */
  143673. L = 4,
  143674. /** R */
  143675. R = 5,
  143676. /** ZL */
  143677. ZL = 6,
  143678. /** ZR */
  143679. ZR = 7,
  143680. /** Minus */
  143681. Minus = 8,
  143682. /** Plus */
  143683. Plus = 9,
  143684. /** LS */
  143685. LS = 10,
  143686. /** RS */
  143687. RS = 11,
  143688. /** DPadUp */
  143689. DPadUp = 12,
  143690. /** DPadDown */
  143691. DPadDown = 13,
  143692. /** DPadLeft */
  143693. DPadLeft = 14,
  143694. /** DRight */
  143695. DPadRight = 15,
  143696. /** Home */
  143697. Home = 16,
  143698. /** Capture */
  143699. Capture = 17,
  143700. /** LStickXAxis */
  143701. LStickXAxis = 18,
  143702. /** LStickYAxis */
  143703. LStickYAxis = 19,
  143704. /** RStickXAxis */
  143705. RStickXAxis = 20,
  143706. /** RStickYAxis */
  143707. RStickYAxis = 21
  143708. }
  143709. }
  143710. declare module BABYLON {
  143711. /**
  143712. * This class will take all inputs from Keyboard, Pointer, and
  143713. * any Gamepads and provide a polling system that all devices
  143714. * will use. This class assumes that there will only be one
  143715. * pointer device and one keyboard.
  143716. */
  143717. export class DeviceInputSystem implements IDisposable {
  143718. /**
  143719. * Returns onDeviceConnected callback property
  143720. * @returns Callback with function to execute when a device is connected
  143721. */
  143722. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  143723. /**
  143724. * Sets callback function when a device is connected and executes against all connected devices
  143725. * @param callback Function to execute when a device is connected
  143726. */
  143727. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  143728. /**
  143729. * Callback to be triggered when a device is disconnected
  143730. */
  143731. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  143732. /**
  143733. * Callback to be triggered when event driven input is updated
  143734. */
  143735. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  143736. private _inputs;
  143737. private _gamepads;
  143738. private _keyboardActive;
  143739. private _pointerActive;
  143740. private _elementToAttachTo;
  143741. private _keyboardDownEvent;
  143742. private _keyboardUpEvent;
  143743. private _pointerMoveEvent;
  143744. private _pointerDownEvent;
  143745. private _pointerUpEvent;
  143746. private _gamepadConnectedEvent;
  143747. private _gamepadDisconnectedEvent;
  143748. private _onDeviceConnected;
  143749. private static _MAX_KEYCODES;
  143750. private static _MAX_POINTER_INPUTS;
  143751. private constructor();
  143752. /**
  143753. * Creates a new DeviceInputSystem instance
  143754. * @param engine Engine to pull input element from
  143755. * @returns The new instance
  143756. */
  143757. static Create(engine: Engine): DeviceInputSystem;
  143758. /**
  143759. * Checks for current device input value, given an id and input index
  143760. * @param deviceName Id of connected device
  143761. * @param inputIndex Index of device input
  143762. * @returns Current value of input
  143763. */
  143764. /**
  143765. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  143766. * @param deviceType Enum specifiying device type
  143767. * @param deviceSlot "Slot" or index that device is referenced in
  143768. * @param inputIndex Id of input to be checked
  143769. * @returns Current value of input
  143770. */
  143771. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  143772. /**
  143773. * Dispose of all the eventlisteners
  143774. */
  143775. dispose(): void;
  143776. /**
  143777. * Checks for existing connections to devices and register them, if necessary
  143778. * Currently handles gamepads and mouse
  143779. */
  143780. private _checkForConnectedDevices;
  143781. /**
  143782. * Add a gamepad to the DeviceInputSystem
  143783. * @param gamepad A single DOM Gamepad object
  143784. */
  143785. private _addGamePad;
  143786. /**
  143787. * Add pointer device to DeviceInputSystem
  143788. * @param deviceType Type of Pointer to add
  143789. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  143790. * @param currentX Current X at point of adding
  143791. * @param currentY Current Y at point of adding
  143792. */
  143793. private _addPointerDevice;
  143794. /**
  143795. * Add device and inputs to device array
  143796. * @param deviceType Enum specifiying device type
  143797. * @param deviceSlot "Slot" or index that device is referenced in
  143798. * @param numberOfInputs Number of input entries to create for given device
  143799. */
  143800. private _registerDevice;
  143801. /**
  143802. * Given a specific device name, remove that device from the device map
  143803. * @param deviceType Enum specifiying device type
  143804. * @param deviceSlot "Slot" or index that device is referenced in
  143805. */
  143806. private _unregisterDevice;
  143807. /**
  143808. * Handle all actions that come from keyboard interaction
  143809. */
  143810. private _handleKeyActions;
  143811. /**
  143812. * Handle all actions that come from pointer interaction
  143813. */
  143814. private _handlePointerActions;
  143815. /**
  143816. * Handle all actions that come from gamepad interaction
  143817. */
  143818. private _handleGamepadActions;
  143819. /**
  143820. * Update all non-event based devices with each frame
  143821. * @param deviceType Enum specifiying device type
  143822. * @param deviceSlot "Slot" or index that device is referenced in
  143823. * @param inputIndex Id of input to be checked
  143824. */
  143825. private _updateDevice;
  143826. /**
  143827. * Gets DeviceType from the device name
  143828. * @param deviceName Name of Device from DeviceInputSystem
  143829. * @returns DeviceType enum value
  143830. */
  143831. private _getGamepadDeviceType;
  143832. }
  143833. }
  143834. declare module BABYLON {
  143835. /**
  143836. * Type to handle enforcement of inputs
  143837. */
  143838. 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;
  143839. }
  143840. declare module BABYLON {
  143841. /**
  143842. * Class that handles all input for a specific device
  143843. */
  143844. export class DeviceSource<T extends DeviceType> {
  143845. /** Type of device */
  143846. readonly deviceType: DeviceType;
  143847. /** "Slot" or index that device is referenced in */
  143848. readonly deviceSlot: number;
  143849. /**
  143850. * Observable to handle device input changes per device
  143851. */
  143852. readonly onInputChangedObservable: Observable<{
  143853. inputIndex: DeviceInput<T>;
  143854. previousState: Nullable<number>;
  143855. currentState: Nullable<number>;
  143856. }>;
  143857. private readonly _deviceInputSystem;
  143858. /**
  143859. * Default Constructor
  143860. * @param deviceInputSystem Reference to DeviceInputSystem
  143861. * @param deviceType Type of device
  143862. * @param deviceSlot "Slot" or index that device is referenced in
  143863. */
  143864. constructor(deviceInputSystem: DeviceInputSystem,
  143865. /** Type of device */
  143866. deviceType: DeviceType,
  143867. /** "Slot" or index that device is referenced in */
  143868. deviceSlot?: number);
  143869. /**
  143870. * Get input for specific input
  143871. * @param inputIndex index of specific input on device
  143872. * @returns Input value from DeviceInputSystem
  143873. */
  143874. getInput(inputIndex: DeviceInput<T>): number;
  143875. }
  143876. /**
  143877. * Class to keep track of devices
  143878. */
  143879. export class DeviceSourceManager implements IDisposable {
  143880. /**
  143881. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  143882. */
  143883. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  143884. /**
  143885. * Observable to be triggered when after a device is disconnected
  143886. */
  143887. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  143888. private readonly _devices;
  143889. private readonly _firstDevice;
  143890. private readonly _deviceInputSystem;
  143891. /**
  143892. * Default Constructor
  143893. * @param engine engine to pull input element from
  143894. */
  143895. constructor(engine: Engine);
  143896. /**
  143897. * Gets a DeviceSource, given a type and slot
  143898. * @param deviceType Enum specifying device type
  143899. * @param deviceSlot "Slot" or index that device is referenced in
  143900. * @returns DeviceSource object
  143901. */
  143902. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  143903. /**
  143904. * Gets an array of DeviceSource objects for a given device type
  143905. * @param deviceType Enum specifying device type
  143906. * @returns Array of DeviceSource objects
  143907. */
  143908. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  143909. /**
  143910. * Returns a read-only list of all available devices
  143911. * @returns Read-only array with active devices
  143912. */
  143913. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  143914. /**
  143915. * Dispose of DeviceInputSystem and other parts
  143916. */
  143917. dispose(): void;
  143918. /**
  143919. * Function to add device name to device list
  143920. * @param deviceType Enum specifying device type
  143921. * @param deviceSlot "Slot" or index that device is referenced in
  143922. */
  143923. private _addDevice;
  143924. /**
  143925. * Function to remove device name to device list
  143926. * @param deviceType Enum specifying device type
  143927. * @param deviceSlot "Slot" or index that device is referenced in
  143928. */
  143929. private _removeDevice;
  143930. /**
  143931. * Updates array storing first connected device of each type
  143932. * @param type Type of Device
  143933. */
  143934. private _updateFirstDevices;
  143935. }
  143936. }
  143937. declare module BABYLON {
  143938. /**
  143939. * Options to create the null engine
  143940. */
  143941. export class NullEngineOptions {
  143942. /**
  143943. * Render width (Default: 512)
  143944. */
  143945. renderWidth: number;
  143946. /**
  143947. * Render height (Default: 256)
  143948. */
  143949. renderHeight: number;
  143950. /**
  143951. * Texture size (Default: 512)
  143952. */
  143953. textureSize: number;
  143954. /**
  143955. * If delta time between frames should be constant
  143956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143957. */
  143958. deterministicLockstep: boolean;
  143959. /**
  143960. * Maximum about of steps between frames (Default: 4)
  143961. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143962. */
  143963. lockstepMaxSteps: number;
  143964. /**
  143965. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  143966. */
  143967. useHighPrecisionMatrix?: boolean;
  143968. }
  143969. /**
  143970. * The null engine class provides support for headless version of babylon.js.
  143971. * This can be used in server side scenario or for testing purposes
  143972. */
  143973. export class NullEngine extends Engine {
  143974. private _options;
  143975. /**
  143976. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  143977. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143978. * @returns true if engine is in deterministic lock step mode
  143979. */
  143980. isDeterministicLockStep(): boolean;
  143981. /**
  143982. * Gets the max steps when engine is running in deterministic lock step
  143983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143984. * @returns the max steps
  143985. */
  143986. getLockstepMaxSteps(): number;
  143987. /**
  143988. * Gets the current hardware scaling level.
  143989. * By default the hardware scaling level is computed from the window device ratio.
  143990. * 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.
  143991. * @returns a number indicating the current hardware scaling level
  143992. */
  143993. getHardwareScalingLevel(): number;
  143994. constructor(options?: NullEngineOptions);
  143995. /**
  143996. * Creates a vertex buffer
  143997. * @param vertices the data for the vertex buffer
  143998. * @returns the new WebGL static buffer
  143999. */
  144000. createVertexBuffer(vertices: FloatArray): DataBuffer;
  144001. /**
  144002. * Creates a new index buffer
  144003. * @param indices defines the content of the index buffer
  144004. * @param updatable defines if the index buffer must be updatable
  144005. * @returns a new webGL buffer
  144006. */
  144007. createIndexBuffer(indices: IndicesArray): DataBuffer;
  144008. /**
  144009. * Clear the current render buffer or the current render target (if any is set up)
  144010. * @param color defines the color to use
  144011. * @param backBuffer defines if the back buffer must be cleared
  144012. * @param depth defines if the depth buffer must be cleared
  144013. * @param stencil defines if the stencil buffer must be cleared
  144014. */
  144015. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  144016. /**
  144017. * Gets the current render width
  144018. * @param useScreen defines if screen size must be used (or the current render target if any)
  144019. * @returns a number defining the current render width
  144020. */
  144021. getRenderWidth(useScreen?: boolean): number;
  144022. /**
  144023. * Gets the current render height
  144024. * @param useScreen defines if screen size must be used (or the current render target if any)
  144025. * @returns a number defining the current render height
  144026. */
  144027. getRenderHeight(useScreen?: boolean): number;
  144028. /**
  144029. * Set the WebGL's viewport
  144030. * @param viewport defines the viewport element to be used
  144031. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  144032. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  144033. */
  144034. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  144035. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  144036. /**
  144037. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  144038. * @param pipelineContext defines the pipeline context to use
  144039. * @param uniformsNames defines the list of uniform names
  144040. * @returns an array of webGL uniform locations
  144041. */
  144042. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  144043. /**
  144044. * Gets the lsit of active attributes for a given webGL program
  144045. * @param pipelineContext defines the pipeline context to use
  144046. * @param attributesNames defines the list of attribute names to get
  144047. * @returns an array of indices indicating the offset of each attribute
  144048. */
  144049. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  144050. /**
  144051. * Binds an effect to the webGL context
  144052. * @param effect defines the effect to bind
  144053. */
  144054. bindSamplers(effect: Effect): void;
  144055. /**
  144056. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  144057. * @param effect defines the effect to activate
  144058. */
  144059. enableEffect(effect: Effect): void;
  144060. /**
  144061. * Set various states to the webGL context
  144062. * @param culling defines backface culling state
  144063. * @param zOffset defines the value to apply to zOffset (0 by default)
  144064. * @param force defines if states must be applied even if cache is up to date
  144065. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  144066. */
  144067. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  144068. /**
  144069. * Set the value of an uniform to an array of int32
  144070. * @param uniform defines the webGL uniform location where to store the value
  144071. * @param array defines the array of int32 to store
  144072. * @returns true if value was set
  144073. */
  144074. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144075. /**
  144076. * Set the value of an uniform to an array of int32 (stored as vec2)
  144077. * @param uniform defines the webGL uniform location where to store the value
  144078. * @param array defines the array of int32 to store
  144079. * @returns true if value was set
  144080. */
  144081. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144082. /**
  144083. * Set the value of an uniform to an array of int32 (stored as vec3)
  144084. * @param uniform defines the webGL uniform location where to store the value
  144085. * @param array defines the array of int32 to store
  144086. * @returns true if value was set
  144087. */
  144088. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144089. /**
  144090. * Set the value of an uniform to an array of int32 (stored as vec4)
  144091. * @param uniform defines the webGL uniform location where to store the value
  144092. * @param array defines the array of int32 to store
  144093. * @returns true if value was set
  144094. */
  144095. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144096. /**
  144097. * Set the value of an uniform to an array of float32
  144098. * @param uniform defines the webGL uniform location where to store the value
  144099. * @param array defines the array of float32 to store
  144100. * @returns true if value was set
  144101. */
  144102. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144103. /**
  144104. * Set the value of an uniform to an array of float32 (stored as vec2)
  144105. * @param uniform defines the webGL uniform location where to store the value
  144106. * @param array defines the array of float32 to store
  144107. * @returns true if value was set
  144108. */
  144109. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144110. /**
  144111. * Set the value of an uniform to an array of float32 (stored as vec3)
  144112. * @param uniform defines the webGL uniform location where to store the value
  144113. * @param array defines the array of float32 to store
  144114. * @returns true if value was set
  144115. */
  144116. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144117. /**
  144118. * Set the value of an uniform to an array of float32 (stored as vec4)
  144119. * @param uniform defines the webGL uniform location where to store the value
  144120. * @param array defines the array of float32 to store
  144121. * @returns true if value was set
  144122. */
  144123. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144124. /**
  144125. * Set the value of an uniform to an array of number
  144126. * @param uniform defines the webGL uniform location where to store the value
  144127. * @param array defines the array of number to store
  144128. * @returns true if value was set
  144129. */
  144130. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  144131. /**
  144132. * Set the value of an uniform to an array of number (stored as vec2)
  144133. * @param uniform defines the webGL uniform location where to store the value
  144134. * @param array defines the array of number to store
  144135. * @returns true if value was set
  144136. */
  144137. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  144138. /**
  144139. * Set the value of an uniform to an array of number (stored as vec3)
  144140. * @param uniform defines the webGL uniform location where to store the value
  144141. * @param array defines the array of number to store
  144142. * @returns true if value was set
  144143. */
  144144. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  144145. /**
  144146. * Set the value of an uniform to an array of number (stored as vec4)
  144147. * @param uniform defines the webGL uniform location where to store the value
  144148. * @param array defines the array of number to store
  144149. * @returns true if value was set
  144150. */
  144151. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  144152. /**
  144153. * Set the value of an uniform to an array of float32 (stored as matrices)
  144154. * @param uniform defines the webGL uniform location where to store the value
  144155. * @param matrices defines the array of float32 to store
  144156. * @returns true if value was set
  144157. */
  144158. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  144159. /**
  144160. * Set the value of an uniform to a matrix (3x3)
  144161. * @param uniform defines the webGL uniform location where to store the value
  144162. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  144163. * @returns true if value was set
  144164. */
  144165. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144166. /**
  144167. * Set the value of an uniform to a matrix (2x2)
  144168. * @param uniform defines the webGL uniform location where to store the value
  144169. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  144170. * @returns true if value was set
  144171. */
  144172. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144173. /**
  144174. * Set the value of an uniform to a number (float)
  144175. * @param uniform defines the webGL uniform location where to store the value
  144176. * @param value defines the float number to store
  144177. * @returns true if value was set
  144178. */
  144179. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  144180. /**
  144181. * Set the value of an uniform to a vec2
  144182. * @param uniform defines the webGL uniform location where to store the value
  144183. * @param x defines the 1st component of the value
  144184. * @param y defines the 2nd component of the value
  144185. * @returns true if value was set
  144186. */
  144187. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  144188. /**
  144189. * Set the value of an uniform to a vec3
  144190. * @param uniform defines the webGL uniform location where to store the value
  144191. * @param x defines the 1st component of the value
  144192. * @param y defines the 2nd component of the value
  144193. * @param z defines the 3rd component of the value
  144194. * @returns true if value was set
  144195. */
  144196. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  144197. /**
  144198. * Set the value of an uniform to a boolean
  144199. * @param uniform defines the webGL uniform location where to store the value
  144200. * @param bool defines the boolean to store
  144201. * @returns true if value was set
  144202. */
  144203. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  144204. /**
  144205. * Set the value of an uniform to a vec4
  144206. * @param uniform defines the webGL uniform location where to store the value
  144207. * @param x defines the 1st component of the value
  144208. * @param y defines the 2nd component of the value
  144209. * @param z defines the 3rd component of the value
  144210. * @param w defines the 4th component of the value
  144211. * @returns true if value was set
  144212. */
  144213. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  144214. /**
  144215. * Sets the current alpha mode
  144216. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  144217. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  144218. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144219. */
  144220. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  144221. /**
  144222. * Bind webGl buffers directly to the webGL context
  144223. * @param vertexBuffers defines the vertex buffer to bind
  144224. * @param indexBuffer defines the index buffer to bind
  144225. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  144226. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  144227. * @param effect defines the effect associated with the vertex buffer
  144228. */
  144229. bindBuffers(vertexBuffers: {
  144230. [key: string]: VertexBuffer;
  144231. }, indexBuffer: DataBuffer, effect: Effect): void;
  144232. /**
  144233. * Force the entire cache to be cleared
  144234. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  144235. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  144236. */
  144237. wipeCaches(bruteForce?: boolean): void;
  144238. /**
  144239. * Send a draw order
  144240. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  144241. * @param indexStart defines the starting index
  144242. * @param indexCount defines the number of index to draw
  144243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144244. */
  144245. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  144246. /**
  144247. * Draw a list of indexed primitives
  144248. * @param fillMode defines the primitive to use
  144249. * @param indexStart defines the starting index
  144250. * @param indexCount defines the number of index to draw
  144251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144252. */
  144253. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  144254. /**
  144255. * Draw a list of unindexed primitives
  144256. * @param fillMode defines the primitive to use
  144257. * @param verticesStart defines the index of first vertex to draw
  144258. * @param verticesCount defines the count of vertices to draw
  144259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144260. */
  144261. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  144262. /** @hidden */
  144263. protected _createTexture(): WebGLTexture;
  144264. /** @hidden */
  144265. _releaseTexture(texture: InternalTexture): void;
  144266. /**
  144267. * Usually called from Texture.ts.
  144268. * Passed information to create a WebGLTexture
  144269. * @param urlArg defines a value which contains one of the following:
  144270. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  144271. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  144272. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  144273. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  144274. * @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)
  144275. * @param scene needed for loading to the correct scene
  144276. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  144277. * @param onLoad optional callback to be called upon successful completion
  144278. * @param onError optional callback to be called upon failure
  144279. * @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
  144280. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  144281. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  144282. * @param forcedExtension defines the extension to use to pick the right loader
  144283. * @param mimeType defines an optional mime type
  144284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  144285. */
  144286. 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;
  144287. /**
  144288. * Creates a new render target texture
  144289. * @param size defines the size of the texture
  144290. * @param options defines the options used to create the texture
  144291. * @returns a new render target texture stored in an InternalTexture
  144292. */
  144293. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  144294. /**
  144295. * Update the sampling mode of a given texture
  144296. * @param samplingMode defines the required sampling mode
  144297. * @param texture defines the texture to update
  144298. */
  144299. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  144300. /**
  144301. * Binds the frame buffer to the specified texture.
  144302. * @param texture The texture to render to or null for the default canvas
  144303. * @param faceIndex The face of the texture to render to in case of cube texture
  144304. * @param requiredWidth The width of the target to render to
  144305. * @param requiredHeight The height of the target to render to
  144306. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  144307. * @param lodLevel defines le lod level to bind to the frame buffer
  144308. */
  144309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  144310. /**
  144311. * Unbind the current render target texture from the webGL context
  144312. * @param texture defines the render target texture to unbind
  144313. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  144314. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  144315. */
  144316. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  144317. /**
  144318. * Creates a dynamic vertex buffer
  144319. * @param vertices the data for the dynamic vertex buffer
  144320. * @returns the new WebGL dynamic buffer
  144321. */
  144322. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  144323. /**
  144324. * Update the content of a dynamic texture
  144325. * @param texture defines the texture to update
  144326. * @param canvas defines the canvas containing the source
  144327. * @param invertY defines if data must be stored with Y axis inverted
  144328. * @param premulAlpha defines if alpha is stored as premultiplied
  144329. * @param format defines the format of the data
  144330. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  144331. */
  144332. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  144333. /**
  144334. * Gets a boolean indicating if all created effects are ready
  144335. * @returns true if all effects are ready
  144336. */
  144337. areAllEffectsReady(): boolean;
  144338. /**
  144339. * @hidden
  144340. * Get the current error code of the webGL context
  144341. * @returns the error code
  144342. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  144343. */
  144344. getError(): number;
  144345. /** @hidden */
  144346. _getUnpackAlignement(): number;
  144347. /** @hidden */
  144348. _unpackFlipY(value: boolean): void;
  144349. /**
  144350. * Update a dynamic index buffer
  144351. * @param indexBuffer defines the target index buffer
  144352. * @param indices defines the data to update
  144353. * @param offset defines the offset in the target index buffer where update should start
  144354. */
  144355. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  144356. /**
  144357. * Updates a dynamic vertex buffer.
  144358. * @param vertexBuffer the vertex buffer to update
  144359. * @param vertices the data used to update the vertex buffer
  144360. * @param byteOffset the byte offset of the data (optional)
  144361. * @param byteLength the byte length of the data (optional)
  144362. */
  144363. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  144364. /** @hidden */
  144365. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  144366. /** @hidden */
  144367. _bindTexture(channel: number, texture: InternalTexture): void;
  144368. protected _deleteBuffer(buffer: WebGLBuffer): void;
  144369. /**
  144370. * 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
  144371. */
  144372. releaseEffects(): void;
  144373. displayLoadingUI(): void;
  144374. hideLoadingUI(): void;
  144375. /** @hidden */
  144376. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144377. /** @hidden */
  144378. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144379. /** @hidden */
  144380. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144381. /** @hidden */
  144382. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  144383. }
  144384. }
  144385. declare module BABYLON {
  144386. /** @hidden */
  144387. export class _OcclusionDataStorage {
  144388. /** @hidden */
  144389. occlusionInternalRetryCounter: number;
  144390. /** @hidden */
  144391. isOcclusionQueryInProgress: boolean;
  144392. /** @hidden */
  144393. isOccluded: boolean;
  144394. /** @hidden */
  144395. occlusionRetryCount: number;
  144396. /** @hidden */
  144397. occlusionType: number;
  144398. /** @hidden */
  144399. occlusionQueryAlgorithmType: number;
  144400. }
  144401. interface Engine {
  144402. /**
  144403. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  144404. * @return the new query
  144405. */
  144406. createQuery(): WebGLQuery;
  144407. /**
  144408. * Delete and release a webGL query
  144409. * @param query defines the query to delete
  144410. * @return the current engine
  144411. */
  144412. deleteQuery(query: WebGLQuery): Engine;
  144413. /**
  144414. * Check if a given query has resolved and got its value
  144415. * @param query defines the query to check
  144416. * @returns true if the query got its value
  144417. */
  144418. isQueryResultAvailable(query: WebGLQuery): boolean;
  144419. /**
  144420. * Gets the value of a given query
  144421. * @param query defines the query to check
  144422. * @returns the value of the query
  144423. */
  144424. getQueryResult(query: WebGLQuery): number;
  144425. /**
  144426. * Initiates an occlusion query
  144427. * @param algorithmType defines the algorithm to use
  144428. * @param query defines the query to use
  144429. * @returns the current engine
  144430. * @see https://doc.babylonjs.com/features/occlusionquery
  144431. */
  144432. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  144433. /**
  144434. * Ends an occlusion query
  144435. * @see https://doc.babylonjs.com/features/occlusionquery
  144436. * @param algorithmType defines the algorithm to use
  144437. * @returns the current engine
  144438. */
  144439. endOcclusionQuery(algorithmType: number): Engine;
  144440. /**
  144441. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  144442. * Please note that only one query can be issued at a time
  144443. * @returns a time token used to track the time span
  144444. */
  144445. startTimeQuery(): Nullable<_TimeToken>;
  144446. /**
  144447. * Ends a time query
  144448. * @param token defines the token used to measure the time span
  144449. * @returns the time spent (in ns)
  144450. */
  144451. endTimeQuery(token: _TimeToken): int;
  144452. /** @hidden */
  144453. _currentNonTimestampToken: Nullable<_TimeToken>;
  144454. /** @hidden */
  144455. _createTimeQuery(): WebGLQuery;
  144456. /** @hidden */
  144457. _deleteTimeQuery(query: WebGLQuery): void;
  144458. /** @hidden */
  144459. _getGlAlgorithmType(algorithmType: number): number;
  144460. /** @hidden */
  144461. _getTimeQueryResult(query: WebGLQuery): any;
  144462. /** @hidden */
  144463. _getTimeQueryAvailability(query: WebGLQuery): any;
  144464. }
  144465. interface AbstractMesh {
  144466. /**
  144467. * Backing filed
  144468. * @hidden
  144469. */
  144470. __occlusionDataStorage: _OcclusionDataStorage;
  144471. /**
  144472. * Access property
  144473. * @hidden
  144474. */
  144475. _occlusionDataStorage: _OcclusionDataStorage;
  144476. /**
  144477. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  144478. * The default value is -1 which means don't break the query and wait till the result
  144479. * @see https://doc.babylonjs.com/features/occlusionquery
  144480. */
  144481. occlusionRetryCount: number;
  144482. /**
  144483. * 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:
  144484. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  144485. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  144486. * * 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.
  144487. * @see https://doc.babylonjs.com/features/occlusionquery
  144488. */
  144489. occlusionType: number;
  144490. /**
  144491. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  144492. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  144493. * * 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.
  144494. * @see https://doc.babylonjs.com/features/occlusionquery
  144495. */
  144496. occlusionQueryAlgorithmType: number;
  144497. /**
  144498. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  144499. * @see https://doc.babylonjs.com/features/occlusionquery
  144500. */
  144501. isOccluded: boolean;
  144502. /**
  144503. * Flag to check the progress status of the query
  144504. * @see https://doc.babylonjs.com/features/occlusionquery
  144505. */
  144506. isOcclusionQueryInProgress: boolean;
  144507. }
  144508. }
  144509. declare module BABYLON {
  144510. /** @hidden */
  144511. export var _forceTransformFeedbackToBundle: boolean;
  144512. interface Engine {
  144513. /**
  144514. * Creates a webGL transform feedback object
  144515. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  144516. * @returns the webGL transform feedback object
  144517. */
  144518. createTransformFeedback(): WebGLTransformFeedback;
  144519. /**
  144520. * Delete a webGL transform feedback object
  144521. * @param value defines the webGL transform feedback object to delete
  144522. */
  144523. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  144524. /**
  144525. * Bind a webGL transform feedback object to the webgl context
  144526. * @param value defines the webGL transform feedback object to bind
  144527. */
  144528. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  144529. /**
  144530. * Begins a transform feedback operation
  144531. * @param usePoints defines if points or triangles must be used
  144532. */
  144533. beginTransformFeedback(usePoints: boolean): void;
  144534. /**
  144535. * Ends a transform feedback operation
  144536. */
  144537. endTransformFeedback(): void;
  144538. /**
  144539. * Specify the varyings to use with transform feedback
  144540. * @param program defines the associated webGL program
  144541. * @param value defines the list of strings representing the varying names
  144542. */
  144543. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  144544. /**
  144545. * Bind a webGL buffer for a transform feedback operation
  144546. * @param value defines the webGL buffer to bind
  144547. */
  144548. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  144549. }
  144550. }
  144551. declare module BABYLON {
  144552. /**
  144553. * Class used to define an additional view for the engine
  144554. * @see https://doc.babylonjs.com/how_to/multi_canvases
  144555. */
  144556. export class EngineView {
  144557. /** Defines the canvas where to render the view */
  144558. target: HTMLCanvasElement;
  144559. /** Defines an optional camera used to render the view (will use active camera else) */
  144560. camera?: Camera;
  144561. }
  144562. interface Engine {
  144563. /**
  144564. * Gets or sets the HTML element to use for attaching events
  144565. */
  144566. inputElement: Nullable<HTMLElement>;
  144567. /**
  144568. * Gets the current engine view
  144569. * @see https://doc.babylonjs.com/how_to/multi_canvases
  144570. */
  144571. activeView: Nullable<EngineView>;
  144572. /** Gets or sets the list of views */
  144573. views: EngineView[];
  144574. /**
  144575. * Register a new child canvas
  144576. * @param canvas defines the canvas to register
  144577. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  144578. * @returns the associated view
  144579. */
  144580. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  144581. /**
  144582. * Remove a registered child canvas
  144583. * @param canvas defines the canvas to remove
  144584. * @returns the current engine
  144585. */
  144586. unRegisterView(canvas: HTMLCanvasElement): Engine;
  144587. }
  144588. }
  144589. declare module BABYLON {
  144590. interface Engine {
  144591. /** @hidden */
  144592. _excludedCompressedTextures: string[];
  144593. /** @hidden */
  144594. _textureFormatInUse: string;
  144595. /**
  144596. * Gets the list of texture formats supported
  144597. */
  144598. readonly texturesSupported: Array<string>;
  144599. /**
  144600. * Gets the texture format in use
  144601. */
  144602. readonly textureFormatInUse: Nullable<string>;
  144603. /**
  144604. * Set the compressed texture extensions or file names to skip.
  144605. *
  144606. * @param skippedFiles defines the list of those texture files you want to skip
  144607. * Example: [".dds", ".env", "myfile.png"]
  144608. */
  144609. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  144610. /**
  144611. * Set the compressed texture format to use, based on the formats you have, and the formats
  144612. * supported by the hardware / browser.
  144613. *
  144614. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  144615. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  144616. * to API arguments needed to compressed textures. This puts the burden on the container
  144617. * generator to house the arcane code for determining these for current & future formats.
  144618. *
  144619. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  144620. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  144621. *
  144622. * Note: The result of this call is not taken into account when a texture is base64.
  144623. *
  144624. * @param formatsAvailable defines the list of those format families you have created
  144625. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  144626. *
  144627. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  144628. * @returns The extension selected.
  144629. */
  144630. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  144631. }
  144632. }
  144633. declare module BABYLON {
  144634. /** @hidden */
  144635. export var rgbdEncodePixelShader: {
  144636. name: string;
  144637. shader: string;
  144638. };
  144639. }
  144640. declare module BABYLON {
  144641. /**
  144642. * Raw texture data and descriptor sufficient for WebGL texture upload
  144643. */
  144644. export interface EnvironmentTextureInfo {
  144645. /**
  144646. * Version of the environment map
  144647. */
  144648. version: number;
  144649. /**
  144650. * Width of image
  144651. */
  144652. width: number;
  144653. /**
  144654. * Irradiance information stored in the file.
  144655. */
  144656. irradiance: any;
  144657. /**
  144658. * Specular information stored in the file.
  144659. */
  144660. specular: any;
  144661. }
  144662. /**
  144663. * Defines One Image in the file. It requires only the position in the file
  144664. * as well as the length.
  144665. */
  144666. interface BufferImageData {
  144667. /**
  144668. * Length of the image data.
  144669. */
  144670. length: number;
  144671. /**
  144672. * Position of the data from the null terminator delimiting the end of the JSON.
  144673. */
  144674. position: number;
  144675. }
  144676. /**
  144677. * Defines the specular data enclosed in the file.
  144678. * This corresponds to the version 1 of the data.
  144679. */
  144680. export interface EnvironmentTextureSpecularInfoV1 {
  144681. /**
  144682. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  144683. */
  144684. specularDataPosition?: number;
  144685. /**
  144686. * This contains all the images data needed to reconstruct the cubemap.
  144687. */
  144688. mipmaps: Array<BufferImageData>;
  144689. /**
  144690. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  144691. */
  144692. lodGenerationScale: number;
  144693. }
  144694. /**
  144695. * Sets of helpers addressing the serialization and deserialization of environment texture
  144696. * stored in a BabylonJS env file.
  144697. * Those files are usually stored as .env files.
  144698. */
  144699. export class EnvironmentTextureTools {
  144700. /**
  144701. * Magic number identifying the env file.
  144702. */
  144703. private static _MagicBytes;
  144704. /**
  144705. * Gets the environment info from an env file.
  144706. * @param data The array buffer containing the .env bytes.
  144707. * @returns the environment file info (the json header) if successfully parsed.
  144708. */
  144709. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  144710. /**
  144711. * Creates an environment texture from a loaded cube texture.
  144712. * @param texture defines the cube texture to convert in env file
  144713. * @return a promise containing the environment data if succesfull.
  144714. */
  144715. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  144716. /**
  144717. * Creates a JSON representation of the spherical data.
  144718. * @param texture defines the texture containing the polynomials
  144719. * @return the JSON representation of the spherical info
  144720. */
  144721. private static _CreateEnvTextureIrradiance;
  144722. /**
  144723. * Creates the ArrayBufferViews used for initializing environment texture image data.
  144724. * @param data the image data
  144725. * @param info parameters that determine what views will be created for accessing the underlying buffer
  144726. * @return the views described by info providing access to the underlying buffer
  144727. */
  144728. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  144729. /**
  144730. * Uploads the texture info contained in the env file to the GPU.
  144731. * @param texture defines the internal texture to upload to
  144732. * @param data defines the data to load
  144733. * @param info defines the texture info retrieved through the GetEnvInfo method
  144734. * @returns a promise
  144735. */
  144736. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  144737. private static _OnImageReadyAsync;
  144738. /**
  144739. * Uploads the levels of image data to the GPU.
  144740. * @param texture defines the internal texture to upload to
  144741. * @param imageData defines the array buffer views of image data [mipmap][face]
  144742. * @returns a promise
  144743. */
  144744. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  144745. /**
  144746. * Uploads spherical polynomials information to the texture.
  144747. * @param texture defines the texture we are trying to upload the information to
  144748. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  144749. */
  144750. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  144751. /** @hidden */
  144752. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144753. }
  144754. }
  144755. declare module BABYLON {
  144756. /**
  144757. * Container for accessors for natively-stored mesh data buffers.
  144758. */
  144759. class NativeDataBuffer extends DataBuffer {
  144760. /**
  144761. * Accessor value used to identify/retrieve a natively-stored index buffer.
  144762. */
  144763. nativeIndexBuffer?: any;
  144764. /**
  144765. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  144766. */
  144767. nativeVertexBuffer?: any;
  144768. }
  144769. /** @hidden */
  144770. class NativeTexture extends InternalTexture {
  144771. getInternalTexture(): InternalTexture;
  144772. getViewCount(): number;
  144773. }
  144774. /** @hidden */
  144775. export class NativeEngine extends Engine {
  144776. private readonly _native;
  144777. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  144778. private readonly INVALID_HANDLE;
  144779. private _boundBuffersVertexArray;
  144780. private _currentDepthTest;
  144781. getHardwareScalingLevel(): number;
  144782. constructor();
  144783. dispose(): void;
  144784. /**
  144785. * Can be used to override the current requestAnimationFrame requester.
  144786. * @hidden
  144787. */
  144788. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  144789. /**
  144790. * Override default engine behavior.
  144791. * @param color
  144792. * @param backBuffer
  144793. * @param depth
  144794. * @param stencil
  144795. */
  144796. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  144797. /**
  144798. * Gets host document
  144799. * @returns the host document object
  144800. */
  144801. getHostDocument(): Nullable<Document>;
  144802. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  144803. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  144804. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  144805. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  144806. [key: string]: VertexBuffer;
  144807. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144808. bindBuffers(vertexBuffers: {
  144809. [key: string]: VertexBuffer;
  144810. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144811. recordVertexArrayObject(vertexBuffers: {
  144812. [key: string]: VertexBuffer;
  144813. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  144814. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144815. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144816. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  144817. /**
  144818. * Draw a list of indexed primitives
  144819. * @param fillMode defines the primitive to use
  144820. * @param indexStart defines the starting index
  144821. * @param indexCount defines the number of index to draw
  144822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144823. */
  144824. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  144825. /**
  144826. * Draw a list of unindexed primitives
  144827. * @param fillMode defines the primitive to use
  144828. * @param verticesStart defines the index of first vertex to draw
  144829. * @param verticesCount defines the count of vertices to draw
  144830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144831. */
  144832. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  144833. createPipelineContext(): IPipelineContext;
  144834. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  144835. /** @hidden */
  144836. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  144837. /** @hidden */
  144838. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  144839. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144840. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144841. protected _setProgram(program: WebGLProgram): void;
  144842. _releaseEffect(effect: Effect): void;
  144843. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  144844. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  144845. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  144846. bindSamplers(effect: Effect): void;
  144847. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  144848. getRenderWidth(useScreen?: boolean): number;
  144849. getRenderHeight(useScreen?: boolean): number;
  144850. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  144851. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  144852. /**
  144853. * Set the z offset to apply to current rendering
  144854. * @param value defines the offset to apply
  144855. */
  144856. setZOffset(value: number): void;
  144857. /**
  144858. * Gets the current value of the zOffset
  144859. * @returns the current zOffset state
  144860. */
  144861. getZOffset(): number;
  144862. /**
  144863. * Enable or disable depth buffering
  144864. * @param enable defines the state to set
  144865. */
  144866. setDepthBuffer(enable: boolean): void;
  144867. /**
  144868. * Gets a boolean indicating if depth writing is enabled
  144869. * @returns the current depth writing state
  144870. */
  144871. getDepthWrite(): boolean;
  144872. setDepthFunctionToGreater(): void;
  144873. setDepthFunctionToGreaterOrEqual(): void;
  144874. setDepthFunctionToLess(): void;
  144875. setDepthFunctionToLessOrEqual(): void;
  144876. /**
  144877. * Enable or disable depth writing
  144878. * @param enable defines the state to set
  144879. */
  144880. setDepthWrite(enable: boolean): void;
  144881. /**
  144882. * Enable or disable color writing
  144883. * @param enable defines the state to set
  144884. */
  144885. setColorWrite(enable: boolean): void;
  144886. /**
  144887. * Gets a boolean indicating if color writing is enabled
  144888. * @returns the current color writing state
  144889. */
  144890. getColorWrite(): boolean;
  144891. /**
  144892. * Sets alpha constants used by some alpha blending modes
  144893. * @param r defines the red component
  144894. * @param g defines the green component
  144895. * @param b defines the blue component
  144896. * @param a defines the alpha component
  144897. */
  144898. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  144899. /**
  144900. * Sets the current alpha mode
  144901. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  144902. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  144903. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144904. */
  144905. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  144906. /**
  144907. * Gets the current alpha mode
  144908. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144909. * @returns the current alpha mode
  144910. */
  144911. getAlphaMode(): number;
  144912. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  144913. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144914. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144915. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144916. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144917. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144918. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144919. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144920. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144921. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  144922. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  144923. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  144924. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  144925. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  144926. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144927. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144928. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  144929. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  144930. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  144931. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  144932. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  144933. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  144934. wipeCaches(bruteForce?: boolean): void;
  144935. protected _createTexture(): WebGLTexture;
  144936. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  144937. /**
  144938. * Update the content of a dynamic texture
  144939. * @param texture defines the texture to update
  144940. * @param canvas defines the canvas containing the source
  144941. * @param invertY defines if data must be stored with Y axis inverted
  144942. * @param premulAlpha defines if alpha is stored as premultiplied
  144943. * @param format defines the format of the data
  144944. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  144945. */
  144946. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  144947. /**
  144948. * Usually called from Texture.ts.
  144949. * Passed information to create a WebGLTexture
  144950. * @param url defines a value which contains one of the following:
  144951. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  144952. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  144953. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  144954. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  144955. * @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)
  144956. * @param scene needed for loading to the correct scene
  144957. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  144958. * @param onLoad optional callback to be called upon successful completion
  144959. * @param onError optional callback to be called upon failure
  144960. * @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
  144961. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  144962. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  144963. * @param forcedExtension defines the extension to use to pick the right loader
  144964. * @param mimeType defines an optional mime type
  144965. * @param loaderOptions options to be passed to the loader
  144966. * @returns a InternalTexture for assignment back into BABYLON.Texture
  144967. */
  144968. 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;
  144969. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  144970. _releaseFramebufferObjects(texture: InternalTexture): void;
  144971. /**
  144972. * Creates a cube texture
  144973. * @param rootUrl defines the url where the files to load is located
  144974. * @param scene defines the current scene
  144975. * @param files defines the list of files to load (1 per face)
  144976. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  144977. * @param onLoad defines an optional callback raised when the texture is loaded
  144978. * @param onError defines an optional callback raised if there is an issue to load the texture
  144979. * @param format defines the format of the data
  144980. * @param forcedExtension defines the extension to use to pick the right loader
  144981. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  144982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144984. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  144985. * @returns the cube texture as an InternalTexture
  144986. */
  144987. 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;
  144988. createRenderTargetTexture(size: number | {
  144989. width: number;
  144990. height: number;
  144991. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  144992. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  144993. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  144994. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  144995. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  144996. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  144997. /**
  144998. * Updates a dynamic vertex buffer.
  144999. * @param vertexBuffer the vertex buffer to update
  145000. * @param data the data used to update the vertex buffer
  145001. * @param byteOffset the byte offset of the data (optional)
  145002. * @param byteLength the byte length of the data (optional)
  145003. */
  145004. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  145005. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  145006. private _updateAnisotropicLevel;
  145007. private _getAddressMode;
  145008. /** @hidden */
  145009. _bindTexture(channel: number, texture: InternalTexture): void;
  145010. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  145011. releaseEffects(): void;
  145012. /** @hidden */
  145013. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145014. /** @hidden */
  145015. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145016. /** @hidden */
  145017. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145018. /** @hidden */
  145019. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  145020. private _getNativeSamplingMode;
  145021. private _getNativeTextureFormat;
  145022. private _getNativeAlphaMode;
  145023. private _getNativeAttribType;
  145024. }
  145025. }
  145026. declare module BABYLON {
  145027. /**
  145028. * Helper class to create the best engine depending on the current hardware
  145029. */
  145030. export class EngineFactory {
  145031. /**
  145032. * Creates an engine based on the capabilities of the underlying hardware
  145033. * @param canvas Defines the canvas to use to display the result
  145034. * @param options Defines the options passed to the engine to create the context dependencies
  145035. * @returns a promise that resolves with the created engine
  145036. */
  145037. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  145038. }
  145039. }
  145040. declare module BABYLON {
  145041. /**
  145042. * Gather the list of clipboard event types as constants.
  145043. */
  145044. export class ClipboardEventTypes {
  145045. /**
  145046. * The clipboard event is fired when a copy command is active (pressed).
  145047. */
  145048. static readonly COPY: number;
  145049. /**
  145050. * The clipboard event is fired when a cut command is active (pressed).
  145051. */
  145052. static readonly CUT: number;
  145053. /**
  145054. * The clipboard event is fired when a paste command is active (pressed).
  145055. */
  145056. static readonly PASTE: number;
  145057. }
  145058. /**
  145059. * This class is used to store clipboard related info for the onClipboardObservable event.
  145060. */
  145061. export class ClipboardInfo {
  145062. /**
  145063. * Defines the type of event (BABYLON.ClipboardEventTypes)
  145064. */
  145065. type: number;
  145066. /**
  145067. * Defines the related dom event
  145068. */
  145069. event: ClipboardEvent;
  145070. /**
  145071. *Creates an instance of ClipboardInfo.
  145072. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  145073. * @param event Defines the related dom event
  145074. */
  145075. constructor(
  145076. /**
  145077. * Defines the type of event (BABYLON.ClipboardEventTypes)
  145078. */
  145079. type: number,
  145080. /**
  145081. * Defines the related dom event
  145082. */
  145083. event: ClipboardEvent);
  145084. /**
  145085. * Get the clipboard event's type from the keycode.
  145086. * @param keyCode Defines the keyCode for the current keyboard event.
  145087. * @return {number}
  145088. */
  145089. static GetTypeFromCharacter(keyCode: number): number;
  145090. }
  145091. }
  145092. declare module BABYLON {
  145093. /**
  145094. * Google Daydream controller
  145095. */
  145096. export class DaydreamController extends WebVRController {
  145097. /**
  145098. * Base Url for the controller model.
  145099. */
  145100. static MODEL_BASE_URL: string;
  145101. /**
  145102. * File name for the controller model.
  145103. */
  145104. static MODEL_FILENAME: string;
  145105. /**
  145106. * Gamepad Id prefix used to identify Daydream Controller.
  145107. */
  145108. static readonly GAMEPAD_ID_PREFIX: string;
  145109. /**
  145110. * Creates a new DaydreamController from a gamepad
  145111. * @param vrGamepad the gamepad that the controller should be created from
  145112. */
  145113. constructor(vrGamepad: any);
  145114. /**
  145115. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145116. * @param scene scene in which to add meshes
  145117. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145118. */
  145119. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145120. /**
  145121. * Called once for each button that changed state since the last frame
  145122. * @param buttonIdx Which button index changed
  145123. * @param state New state of the button
  145124. * @param changes Which properties on the state changed since last frame
  145125. */
  145126. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145127. }
  145128. }
  145129. declare module BABYLON {
  145130. /**
  145131. * Gear VR Controller
  145132. */
  145133. export class GearVRController extends WebVRController {
  145134. /**
  145135. * Base Url for the controller model.
  145136. */
  145137. static MODEL_BASE_URL: string;
  145138. /**
  145139. * File name for the controller model.
  145140. */
  145141. static MODEL_FILENAME: string;
  145142. /**
  145143. * Gamepad Id prefix used to identify this controller.
  145144. */
  145145. static readonly GAMEPAD_ID_PREFIX: string;
  145146. private readonly _buttonIndexToObservableNameMap;
  145147. /**
  145148. * Creates a new GearVRController from a gamepad
  145149. * @param vrGamepad the gamepad that the controller should be created from
  145150. */
  145151. constructor(vrGamepad: any);
  145152. /**
  145153. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145154. * @param scene scene in which to add meshes
  145155. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145156. */
  145157. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145158. /**
  145159. * Called once for each button that changed state since the last frame
  145160. * @param buttonIdx Which button index changed
  145161. * @param state New state of the button
  145162. * @param changes Which properties on the state changed since last frame
  145163. */
  145164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145165. }
  145166. }
  145167. declare module BABYLON {
  145168. /**
  145169. * Generic Controller
  145170. */
  145171. export class GenericController extends WebVRController {
  145172. /**
  145173. * Base Url for the controller model.
  145174. */
  145175. static readonly MODEL_BASE_URL: string;
  145176. /**
  145177. * File name for the controller model.
  145178. */
  145179. static readonly MODEL_FILENAME: string;
  145180. /**
  145181. * Creates a new GenericController from a gamepad
  145182. * @param vrGamepad the gamepad that the controller should be created from
  145183. */
  145184. constructor(vrGamepad: any);
  145185. /**
  145186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145187. * @param scene scene in which to add meshes
  145188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145189. */
  145190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145191. /**
  145192. * Called once for each button that changed state since the last frame
  145193. * @param buttonIdx Which button index changed
  145194. * @param state New state of the button
  145195. * @param changes Which properties on the state changed since last frame
  145196. */
  145197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145198. }
  145199. }
  145200. declare module BABYLON {
  145201. /**
  145202. * Oculus Touch Controller
  145203. */
  145204. export class OculusTouchController extends WebVRController {
  145205. /**
  145206. * Base Url for the controller model.
  145207. */
  145208. static MODEL_BASE_URL: string;
  145209. /**
  145210. * File name for the left controller model.
  145211. */
  145212. static MODEL_LEFT_FILENAME: string;
  145213. /**
  145214. * File name for the right controller model.
  145215. */
  145216. static MODEL_RIGHT_FILENAME: string;
  145217. /**
  145218. * Base Url for the Quest controller model.
  145219. */
  145220. static QUEST_MODEL_BASE_URL: string;
  145221. /**
  145222. * @hidden
  145223. * If the controllers are running on a device that needs the updated Quest controller models
  145224. */
  145225. static _IsQuest: boolean;
  145226. /**
  145227. * Fired when the secondary trigger on this controller is modified
  145228. */
  145229. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  145230. /**
  145231. * Fired when the thumb rest on this controller is modified
  145232. */
  145233. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  145234. /**
  145235. * Creates a new OculusTouchController from a gamepad
  145236. * @param vrGamepad the gamepad that the controller should be created from
  145237. */
  145238. constructor(vrGamepad: any);
  145239. /**
  145240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145241. * @param scene scene in which to add meshes
  145242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145243. */
  145244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145245. /**
  145246. * Fired when the A button on this controller is modified
  145247. */
  145248. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145249. /**
  145250. * Fired when the B button on this controller is modified
  145251. */
  145252. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145253. /**
  145254. * Fired when the X button on this controller is modified
  145255. */
  145256. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145257. /**
  145258. * Fired when the Y button on this controller is modified
  145259. */
  145260. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145261. /**
  145262. * Called once for each button that changed state since the last frame
  145263. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  145264. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  145265. * 2) secondary trigger (same)
  145266. * 3) A (right) X (left), touch, pressed = value
  145267. * 4) B / Y
  145268. * 5) thumb rest
  145269. * @param buttonIdx Which button index changed
  145270. * @param state New state of the button
  145271. * @param changes Which properties on the state changed since last frame
  145272. */
  145273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145274. }
  145275. }
  145276. declare module BABYLON {
  145277. /**
  145278. * Vive Controller
  145279. */
  145280. export class ViveController extends WebVRController {
  145281. /**
  145282. * Base Url for the controller model.
  145283. */
  145284. static MODEL_BASE_URL: string;
  145285. /**
  145286. * File name for the controller model.
  145287. */
  145288. static MODEL_FILENAME: string;
  145289. /**
  145290. * Creates a new ViveController from a gamepad
  145291. * @param vrGamepad the gamepad that the controller should be created from
  145292. */
  145293. constructor(vrGamepad: any);
  145294. /**
  145295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145296. * @param scene scene in which to add meshes
  145297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145298. */
  145299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145300. /**
  145301. * Fired when the left button on this controller is modified
  145302. */
  145303. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145304. /**
  145305. * Fired when the right button on this controller is modified
  145306. */
  145307. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145308. /**
  145309. * Fired when the menu button on this controller is modified
  145310. */
  145311. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145312. /**
  145313. * Called once for each button that changed state since the last frame
  145314. * Vive mapping:
  145315. * 0: touchpad
  145316. * 1: trigger
  145317. * 2: left AND right buttons
  145318. * 3: menu button
  145319. * @param buttonIdx Which button index changed
  145320. * @param state New state of the button
  145321. * @param changes Which properties on the state changed since last frame
  145322. */
  145323. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145324. }
  145325. }
  145326. declare module BABYLON {
  145327. /**
  145328. * Defines the WindowsMotionController object that the state of the windows motion controller
  145329. */
  145330. export class WindowsMotionController extends WebVRController {
  145331. /**
  145332. * The base url used to load the left and right controller models
  145333. */
  145334. static MODEL_BASE_URL: string;
  145335. /**
  145336. * The name of the left controller model file
  145337. */
  145338. static MODEL_LEFT_FILENAME: string;
  145339. /**
  145340. * The name of the right controller model file
  145341. */
  145342. static MODEL_RIGHT_FILENAME: string;
  145343. /**
  145344. * The controller name prefix for this controller type
  145345. */
  145346. static readonly GAMEPAD_ID_PREFIX: string;
  145347. /**
  145348. * The controller id pattern for this controller type
  145349. */
  145350. private static readonly GAMEPAD_ID_PATTERN;
  145351. private _loadedMeshInfo;
  145352. protected readonly _mapping: {
  145353. buttons: string[];
  145354. buttonMeshNames: {
  145355. trigger: string;
  145356. menu: string;
  145357. grip: string;
  145358. thumbstick: string;
  145359. trackpad: string;
  145360. };
  145361. buttonObservableNames: {
  145362. trigger: string;
  145363. menu: string;
  145364. grip: string;
  145365. thumbstick: string;
  145366. trackpad: string;
  145367. };
  145368. axisMeshNames: string[];
  145369. pointingPoseMeshName: string;
  145370. };
  145371. /**
  145372. * Fired when the trackpad on this controller is clicked
  145373. */
  145374. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  145375. /**
  145376. * Fired when the trackpad on this controller is modified
  145377. */
  145378. onTrackpadValuesChangedObservable: Observable<StickValues>;
  145379. /**
  145380. * The current x and y values of this controller's trackpad
  145381. */
  145382. trackpad: StickValues;
  145383. /**
  145384. * Creates a new WindowsMotionController from a gamepad
  145385. * @param vrGamepad the gamepad that the controller should be created from
  145386. */
  145387. constructor(vrGamepad: any);
  145388. /**
  145389. * Fired when the trigger on this controller is modified
  145390. */
  145391. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145392. /**
  145393. * Fired when the menu button on this controller is modified
  145394. */
  145395. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145396. /**
  145397. * Fired when the grip button on this controller is modified
  145398. */
  145399. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145400. /**
  145401. * Fired when the thumbstick button on this controller is modified
  145402. */
  145403. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145404. /**
  145405. * Fired when the touchpad button on this controller is modified
  145406. */
  145407. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145408. /**
  145409. * Fired when the touchpad values on this controller are modified
  145410. */
  145411. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  145412. protected _updateTrackpad(): void;
  145413. /**
  145414. * Called once per frame by the engine.
  145415. */
  145416. update(): void;
  145417. /**
  145418. * Called once for each button that changed state since the last frame
  145419. * @param buttonIdx Which button index changed
  145420. * @param state New state of the button
  145421. * @param changes Which properties on the state changed since last frame
  145422. */
  145423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145424. /**
  145425. * Moves the buttons on the controller mesh based on their current state
  145426. * @param buttonName the name of the button to move
  145427. * @param buttonValue the value of the button which determines the buttons new position
  145428. */
  145429. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  145430. /**
  145431. * Moves the axis on the controller mesh based on its current state
  145432. * @param axis the index of the axis
  145433. * @param axisValue the value of the axis which determines the meshes new position
  145434. * @hidden
  145435. */
  145436. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  145437. /**
  145438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145439. * @param scene scene in which to add meshes
  145440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145441. */
  145442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  145443. /**
  145444. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  145445. * can be transformed by button presses and axes values, based on this._mapping.
  145446. *
  145447. * @param scene scene in which the meshes exist
  145448. * @param meshes list of meshes that make up the controller model to process
  145449. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  145450. */
  145451. private processModel;
  145452. private createMeshInfo;
  145453. /**
  145454. * Gets the ray of the controller in the direction the controller is pointing
  145455. * @param length the length the resulting ray should be
  145456. * @returns a ray in the direction the controller is pointing
  145457. */
  145458. getForwardRay(length?: number): Ray;
  145459. /**
  145460. * Disposes of the controller
  145461. */
  145462. dispose(): void;
  145463. }
  145464. /**
  145465. * This class represents a new windows motion controller in XR.
  145466. */
  145467. export class XRWindowsMotionController extends WindowsMotionController {
  145468. /**
  145469. * Changing the original WIndowsMotionController mapping to fir the new mapping
  145470. */
  145471. protected readonly _mapping: {
  145472. buttons: string[];
  145473. buttonMeshNames: {
  145474. trigger: string;
  145475. menu: string;
  145476. grip: string;
  145477. thumbstick: string;
  145478. trackpad: string;
  145479. };
  145480. buttonObservableNames: {
  145481. trigger: string;
  145482. menu: string;
  145483. grip: string;
  145484. thumbstick: string;
  145485. trackpad: string;
  145486. };
  145487. axisMeshNames: string[];
  145488. pointingPoseMeshName: string;
  145489. };
  145490. /**
  145491. * Construct a new XR-Based windows motion controller
  145492. *
  145493. * @param gamepadInfo the gamepad object from the browser
  145494. */
  145495. constructor(gamepadInfo: any);
  145496. /**
  145497. * holds the thumbstick values (X,Y)
  145498. */
  145499. thumbstickValues: StickValues;
  145500. /**
  145501. * Fired when the thumbstick on this controller is clicked
  145502. */
  145503. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  145504. /**
  145505. * Fired when the thumbstick on this controller is modified
  145506. */
  145507. onThumbstickValuesChangedObservable: Observable<StickValues>;
  145508. /**
  145509. * Fired when the touchpad button on this controller is modified
  145510. */
  145511. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  145512. /**
  145513. * Fired when the touchpad values on this controller are modified
  145514. */
  145515. onTrackpadValuesChangedObservable: Observable<StickValues>;
  145516. /**
  145517. * Fired when the thumbstick button on this controller is modified
  145518. * here to prevent breaking changes
  145519. */
  145520. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145521. /**
  145522. * updating the thumbstick(!) and not the trackpad.
  145523. * This is named this way due to the difference between WebVR and XR and to avoid
  145524. * changing the parent class.
  145525. */
  145526. protected _updateTrackpad(): void;
  145527. /**
  145528. * Disposes the class with joy
  145529. */
  145530. dispose(): void;
  145531. }
  145532. }
  145533. declare module BABYLON {
  145534. /**
  145535. * A directional light is defined by a direction (what a surprise!).
  145536. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  145537. * 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.
  145538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145539. */
  145540. export class DirectionalLight extends ShadowLight {
  145541. private _shadowFrustumSize;
  145542. /**
  145543. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  145544. */
  145545. get shadowFrustumSize(): number;
  145546. /**
  145547. * Specifies a fix frustum size for the shadow generation.
  145548. */
  145549. set shadowFrustumSize(value: number);
  145550. private _shadowOrthoScale;
  145551. /**
  145552. * Gets the shadow projection scale against the optimal computed one.
  145553. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  145554. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  145555. */
  145556. get shadowOrthoScale(): number;
  145557. /**
  145558. * Sets the shadow projection scale against the optimal computed one.
  145559. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  145560. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  145561. */
  145562. set shadowOrthoScale(value: number);
  145563. /**
  145564. * Automatically compute the projection matrix to best fit (including all the casters)
  145565. * on each frame.
  145566. */
  145567. autoUpdateExtends: boolean;
  145568. /**
  145569. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  145570. * on each frame. autoUpdateExtends must be set to true for this to work
  145571. */
  145572. autoCalcShadowZBounds: boolean;
  145573. private _orthoLeft;
  145574. private _orthoRight;
  145575. private _orthoTop;
  145576. private _orthoBottom;
  145577. /**
  145578. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  145579. * The directional light is emitted from everywhere in the given direction.
  145580. * It can cast shadows.
  145581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  145582. * @param name The friendly name of the light
  145583. * @param direction The direction of the light
  145584. * @param scene The scene the light belongs to
  145585. */
  145586. constructor(name: string, direction: Vector3, scene: Scene);
  145587. /**
  145588. * Returns the string "DirectionalLight".
  145589. * @return The class name
  145590. */
  145591. getClassName(): string;
  145592. /**
  145593. * Returns the integer 1.
  145594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  145595. */
  145596. getTypeID(): number;
  145597. /**
  145598. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  145599. * Returns the DirectionalLight Shadow projection matrix.
  145600. */
  145601. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145602. /**
  145603. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  145604. * Returns the DirectionalLight Shadow projection matrix.
  145605. */
  145606. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  145607. /**
  145608. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  145609. * Returns the DirectionalLight Shadow projection matrix.
  145610. */
  145611. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145612. protected _buildUniformLayout(): void;
  145613. /**
  145614. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  145615. * @param effect The effect to update
  145616. * @param lightIndex The index of the light in the effect to update
  145617. * @returns The directional light
  145618. */
  145619. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  145620. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  145621. /**
  145622. * Gets the minZ used for shadow according to both the scene and the light.
  145623. *
  145624. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145625. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145626. * @param activeCamera The camera we are returning the min for
  145627. * @returns the depth min z
  145628. */
  145629. getDepthMinZ(activeCamera: Camera): number;
  145630. /**
  145631. * Gets the maxZ used for shadow according to both the scene and the light.
  145632. *
  145633. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145634. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145635. * @param activeCamera The camera we are returning the max for
  145636. * @returns the depth max z
  145637. */
  145638. getDepthMaxZ(activeCamera: Camera): number;
  145639. /**
  145640. * Prepares the list of defines specific to the light type.
  145641. * @param defines the list of defines
  145642. * @param lightIndex defines the index of the light for the effect
  145643. */
  145644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145645. }
  145646. }
  145647. declare module BABYLON {
  145648. /**
  145649. * Class containing static functions to help procedurally build meshes
  145650. */
  145651. export class HemisphereBuilder {
  145652. /**
  145653. * Creates a hemisphere mesh
  145654. * @param name defines the name of the mesh
  145655. * @param options defines the options used to create the mesh
  145656. * @param scene defines the hosting scene
  145657. * @returns the hemisphere mesh
  145658. */
  145659. static CreateHemisphere(name: string, options: {
  145660. segments?: number;
  145661. diameter?: number;
  145662. sideOrientation?: number;
  145663. }, scene: any): Mesh;
  145664. }
  145665. }
  145666. declare module BABYLON {
  145667. /**
  145668. * A spot light is defined by a position, a direction, an angle, and an exponent.
  145669. * These values define a cone of light starting from the position, emitting toward the direction.
  145670. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  145671. * and the exponent defines the speed of the decay of the light with distance (reach).
  145672. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145673. */
  145674. export class SpotLight extends ShadowLight {
  145675. private _angle;
  145676. private _innerAngle;
  145677. private _cosHalfAngle;
  145678. private _lightAngleScale;
  145679. private _lightAngleOffset;
  145680. /**
  145681. * Gets the cone angle of the spot light in Radians.
  145682. */
  145683. get angle(): number;
  145684. /**
  145685. * Sets the cone angle of the spot light in Radians.
  145686. */
  145687. set angle(value: number);
  145688. /**
  145689. * Only used in gltf falloff mode, this defines the angle where
  145690. * the directional falloff will start before cutting at angle which could be seen
  145691. * as outer angle.
  145692. */
  145693. get innerAngle(): number;
  145694. /**
  145695. * Only used in gltf falloff mode, this defines the angle where
  145696. * the directional falloff will start before cutting at angle which could be seen
  145697. * as outer angle.
  145698. */
  145699. set innerAngle(value: number);
  145700. private _shadowAngleScale;
  145701. /**
  145702. * Allows scaling the angle of the light for shadow generation only.
  145703. */
  145704. get shadowAngleScale(): number;
  145705. /**
  145706. * Allows scaling the angle of the light for shadow generation only.
  145707. */
  145708. set shadowAngleScale(value: number);
  145709. /**
  145710. * The light decay speed with the distance from the emission spot.
  145711. */
  145712. exponent: number;
  145713. private _projectionTextureMatrix;
  145714. /**
  145715. * Allows reading the projecton texture
  145716. */
  145717. get projectionTextureMatrix(): Matrix;
  145718. protected _projectionTextureLightNear: number;
  145719. /**
  145720. * Gets the near clip of the Spotlight for texture projection.
  145721. */
  145722. get projectionTextureLightNear(): number;
  145723. /**
  145724. * Sets the near clip of the Spotlight for texture projection.
  145725. */
  145726. set projectionTextureLightNear(value: number);
  145727. protected _projectionTextureLightFar: number;
  145728. /**
  145729. * Gets the far clip of the Spotlight for texture projection.
  145730. */
  145731. get projectionTextureLightFar(): number;
  145732. /**
  145733. * Sets the far clip of the Spotlight for texture projection.
  145734. */
  145735. set projectionTextureLightFar(value: number);
  145736. protected _projectionTextureUpDirection: Vector3;
  145737. /**
  145738. * Gets the Up vector of the Spotlight for texture projection.
  145739. */
  145740. get projectionTextureUpDirection(): Vector3;
  145741. /**
  145742. * Sets the Up vector of the Spotlight for texture projection.
  145743. */
  145744. set projectionTextureUpDirection(value: Vector3);
  145745. private _projectionTexture;
  145746. /**
  145747. * Gets the projection texture of the light.
  145748. */
  145749. get projectionTexture(): Nullable<BaseTexture>;
  145750. /**
  145751. * Sets the projection texture of the light.
  145752. */
  145753. set projectionTexture(value: Nullable<BaseTexture>);
  145754. private static _IsProceduralTexture;
  145755. private static _IsTexture;
  145756. private _projectionTextureViewLightDirty;
  145757. private _projectionTextureProjectionLightDirty;
  145758. private _projectionTextureDirty;
  145759. private _projectionTextureViewTargetVector;
  145760. private _projectionTextureViewLightMatrix;
  145761. private _projectionTextureProjectionLightMatrix;
  145762. private _projectionTextureScalingMatrix;
  145763. /**
  145764. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  145765. * It can cast shadows.
  145766. * Documentation : https://doc.babylonjs.com/babylon101/lights
  145767. * @param name The light friendly name
  145768. * @param position The position of the spot light in the scene
  145769. * @param direction The direction of the light in the scene
  145770. * @param angle The cone angle of the light in Radians
  145771. * @param exponent The light decay speed with the distance from the emission spot
  145772. * @param scene The scene the lights belongs to
  145773. */
  145774. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  145775. /**
  145776. * Returns the string "SpotLight".
  145777. * @returns the class name
  145778. */
  145779. getClassName(): string;
  145780. /**
  145781. * Returns the integer 2.
  145782. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  145783. */
  145784. getTypeID(): number;
  145785. /**
  145786. * Overrides the direction setter to recompute the projection texture view light Matrix.
  145787. */
  145788. protected _setDirection(value: Vector3): void;
  145789. /**
  145790. * Overrides the position setter to recompute the projection texture view light Matrix.
  145791. */
  145792. protected _setPosition(value: Vector3): void;
  145793. /**
  145794. * 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.
  145795. * Returns the SpotLight.
  145796. */
  145797. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145798. protected _computeProjectionTextureViewLightMatrix(): void;
  145799. protected _computeProjectionTextureProjectionLightMatrix(): void;
  145800. /**
  145801. * Main function for light texture projection matrix computing.
  145802. */
  145803. protected _computeProjectionTextureMatrix(): void;
  145804. protected _buildUniformLayout(): void;
  145805. private _computeAngleValues;
  145806. /**
  145807. * Sets the passed Effect "effect" with the Light textures.
  145808. * @param effect The effect to update
  145809. * @param lightIndex The index of the light in the effect to update
  145810. * @returns The light
  145811. */
  145812. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  145813. /**
  145814. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  145815. * @param effect The effect to update
  145816. * @param lightIndex The index of the light in the effect to update
  145817. * @returns The spot light
  145818. */
  145819. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  145820. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  145821. /**
  145822. * Disposes the light and the associated resources.
  145823. */
  145824. dispose(): void;
  145825. /**
  145826. * Prepares the list of defines specific to the light type.
  145827. * @param defines the list of defines
  145828. * @param lightIndex defines the index of the light for the effect
  145829. */
  145830. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145831. }
  145832. }
  145833. declare module BABYLON {
  145834. /**
  145835. * Gizmo that enables viewing a light
  145836. */
  145837. export class LightGizmo extends Gizmo {
  145838. private _lightMesh;
  145839. private _material;
  145840. private _cachedPosition;
  145841. private _cachedForward;
  145842. private _attachedMeshParent;
  145843. private _pointerObserver;
  145844. /**
  145845. * Event that fires each time the gizmo is clicked
  145846. */
  145847. onClickedObservable: Observable<Light>;
  145848. /**
  145849. * Creates a LightGizmo
  145850. * @param gizmoLayer The utility layer the gizmo will be added to
  145851. */
  145852. constructor(gizmoLayer?: UtilityLayerRenderer);
  145853. private _light;
  145854. /**
  145855. * The light that the gizmo is attached to
  145856. */
  145857. set light(light: Nullable<Light>);
  145858. get light(): Nullable<Light>;
  145859. /**
  145860. * Gets the material used to render the light gizmo
  145861. */
  145862. get material(): StandardMaterial;
  145863. /**
  145864. * @hidden
  145865. * Updates the gizmo to match the attached mesh's position/rotation
  145866. */
  145867. protected _update(): void;
  145868. private static _Scale;
  145869. /**
  145870. * Creates the lines for a light mesh
  145871. */
  145872. private static _CreateLightLines;
  145873. /**
  145874. * Disposes of the light gizmo
  145875. */
  145876. dispose(): void;
  145877. private static _CreateHemisphericLightMesh;
  145878. private static _CreatePointLightMesh;
  145879. private static _CreateSpotLightMesh;
  145880. private static _CreateDirectionalLightMesh;
  145881. }
  145882. }
  145883. declare module BABYLON {
  145884. /**
  145885. * Gizmo that enables viewing a camera
  145886. */
  145887. export class CameraGizmo extends Gizmo {
  145888. private _cameraMesh;
  145889. private _cameraLinesMesh;
  145890. private _material;
  145891. private _pointerObserver;
  145892. /**
  145893. * Event that fires each time the gizmo is clicked
  145894. */
  145895. onClickedObservable: Observable<Camera>;
  145896. /**
  145897. * Creates a CameraGizmo
  145898. * @param gizmoLayer The utility layer the gizmo will be added to
  145899. */
  145900. constructor(gizmoLayer?: UtilityLayerRenderer);
  145901. private _camera;
  145902. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  145903. get displayFrustum(): boolean;
  145904. set displayFrustum(value: boolean);
  145905. /**
  145906. * The camera that the gizmo is attached to
  145907. */
  145908. set camera(camera: Nullable<Camera>);
  145909. get camera(): Nullable<Camera>;
  145910. /**
  145911. * Gets the material used to render the camera gizmo
  145912. */
  145913. get material(): StandardMaterial;
  145914. /**
  145915. * @hidden
  145916. * Updates the gizmo to match the attached mesh's position/rotation
  145917. */
  145918. protected _update(): void;
  145919. private static _Scale;
  145920. private _invProjection;
  145921. /**
  145922. * Disposes of the camera gizmo
  145923. */
  145924. dispose(): void;
  145925. private static _CreateCameraMesh;
  145926. private static _CreateCameraFrustum;
  145927. }
  145928. }
  145929. declare module BABYLON {
  145930. /** @hidden */
  145931. export var backgroundFragmentDeclaration: {
  145932. name: string;
  145933. shader: string;
  145934. };
  145935. }
  145936. declare module BABYLON {
  145937. /** @hidden */
  145938. export var backgroundUboDeclaration: {
  145939. name: string;
  145940. shader: string;
  145941. };
  145942. }
  145943. declare module BABYLON {
  145944. /** @hidden */
  145945. export var backgroundPixelShader: {
  145946. name: string;
  145947. shader: string;
  145948. };
  145949. }
  145950. declare module BABYLON {
  145951. /** @hidden */
  145952. export var backgroundVertexDeclaration: {
  145953. name: string;
  145954. shader: string;
  145955. };
  145956. }
  145957. declare module BABYLON {
  145958. /** @hidden */
  145959. export var backgroundVertexShader: {
  145960. name: string;
  145961. shader: string;
  145962. };
  145963. }
  145964. declare module BABYLON {
  145965. /**
  145966. * Background material used to create an efficient environement around your scene.
  145967. */
  145968. export class BackgroundMaterial extends PushMaterial {
  145969. /**
  145970. * Standard reflectance value at parallel view angle.
  145971. */
  145972. static StandardReflectance0: number;
  145973. /**
  145974. * Standard reflectance value at grazing angle.
  145975. */
  145976. static StandardReflectance90: number;
  145977. protected _primaryColor: Color3;
  145978. /**
  145979. * Key light Color (multiply against the environement texture)
  145980. */
  145981. primaryColor: Color3;
  145982. protected __perceptualColor: Nullable<Color3>;
  145983. /**
  145984. * Experimental Internal Use Only.
  145985. *
  145986. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  145987. * This acts as a helper to set the primary color to a more "human friendly" value.
  145988. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  145989. * output color as close as possible from the chosen value.
  145990. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  145991. * part of lighting setup.)
  145992. */
  145993. get _perceptualColor(): Nullable<Color3>;
  145994. set _perceptualColor(value: Nullable<Color3>);
  145995. protected _primaryColorShadowLevel: float;
  145996. /**
  145997. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  145998. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  145999. */
  146000. get primaryColorShadowLevel(): float;
  146001. set primaryColorShadowLevel(value: float);
  146002. protected _primaryColorHighlightLevel: float;
  146003. /**
  146004. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  146005. * The primary color is used at the level chosen to define what the white area would look.
  146006. */
  146007. get primaryColorHighlightLevel(): float;
  146008. set primaryColorHighlightLevel(value: float);
  146009. protected _reflectionTexture: Nullable<BaseTexture>;
  146010. /**
  146011. * Reflection Texture used in the material.
  146012. * Should be author in a specific way for the best result (refer to the documentation).
  146013. */
  146014. reflectionTexture: Nullable<BaseTexture>;
  146015. protected _reflectionBlur: float;
  146016. /**
  146017. * Reflection Texture level of blur.
  146018. *
  146019. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  146020. * texture twice.
  146021. */
  146022. reflectionBlur: float;
  146023. protected _diffuseTexture: Nullable<BaseTexture>;
  146024. /**
  146025. * Diffuse Texture used in the material.
  146026. * Should be author in a specific way for the best result (refer to the documentation).
  146027. */
  146028. diffuseTexture: Nullable<BaseTexture>;
  146029. protected _shadowLights: Nullable<IShadowLight[]>;
  146030. /**
  146031. * Specify the list of lights casting shadow on the material.
  146032. * All scene shadow lights will be included if null.
  146033. */
  146034. shadowLights: Nullable<IShadowLight[]>;
  146035. protected _shadowLevel: float;
  146036. /**
  146037. * Helps adjusting the shadow to a softer level if required.
  146038. * 0 means black shadows and 1 means no shadows.
  146039. */
  146040. shadowLevel: float;
  146041. protected _sceneCenter: Vector3;
  146042. /**
  146043. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  146044. * It is usually zero but might be interesting to modify according to your setup.
  146045. */
  146046. sceneCenter: Vector3;
  146047. protected _opacityFresnel: boolean;
  146048. /**
  146049. * This helps specifying that the material is falling off to the sky box at grazing angle.
  146050. * This helps ensuring a nice transition when the camera goes under the ground.
  146051. */
  146052. opacityFresnel: boolean;
  146053. protected _reflectionFresnel: boolean;
  146054. /**
  146055. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  146056. * This helps adding a mirror texture on the ground.
  146057. */
  146058. reflectionFresnel: boolean;
  146059. protected _reflectionFalloffDistance: number;
  146060. /**
  146061. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  146062. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  146063. */
  146064. reflectionFalloffDistance: number;
  146065. protected _reflectionAmount: number;
  146066. /**
  146067. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  146068. */
  146069. reflectionAmount: number;
  146070. protected _reflectionReflectance0: number;
  146071. /**
  146072. * This specifies the weight of the reflection at grazing angle.
  146073. */
  146074. reflectionReflectance0: number;
  146075. protected _reflectionReflectance90: number;
  146076. /**
  146077. * This specifies the weight of the reflection at a perpendicular point of view.
  146078. */
  146079. reflectionReflectance90: number;
  146080. /**
  146081. * Sets the reflection reflectance fresnel values according to the default standard
  146082. * empirically know to work well :-)
  146083. */
  146084. set reflectionStandardFresnelWeight(value: number);
  146085. protected _useRGBColor: boolean;
  146086. /**
  146087. * Helps to directly use the maps channels instead of their level.
  146088. */
  146089. useRGBColor: boolean;
  146090. protected _enableNoise: boolean;
  146091. /**
  146092. * This helps reducing the banding effect that could occur on the background.
  146093. */
  146094. enableNoise: boolean;
  146095. /**
  146096. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146097. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  146098. * Recommended to be keep at 1.0 except for special cases.
  146099. */
  146100. get fovMultiplier(): number;
  146101. set fovMultiplier(value: number);
  146102. private _fovMultiplier;
  146103. /**
  146104. * Enable the FOV adjustment feature controlled by fovMultiplier.
  146105. */
  146106. useEquirectangularFOV: boolean;
  146107. private _maxSimultaneousLights;
  146108. /**
  146109. * Number of Simultaneous lights allowed on the material.
  146110. */
  146111. maxSimultaneousLights: int;
  146112. private _shadowOnly;
  146113. /**
  146114. * Make the material only render shadows
  146115. */
  146116. shadowOnly: boolean;
  146117. /**
  146118. * Default configuration related to image processing available in the Background Material.
  146119. */
  146120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  146121. /**
  146122. * Keep track of the image processing observer to allow dispose and replace.
  146123. */
  146124. private _imageProcessingObserver;
  146125. /**
  146126. * Attaches a new image processing configuration to the PBR Material.
  146127. * @param configuration (if null the scene configuration will be use)
  146128. */
  146129. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  146130. /**
  146131. * Gets the image processing configuration used either in this material.
  146132. */
  146133. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  146134. /**
  146135. * Sets the Default image processing configuration used either in the this material.
  146136. *
  146137. * If sets to null, the scene one is in use.
  146138. */
  146139. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  146140. /**
  146141. * Gets wether the color curves effect is enabled.
  146142. */
  146143. get cameraColorCurvesEnabled(): boolean;
  146144. /**
  146145. * Sets wether the color curves effect is enabled.
  146146. */
  146147. set cameraColorCurvesEnabled(value: boolean);
  146148. /**
  146149. * Gets wether the color grading effect is enabled.
  146150. */
  146151. get cameraColorGradingEnabled(): boolean;
  146152. /**
  146153. * Gets wether the color grading effect is enabled.
  146154. */
  146155. set cameraColorGradingEnabled(value: boolean);
  146156. /**
  146157. * Gets wether tonemapping is enabled or not.
  146158. */
  146159. get cameraToneMappingEnabled(): boolean;
  146160. /**
  146161. * Sets wether tonemapping is enabled or not
  146162. */
  146163. set cameraToneMappingEnabled(value: boolean);
  146164. /**
  146165. * The camera exposure used on this material.
  146166. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  146167. * This corresponds to a photographic exposure.
  146168. */
  146169. get cameraExposure(): float;
  146170. /**
  146171. * The camera exposure used on this material.
  146172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  146173. * This corresponds to a photographic exposure.
  146174. */
  146175. set cameraExposure(value: float);
  146176. /**
  146177. * Gets The camera contrast used on this material.
  146178. */
  146179. get cameraContrast(): float;
  146180. /**
  146181. * Sets The camera contrast used on this material.
  146182. */
  146183. set cameraContrast(value: float);
  146184. /**
  146185. * Gets the Color Grading 2D Lookup Texture.
  146186. */
  146187. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  146188. /**
  146189. * Sets the Color Grading 2D Lookup Texture.
  146190. */
  146191. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  146192. /**
  146193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  146194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  146195. * 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;
  146196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  146197. */
  146198. get cameraColorCurves(): Nullable<ColorCurves>;
  146199. /**
  146200. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  146201. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  146202. * 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;
  146203. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  146204. */
  146205. set cameraColorCurves(value: Nullable<ColorCurves>);
  146206. /**
  146207. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  146208. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  146209. */
  146210. switchToBGR: boolean;
  146211. private _renderTargets;
  146212. private _reflectionControls;
  146213. private _white;
  146214. private _primaryShadowColor;
  146215. private _primaryHighlightColor;
  146216. /**
  146217. * Instantiates a Background Material in the given scene
  146218. * @param name The friendly name of the material
  146219. * @param scene The scene to add the material to
  146220. */
  146221. constructor(name: string, scene: Scene);
  146222. /**
  146223. * Gets a boolean indicating that current material needs to register RTT
  146224. */
  146225. get hasRenderTargetTextures(): boolean;
  146226. /**
  146227. * The entire material has been created in order to prevent overdraw.
  146228. * @returns false
  146229. */
  146230. needAlphaTesting(): boolean;
  146231. /**
  146232. * The entire material has been created in order to prevent overdraw.
  146233. * @returns true if blending is enable
  146234. */
  146235. needAlphaBlending(): boolean;
  146236. /**
  146237. * Checks wether the material is ready to be rendered for a given mesh.
  146238. * @param mesh The mesh to render
  146239. * @param subMesh The submesh to check against
  146240. * @param useInstances Specify wether or not the material is used with instances
  146241. * @returns true if all the dependencies are ready (Textures, Effects...)
  146242. */
  146243. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  146244. /**
  146245. * Compute the primary color according to the chosen perceptual color.
  146246. */
  146247. private _computePrimaryColorFromPerceptualColor;
  146248. /**
  146249. * Compute the highlights and shadow colors according to their chosen levels.
  146250. */
  146251. private _computePrimaryColors;
  146252. /**
  146253. * Build the uniform buffer used in the material.
  146254. */
  146255. buildUniformLayout(): void;
  146256. /**
  146257. * Unbind the material.
  146258. */
  146259. unbind(): void;
  146260. /**
  146261. * Bind only the world matrix to the material.
  146262. * @param world The world matrix to bind.
  146263. */
  146264. bindOnlyWorldMatrix(world: Matrix): void;
  146265. /**
  146266. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  146267. * @param world The world matrix to bind.
  146268. * @param subMesh The submesh to bind for.
  146269. */
  146270. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  146271. /**
  146272. * Checks to see if a texture is used in the material.
  146273. * @param texture - Base texture to use.
  146274. * @returns - Boolean specifying if a texture is used in the material.
  146275. */
  146276. hasTexture(texture: BaseTexture): boolean;
  146277. /**
  146278. * Dispose the material.
  146279. * @param forceDisposeEffect Force disposal of the associated effect.
  146280. * @param forceDisposeTextures Force disposal of the associated textures.
  146281. */
  146282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  146283. /**
  146284. * Clones the material.
  146285. * @param name The cloned name.
  146286. * @returns The cloned material.
  146287. */
  146288. clone(name: string): BackgroundMaterial;
  146289. /**
  146290. * Serializes the current material to its JSON representation.
  146291. * @returns The JSON representation.
  146292. */
  146293. serialize(): any;
  146294. /**
  146295. * Gets the class name of the material
  146296. * @returns "BackgroundMaterial"
  146297. */
  146298. getClassName(): string;
  146299. /**
  146300. * Parse a JSON input to create back a background material.
  146301. * @param source The JSON data to parse
  146302. * @param scene The scene to create the parsed material in
  146303. * @param rootUrl The root url of the assets the material depends upon
  146304. * @returns the instantiated BackgroundMaterial.
  146305. */
  146306. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  146307. }
  146308. }
  146309. declare module BABYLON {
  146310. /**
  146311. * Represents the different options available during the creation of
  146312. * a Environment helper.
  146313. *
  146314. * This can control the default ground, skybox and image processing setup of your scene.
  146315. */
  146316. export interface IEnvironmentHelperOptions {
  146317. /**
  146318. * Specifies whether or not to create a ground.
  146319. * True by default.
  146320. */
  146321. createGround: boolean;
  146322. /**
  146323. * Specifies the ground size.
  146324. * 15 by default.
  146325. */
  146326. groundSize: number;
  146327. /**
  146328. * The texture used on the ground for the main color.
  146329. * Comes from the BabylonJS CDN by default.
  146330. *
  146331. * Remarks: Can be either a texture or a url.
  146332. */
  146333. groundTexture: string | BaseTexture;
  146334. /**
  146335. * The color mixed in the ground texture by default.
  146336. * BabylonJS clearColor by default.
  146337. */
  146338. groundColor: Color3;
  146339. /**
  146340. * Specifies the ground opacity.
  146341. * 1 by default.
  146342. */
  146343. groundOpacity: number;
  146344. /**
  146345. * Enables the ground to receive shadows.
  146346. * True by default.
  146347. */
  146348. enableGroundShadow: boolean;
  146349. /**
  146350. * Helps preventing the shadow to be fully black on the ground.
  146351. * 0.5 by default.
  146352. */
  146353. groundShadowLevel: number;
  146354. /**
  146355. * Creates a mirror texture attach to the ground.
  146356. * false by default.
  146357. */
  146358. enableGroundMirror: boolean;
  146359. /**
  146360. * Specifies the ground mirror size ratio.
  146361. * 0.3 by default as the default kernel is 64.
  146362. */
  146363. groundMirrorSizeRatio: number;
  146364. /**
  146365. * Specifies the ground mirror blur kernel size.
  146366. * 64 by default.
  146367. */
  146368. groundMirrorBlurKernel: number;
  146369. /**
  146370. * Specifies the ground mirror visibility amount.
  146371. * 1 by default
  146372. */
  146373. groundMirrorAmount: number;
  146374. /**
  146375. * Specifies the ground mirror reflectance weight.
  146376. * This uses the standard weight of the background material to setup the fresnel effect
  146377. * of the mirror.
  146378. * 1 by default.
  146379. */
  146380. groundMirrorFresnelWeight: number;
  146381. /**
  146382. * Specifies the ground mirror Falloff distance.
  146383. * This can helps reducing the size of the reflection.
  146384. * 0 by Default.
  146385. */
  146386. groundMirrorFallOffDistance: number;
  146387. /**
  146388. * Specifies the ground mirror texture type.
  146389. * Unsigned Int by Default.
  146390. */
  146391. groundMirrorTextureType: number;
  146392. /**
  146393. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  146394. * the shown objects.
  146395. */
  146396. groundYBias: number;
  146397. /**
  146398. * Specifies whether or not to create a skybox.
  146399. * True by default.
  146400. */
  146401. createSkybox: boolean;
  146402. /**
  146403. * Specifies the skybox size.
  146404. * 20 by default.
  146405. */
  146406. skyboxSize: number;
  146407. /**
  146408. * The texture used on the skybox for the main color.
  146409. * Comes from the BabylonJS CDN by default.
  146410. *
  146411. * Remarks: Can be either a texture or a url.
  146412. */
  146413. skyboxTexture: string | BaseTexture;
  146414. /**
  146415. * The color mixed in the skybox texture by default.
  146416. * BabylonJS clearColor by default.
  146417. */
  146418. skyboxColor: Color3;
  146419. /**
  146420. * The background rotation around the Y axis of the scene.
  146421. * This helps aligning the key lights of your scene with the background.
  146422. * 0 by default.
  146423. */
  146424. backgroundYRotation: number;
  146425. /**
  146426. * Compute automatically the size of the elements to best fit with the scene.
  146427. */
  146428. sizeAuto: boolean;
  146429. /**
  146430. * Default position of the rootMesh if autoSize is not true.
  146431. */
  146432. rootPosition: Vector3;
  146433. /**
  146434. * Sets up the image processing in the scene.
  146435. * true by default.
  146436. */
  146437. setupImageProcessing: boolean;
  146438. /**
  146439. * The texture used as your environment texture in the scene.
  146440. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  146441. *
  146442. * Remarks: Can be either a texture or a url.
  146443. */
  146444. environmentTexture: string | BaseTexture;
  146445. /**
  146446. * The value of the exposure to apply to the scene.
  146447. * 0.6 by default if setupImageProcessing is true.
  146448. */
  146449. cameraExposure: number;
  146450. /**
  146451. * The value of the contrast to apply to the scene.
  146452. * 1.6 by default if setupImageProcessing is true.
  146453. */
  146454. cameraContrast: number;
  146455. /**
  146456. * Specifies whether or not tonemapping should be enabled in the scene.
  146457. * true by default if setupImageProcessing is true.
  146458. */
  146459. toneMappingEnabled: boolean;
  146460. }
  146461. /**
  146462. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  146463. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  146464. * It also helps with the default setup of your imageProcessing configuration.
  146465. */
  146466. export class EnvironmentHelper {
  146467. /**
  146468. * Default ground texture URL.
  146469. */
  146470. private static _groundTextureCDNUrl;
  146471. /**
  146472. * Default skybox texture URL.
  146473. */
  146474. private static _skyboxTextureCDNUrl;
  146475. /**
  146476. * Default environment texture URL.
  146477. */
  146478. private static _environmentTextureCDNUrl;
  146479. /**
  146480. * Creates the default options for the helper.
  146481. */
  146482. private static _getDefaultOptions;
  146483. private _rootMesh;
  146484. /**
  146485. * Gets the root mesh created by the helper.
  146486. */
  146487. get rootMesh(): Mesh;
  146488. private _skybox;
  146489. /**
  146490. * Gets the skybox created by the helper.
  146491. */
  146492. get skybox(): Nullable<Mesh>;
  146493. private _skyboxTexture;
  146494. /**
  146495. * Gets the skybox texture created by the helper.
  146496. */
  146497. get skyboxTexture(): Nullable<BaseTexture>;
  146498. private _skyboxMaterial;
  146499. /**
  146500. * Gets the skybox material created by the helper.
  146501. */
  146502. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  146503. private _ground;
  146504. /**
  146505. * Gets the ground mesh created by the helper.
  146506. */
  146507. get ground(): Nullable<Mesh>;
  146508. private _groundTexture;
  146509. /**
  146510. * Gets the ground texture created by the helper.
  146511. */
  146512. get groundTexture(): Nullable<BaseTexture>;
  146513. private _groundMirror;
  146514. /**
  146515. * Gets the ground mirror created by the helper.
  146516. */
  146517. get groundMirror(): Nullable<MirrorTexture>;
  146518. /**
  146519. * Gets the ground mirror render list to helps pushing the meshes
  146520. * you wish in the ground reflection.
  146521. */
  146522. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  146523. private _groundMaterial;
  146524. /**
  146525. * Gets the ground material created by the helper.
  146526. */
  146527. get groundMaterial(): Nullable<BackgroundMaterial>;
  146528. /**
  146529. * Stores the creation options.
  146530. */
  146531. private readonly _scene;
  146532. private _options;
  146533. /**
  146534. * This observable will be notified with any error during the creation of the environment,
  146535. * mainly texture creation errors.
  146536. */
  146537. onErrorObservable: Observable<{
  146538. message?: string;
  146539. exception?: any;
  146540. }>;
  146541. /**
  146542. * constructor
  146543. * @param options Defines the options we want to customize the helper
  146544. * @param scene The scene to add the material to
  146545. */
  146546. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  146547. /**
  146548. * Updates the background according to the new options
  146549. * @param options
  146550. */
  146551. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  146552. /**
  146553. * Sets the primary color of all the available elements.
  146554. * @param color the main color to affect to the ground and the background
  146555. */
  146556. setMainColor(color: Color3): void;
  146557. /**
  146558. * Setup the image processing according to the specified options.
  146559. */
  146560. private _setupImageProcessing;
  146561. /**
  146562. * Setup the environment texture according to the specified options.
  146563. */
  146564. private _setupEnvironmentTexture;
  146565. /**
  146566. * Setup the background according to the specified options.
  146567. */
  146568. private _setupBackground;
  146569. /**
  146570. * Get the scene sizes according to the setup.
  146571. */
  146572. private _getSceneSize;
  146573. /**
  146574. * Setup the ground according to the specified options.
  146575. */
  146576. private _setupGround;
  146577. /**
  146578. * Setup the ground material according to the specified options.
  146579. */
  146580. private _setupGroundMaterial;
  146581. /**
  146582. * Setup the ground diffuse texture according to the specified options.
  146583. */
  146584. private _setupGroundDiffuseTexture;
  146585. /**
  146586. * Setup the ground mirror texture according to the specified options.
  146587. */
  146588. private _setupGroundMirrorTexture;
  146589. /**
  146590. * Setup the ground to receive the mirror texture.
  146591. */
  146592. private _setupMirrorInGroundMaterial;
  146593. /**
  146594. * Setup the skybox according to the specified options.
  146595. */
  146596. private _setupSkybox;
  146597. /**
  146598. * Setup the skybox material according to the specified options.
  146599. */
  146600. private _setupSkyboxMaterial;
  146601. /**
  146602. * Setup the skybox reflection texture according to the specified options.
  146603. */
  146604. private _setupSkyboxReflectionTexture;
  146605. private _errorHandler;
  146606. /**
  146607. * Dispose all the elements created by the Helper.
  146608. */
  146609. dispose(): void;
  146610. }
  146611. }
  146612. declare module BABYLON {
  146613. /**
  146614. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  146615. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  146616. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146617. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146618. */
  146619. export abstract class TextureDome<T extends Texture> extends TransformNode {
  146620. protected onError: Nullable<(message?: string, exception?: any) => void>;
  146621. /**
  146622. * Define the source as a Monoscopic panoramic 360/180.
  146623. */
  146624. static readonly MODE_MONOSCOPIC: number;
  146625. /**
  146626. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  146627. */
  146628. static readonly MODE_TOPBOTTOM: number;
  146629. /**
  146630. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  146631. */
  146632. static readonly MODE_SIDEBYSIDE: number;
  146633. private _halfDome;
  146634. private _crossEye;
  146635. protected _useDirectMapping: boolean;
  146636. /**
  146637. * The texture being displayed on the sphere
  146638. */
  146639. protected _texture: T;
  146640. /**
  146641. * Gets the texture being displayed on the sphere
  146642. */
  146643. get texture(): T;
  146644. /**
  146645. * Sets the texture being displayed on the sphere
  146646. */
  146647. set texture(newTexture: T);
  146648. /**
  146649. * The skybox material
  146650. */
  146651. protected _material: BackgroundMaterial;
  146652. /**
  146653. * The surface used for the dome
  146654. */
  146655. protected _mesh: Mesh;
  146656. /**
  146657. * Gets the mesh used for the dome.
  146658. */
  146659. get mesh(): Mesh;
  146660. /**
  146661. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  146662. */
  146663. private _halfDomeMask;
  146664. /**
  146665. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146666. * Also see the options.resolution property.
  146667. */
  146668. get fovMultiplier(): number;
  146669. set fovMultiplier(value: number);
  146670. protected _textureMode: number;
  146671. /**
  146672. * Gets or set the current texture mode for the texture. It can be:
  146673. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146674. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146675. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146676. */
  146677. get textureMode(): number;
  146678. /**
  146679. * Sets the current texture mode for the texture. It can be:
  146680. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146681. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146682. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146683. */
  146684. set textureMode(value: number);
  146685. /**
  146686. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  146687. */
  146688. get halfDome(): boolean;
  146689. /**
  146690. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  146691. */
  146692. set halfDome(enabled: boolean);
  146693. /**
  146694. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  146695. */
  146696. set crossEye(enabled: boolean);
  146697. /**
  146698. * Is it a cross-eye texture?
  146699. */
  146700. get crossEye(): boolean;
  146701. /**
  146702. * The background material of this dome.
  146703. */
  146704. get material(): BackgroundMaterial;
  146705. /**
  146706. * Oberserver used in Stereoscopic VR Mode.
  146707. */
  146708. private _onBeforeCameraRenderObserver;
  146709. /**
  146710. * Observable raised when an error occured while loading the 360 image
  146711. */
  146712. onLoadErrorObservable: Observable<string>;
  146713. /**
  146714. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  146715. * @param name Element's name, child elements will append suffixes for their own names.
  146716. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  146717. * @param options An object containing optional or exposed sub element properties
  146718. */
  146719. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  146720. resolution?: number;
  146721. clickToPlay?: boolean;
  146722. autoPlay?: boolean;
  146723. loop?: boolean;
  146724. size?: number;
  146725. poster?: string;
  146726. faceForward?: boolean;
  146727. useDirectMapping?: boolean;
  146728. halfDomeMode?: boolean;
  146729. crossEyeMode?: boolean;
  146730. generateMipMaps?: boolean;
  146731. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  146732. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  146733. protected _changeTextureMode(value: number): void;
  146734. /**
  146735. * Releases resources associated with this node.
  146736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  146737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  146738. */
  146739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  146740. }
  146741. }
  146742. declare module BABYLON {
  146743. /**
  146744. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  146745. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  146746. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146747. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146748. */
  146749. export class PhotoDome extends TextureDome<Texture> {
  146750. /**
  146751. * Define the image as a Monoscopic panoramic 360 image.
  146752. */
  146753. static readonly MODE_MONOSCOPIC: number;
  146754. /**
  146755. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  146756. */
  146757. static readonly MODE_TOPBOTTOM: number;
  146758. /**
  146759. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  146760. */
  146761. static readonly MODE_SIDEBYSIDE: number;
  146762. /**
  146763. * Gets or sets the texture being displayed on the sphere
  146764. */
  146765. get photoTexture(): Texture;
  146766. /**
  146767. * sets the texture being displayed on the sphere
  146768. */
  146769. set photoTexture(value: Texture);
  146770. /**
  146771. * Gets the current video mode for the video. It can be:
  146772. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146773. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146774. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146775. */
  146776. get imageMode(): number;
  146777. /**
  146778. * Sets the current video mode for the video. It can be:
  146779. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146780. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146781. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146782. */
  146783. set imageMode(value: number);
  146784. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  146785. }
  146786. }
  146787. declare module BABYLON {
  146788. /**
  146789. * Direct draw surface info
  146790. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  146791. */
  146792. export interface DDSInfo {
  146793. /**
  146794. * Width of the texture
  146795. */
  146796. width: number;
  146797. /**
  146798. * Width of the texture
  146799. */
  146800. height: number;
  146801. /**
  146802. * Number of Mipmaps for the texture
  146803. * @see https://en.wikipedia.org/wiki/Mipmap
  146804. */
  146805. mipmapCount: number;
  146806. /**
  146807. * If the textures format is a known fourCC format
  146808. * @see https://www.fourcc.org/
  146809. */
  146810. isFourCC: boolean;
  146811. /**
  146812. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  146813. */
  146814. isRGB: boolean;
  146815. /**
  146816. * If the texture is a lumincance format
  146817. */
  146818. isLuminance: boolean;
  146819. /**
  146820. * If this is a cube texture
  146821. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  146822. */
  146823. isCube: boolean;
  146824. /**
  146825. * If the texture is a compressed format eg. FOURCC_DXT1
  146826. */
  146827. isCompressed: boolean;
  146828. /**
  146829. * The dxgiFormat of the texture
  146830. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  146831. */
  146832. dxgiFormat: number;
  146833. /**
  146834. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  146835. */
  146836. textureType: number;
  146837. /**
  146838. * Sphericle polynomial created for the dds texture
  146839. */
  146840. sphericalPolynomial?: SphericalPolynomial;
  146841. }
  146842. /**
  146843. * Class used to provide DDS decompression tools
  146844. */
  146845. export class DDSTools {
  146846. /**
  146847. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  146848. */
  146849. static StoreLODInAlphaChannel: boolean;
  146850. /**
  146851. * Gets DDS information from an array buffer
  146852. * @param data defines the array buffer view to read data from
  146853. * @returns the DDS information
  146854. */
  146855. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  146856. private static _FloatView;
  146857. private static _Int32View;
  146858. private static _ToHalfFloat;
  146859. private static _FromHalfFloat;
  146860. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  146861. private static _GetHalfFloatRGBAArrayBuffer;
  146862. private static _GetFloatRGBAArrayBuffer;
  146863. private static _GetFloatAsUIntRGBAArrayBuffer;
  146864. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  146865. private static _GetRGBAArrayBuffer;
  146866. private static _ExtractLongWordOrder;
  146867. private static _GetRGBArrayBuffer;
  146868. private static _GetLuminanceArrayBuffer;
  146869. /**
  146870. * Uploads DDS Levels to a Babylon Texture
  146871. * @hidden
  146872. */
  146873. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  146874. }
  146875. interface ThinEngine {
  146876. /**
  146877. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  146878. * @param rootUrl defines the url where the file to load is located
  146879. * @param scene defines the current scene
  146880. * @param lodScale defines scale to apply to the mip map selection
  146881. * @param lodOffset defines offset to apply to the mip map selection
  146882. * @param onLoad defines an optional callback raised when the texture is loaded
  146883. * @param onError defines an optional callback raised if there is an issue to load the texture
  146884. * @param format defines the format of the data
  146885. * @param forcedExtension defines the extension to use to pick the right loader
  146886. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  146887. * @returns the cube texture as an InternalTexture
  146888. */
  146889. 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;
  146890. }
  146891. }
  146892. declare module BABYLON {
  146893. /**
  146894. * Implementation of the DDS Texture Loader.
  146895. * @hidden
  146896. */
  146897. export class _DDSTextureLoader implements IInternalTextureLoader {
  146898. /**
  146899. * Defines wether the loader supports cascade loading the different faces.
  146900. */
  146901. readonly supportCascades: boolean;
  146902. /**
  146903. * This returns if the loader support the current file information.
  146904. * @param extension defines the file extension of the file being loaded
  146905. * @returns true if the loader can load the specified file
  146906. */
  146907. canLoad(extension: string): boolean;
  146908. /**
  146909. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146910. * @param data contains the texture data
  146911. * @param texture defines the BabylonJS internal texture
  146912. * @param createPolynomials will be true if polynomials have been requested
  146913. * @param onLoad defines the callback to trigger once the texture is ready
  146914. * @param onError defines the callback to trigger in case of error
  146915. */
  146916. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146917. /**
  146918. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146919. * @param data contains the texture data
  146920. * @param texture defines the BabylonJS internal texture
  146921. * @param callback defines the method to call once ready to upload
  146922. */
  146923. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146924. }
  146925. }
  146926. declare module BABYLON {
  146927. /**
  146928. * Implementation of the ENV Texture Loader.
  146929. * @hidden
  146930. */
  146931. export class _ENVTextureLoader implements IInternalTextureLoader {
  146932. /**
  146933. * Defines wether the loader supports cascade loading the different faces.
  146934. */
  146935. readonly supportCascades: boolean;
  146936. /**
  146937. * This returns if the loader support the current file information.
  146938. * @param extension defines the file extension of the file being loaded
  146939. * @returns true if the loader can load the specified file
  146940. */
  146941. canLoad(extension: string): boolean;
  146942. /**
  146943. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146944. * @param data contains the texture data
  146945. * @param texture defines the BabylonJS internal texture
  146946. * @param createPolynomials will be true if polynomials have been requested
  146947. * @param onLoad defines the callback to trigger once the texture is ready
  146948. * @param onError defines the callback to trigger in case of error
  146949. */
  146950. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146951. /**
  146952. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146953. * @param data contains the texture data
  146954. * @param texture defines the BabylonJS internal texture
  146955. * @param callback defines the method to call once ready to upload
  146956. */
  146957. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146958. }
  146959. }
  146960. declare module BABYLON {
  146961. /**
  146962. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  146963. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  146964. */
  146965. export class KhronosTextureContainer {
  146966. /** contents of the KTX container file */
  146967. data: ArrayBufferView;
  146968. private static HEADER_LEN;
  146969. private static COMPRESSED_2D;
  146970. private static COMPRESSED_3D;
  146971. private static TEX_2D;
  146972. private static TEX_3D;
  146973. /**
  146974. * Gets the openGL type
  146975. */
  146976. glType: number;
  146977. /**
  146978. * Gets the openGL type size
  146979. */
  146980. glTypeSize: number;
  146981. /**
  146982. * Gets the openGL format
  146983. */
  146984. glFormat: number;
  146985. /**
  146986. * Gets the openGL internal format
  146987. */
  146988. glInternalFormat: number;
  146989. /**
  146990. * Gets the base internal format
  146991. */
  146992. glBaseInternalFormat: number;
  146993. /**
  146994. * Gets image width in pixel
  146995. */
  146996. pixelWidth: number;
  146997. /**
  146998. * Gets image height in pixel
  146999. */
  147000. pixelHeight: number;
  147001. /**
  147002. * Gets image depth in pixels
  147003. */
  147004. pixelDepth: number;
  147005. /**
  147006. * Gets the number of array elements
  147007. */
  147008. numberOfArrayElements: number;
  147009. /**
  147010. * Gets the number of faces
  147011. */
  147012. numberOfFaces: number;
  147013. /**
  147014. * Gets the number of mipmap levels
  147015. */
  147016. numberOfMipmapLevels: number;
  147017. /**
  147018. * Gets the bytes of key value data
  147019. */
  147020. bytesOfKeyValueData: number;
  147021. /**
  147022. * Gets the load type
  147023. */
  147024. loadType: number;
  147025. /**
  147026. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  147027. */
  147028. isInvalid: boolean;
  147029. /**
  147030. * Creates a new KhronosTextureContainer
  147031. * @param data contents of the KTX container file
  147032. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  147033. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  147034. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  147035. */
  147036. constructor(
  147037. /** contents of the KTX container file */
  147038. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  147039. /**
  147040. * Uploads KTX content to a Babylon Texture.
  147041. * It is assumed that the texture has already been created & is currently bound
  147042. * @hidden
  147043. */
  147044. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  147045. private _upload2DCompressedLevels;
  147046. /**
  147047. * Checks if the given data starts with a KTX file identifier.
  147048. * @param data the data to check
  147049. * @returns true if the data is a KTX file or false otherwise
  147050. */
  147051. static IsValid(data: ArrayBufferView): boolean;
  147052. }
  147053. }
  147054. declare module BABYLON {
  147055. /**
  147056. * Helper class to push actions to a pool of workers.
  147057. */
  147058. export class WorkerPool implements IDisposable {
  147059. private _workerInfos;
  147060. private _pendingActions;
  147061. /**
  147062. * Constructor
  147063. * @param workers Array of workers to use for actions
  147064. */
  147065. constructor(workers: Array<Worker>);
  147066. /**
  147067. * Terminates all workers and clears any pending actions.
  147068. */
  147069. dispose(): void;
  147070. /**
  147071. * Pushes an action to the worker pool. If all the workers are active, the action will be
  147072. * pended until a worker has completed its action.
  147073. * @param action The action to perform. Call onComplete when the action is complete.
  147074. */
  147075. push(action: (worker: Worker, onComplete: () => void) => void): void;
  147076. private _execute;
  147077. }
  147078. }
  147079. declare module BABYLON {
  147080. /**
  147081. * Class for loading KTX2 files
  147082. */
  147083. export class KhronosTextureContainer2 {
  147084. private static _WorkerPoolPromise?;
  147085. private static _Initialized;
  147086. private static _Ktx2Decoder;
  147087. /**
  147088. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  147089. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  147090. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  147091. * Urls you can change:
  147092. * URLConfig.jsDecoderModule
  147093. * URLConfig.wasmUASTCToASTC
  147094. * URLConfig.wasmUASTCToBC7
  147095. * URLConfig.wasmUASTCToRGBA_UNORM
  147096. * URLConfig.wasmUASTCToRGBA_SRGB
  147097. * URLConfig.jsMSCTranscoder
  147098. * URLConfig.wasmMSCTranscoder
  147099. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  147100. */
  147101. static URLConfig: {
  147102. jsDecoderModule: string;
  147103. wasmUASTCToASTC: null;
  147104. wasmUASTCToBC7: null;
  147105. wasmUASTCToRGBA_UNORM: null;
  147106. wasmUASTCToRGBA_SRGB: null;
  147107. jsMSCTranscoder: null;
  147108. wasmMSCTranscoder: null;
  147109. };
  147110. /**
  147111. * Default number of workers used to handle data decoding
  147112. */
  147113. static DefaultNumWorkers: number;
  147114. private static GetDefaultNumWorkers;
  147115. private _engine;
  147116. private static _CreateWorkerPool;
  147117. /**
  147118. * Constructor
  147119. * @param engine The engine to use
  147120. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147121. */
  147122. constructor(engine: ThinEngine, numWorkers?: number);
  147123. /** @hidden */
  147124. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  147125. /**
  147126. * Stop all async operations and release resources.
  147127. */
  147128. dispose(): void;
  147129. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  147130. /**
  147131. * Checks if the given data starts with a KTX2 file identifier.
  147132. * @param data the data to check
  147133. * @returns true if the data is a KTX2 file or false otherwise
  147134. */
  147135. static IsValid(data: ArrayBufferView): boolean;
  147136. }
  147137. }
  147138. declare module BABYLON {
  147139. /**
  147140. * Implementation of the KTX Texture Loader.
  147141. * @hidden
  147142. */
  147143. export class _KTXTextureLoader implements IInternalTextureLoader {
  147144. /**
  147145. * Defines wether the loader supports cascade loading the different faces.
  147146. */
  147147. readonly supportCascades: boolean;
  147148. /**
  147149. * This returns if the loader support the current file information.
  147150. * @param extension defines the file extension of the file being loaded
  147151. * @param mimeType defines the optional mime type of the file being loaded
  147152. * @returns true if the loader can load the specified file
  147153. */
  147154. canLoad(extension: string, mimeType?: string): boolean;
  147155. /**
  147156. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  147157. * @param data contains the texture data
  147158. * @param texture defines the BabylonJS internal texture
  147159. * @param createPolynomials will be true if polynomials have been requested
  147160. * @param onLoad defines the callback to trigger once the texture is ready
  147161. * @param onError defines the callback to trigger in case of error
  147162. */
  147163. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  147164. /**
  147165. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  147166. * @param data contains the texture data
  147167. * @param texture defines the BabylonJS internal texture
  147168. * @param callback defines the method to call once ready to upload
  147169. */
  147170. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  147171. }
  147172. }
  147173. declare module BABYLON {
  147174. /** @hidden */
  147175. export var _forceSceneHelpersToBundle: boolean;
  147176. interface Scene {
  147177. /**
  147178. * Creates a default light for the scene.
  147179. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  147180. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  147181. */
  147182. createDefaultLight(replace?: boolean): void;
  147183. /**
  147184. * Creates a default camera for the scene.
  147185. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  147186. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  147187. * @param replace has default false, when true replaces the active camera in the scene
  147188. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  147189. */
  147190. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  147191. /**
  147192. * Creates a default camera and a default light.
  147193. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  147194. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  147195. * @param replace has the default false, when true replaces the active camera/light in the scene
  147196. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  147197. */
  147198. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  147199. /**
  147200. * Creates a new sky box
  147201. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  147202. * @param environmentTexture defines the texture to use as environment texture
  147203. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  147204. * @param scale defines the overall scale of the skybox
  147205. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  147206. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  147207. * @returns a new mesh holding the sky box
  147208. */
  147209. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  147210. /**
  147211. * Creates a new environment
  147212. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  147213. * @param options defines the options you can use to configure the environment
  147214. * @returns the new EnvironmentHelper
  147215. */
  147216. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  147217. /**
  147218. * Creates a new VREXperienceHelper
  147219. * @see https://doc.babylonjs.com/how_to/webvr_helper
  147220. * @param webVROptions defines the options used to create the new VREXperienceHelper
  147221. * @returns a new VREXperienceHelper
  147222. */
  147223. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  147224. /**
  147225. * Creates a new WebXRDefaultExperience
  147226. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  147227. * @param options experience options
  147228. * @returns a promise for a new WebXRDefaultExperience
  147229. */
  147230. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  147231. }
  147232. }
  147233. declare module BABYLON {
  147234. /**
  147235. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  147236. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  147237. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  147238. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  147239. */
  147240. export class VideoDome extends TextureDome<VideoTexture> {
  147241. /**
  147242. * Define the video source as a Monoscopic panoramic 360 video.
  147243. */
  147244. static readonly MODE_MONOSCOPIC: number;
  147245. /**
  147246. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  147247. */
  147248. static readonly MODE_TOPBOTTOM: number;
  147249. /**
  147250. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  147251. */
  147252. static readonly MODE_SIDEBYSIDE: number;
  147253. /**
  147254. * Get the video texture associated with this video dome
  147255. */
  147256. get videoTexture(): VideoTexture;
  147257. /**
  147258. * Get the video mode of this dome
  147259. */
  147260. get videoMode(): number;
  147261. /**
  147262. * Set the video mode of this dome.
  147263. * @see textureMode
  147264. */
  147265. set videoMode(value: number);
  147266. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  147267. }
  147268. }
  147269. declare module BABYLON {
  147270. /**
  147271. * This class can be used to get instrumentation data from a Babylon engine
  147272. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  147273. */
  147274. export class EngineInstrumentation implements IDisposable {
  147275. /**
  147276. * Define the instrumented engine.
  147277. */
  147278. engine: Engine;
  147279. private _captureGPUFrameTime;
  147280. private _gpuFrameTimeToken;
  147281. private _gpuFrameTime;
  147282. private _captureShaderCompilationTime;
  147283. private _shaderCompilationTime;
  147284. private _onBeginFrameObserver;
  147285. private _onEndFrameObserver;
  147286. private _onBeforeShaderCompilationObserver;
  147287. private _onAfterShaderCompilationObserver;
  147288. /**
  147289. * Gets the perf counter used for GPU frame time
  147290. */
  147291. get gpuFrameTimeCounter(): PerfCounter;
  147292. /**
  147293. * Gets the GPU frame time capture status
  147294. */
  147295. get captureGPUFrameTime(): boolean;
  147296. /**
  147297. * Enable or disable the GPU frame time capture
  147298. */
  147299. set captureGPUFrameTime(value: boolean);
  147300. /**
  147301. * Gets the perf counter used for shader compilation time
  147302. */
  147303. get shaderCompilationTimeCounter(): PerfCounter;
  147304. /**
  147305. * Gets the shader compilation time capture status
  147306. */
  147307. get captureShaderCompilationTime(): boolean;
  147308. /**
  147309. * Enable or disable the shader compilation time capture
  147310. */
  147311. set captureShaderCompilationTime(value: boolean);
  147312. /**
  147313. * Instantiates a new engine instrumentation.
  147314. * This class can be used to get instrumentation data from a Babylon engine
  147315. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  147316. * @param engine Defines the engine to instrument
  147317. */
  147318. constructor(
  147319. /**
  147320. * Define the instrumented engine.
  147321. */
  147322. engine: Engine);
  147323. /**
  147324. * Dispose and release associated resources.
  147325. */
  147326. dispose(): void;
  147327. }
  147328. }
  147329. declare module BABYLON {
  147330. /**
  147331. * This class can be used to get instrumentation data from a Babylon engine
  147332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  147333. */
  147334. export class SceneInstrumentation implements IDisposable {
  147335. /**
  147336. * Defines the scene to instrument
  147337. */
  147338. scene: Scene;
  147339. private _captureActiveMeshesEvaluationTime;
  147340. private _activeMeshesEvaluationTime;
  147341. private _captureRenderTargetsRenderTime;
  147342. private _renderTargetsRenderTime;
  147343. private _captureFrameTime;
  147344. private _frameTime;
  147345. private _captureRenderTime;
  147346. private _renderTime;
  147347. private _captureInterFrameTime;
  147348. private _interFrameTime;
  147349. private _captureParticlesRenderTime;
  147350. private _particlesRenderTime;
  147351. private _captureSpritesRenderTime;
  147352. private _spritesRenderTime;
  147353. private _capturePhysicsTime;
  147354. private _physicsTime;
  147355. private _captureAnimationsTime;
  147356. private _animationsTime;
  147357. private _captureCameraRenderTime;
  147358. private _cameraRenderTime;
  147359. private _onBeforeActiveMeshesEvaluationObserver;
  147360. private _onAfterActiveMeshesEvaluationObserver;
  147361. private _onBeforeRenderTargetsRenderObserver;
  147362. private _onAfterRenderTargetsRenderObserver;
  147363. private _onAfterRenderObserver;
  147364. private _onBeforeDrawPhaseObserver;
  147365. private _onAfterDrawPhaseObserver;
  147366. private _onBeforeAnimationsObserver;
  147367. private _onBeforeParticlesRenderingObserver;
  147368. private _onAfterParticlesRenderingObserver;
  147369. private _onBeforeSpritesRenderingObserver;
  147370. private _onAfterSpritesRenderingObserver;
  147371. private _onBeforePhysicsObserver;
  147372. private _onAfterPhysicsObserver;
  147373. private _onAfterAnimationsObserver;
  147374. private _onBeforeCameraRenderObserver;
  147375. private _onAfterCameraRenderObserver;
  147376. /**
  147377. * Gets the perf counter used for active meshes evaluation time
  147378. */
  147379. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  147380. /**
  147381. * Gets the active meshes evaluation time capture status
  147382. */
  147383. get captureActiveMeshesEvaluationTime(): boolean;
  147384. /**
  147385. * Enable or disable the active meshes evaluation time capture
  147386. */
  147387. set captureActiveMeshesEvaluationTime(value: boolean);
  147388. /**
  147389. * Gets the perf counter used for render targets render time
  147390. */
  147391. get renderTargetsRenderTimeCounter(): PerfCounter;
  147392. /**
  147393. * Gets the render targets render time capture status
  147394. */
  147395. get captureRenderTargetsRenderTime(): boolean;
  147396. /**
  147397. * Enable or disable the render targets render time capture
  147398. */
  147399. set captureRenderTargetsRenderTime(value: boolean);
  147400. /**
  147401. * Gets the perf counter used for particles render time
  147402. */
  147403. get particlesRenderTimeCounter(): PerfCounter;
  147404. /**
  147405. * Gets the particles render time capture status
  147406. */
  147407. get captureParticlesRenderTime(): boolean;
  147408. /**
  147409. * Enable or disable the particles render time capture
  147410. */
  147411. set captureParticlesRenderTime(value: boolean);
  147412. /**
  147413. * Gets the perf counter used for sprites render time
  147414. */
  147415. get spritesRenderTimeCounter(): PerfCounter;
  147416. /**
  147417. * Gets the sprites render time capture status
  147418. */
  147419. get captureSpritesRenderTime(): boolean;
  147420. /**
  147421. * Enable or disable the sprites render time capture
  147422. */
  147423. set captureSpritesRenderTime(value: boolean);
  147424. /**
  147425. * Gets the perf counter used for physics time
  147426. */
  147427. get physicsTimeCounter(): PerfCounter;
  147428. /**
  147429. * Gets the physics time capture status
  147430. */
  147431. get capturePhysicsTime(): boolean;
  147432. /**
  147433. * Enable or disable the physics time capture
  147434. */
  147435. set capturePhysicsTime(value: boolean);
  147436. /**
  147437. * Gets the perf counter used for animations time
  147438. */
  147439. get animationsTimeCounter(): PerfCounter;
  147440. /**
  147441. * Gets the animations time capture status
  147442. */
  147443. get captureAnimationsTime(): boolean;
  147444. /**
  147445. * Enable or disable the animations time capture
  147446. */
  147447. set captureAnimationsTime(value: boolean);
  147448. /**
  147449. * Gets the perf counter used for frame time capture
  147450. */
  147451. get frameTimeCounter(): PerfCounter;
  147452. /**
  147453. * Gets the frame time capture status
  147454. */
  147455. get captureFrameTime(): boolean;
  147456. /**
  147457. * Enable or disable the frame time capture
  147458. */
  147459. set captureFrameTime(value: boolean);
  147460. /**
  147461. * Gets the perf counter used for inter-frames time capture
  147462. */
  147463. get interFrameTimeCounter(): PerfCounter;
  147464. /**
  147465. * Gets the inter-frames time capture status
  147466. */
  147467. get captureInterFrameTime(): boolean;
  147468. /**
  147469. * Enable or disable the inter-frames time capture
  147470. */
  147471. set captureInterFrameTime(value: boolean);
  147472. /**
  147473. * Gets the perf counter used for render time capture
  147474. */
  147475. get renderTimeCounter(): PerfCounter;
  147476. /**
  147477. * Gets the render time capture status
  147478. */
  147479. get captureRenderTime(): boolean;
  147480. /**
  147481. * Enable or disable the render time capture
  147482. */
  147483. set captureRenderTime(value: boolean);
  147484. /**
  147485. * Gets the perf counter used for camera render time capture
  147486. */
  147487. get cameraRenderTimeCounter(): PerfCounter;
  147488. /**
  147489. * Gets the camera render time capture status
  147490. */
  147491. get captureCameraRenderTime(): boolean;
  147492. /**
  147493. * Enable or disable the camera render time capture
  147494. */
  147495. set captureCameraRenderTime(value: boolean);
  147496. /**
  147497. * Gets the perf counter used for draw calls
  147498. */
  147499. get drawCallsCounter(): PerfCounter;
  147500. /**
  147501. * Instantiates a new scene instrumentation.
  147502. * This class can be used to get instrumentation data from a Babylon engine
  147503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  147504. * @param scene Defines the scene to instrument
  147505. */
  147506. constructor(
  147507. /**
  147508. * Defines the scene to instrument
  147509. */
  147510. scene: Scene);
  147511. /**
  147512. * Dispose and release associated resources.
  147513. */
  147514. dispose(): void;
  147515. }
  147516. }
  147517. declare module BABYLON {
  147518. /** @hidden */
  147519. export var glowMapGenerationPixelShader: {
  147520. name: string;
  147521. shader: string;
  147522. };
  147523. }
  147524. declare module BABYLON {
  147525. /** @hidden */
  147526. export var glowMapGenerationVertexShader: {
  147527. name: string;
  147528. shader: string;
  147529. };
  147530. }
  147531. declare module BABYLON {
  147532. /**
  147533. * Effect layer options. This helps customizing the behaviour
  147534. * of the effect layer.
  147535. */
  147536. export interface IEffectLayerOptions {
  147537. /**
  147538. * Multiplication factor apply to the canvas size to compute the render target size
  147539. * used to generated the objects (the smaller the faster).
  147540. */
  147541. mainTextureRatio: number;
  147542. /**
  147543. * Enforces a fixed size texture to ensure effect stability across devices.
  147544. */
  147545. mainTextureFixedSize?: number;
  147546. /**
  147547. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  147548. */
  147549. alphaBlendingMode: number;
  147550. /**
  147551. * The camera attached to the layer.
  147552. */
  147553. camera: Nullable<Camera>;
  147554. /**
  147555. * The rendering group to draw the layer in.
  147556. */
  147557. renderingGroupId: number;
  147558. }
  147559. /**
  147560. * The effect layer Helps adding post process effect blended with the main pass.
  147561. *
  147562. * This can be for instance use to generate glow or higlight effects on the scene.
  147563. *
  147564. * The effect layer class can not be used directly and is intented to inherited from to be
  147565. * customized per effects.
  147566. */
  147567. export abstract class EffectLayer {
  147568. private _vertexBuffers;
  147569. private _indexBuffer;
  147570. private _cachedDefines;
  147571. private _effectLayerMapGenerationEffect;
  147572. private _effectLayerOptions;
  147573. private _mergeEffect;
  147574. protected _scene: Scene;
  147575. protected _engine: Engine;
  147576. protected _maxSize: number;
  147577. protected _mainTextureDesiredSize: ISize;
  147578. protected _mainTexture: RenderTargetTexture;
  147579. protected _shouldRender: boolean;
  147580. protected _postProcesses: PostProcess[];
  147581. protected _textures: BaseTexture[];
  147582. protected _emissiveTextureAndColor: {
  147583. texture: Nullable<BaseTexture>;
  147584. color: Color4;
  147585. };
  147586. /**
  147587. * The name of the layer
  147588. */
  147589. name: string;
  147590. /**
  147591. * The clear color of the texture used to generate the glow map.
  147592. */
  147593. neutralColor: Color4;
  147594. /**
  147595. * Specifies whether the highlight layer is enabled or not.
  147596. */
  147597. isEnabled: boolean;
  147598. /**
  147599. * Gets the camera attached to the layer.
  147600. */
  147601. get camera(): Nullable<Camera>;
  147602. /**
  147603. * Gets the rendering group id the layer should render in.
  147604. */
  147605. get renderingGroupId(): number;
  147606. set renderingGroupId(renderingGroupId: number);
  147607. /**
  147608. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  147609. */
  147610. disableBoundingBoxesFromEffectLayer: boolean;
  147611. /**
  147612. * An event triggered when the effect layer has been disposed.
  147613. */
  147614. onDisposeObservable: Observable<EffectLayer>;
  147615. /**
  147616. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  147617. */
  147618. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  147619. /**
  147620. * An event triggered when the generated texture is being merged in the scene.
  147621. */
  147622. onBeforeComposeObservable: Observable<EffectLayer>;
  147623. /**
  147624. * An event triggered when the mesh is rendered into the effect render target.
  147625. */
  147626. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  147627. /**
  147628. * An event triggered after the mesh has been rendered into the effect render target.
  147629. */
  147630. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  147631. /**
  147632. * An event triggered when the generated texture has been merged in the scene.
  147633. */
  147634. onAfterComposeObservable: Observable<EffectLayer>;
  147635. /**
  147636. * An event triggered when the efffect layer changes its size.
  147637. */
  147638. onSizeChangedObservable: Observable<EffectLayer>;
  147639. /** @hidden */
  147640. static _SceneComponentInitialization: (scene: Scene) => void;
  147641. /**
  147642. * Instantiates a new effect Layer and references it in the scene.
  147643. * @param name The name of the layer
  147644. * @param scene The scene to use the layer in
  147645. */
  147646. constructor(
  147647. /** The Friendly of the effect in the scene */
  147648. name: string, scene: Scene);
  147649. /**
  147650. * Get the effect name of the layer.
  147651. * @return The effect name
  147652. */
  147653. abstract getEffectName(): string;
  147654. /**
  147655. * Checks for the readiness of the element composing the layer.
  147656. * @param subMesh the mesh to check for
  147657. * @param useInstances specify whether or not to use instances to render the mesh
  147658. * @return true if ready otherwise, false
  147659. */
  147660. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147661. /**
  147662. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147663. * @returns true if the effect requires stencil during the main canvas render pass.
  147664. */
  147665. abstract needStencil(): boolean;
  147666. /**
  147667. * Create the merge effect. This is the shader use to blit the information back
  147668. * to the main canvas at the end of the scene rendering.
  147669. * @returns The effect containing the shader used to merge the effect on the main canvas
  147670. */
  147671. protected abstract _createMergeEffect(): Effect;
  147672. /**
  147673. * Creates the render target textures and post processes used in the effect layer.
  147674. */
  147675. protected abstract _createTextureAndPostProcesses(): void;
  147676. /**
  147677. * Implementation specific of rendering the generating effect on the main canvas.
  147678. * @param effect The effect used to render through
  147679. */
  147680. protected abstract _internalRender(effect: Effect): void;
  147681. /**
  147682. * Sets the required values for both the emissive texture and and the main color.
  147683. */
  147684. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147685. /**
  147686. * Free any resources and references associated to a mesh.
  147687. * Internal use
  147688. * @param mesh The mesh to free.
  147689. */
  147690. abstract _disposeMesh(mesh: Mesh): void;
  147691. /**
  147692. * Serializes this layer (Glow or Highlight for example)
  147693. * @returns a serialized layer object
  147694. */
  147695. abstract serialize?(): any;
  147696. /**
  147697. * Initializes the effect layer with the required options.
  147698. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  147699. */
  147700. protected _init(options: Partial<IEffectLayerOptions>): void;
  147701. /**
  147702. * Generates the index buffer of the full screen quad blending to the main canvas.
  147703. */
  147704. private _generateIndexBuffer;
  147705. /**
  147706. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  147707. */
  147708. private _generateVertexBuffer;
  147709. /**
  147710. * Sets the main texture desired size which is the closest power of two
  147711. * of the engine canvas size.
  147712. */
  147713. private _setMainTextureSize;
  147714. /**
  147715. * Creates the main texture for the effect layer.
  147716. */
  147717. protected _createMainTexture(): void;
  147718. /**
  147719. * Adds specific effects defines.
  147720. * @param defines The defines to add specifics to.
  147721. */
  147722. protected _addCustomEffectDefines(defines: string[]): void;
  147723. /**
  147724. * Checks for the readiness of the element composing the layer.
  147725. * @param subMesh the mesh to check for
  147726. * @param useInstances specify whether or not to use instances to render the mesh
  147727. * @param emissiveTexture the associated emissive texture used to generate the glow
  147728. * @return true if ready otherwise, false
  147729. */
  147730. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  147731. /**
  147732. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  147733. */
  147734. render(): void;
  147735. /**
  147736. * Determine if a given mesh will be used in the current effect.
  147737. * @param mesh mesh to test
  147738. * @returns true if the mesh will be used
  147739. */
  147740. hasMesh(mesh: AbstractMesh): boolean;
  147741. /**
  147742. * Returns true if the layer contains information to display, otherwise false.
  147743. * @returns true if the glow layer should be rendered
  147744. */
  147745. shouldRender(): boolean;
  147746. /**
  147747. * Returns true if the mesh should render, otherwise false.
  147748. * @param mesh The mesh to render
  147749. * @returns true if it should render otherwise false
  147750. */
  147751. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  147752. /**
  147753. * Returns true if the mesh can be rendered, otherwise false.
  147754. * @param mesh The mesh to render
  147755. * @param material The material used on the mesh
  147756. * @returns true if it can be rendered otherwise false
  147757. */
  147758. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147759. /**
  147760. * Returns true if the mesh should render, otherwise false.
  147761. * @param mesh The mesh to render
  147762. * @returns true if it should render otherwise false
  147763. */
  147764. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  147765. /**
  147766. * Renders the submesh passed in parameter to the generation map.
  147767. */
  147768. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  147769. /**
  147770. * Defines whether the current material of the mesh should be use to render the effect.
  147771. * @param mesh defines the current mesh to render
  147772. */
  147773. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  147774. /**
  147775. * Rebuild the required buffers.
  147776. * @hidden Internal use only.
  147777. */
  147778. _rebuild(): void;
  147779. /**
  147780. * Dispose only the render target textures and post process.
  147781. */
  147782. private _disposeTextureAndPostProcesses;
  147783. /**
  147784. * Dispose the highlight layer and free resources.
  147785. */
  147786. dispose(): void;
  147787. /**
  147788. * Gets the class name of the effect layer
  147789. * @returns the string with the class name of the effect layer
  147790. */
  147791. getClassName(): string;
  147792. /**
  147793. * Creates an effect layer from parsed effect layer data
  147794. * @param parsedEffectLayer defines effect layer data
  147795. * @param scene defines the current scene
  147796. * @param rootUrl defines the root URL containing the effect layer information
  147797. * @returns a parsed effect Layer
  147798. */
  147799. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  147800. }
  147801. }
  147802. declare module BABYLON {
  147803. interface AbstractScene {
  147804. /**
  147805. * The list of effect layers (highlights/glow) added to the scene
  147806. * @see https://doc.babylonjs.com/how_to/highlight_layer
  147807. * @see https://doc.babylonjs.com/how_to/glow_layer
  147808. */
  147809. effectLayers: Array<EffectLayer>;
  147810. /**
  147811. * Removes the given effect layer from this scene.
  147812. * @param toRemove defines the effect layer to remove
  147813. * @returns the index of the removed effect layer
  147814. */
  147815. removeEffectLayer(toRemove: EffectLayer): number;
  147816. /**
  147817. * Adds the given effect layer to this scene
  147818. * @param newEffectLayer defines the effect layer to add
  147819. */
  147820. addEffectLayer(newEffectLayer: EffectLayer): void;
  147821. }
  147822. /**
  147823. * Defines the layer scene component responsible to manage any effect layers
  147824. * in a given scene.
  147825. */
  147826. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  147827. /**
  147828. * The component name helpfull to identify the component in the list of scene components.
  147829. */
  147830. readonly name: string;
  147831. /**
  147832. * The scene the component belongs to.
  147833. */
  147834. scene: Scene;
  147835. private _engine;
  147836. private _renderEffects;
  147837. private _needStencil;
  147838. private _previousStencilState;
  147839. /**
  147840. * Creates a new instance of the component for the given scene
  147841. * @param scene Defines the scene to register the component in
  147842. */
  147843. constructor(scene: Scene);
  147844. /**
  147845. * Registers the component in a given scene
  147846. */
  147847. register(): void;
  147848. /**
  147849. * Rebuilds the elements related to this component in case of
  147850. * context lost for instance.
  147851. */
  147852. rebuild(): void;
  147853. /**
  147854. * Serializes the component data to the specified json object
  147855. * @param serializationObject The object to serialize to
  147856. */
  147857. serialize(serializationObject: any): void;
  147858. /**
  147859. * Adds all the elements from the container to the scene
  147860. * @param container the container holding the elements
  147861. */
  147862. addFromContainer(container: AbstractScene): void;
  147863. /**
  147864. * Removes all the elements in the container from the scene
  147865. * @param container contains the elements to remove
  147866. * @param dispose if the removed element should be disposed (default: false)
  147867. */
  147868. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  147869. /**
  147870. * Disposes the component and the associated ressources.
  147871. */
  147872. dispose(): void;
  147873. private _isReadyForMesh;
  147874. private _renderMainTexture;
  147875. private _setStencil;
  147876. private _setStencilBack;
  147877. private _draw;
  147878. private _drawCamera;
  147879. private _drawRenderingGroup;
  147880. }
  147881. }
  147882. declare module BABYLON {
  147883. /** @hidden */
  147884. export var glowMapMergePixelShader: {
  147885. name: string;
  147886. shader: string;
  147887. };
  147888. }
  147889. declare module BABYLON {
  147890. /** @hidden */
  147891. export var glowMapMergeVertexShader: {
  147892. name: string;
  147893. shader: string;
  147894. };
  147895. }
  147896. declare module BABYLON {
  147897. interface AbstractScene {
  147898. /**
  147899. * Return a the first highlight layer of the scene with a given name.
  147900. * @param name The name of the highlight layer to look for.
  147901. * @return The highlight layer if found otherwise null.
  147902. */
  147903. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  147904. }
  147905. /**
  147906. * Glow layer options. This helps customizing the behaviour
  147907. * of the glow layer.
  147908. */
  147909. export interface IGlowLayerOptions {
  147910. /**
  147911. * Multiplication factor apply to the canvas size to compute the render target size
  147912. * used to generated the glowing objects (the smaller the faster).
  147913. */
  147914. mainTextureRatio: number;
  147915. /**
  147916. * Enforces a fixed size texture to ensure resize independant blur.
  147917. */
  147918. mainTextureFixedSize?: number;
  147919. /**
  147920. * How big is the kernel of the blur texture.
  147921. */
  147922. blurKernelSize: number;
  147923. /**
  147924. * The camera attached to the layer.
  147925. */
  147926. camera: Nullable<Camera>;
  147927. /**
  147928. * Enable MSAA by chosing the number of samples.
  147929. */
  147930. mainTextureSamples?: number;
  147931. /**
  147932. * The rendering group to draw the layer in.
  147933. */
  147934. renderingGroupId: number;
  147935. }
  147936. /**
  147937. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  147938. *
  147939. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  147940. *
  147941. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  147942. */
  147943. export class GlowLayer extends EffectLayer {
  147944. /**
  147945. * Effect Name of the layer.
  147946. */
  147947. static readonly EffectName: string;
  147948. /**
  147949. * The default blur kernel size used for the glow.
  147950. */
  147951. static DefaultBlurKernelSize: number;
  147952. /**
  147953. * The default texture size ratio used for the glow.
  147954. */
  147955. static DefaultTextureRatio: number;
  147956. /**
  147957. * Sets the kernel size of the blur.
  147958. */
  147959. set blurKernelSize(value: number);
  147960. /**
  147961. * Gets the kernel size of the blur.
  147962. */
  147963. get blurKernelSize(): number;
  147964. /**
  147965. * Sets the glow intensity.
  147966. */
  147967. set intensity(value: number);
  147968. /**
  147969. * Gets the glow intensity.
  147970. */
  147971. get intensity(): number;
  147972. private _options;
  147973. private _intensity;
  147974. private _horizontalBlurPostprocess1;
  147975. private _verticalBlurPostprocess1;
  147976. private _horizontalBlurPostprocess2;
  147977. private _verticalBlurPostprocess2;
  147978. private _blurTexture1;
  147979. private _blurTexture2;
  147980. private _postProcesses1;
  147981. private _postProcesses2;
  147982. private _includedOnlyMeshes;
  147983. private _excludedMeshes;
  147984. private _meshesUsingTheirOwnMaterials;
  147985. /**
  147986. * Callback used to let the user override the color selection on a per mesh basis
  147987. */
  147988. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  147989. /**
  147990. * Callback used to let the user override the texture selection on a per mesh basis
  147991. */
  147992. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  147993. /**
  147994. * Instantiates a new glow Layer and references it to the scene.
  147995. * @param name The name of the layer
  147996. * @param scene The scene to use the layer in
  147997. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  147998. */
  147999. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  148000. /**
  148001. * Get the effect name of the layer.
  148002. * @return The effect name
  148003. */
  148004. getEffectName(): string;
  148005. /**
  148006. * Create the merge effect. This is the shader use to blit the information back
  148007. * to the main canvas at the end of the scene rendering.
  148008. */
  148009. protected _createMergeEffect(): Effect;
  148010. /**
  148011. * Creates the render target textures and post processes used in the glow layer.
  148012. */
  148013. protected _createTextureAndPostProcesses(): void;
  148014. /**
  148015. * Checks for the readiness of the element composing the layer.
  148016. * @param subMesh the mesh to check for
  148017. * @param useInstances specify wether or not to use instances to render the mesh
  148018. * @param emissiveTexture the associated emissive texture used to generate the glow
  148019. * @return true if ready otherwise, false
  148020. */
  148021. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148022. /**
  148023. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  148024. */
  148025. needStencil(): boolean;
  148026. /**
  148027. * Returns true if the mesh can be rendered, otherwise false.
  148028. * @param mesh The mesh to render
  148029. * @param material The material used on the mesh
  148030. * @returns true if it can be rendered otherwise false
  148031. */
  148032. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  148033. /**
  148034. * Implementation specific of rendering the generating effect on the main canvas.
  148035. * @param effect The effect used to render through
  148036. */
  148037. protected _internalRender(effect: Effect): void;
  148038. /**
  148039. * Sets the required values for both the emissive texture and and the main color.
  148040. */
  148041. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  148042. /**
  148043. * Returns true if the mesh should render, otherwise false.
  148044. * @param mesh The mesh to render
  148045. * @returns true if it should render otherwise false
  148046. */
  148047. protected _shouldRenderMesh(mesh: Mesh): boolean;
  148048. /**
  148049. * Adds specific effects defines.
  148050. * @param defines The defines to add specifics to.
  148051. */
  148052. protected _addCustomEffectDefines(defines: string[]): void;
  148053. /**
  148054. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  148055. * @param mesh The mesh to exclude from the glow layer
  148056. */
  148057. addExcludedMesh(mesh: Mesh): void;
  148058. /**
  148059. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  148060. * @param mesh The mesh to remove
  148061. */
  148062. removeExcludedMesh(mesh: Mesh): void;
  148063. /**
  148064. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  148065. * @param mesh The mesh to include in the glow layer
  148066. */
  148067. addIncludedOnlyMesh(mesh: Mesh): void;
  148068. /**
  148069. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  148070. * @param mesh The mesh to remove
  148071. */
  148072. removeIncludedOnlyMesh(mesh: Mesh): void;
  148073. /**
  148074. * Determine if a given mesh will be used in the glow layer
  148075. * @param mesh The mesh to test
  148076. * @returns true if the mesh will be highlighted by the current glow layer
  148077. */
  148078. hasMesh(mesh: AbstractMesh): boolean;
  148079. /**
  148080. * Defines whether the current material of the mesh should be use to render the effect.
  148081. * @param mesh defines the current mesh to render
  148082. */
  148083. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  148084. /**
  148085. * Add a mesh to be rendered through its own material and not with emissive only.
  148086. * @param mesh The mesh for which we need to use its material
  148087. */
  148088. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  148089. /**
  148090. * Remove a mesh from being rendered through its own material and not with emissive only.
  148091. * @param mesh The mesh for which we need to not use its material
  148092. */
  148093. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  148094. /**
  148095. * Free any resources and references associated to a mesh.
  148096. * Internal use
  148097. * @param mesh The mesh to free.
  148098. * @hidden
  148099. */
  148100. _disposeMesh(mesh: Mesh): void;
  148101. /**
  148102. * Gets the class name of the effect layer
  148103. * @returns the string with the class name of the effect layer
  148104. */
  148105. getClassName(): string;
  148106. /**
  148107. * Serializes this glow layer
  148108. * @returns a serialized glow layer object
  148109. */
  148110. serialize(): any;
  148111. /**
  148112. * Creates a Glow Layer from parsed glow layer data
  148113. * @param parsedGlowLayer defines glow layer data
  148114. * @param scene defines the current scene
  148115. * @param rootUrl defines the root URL containing the glow layer information
  148116. * @returns a parsed Glow Layer
  148117. */
  148118. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  148119. }
  148120. }
  148121. declare module BABYLON {
  148122. /** @hidden */
  148123. export var glowBlurPostProcessPixelShader: {
  148124. name: string;
  148125. shader: string;
  148126. };
  148127. }
  148128. declare module BABYLON {
  148129. interface AbstractScene {
  148130. /**
  148131. * Return a the first highlight layer of the scene with a given name.
  148132. * @param name The name of the highlight layer to look for.
  148133. * @return The highlight layer if found otherwise null.
  148134. */
  148135. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  148136. }
  148137. /**
  148138. * Highlight layer options. This helps customizing the behaviour
  148139. * of the highlight layer.
  148140. */
  148141. export interface IHighlightLayerOptions {
  148142. /**
  148143. * Multiplication factor apply to the canvas size to compute the render target size
  148144. * used to generated the glowing objects (the smaller the faster).
  148145. */
  148146. mainTextureRatio: number;
  148147. /**
  148148. * Enforces a fixed size texture to ensure resize independant blur.
  148149. */
  148150. mainTextureFixedSize?: number;
  148151. /**
  148152. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  148153. * of the picture to blur (the smaller the faster).
  148154. */
  148155. blurTextureSizeRatio: number;
  148156. /**
  148157. * How big in texel of the blur texture is the vertical blur.
  148158. */
  148159. blurVerticalSize: number;
  148160. /**
  148161. * How big in texel of the blur texture is the horizontal blur.
  148162. */
  148163. blurHorizontalSize: number;
  148164. /**
  148165. * Alpha blending mode used to apply the blur. Default is combine.
  148166. */
  148167. alphaBlendingMode: number;
  148168. /**
  148169. * The camera attached to the layer.
  148170. */
  148171. camera: Nullable<Camera>;
  148172. /**
  148173. * Should we display highlight as a solid stroke?
  148174. */
  148175. isStroke?: boolean;
  148176. /**
  148177. * The rendering group to draw the layer in.
  148178. */
  148179. renderingGroupId: number;
  148180. }
  148181. /**
  148182. * The highlight layer Helps adding a glow effect around a mesh.
  148183. *
  148184. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  148185. * glowy meshes to your scene.
  148186. *
  148187. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  148188. */
  148189. export class HighlightLayer extends EffectLayer {
  148190. name: string;
  148191. /**
  148192. * Effect Name of the highlight layer.
  148193. */
  148194. static readonly EffectName: string;
  148195. /**
  148196. * The neutral color used during the preparation of the glow effect.
  148197. * This is black by default as the blend operation is a blend operation.
  148198. */
  148199. static NeutralColor: Color4;
  148200. /**
  148201. * Stencil value used for glowing meshes.
  148202. */
  148203. static GlowingMeshStencilReference: number;
  148204. /**
  148205. * Stencil value used for the other meshes in the scene.
  148206. */
  148207. static NormalMeshStencilReference: number;
  148208. /**
  148209. * Specifies whether or not the inner glow is ACTIVE in the layer.
  148210. */
  148211. innerGlow: boolean;
  148212. /**
  148213. * Specifies whether or not the outer glow is ACTIVE in the layer.
  148214. */
  148215. outerGlow: boolean;
  148216. /**
  148217. * Specifies the horizontal size of the blur.
  148218. */
  148219. set blurHorizontalSize(value: number);
  148220. /**
  148221. * Specifies the vertical size of the blur.
  148222. */
  148223. set blurVerticalSize(value: number);
  148224. /**
  148225. * Gets the horizontal size of the blur.
  148226. */
  148227. get blurHorizontalSize(): number;
  148228. /**
  148229. * Gets the vertical size of the blur.
  148230. */
  148231. get blurVerticalSize(): number;
  148232. /**
  148233. * An event triggered when the highlight layer is being blurred.
  148234. */
  148235. onBeforeBlurObservable: Observable<HighlightLayer>;
  148236. /**
  148237. * An event triggered when the highlight layer has been blurred.
  148238. */
  148239. onAfterBlurObservable: Observable<HighlightLayer>;
  148240. private _instanceGlowingMeshStencilReference;
  148241. private _options;
  148242. private _downSamplePostprocess;
  148243. private _horizontalBlurPostprocess;
  148244. private _verticalBlurPostprocess;
  148245. private _blurTexture;
  148246. private _meshes;
  148247. private _excludedMeshes;
  148248. /**
  148249. * Instantiates a new highlight Layer and references it to the scene..
  148250. * @param name The name of the layer
  148251. * @param scene The scene to use the layer in
  148252. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  148253. */
  148254. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  148255. /**
  148256. * Get the effect name of the layer.
  148257. * @return The effect name
  148258. */
  148259. getEffectName(): string;
  148260. /**
  148261. * Create the merge effect. This is the shader use to blit the information back
  148262. * to the main canvas at the end of the scene rendering.
  148263. */
  148264. protected _createMergeEffect(): Effect;
  148265. /**
  148266. * Creates the render target textures and post processes used in the highlight layer.
  148267. */
  148268. protected _createTextureAndPostProcesses(): void;
  148269. /**
  148270. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  148271. */
  148272. needStencil(): boolean;
  148273. /**
  148274. * Checks for the readiness of the element composing the layer.
  148275. * @param subMesh the mesh to check for
  148276. * @param useInstances specify wether or not to use instances to render the mesh
  148277. * @param emissiveTexture the associated emissive texture used to generate the glow
  148278. * @return true if ready otherwise, false
  148279. */
  148280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148281. /**
  148282. * Implementation specific of rendering the generating effect on the main canvas.
  148283. * @param effect The effect used to render through
  148284. */
  148285. protected _internalRender(effect: Effect): void;
  148286. /**
  148287. * Returns true if the layer contains information to display, otherwise false.
  148288. */
  148289. shouldRender(): boolean;
  148290. /**
  148291. * Returns true if the mesh should render, otherwise false.
  148292. * @param mesh The mesh to render
  148293. * @returns true if it should render otherwise false
  148294. */
  148295. protected _shouldRenderMesh(mesh: Mesh): boolean;
  148296. /**
  148297. * Returns true if the mesh can be rendered, otherwise false.
  148298. * @param mesh The mesh to render
  148299. * @param material The material used on the mesh
  148300. * @returns true if it can be rendered otherwise false
  148301. */
  148302. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  148303. /**
  148304. * Adds specific effects defines.
  148305. * @param defines The defines to add specifics to.
  148306. */
  148307. protected _addCustomEffectDefines(defines: string[]): void;
  148308. /**
  148309. * Sets the required values for both the emissive texture and and the main color.
  148310. */
  148311. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  148312. /**
  148313. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  148314. * @param mesh The mesh to exclude from the highlight layer
  148315. */
  148316. addExcludedMesh(mesh: Mesh): void;
  148317. /**
  148318. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  148319. * @param mesh The mesh to highlight
  148320. */
  148321. removeExcludedMesh(mesh: Mesh): void;
  148322. /**
  148323. * Determine if a given mesh will be highlighted by the current HighlightLayer
  148324. * @param mesh mesh to test
  148325. * @returns true if the mesh will be highlighted by the current HighlightLayer
  148326. */
  148327. hasMesh(mesh: AbstractMesh): boolean;
  148328. /**
  148329. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  148330. * @param mesh The mesh to highlight
  148331. * @param color The color of the highlight
  148332. * @param glowEmissiveOnly Extract the glow from the emissive texture
  148333. */
  148334. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  148335. /**
  148336. * Remove a mesh from the highlight layer in order to make it stop glowing.
  148337. * @param mesh The mesh to highlight
  148338. */
  148339. removeMesh(mesh: Mesh): void;
  148340. /**
  148341. * Remove all the meshes currently referenced in the highlight layer
  148342. */
  148343. removeAllMeshes(): void;
  148344. /**
  148345. * Force the stencil to the normal expected value for none glowing parts
  148346. */
  148347. private _defaultStencilReference;
  148348. /**
  148349. * Free any resources and references associated to a mesh.
  148350. * Internal use
  148351. * @param mesh The mesh to free.
  148352. * @hidden
  148353. */
  148354. _disposeMesh(mesh: Mesh): void;
  148355. /**
  148356. * Dispose the highlight layer and free resources.
  148357. */
  148358. dispose(): void;
  148359. /**
  148360. * Gets the class name of the effect layer
  148361. * @returns the string with the class name of the effect layer
  148362. */
  148363. getClassName(): string;
  148364. /**
  148365. * Serializes this Highlight layer
  148366. * @returns a serialized Highlight layer object
  148367. */
  148368. serialize(): any;
  148369. /**
  148370. * Creates a Highlight layer from parsed Highlight layer data
  148371. * @param parsedHightlightLayer defines the Highlight layer data
  148372. * @param scene defines the current scene
  148373. * @param rootUrl defines the root URL containing the Highlight layer information
  148374. * @returns a parsed Highlight layer
  148375. */
  148376. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  148377. }
  148378. }
  148379. declare module BABYLON {
  148380. interface AbstractScene {
  148381. /**
  148382. * The list of layers (background and foreground) of the scene
  148383. */
  148384. layers: Array<Layer>;
  148385. }
  148386. /**
  148387. * Defines the layer scene component responsible to manage any layers
  148388. * in a given scene.
  148389. */
  148390. export class LayerSceneComponent implements ISceneComponent {
  148391. /**
  148392. * The component name helpfull to identify the component in the list of scene components.
  148393. */
  148394. readonly name: string;
  148395. /**
  148396. * The scene the component belongs to.
  148397. */
  148398. scene: Scene;
  148399. private _engine;
  148400. /**
  148401. * Creates a new instance of the component for the given scene
  148402. * @param scene Defines the scene to register the component in
  148403. */
  148404. constructor(scene: Scene);
  148405. /**
  148406. * Registers the component in a given scene
  148407. */
  148408. register(): void;
  148409. /**
  148410. * Rebuilds the elements related to this component in case of
  148411. * context lost for instance.
  148412. */
  148413. rebuild(): void;
  148414. /**
  148415. * Disposes the component and the associated ressources.
  148416. */
  148417. dispose(): void;
  148418. private _draw;
  148419. private _drawCameraPredicate;
  148420. private _drawCameraBackground;
  148421. private _drawCameraForeground;
  148422. private _drawRenderTargetPredicate;
  148423. private _drawRenderTargetBackground;
  148424. private _drawRenderTargetForeground;
  148425. /**
  148426. * Adds all the elements from the container to the scene
  148427. * @param container the container holding the elements
  148428. */
  148429. addFromContainer(container: AbstractScene): void;
  148430. /**
  148431. * Removes all the elements in the container from the scene
  148432. * @param container contains the elements to remove
  148433. * @param dispose if the removed element should be disposed (default: false)
  148434. */
  148435. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148436. }
  148437. }
  148438. declare module BABYLON {
  148439. /** @hidden */
  148440. export var layerPixelShader: {
  148441. name: string;
  148442. shader: string;
  148443. };
  148444. }
  148445. declare module BABYLON {
  148446. /** @hidden */
  148447. export var layerVertexShader: {
  148448. name: string;
  148449. shader: string;
  148450. };
  148451. }
  148452. declare module BABYLON {
  148453. /**
  148454. * This represents a full screen 2d layer.
  148455. * This can be useful to display a picture in the background of your scene for instance.
  148456. * @see https://www.babylonjs-playground.com/#08A2BS#1
  148457. */
  148458. export class Layer {
  148459. /**
  148460. * Define the name of the layer.
  148461. */
  148462. name: string;
  148463. /**
  148464. * Define the texture the layer should display.
  148465. */
  148466. texture: Nullable<Texture>;
  148467. /**
  148468. * Is the layer in background or foreground.
  148469. */
  148470. isBackground: boolean;
  148471. /**
  148472. * Define the color of the layer (instead of texture).
  148473. */
  148474. color: Color4;
  148475. /**
  148476. * Define the scale of the layer in order to zoom in out of the texture.
  148477. */
  148478. scale: Vector2;
  148479. /**
  148480. * Define an offset for the layer in order to shift the texture.
  148481. */
  148482. offset: Vector2;
  148483. /**
  148484. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  148485. */
  148486. alphaBlendingMode: number;
  148487. /**
  148488. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  148489. * Alpha test will not mix with the background color in case of transparency.
  148490. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  148491. */
  148492. alphaTest: boolean;
  148493. /**
  148494. * Define a mask to restrict the layer to only some of the scene cameras.
  148495. */
  148496. layerMask: number;
  148497. /**
  148498. * Define the list of render target the layer is visible into.
  148499. */
  148500. renderTargetTextures: RenderTargetTexture[];
  148501. /**
  148502. * Define if the layer is only used in renderTarget or if it also
  148503. * renders in the main frame buffer of the canvas.
  148504. */
  148505. renderOnlyInRenderTargetTextures: boolean;
  148506. private _scene;
  148507. private _vertexBuffers;
  148508. private _indexBuffer;
  148509. private _effect;
  148510. private _previousDefines;
  148511. /**
  148512. * An event triggered when the layer is disposed.
  148513. */
  148514. onDisposeObservable: Observable<Layer>;
  148515. private _onDisposeObserver;
  148516. /**
  148517. * Back compatibility with callback before the onDisposeObservable existed.
  148518. * The set callback will be triggered when the layer has been disposed.
  148519. */
  148520. set onDispose(callback: () => void);
  148521. /**
  148522. * An event triggered before rendering the scene
  148523. */
  148524. onBeforeRenderObservable: Observable<Layer>;
  148525. private _onBeforeRenderObserver;
  148526. /**
  148527. * Back compatibility with callback before the onBeforeRenderObservable existed.
  148528. * The set callback will be triggered just before rendering the layer.
  148529. */
  148530. set onBeforeRender(callback: () => void);
  148531. /**
  148532. * An event triggered after rendering the scene
  148533. */
  148534. onAfterRenderObservable: Observable<Layer>;
  148535. private _onAfterRenderObserver;
  148536. /**
  148537. * Back compatibility with callback before the onAfterRenderObservable existed.
  148538. * The set callback will be triggered just after rendering the layer.
  148539. */
  148540. set onAfterRender(callback: () => void);
  148541. /**
  148542. * Instantiates a new layer.
  148543. * This represents a full screen 2d layer.
  148544. * This can be useful to display a picture in the background of your scene for instance.
  148545. * @see https://www.babylonjs-playground.com/#08A2BS#1
  148546. * @param name Define the name of the layer in the scene
  148547. * @param imgUrl Define the url of the texture to display in the layer
  148548. * @param scene Define the scene the layer belongs to
  148549. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  148550. * @param color Defines a color for the layer
  148551. */
  148552. constructor(
  148553. /**
  148554. * Define the name of the layer.
  148555. */
  148556. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  148557. private _createIndexBuffer;
  148558. /** @hidden */
  148559. _rebuild(): void;
  148560. /**
  148561. * Renders the layer in the scene.
  148562. */
  148563. render(): void;
  148564. /**
  148565. * Disposes and releases the associated ressources.
  148566. */
  148567. dispose(): void;
  148568. }
  148569. }
  148570. declare module BABYLON {
  148571. /** @hidden */
  148572. export var lensFlarePixelShader: {
  148573. name: string;
  148574. shader: string;
  148575. };
  148576. }
  148577. declare module BABYLON {
  148578. /** @hidden */
  148579. export var lensFlareVertexShader: {
  148580. name: string;
  148581. shader: string;
  148582. };
  148583. }
  148584. declare module BABYLON {
  148585. /**
  148586. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  148587. * It is usually composed of several `lensFlare`.
  148588. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148589. */
  148590. export class LensFlareSystem {
  148591. /**
  148592. * Define the name of the lens flare system
  148593. */
  148594. name: string;
  148595. /**
  148596. * List of lens flares used in this system.
  148597. */
  148598. lensFlares: LensFlare[];
  148599. /**
  148600. * Define a limit from the border the lens flare can be visible.
  148601. */
  148602. borderLimit: number;
  148603. /**
  148604. * Define a viewport border we do not want to see the lens flare in.
  148605. */
  148606. viewportBorder: number;
  148607. /**
  148608. * Define a predicate which could limit the list of meshes able to occlude the effect.
  148609. */
  148610. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  148611. /**
  148612. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  148613. */
  148614. layerMask: number;
  148615. /**
  148616. * Define the id of the lens flare system in the scene.
  148617. * (equal to name by default)
  148618. */
  148619. id: string;
  148620. private _scene;
  148621. private _emitter;
  148622. private _vertexBuffers;
  148623. private _indexBuffer;
  148624. private _effect;
  148625. private _positionX;
  148626. private _positionY;
  148627. private _isEnabled;
  148628. /** @hidden */
  148629. static _SceneComponentInitialization: (scene: Scene) => void;
  148630. /**
  148631. * Instantiates a lens flare system.
  148632. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  148633. * It is usually composed of several `lensFlare`.
  148634. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148635. * @param name Define the name of the lens flare system in the scene
  148636. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  148637. * @param scene Define the scene the lens flare system belongs to
  148638. */
  148639. constructor(
  148640. /**
  148641. * Define the name of the lens flare system
  148642. */
  148643. name: string, emitter: any, scene: Scene);
  148644. /**
  148645. * Define if the lens flare system is enabled.
  148646. */
  148647. get isEnabled(): boolean;
  148648. set isEnabled(value: boolean);
  148649. /**
  148650. * Get the scene the effects belongs to.
  148651. * @returns the scene holding the lens flare system
  148652. */
  148653. getScene(): Scene;
  148654. /**
  148655. * Get the emitter of the lens flare system.
  148656. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148657. * @returns the emitter of the lens flare system
  148658. */
  148659. getEmitter(): any;
  148660. /**
  148661. * Set the emitter of the lens flare system.
  148662. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148663. * @param newEmitter Define the new emitter of the system
  148664. */
  148665. setEmitter(newEmitter: any): void;
  148666. /**
  148667. * Get the lens flare system emitter position.
  148668. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  148669. * @returns the position
  148670. */
  148671. getEmitterPosition(): Vector3;
  148672. /**
  148673. * @hidden
  148674. */
  148675. computeEffectivePosition(globalViewport: Viewport): boolean;
  148676. /** @hidden */
  148677. _isVisible(): boolean;
  148678. /**
  148679. * @hidden
  148680. */
  148681. render(): boolean;
  148682. /**
  148683. * Dispose and release the lens flare with its associated resources.
  148684. */
  148685. dispose(): void;
  148686. /**
  148687. * Parse a lens flare system from a JSON repressentation
  148688. * @param parsedLensFlareSystem Define the JSON to parse
  148689. * @param scene Define the scene the parsed system should be instantiated in
  148690. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  148691. * @returns the parsed system
  148692. */
  148693. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  148694. /**
  148695. * Serialize the current Lens Flare System into a JSON representation.
  148696. * @returns the serialized JSON
  148697. */
  148698. serialize(): any;
  148699. }
  148700. }
  148701. declare module BABYLON {
  148702. /**
  148703. * This represents one of the lens effect in a `lensFlareSystem`.
  148704. * It controls one of the indiviual texture used in the effect.
  148705. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148706. */
  148707. export class LensFlare {
  148708. /**
  148709. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148710. */
  148711. size: number;
  148712. /**
  148713. * 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.
  148714. */
  148715. position: number;
  148716. /**
  148717. * Define the lens color.
  148718. */
  148719. color: Color3;
  148720. /**
  148721. * Define the lens texture.
  148722. */
  148723. texture: Nullable<Texture>;
  148724. /**
  148725. * Define the alpha mode to render this particular lens.
  148726. */
  148727. alphaMode: number;
  148728. private _system;
  148729. /**
  148730. * Creates a new Lens Flare.
  148731. * This represents one of the lens effect in a `lensFlareSystem`.
  148732. * It controls one of the indiviual texture used in the effect.
  148733. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148734. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  148735. * @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.
  148736. * @param color Define the lens color
  148737. * @param imgUrl Define the lens texture url
  148738. * @param system Define the `lensFlareSystem` this flare is part of
  148739. * @returns The newly created Lens Flare
  148740. */
  148741. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  148742. /**
  148743. * Instantiates a new Lens Flare.
  148744. * This represents one of the lens effect in a `lensFlareSystem`.
  148745. * It controls one of the indiviual texture used in the effect.
  148746. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148747. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  148748. * @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.
  148749. * @param color Define the lens color
  148750. * @param imgUrl Define the lens texture url
  148751. * @param system Define the `lensFlareSystem` this flare is part of
  148752. */
  148753. constructor(
  148754. /**
  148755. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148756. */
  148757. size: number,
  148758. /**
  148759. * 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.
  148760. */
  148761. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  148762. /**
  148763. * Dispose and release the lens flare with its associated resources.
  148764. */
  148765. dispose(): void;
  148766. }
  148767. }
  148768. declare module BABYLON {
  148769. interface AbstractScene {
  148770. /**
  148771. * The list of lens flare system added to the scene
  148772. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148773. */
  148774. lensFlareSystems: Array<LensFlareSystem>;
  148775. /**
  148776. * Removes the given lens flare system from this scene.
  148777. * @param toRemove The lens flare system to remove
  148778. * @returns The index of the removed lens flare system
  148779. */
  148780. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  148781. /**
  148782. * Adds the given lens flare system to this scene
  148783. * @param newLensFlareSystem The lens flare system to add
  148784. */
  148785. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  148786. /**
  148787. * Gets a lens flare system using its name
  148788. * @param name defines the name to look for
  148789. * @returns the lens flare system or null if not found
  148790. */
  148791. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  148792. /**
  148793. * Gets a lens flare system using its id
  148794. * @param id defines the id to look for
  148795. * @returns the lens flare system or null if not found
  148796. */
  148797. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  148798. }
  148799. /**
  148800. * Defines the lens flare scene component responsible to manage any lens flares
  148801. * in a given scene.
  148802. */
  148803. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  148804. /**
  148805. * The component name helpfull to identify the component in the list of scene components.
  148806. */
  148807. readonly name: string;
  148808. /**
  148809. * The scene the component belongs to.
  148810. */
  148811. scene: Scene;
  148812. /**
  148813. * Creates a new instance of the component for the given scene
  148814. * @param scene Defines the scene to register the component in
  148815. */
  148816. constructor(scene: Scene);
  148817. /**
  148818. * Registers the component in a given scene
  148819. */
  148820. register(): void;
  148821. /**
  148822. * Rebuilds the elements related to this component in case of
  148823. * context lost for instance.
  148824. */
  148825. rebuild(): void;
  148826. /**
  148827. * Adds all the elements from the container to the scene
  148828. * @param container the container holding the elements
  148829. */
  148830. addFromContainer(container: AbstractScene): void;
  148831. /**
  148832. * Removes all the elements in the container from the scene
  148833. * @param container contains the elements to remove
  148834. * @param dispose if the removed element should be disposed (default: false)
  148835. */
  148836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148837. /**
  148838. * Serializes the component data to the specified json object
  148839. * @param serializationObject The object to serialize to
  148840. */
  148841. serialize(serializationObject: any): void;
  148842. /**
  148843. * Disposes the component and the associated ressources.
  148844. */
  148845. dispose(): void;
  148846. private _draw;
  148847. }
  148848. }
  148849. declare module BABYLON {
  148850. /** @hidden */
  148851. export var depthPixelShader: {
  148852. name: string;
  148853. shader: string;
  148854. };
  148855. }
  148856. declare module BABYLON {
  148857. /** @hidden */
  148858. export var depthVertexShader: {
  148859. name: string;
  148860. shader: string;
  148861. };
  148862. }
  148863. declare module BABYLON {
  148864. /**
  148865. * This represents a depth renderer in Babylon.
  148866. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  148867. */
  148868. export class DepthRenderer {
  148869. private _scene;
  148870. private _depthMap;
  148871. private _effect;
  148872. private readonly _storeNonLinearDepth;
  148873. private readonly _clearColor;
  148874. /** Get if the depth renderer is using packed depth or not */
  148875. readonly isPacked: boolean;
  148876. private _cachedDefines;
  148877. private _camera;
  148878. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  148879. enabled: boolean;
  148880. /**
  148881. * Specifiess that the depth renderer will only be used within
  148882. * the camera it is created for.
  148883. * This can help forcing its rendering during the camera processing.
  148884. */
  148885. useOnlyInActiveCamera: boolean;
  148886. /** @hidden */
  148887. static _SceneComponentInitialization: (scene: Scene) => void;
  148888. /**
  148889. * Instantiates a depth renderer
  148890. * @param scene The scene the renderer belongs to
  148891. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  148892. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  148893. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148894. */
  148895. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  148896. /**
  148897. * Creates the depth rendering effect and checks if the effect is ready.
  148898. * @param subMesh The submesh to be used to render the depth map of
  148899. * @param useInstances If multiple world instances should be used
  148900. * @returns if the depth renderer is ready to render the depth map
  148901. */
  148902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148903. /**
  148904. * Gets the texture which the depth map will be written to.
  148905. * @returns The depth map texture
  148906. */
  148907. getDepthMap(): RenderTargetTexture;
  148908. /**
  148909. * Disposes of the depth renderer.
  148910. */
  148911. dispose(): void;
  148912. }
  148913. }
  148914. declare module BABYLON {
  148915. /** @hidden */
  148916. export var minmaxReduxPixelShader: {
  148917. name: string;
  148918. shader: string;
  148919. };
  148920. }
  148921. declare module BABYLON {
  148922. /**
  148923. * This class computes a min/max reduction from a texture: it means it computes the minimum
  148924. * and maximum values from all values of the texture.
  148925. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  148926. * The source values are read from the red channel of the texture.
  148927. */
  148928. export class MinMaxReducer {
  148929. /**
  148930. * Observable triggered when the computation has been performed
  148931. */
  148932. onAfterReductionPerformed: Observable<{
  148933. min: number;
  148934. max: number;
  148935. }>;
  148936. protected _camera: Camera;
  148937. protected _sourceTexture: Nullable<RenderTargetTexture>;
  148938. protected _reductionSteps: Nullable<Array<PostProcess>>;
  148939. protected _postProcessManager: PostProcessManager;
  148940. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  148941. protected _forceFullscreenViewport: boolean;
  148942. /**
  148943. * Creates a min/max reducer
  148944. * @param camera The camera to use for the post processes
  148945. */
  148946. constructor(camera: Camera);
  148947. /**
  148948. * Gets the texture used to read the values from.
  148949. */
  148950. get sourceTexture(): Nullable<RenderTargetTexture>;
  148951. /**
  148952. * Sets the source texture to read the values from.
  148953. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  148954. * because in such textures '1' value must not be taken into account to compute the maximum
  148955. * as this value is used to clear the texture.
  148956. * Note that the computation is not activated by calling this function, you must call activate() for that!
  148957. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  148958. * @param depthRedux Indicates if the texture is a depth texture or not
  148959. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  148960. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  148961. */
  148962. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  148963. /**
  148964. * Defines the refresh rate of the computation.
  148965. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  148966. */
  148967. get refreshRate(): number;
  148968. set refreshRate(value: number);
  148969. protected _activated: boolean;
  148970. /**
  148971. * Gets the activation status of the reducer
  148972. */
  148973. get activated(): boolean;
  148974. /**
  148975. * Activates the reduction computation.
  148976. * When activated, the observers registered in onAfterReductionPerformed are
  148977. * called after the compuation is performed
  148978. */
  148979. activate(): void;
  148980. /**
  148981. * Deactivates the reduction computation.
  148982. */
  148983. deactivate(): void;
  148984. /**
  148985. * Disposes the min/max reducer
  148986. * @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.
  148987. */
  148988. dispose(disposeAll?: boolean): void;
  148989. }
  148990. }
  148991. declare module BABYLON {
  148992. /**
  148993. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  148994. */
  148995. export class DepthReducer extends MinMaxReducer {
  148996. private _depthRenderer;
  148997. private _depthRendererId;
  148998. /**
  148999. * Gets the depth renderer used for the computation.
  149000. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  149001. */
  149002. get depthRenderer(): Nullable<DepthRenderer>;
  149003. /**
  149004. * Creates a depth reducer
  149005. * @param camera The camera used to render the depth texture
  149006. */
  149007. constructor(camera: Camera);
  149008. /**
  149009. * Sets the depth renderer to use to generate the depth map
  149010. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  149011. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  149012. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  149013. */
  149014. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  149015. /** @hidden */
  149016. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  149017. /**
  149018. * Activates the reduction computation.
  149019. * When activated, the observers registered in onAfterReductionPerformed are
  149020. * called after the compuation is performed
  149021. */
  149022. activate(): void;
  149023. /**
  149024. * Deactivates the reduction computation.
  149025. */
  149026. deactivate(): void;
  149027. /**
  149028. * Disposes the depth reducer
  149029. * @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.
  149030. */
  149031. dispose(disposeAll?: boolean): void;
  149032. }
  149033. }
  149034. declare module BABYLON {
  149035. /**
  149036. * A CSM implementation allowing casting shadows on large scenes.
  149037. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  149038. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  149039. */
  149040. export class CascadedShadowGenerator extends ShadowGenerator {
  149041. private static readonly frustumCornersNDCSpace;
  149042. /**
  149043. * Name of the CSM class
  149044. */
  149045. static CLASSNAME: string;
  149046. /**
  149047. * Defines the default number of cascades used by the CSM.
  149048. */
  149049. static readonly DEFAULT_CASCADES_COUNT: number;
  149050. /**
  149051. * Defines the minimum number of cascades used by the CSM.
  149052. */
  149053. static readonly MIN_CASCADES_COUNT: number;
  149054. /**
  149055. * Defines the maximum number of cascades used by the CSM.
  149056. */
  149057. static readonly MAX_CASCADES_COUNT: number;
  149058. protected _validateFilter(filter: number): number;
  149059. /**
  149060. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  149061. */
  149062. penumbraDarkness: number;
  149063. private _numCascades;
  149064. /**
  149065. * Gets or set the number of cascades used by the CSM.
  149066. */
  149067. get numCascades(): number;
  149068. set numCascades(value: number);
  149069. /**
  149070. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  149071. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  149072. */
  149073. stabilizeCascades: boolean;
  149074. private _freezeShadowCastersBoundingInfo;
  149075. private _freezeShadowCastersBoundingInfoObservable;
  149076. /**
  149077. * Enables or disables the shadow casters bounding info computation.
  149078. * If your shadow casters don't move, you can disable this feature.
  149079. * If it is enabled, the bounding box computation is done every frame.
  149080. */
  149081. get freezeShadowCastersBoundingInfo(): boolean;
  149082. set freezeShadowCastersBoundingInfo(freeze: boolean);
  149083. private _scbiMin;
  149084. private _scbiMax;
  149085. protected _computeShadowCastersBoundingInfo(): void;
  149086. protected _shadowCastersBoundingInfo: BoundingInfo;
  149087. /**
  149088. * Gets or sets the shadow casters bounding info.
  149089. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  149090. * so that the system won't overwrite the bounds you provide
  149091. */
  149092. get shadowCastersBoundingInfo(): BoundingInfo;
  149093. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  149094. protected _breaksAreDirty: boolean;
  149095. protected _minDistance: number;
  149096. protected _maxDistance: number;
  149097. /**
  149098. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  149099. *
  149100. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  149101. * If you don't know these values, simply leave them to their defaults and don't call this function.
  149102. * @param min minimal distance for the breaks (default to 0.)
  149103. * @param max maximal distance for the breaks (default to 1.)
  149104. */
  149105. setMinMaxDistance(min: number, max: number): void;
  149106. /** Gets the minimal distance used in the cascade break computation */
  149107. get minDistance(): number;
  149108. /** Gets the maximal distance used in the cascade break computation */
  149109. get maxDistance(): number;
  149110. /**
  149111. * Gets the class name of that object
  149112. * @returns "CascadedShadowGenerator"
  149113. */
  149114. getClassName(): string;
  149115. private _cascadeMinExtents;
  149116. private _cascadeMaxExtents;
  149117. /**
  149118. * Gets a cascade minimum extents
  149119. * @param cascadeIndex index of the cascade
  149120. * @returns the minimum cascade extents
  149121. */
  149122. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  149123. /**
  149124. * Gets a cascade maximum extents
  149125. * @param cascadeIndex index of the cascade
  149126. * @returns the maximum cascade extents
  149127. */
  149128. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  149129. private _cascades;
  149130. private _currentLayer;
  149131. private _viewSpaceFrustumsZ;
  149132. private _viewMatrices;
  149133. private _projectionMatrices;
  149134. private _transformMatrices;
  149135. private _transformMatricesAsArray;
  149136. private _frustumLengths;
  149137. private _lightSizeUVCorrection;
  149138. private _depthCorrection;
  149139. private _frustumCornersWorldSpace;
  149140. private _frustumCenter;
  149141. private _shadowCameraPos;
  149142. private _shadowMaxZ;
  149143. /**
  149144. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  149145. * It defaults to camera.maxZ
  149146. */
  149147. get shadowMaxZ(): number;
  149148. /**
  149149. * Sets the shadow max z distance.
  149150. */
  149151. set shadowMaxZ(value: number);
  149152. protected _debug: boolean;
  149153. /**
  149154. * Gets or sets the debug flag.
  149155. * When enabled, the cascades are materialized by different colors on the screen.
  149156. */
  149157. get debug(): boolean;
  149158. set debug(dbg: boolean);
  149159. private _depthClamp;
  149160. /**
  149161. * Gets or sets the depth clamping value.
  149162. *
  149163. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  149164. * to account for the shadow casters far away.
  149165. *
  149166. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  149167. */
  149168. get depthClamp(): boolean;
  149169. set depthClamp(value: boolean);
  149170. private _cascadeBlendPercentage;
  149171. /**
  149172. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  149173. * It defaults to 0.1 (10% blending).
  149174. */
  149175. get cascadeBlendPercentage(): number;
  149176. set cascadeBlendPercentage(value: number);
  149177. private _lambda;
  149178. /**
  149179. * Gets or set the lambda parameter.
  149180. * This parameter is used to split the camera frustum and create the cascades.
  149181. * 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.
  149182. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  149183. */
  149184. get lambda(): number;
  149185. set lambda(value: number);
  149186. /**
  149187. * Gets the view matrix corresponding to a given cascade
  149188. * @param cascadeNum cascade to retrieve the view matrix from
  149189. * @returns the cascade view matrix
  149190. */
  149191. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  149192. /**
  149193. * Gets the projection matrix corresponding to a given cascade
  149194. * @param cascadeNum cascade to retrieve the projection matrix from
  149195. * @returns the cascade projection matrix
  149196. */
  149197. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  149198. /**
  149199. * Gets the transformation matrix corresponding to a given cascade
  149200. * @param cascadeNum cascade to retrieve the transformation matrix from
  149201. * @returns the cascade transformation matrix
  149202. */
  149203. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  149204. private _depthRenderer;
  149205. /**
  149206. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  149207. *
  149208. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  149209. *
  149210. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  149211. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  149212. * @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
  149213. */
  149214. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  149215. private _depthReducer;
  149216. private _autoCalcDepthBounds;
  149217. /**
  149218. * Gets or sets the autoCalcDepthBounds property.
  149219. *
  149220. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  149221. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  149222. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  149223. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  149224. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  149225. */
  149226. get autoCalcDepthBounds(): boolean;
  149227. set autoCalcDepthBounds(value: boolean);
  149228. /**
  149229. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  149230. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  149231. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  149232. * for setting the refresh rate on the renderer yourself!
  149233. */
  149234. get autoCalcDepthBoundsRefreshRate(): number;
  149235. set autoCalcDepthBoundsRefreshRate(value: number);
  149236. /**
  149237. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  149238. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  149239. * you change the camera near/far planes!
  149240. */
  149241. splitFrustum(): void;
  149242. private _splitFrustum;
  149243. private _computeMatrices;
  149244. private _computeFrustumInWorldSpace;
  149245. private _computeCascadeFrustum;
  149246. /**
  149247. * Support test.
  149248. */
  149249. static get IsSupported(): boolean;
  149250. /** @hidden */
  149251. static _SceneComponentInitialization: (scene: Scene) => void;
  149252. /**
  149253. * Creates a Cascaded Shadow Generator object.
  149254. * A ShadowGenerator is the required tool to use the shadows.
  149255. * Each directional light casting shadows needs to use its own ShadowGenerator.
  149256. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  149257. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  149258. * @param light The directional light object generating the shadows.
  149259. * @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.
  149260. */
  149261. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  149262. protected _initializeGenerator(): void;
  149263. protected _createTargetRenderTexture(): void;
  149264. protected _initializeShadowMap(): void;
  149265. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  149266. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  149267. /**
  149268. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  149269. * @param defines Defines of the material we want to update
  149270. * @param lightIndex Index of the light in the enabled light list of the material
  149271. */
  149272. prepareDefines(defines: any, lightIndex: number): void;
  149273. /**
  149274. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  149275. * defined in the generator but impacting the effect).
  149276. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  149277. * @param effect The effect we are binfing the information for
  149278. */
  149279. bindShadowLight(lightIndex: string, effect: Effect): void;
  149280. /**
  149281. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  149282. * (eq to view projection * shadow projection matrices)
  149283. * @returns The transform matrix used to create the shadow map
  149284. */
  149285. getTransformMatrix(): Matrix;
  149286. /**
  149287. * Disposes the ShadowGenerator.
  149288. * Returns nothing.
  149289. */
  149290. dispose(): void;
  149291. /**
  149292. * Serializes the shadow generator setup to a json object.
  149293. * @returns The serialized JSON object
  149294. */
  149295. serialize(): any;
  149296. /**
  149297. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  149298. * @param parsedShadowGenerator The JSON object to parse
  149299. * @param scene The scene to create the shadow map for
  149300. * @returns The parsed shadow generator
  149301. */
  149302. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  149303. }
  149304. }
  149305. declare module BABYLON {
  149306. /**
  149307. * Defines the shadow generator component responsible to manage any shadow generators
  149308. * in a given scene.
  149309. */
  149310. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  149311. /**
  149312. * The component name helpfull to identify the component in the list of scene components.
  149313. */
  149314. readonly name: string;
  149315. /**
  149316. * The scene the component belongs to.
  149317. */
  149318. scene: Scene;
  149319. /**
  149320. * Creates a new instance of the component for the given scene
  149321. * @param scene Defines the scene to register the component in
  149322. */
  149323. constructor(scene: Scene);
  149324. /**
  149325. * Registers the component in a given scene
  149326. */
  149327. register(): void;
  149328. /**
  149329. * Rebuilds the elements related to this component in case of
  149330. * context lost for instance.
  149331. */
  149332. rebuild(): void;
  149333. /**
  149334. * Serializes the component data to the specified json object
  149335. * @param serializationObject The object to serialize to
  149336. */
  149337. serialize(serializationObject: any): void;
  149338. /**
  149339. * Adds all the elements from the container to the scene
  149340. * @param container the container holding the elements
  149341. */
  149342. addFromContainer(container: AbstractScene): void;
  149343. /**
  149344. * Removes all the elements in the container from the scene
  149345. * @param container contains the elements to remove
  149346. * @param dispose if the removed element should be disposed (default: false)
  149347. */
  149348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149349. /**
  149350. * Rebuilds the elements related to this component in case of
  149351. * context lost for instance.
  149352. */
  149353. dispose(): void;
  149354. private _gatherRenderTargets;
  149355. }
  149356. }
  149357. declare module BABYLON {
  149358. /**
  149359. * A point light is a light defined by an unique point in world space.
  149360. * The light is emitted in every direction from this point.
  149361. * A good example of a point light is a standard light bulb.
  149362. * Documentation: https://doc.babylonjs.com/babylon101/lights
  149363. */
  149364. export class PointLight extends ShadowLight {
  149365. private _shadowAngle;
  149366. /**
  149367. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149368. * This specifies what angle the shadow will use to be created.
  149369. *
  149370. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  149371. */
  149372. get shadowAngle(): number;
  149373. /**
  149374. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149375. * This specifies what angle the shadow will use to be created.
  149376. *
  149377. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  149378. */
  149379. set shadowAngle(value: number);
  149380. /**
  149381. * Gets the direction if it has been set.
  149382. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149383. */
  149384. get direction(): Vector3;
  149385. /**
  149386. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149387. */
  149388. set direction(value: Vector3);
  149389. /**
  149390. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  149391. * A PointLight emits the light in every direction.
  149392. * It can cast shadows.
  149393. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  149394. * ```javascript
  149395. * var pointLight = new PointLight("pl", camera.position, scene);
  149396. * ```
  149397. * Documentation : https://doc.babylonjs.com/babylon101/lights
  149398. * @param name The light friendly name
  149399. * @param position The position of the point light in the scene
  149400. * @param scene The scene the lights belongs to
  149401. */
  149402. constructor(name: string, position: Vector3, scene: Scene);
  149403. /**
  149404. * Returns the string "PointLight"
  149405. * @returns the class name
  149406. */
  149407. getClassName(): string;
  149408. /**
  149409. * Returns the integer 0.
  149410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  149411. */
  149412. getTypeID(): number;
  149413. /**
  149414. * Specifies wether or not the shadowmap should be a cube texture.
  149415. * @returns true if the shadowmap needs to be a cube texture.
  149416. */
  149417. needCube(): boolean;
  149418. /**
  149419. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  149420. * @param faceIndex The index of the face we are computed the direction to generate shadow
  149421. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  149422. */
  149423. getShadowDirection(faceIndex?: number): Vector3;
  149424. /**
  149425. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  149426. * - fov = PI / 2
  149427. * - aspect ratio : 1.0
  149428. * - z-near and far equal to the active camera minZ and maxZ.
  149429. * Returns the PointLight.
  149430. */
  149431. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  149432. protected _buildUniformLayout(): void;
  149433. /**
  149434. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  149435. * @param effect The effect to update
  149436. * @param lightIndex The index of the light in the effect to update
  149437. * @returns The point light
  149438. */
  149439. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  149440. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  149441. /**
  149442. * Prepares the list of defines specific to the light type.
  149443. * @param defines the list of defines
  149444. * @param lightIndex defines the index of the light for the effect
  149445. */
  149446. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  149447. }
  149448. }
  149449. declare module BABYLON {
  149450. /**
  149451. * Header information of HDR texture files.
  149452. */
  149453. export interface HDRInfo {
  149454. /**
  149455. * The height of the texture in pixels.
  149456. */
  149457. height: number;
  149458. /**
  149459. * The width of the texture in pixels.
  149460. */
  149461. width: number;
  149462. /**
  149463. * The index of the beginning of the data in the binary file.
  149464. */
  149465. dataPosition: number;
  149466. }
  149467. /**
  149468. * This groups tools to convert HDR texture to native colors array.
  149469. */
  149470. export class HDRTools {
  149471. private static Ldexp;
  149472. private static Rgbe2float;
  149473. private static readStringLine;
  149474. /**
  149475. * Reads header information from an RGBE texture stored in a native array.
  149476. * More information on this format are available here:
  149477. * https://en.wikipedia.org/wiki/RGBE_image_format
  149478. *
  149479. * @param uint8array The binary file stored in native array.
  149480. * @return The header information.
  149481. */
  149482. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  149483. /**
  149484. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  149485. * This RGBE texture needs to store the information as a panorama.
  149486. *
  149487. * More information on this format are available here:
  149488. * https://en.wikipedia.org/wiki/RGBE_image_format
  149489. *
  149490. * @param buffer The binary file stored in an array buffer.
  149491. * @param size The expected size of the extracted cubemap.
  149492. * @return The Cube Map information.
  149493. */
  149494. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  149495. /**
  149496. * Returns the pixels data extracted from an RGBE texture.
  149497. * This pixels will be stored left to right up to down in the R G B order in one array.
  149498. *
  149499. * More information on this format are available here:
  149500. * https://en.wikipedia.org/wiki/RGBE_image_format
  149501. *
  149502. * @param uint8array The binary file stored in an array buffer.
  149503. * @param hdrInfo The header information of the file.
  149504. * @return The pixels data in RGB right to left up to down order.
  149505. */
  149506. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  149507. private static RGBE_ReadPixels_RLE;
  149508. private static RGBE_ReadPixels_NOT_RLE;
  149509. }
  149510. }
  149511. declare module BABYLON {
  149512. /**
  149513. * Effect Render Options
  149514. */
  149515. export interface IEffectRendererOptions {
  149516. /**
  149517. * Defines the vertices positions.
  149518. */
  149519. positions?: number[];
  149520. /**
  149521. * Defines the indices.
  149522. */
  149523. indices?: number[];
  149524. }
  149525. /**
  149526. * Helper class to render one or more effects.
  149527. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  149528. */
  149529. export class EffectRenderer {
  149530. private engine;
  149531. private static _DefaultOptions;
  149532. private _vertexBuffers;
  149533. private _indexBuffer;
  149534. private _fullscreenViewport;
  149535. /**
  149536. * Creates an effect renderer
  149537. * @param engine the engine to use for rendering
  149538. * @param options defines the options of the effect renderer
  149539. */
  149540. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  149541. /**
  149542. * Sets the current viewport in normalized coordinates 0-1
  149543. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  149544. */
  149545. setViewport(viewport?: Viewport): void;
  149546. /**
  149547. * Binds the embedded attributes buffer to the effect.
  149548. * @param effect Defines the effect to bind the attributes for
  149549. */
  149550. bindBuffers(effect: Effect): void;
  149551. /**
  149552. * Sets the current effect wrapper to use during draw.
  149553. * The effect needs to be ready before calling this api.
  149554. * This also sets the default full screen position attribute.
  149555. * @param effectWrapper Defines the effect to draw with
  149556. */
  149557. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  149558. /**
  149559. * Restores engine states
  149560. */
  149561. restoreStates(): void;
  149562. /**
  149563. * Draws a full screen quad.
  149564. */
  149565. draw(): void;
  149566. private isRenderTargetTexture;
  149567. /**
  149568. * renders one or more effects to a specified texture
  149569. * @param effectWrapper the effect to renderer
  149570. * @param outputTexture texture to draw to, if null it will render to the screen.
  149571. */
  149572. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  149573. /**
  149574. * Disposes of the effect renderer
  149575. */
  149576. dispose(): void;
  149577. }
  149578. /**
  149579. * Options to create an EffectWrapper
  149580. */
  149581. interface EffectWrapperCreationOptions {
  149582. /**
  149583. * Engine to use to create the effect
  149584. */
  149585. engine: ThinEngine;
  149586. /**
  149587. * Fragment shader for the effect
  149588. */
  149589. fragmentShader: string;
  149590. /**
  149591. * Use the shader store instead of direct source code
  149592. */
  149593. useShaderStore?: boolean;
  149594. /**
  149595. * Vertex shader for the effect
  149596. */
  149597. vertexShader?: string;
  149598. /**
  149599. * Attributes to use in the shader
  149600. */
  149601. attributeNames?: Array<string>;
  149602. /**
  149603. * Uniforms to use in the shader
  149604. */
  149605. uniformNames?: Array<string>;
  149606. /**
  149607. * Texture sampler names to use in the shader
  149608. */
  149609. samplerNames?: Array<string>;
  149610. /**
  149611. * Defines to use in the shader
  149612. */
  149613. defines?: Array<string>;
  149614. /**
  149615. * Callback when effect is compiled
  149616. */
  149617. onCompiled?: Nullable<(effect: Effect) => void>;
  149618. /**
  149619. * The friendly name of the effect displayed in Spector.
  149620. */
  149621. name?: string;
  149622. }
  149623. /**
  149624. * Wraps an effect to be used for rendering
  149625. */
  149626. export class EffectWrapper {
  149627. /**
  149628. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  149629. */
  149630. onApplyObservable: Observable<{}>;
  149631. /**
  149632. * The underlying effect
  149633. */
  149634. effect: Effect;
  149635. /**
  149636. * Creates an effect to be renderer
  149637. * @param creationOptions options to create the effect
  149638. */
  149639. constructor(creationOptions: EffectWrapperCreationOptions);
  149640. /**
  149641. * Disposes of the effect wrapper
  149642. */
  149643. dispose(): void;
  149644. }
  149645. }
  149646. declare module BABYLON {
  149647. /** @hidden */
  149648. export var hdrFilteringVertexShader: {
  149649. name: string;
  149650. shader: string;
  149651. };
  149652. }
  149653. declare module BABYLON {
  149654. /** @hidden */
  149655. export var hdrFilteringPixelShader: {
  149656. name: string;
  149657. shader: string;
  149658. };
  149659. }
  149660. declare module BABYLON {
  149661. /**
  149662. * Options for texture filtering
  149663. */
  149664. interface IHDRFilteringOptions {
  149665. /**
  149666. * Scales pixel intensity for the input HDR map.
  149667. */
  149668. hdrScale?: number;
  149669. /**
  149670. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  149671. */
  149672. quality?: number;
  149673. }
  149674. /**
  149675. * Filters HDR maps to get correct renderings of PBR reflections
  149676. */
  149677. export class HDRFiltering {
  149678. private _engine;
  149679. private _effectRenderer;
  149680. private _effectWrapper;
  149681. private _lodGenerationOffset;
  149682. private _lodGenerationScale;
  149683. /**
  149684. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  149685. * you care about baking speed.
  149686. */
  149687. quality: number;
  149688. /**
  149689. * Scales pixel intensity for the input HDR map.
  149690. */
  149691. hdrScale: number;
  149692. /**
  149693. * Instantiates HDR filter for reflection maps
  149694. *
  149695. * @param engine Thin engine
  149696. * @param options Options
  149697. */
  149698. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  149699. private _createRenderTarget;
  149700. private _prefilterInternal;
  149701. private _createEffect;
  149702. /**
  149703. * Get a value indicating if the filter is ready to be used
  149704. * @param texture Texture to filter
  149705. * @returns true if the filter is ready
  149706. */
  149707. isReady(texture: BaseTexture): boolean;
  149708. /**
  149709. * Prefilters a cube texture to have mipmap levels representing roughness values.
  149710. * Prefiltering will be invoked at the end of next rendering pass.
  149711. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  149712. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  149713. * @param texture Texture to filter
  149714. * @param onFinished Callback when filtering is done
  149715. * @return Promise called when prefiltering is done
  149716. */
  149717. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  149718. }
  149719. }
  149720. declare module BABYLON {
  149721. /**
  149722. * This represents a texture coming from an HDR input.
  149723. *
  149724. * The only supported format is currently panorama picture stored in RGBE format.
  149725. * Example of such files can be found on HDRLib: http://hdrlib.com/
  149726. */
  149727. export class HDRCubeTexture extends BaseTexture {
  149728. private static _facesMapping;
  149729. private _generateHarmonics;
  149730. private _noMipmap;
  149731. private _prefilterOnLoad;
  149732. private _textureMatrix;
  149733. private _size;
  149734. private _onLoad;
  149735. private _onError;
  149736. /**
  149737. * The texture URL.
  149738. */
  149739. url: string;
  149740. protected _isBlocking: boolean;
  149741. /**
  149742. * Sets wether or not the texture is blocking during loading.
  149743. */
  149744. set isBlocking(value: boolean);
  149745. /**
  149746. * Gets wether or not the texture is blocking during loading.
  149747. */
  149748. get isBlocking(): boolean;
  149749. protected _rotationY: number;
  149750. /**
  149751. * Sets texture matrix rotation angle around Y axis in radians.
  149752. */
  149753. set rotationY(value: number);
  149754. /**
  149755. * Gets texture matrix rotation angle around Y axis radians.
  149756. */
  149757. get rotationY(): number;
  149758. /**
  149759. * Gets or sets the center of the bounding box associated with the cube texture
  149760. * It must define where the camera used to render the texture was set
  149761. */
  149762. boundingBoxPosition: Vector3;
  149763. private _boundingBoxSize;
  149764. /**
  149765. * Gets or sets the size of the bounding box associated with the cube texture
  149766. * When defined, the cubemap will switch to local mode
  149767. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  149768. * @example https://www.babylonjs-playground.com/#RNASML
  149769. */
  149770. set boundingBoxSize(value: Vector3);
  149771. get boundingBoxSize(): Vector3;
  149772. /**
  149773. * Instantiates an HDRTexture from the following parameters.
  149774. *
  149775. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  149776. * @param sceneOrEngine The scene or engine the texture will be used in
  149777. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  149778. * @param noMipmap Forces to not generate the mipmap if true
  149779. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  149780. * @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)
  149781. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  149782. */
  149783. 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>);
  149784. /**
  149785. * Get the current class name of the texture useful for serialization or dynamic coding.
  149786. * @returns "HDRCubeTexture"
  149787. */
  149788. getClassName(): string;
  149789. /**
  149790. * Occurs when the file is raw .hdr file.
  149791. */
  149792. private loadTexture;
  149793. clone(): HDRCubeTexture;
  149794. delayLoad(): void;
  149795. /**
  149796. * Get the texture reflection matrix used to rotate/transform the reflection.
  149797. * @returns the reflection matrix
  149798. */
  149799. getReflectionTextureMatrix(): Matrix;
  149800. /**
  149801. * Set the texture reflection matrix used to rotate/transform the reflection.
  149802. * @param value Define the reflection matrix to set
  149803. */
  149804. setReflectionTextureMatrix(value: Matrix): void;
  149805. /**
  149806. * Parses a JSON representation of an HDR Texture in order to create the texture
  149807. * @param parsedTexture Define the JSON representation
  149808. * @param scene Define the scene the texture should be created in
  149809. * @param rootUrl Define the root url in case we need to load relative dependencies
  149810. * @returns the newly created texture after parsing
  149811. */
  149812. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  149813. serialize(): any;
  149814. }
  149815. }
  149816. declare module BABYLON {
  149817. /**
  149818. * Class used to control physics engine
  149819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149820. */
  149821. export class PhysicsEngine implements IPhysicsEngine {
  149822. private _physicsPlugin;
  149823. /**
  149824. * Global value used to control the smallest number supported by the simulation
  149825. */
  149826. static Epsilon: number;
  149827. private _impostors;
  149828. private _joints;
  149829. private _subTimeStep;
  149830. /**
  149831. * Gets the gravity vector used by the simulation
  149832. */
  149833. gravity: Vector3;
  149834. /**
  149835. * Factory used to create the default physics plugin.
  149836. * @returns The default physics plugin
  149837. */
  149838. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  149839. /**
  149840. * Creates a new Physics Engine
  149841. * @param gravity defines the gravity vector used by the simulation
  149842. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  149843. */
  149844. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  149845. /**
  149846. * Sets the gravity vector used by the simulation
  149847. * @param gravity defines the gravity vector to use
  149848. */
  149849. setGravity(gravity: Vector3): void;
  149850. /**
  149851. * Set the time step of the physics engine.
  149852. * Default is 1/60.
  149853. * To slow it down, enter 1/600 for example.
  149854. * To speed it up, 1/30
  149855. * @param newTimeStep defines the new timestep to apply to this world.
  149856. */
  149857. setTimeStep(newTimeStep?: number): void;
  149858. /**
  149859. * Get the time step of the physics engine.
  149860. * @returns the current time step
  149861. */
  149862. getTimeStep(): number;
  149863. /**
  149864. * Set the sub time step of the physics engine.
  149865. * Default is 0 meaning there is no sub steps
  149866. * To increase physics resolution precision, set a small value (like 1 ms)
  149867. * @param subTimeStep defines the new sub timestep used for physics resolution.
  149868. */
  149869. setSubTimeStep(subTimeStep?: number): void;
  149870. /**
  149871. * Get the sub time step of the physics engine.
  149872. * @returns the current sub time step
  149873. */
  149874. getSubTimeStep(): number;
  149875. /**
  149876. * Release all resources
  149877. */
  149878. dispose(): void;
  149879. /**
  149880. * Gets the name of the current physics plugin
  149881. * @returns the name of the plugin
  149882. */
  149883. getPhysicsPluginName(): string;
  149884. /**
  149885. * Adding a new impostor for the impostor tracking.
  149886. * This will be done by the impostor itself.
  149887. * @param impostor the impostor to add
  149888. */
  149889. addImpostor(impostor: PhysicsImpostor): void;
  149890. /**
  149891. * Remove an impostor from the engine.
  149892. * This impostor and its mesh will not longer be updated by the physics engine.
  149893. * @param impostor the impostor to remove
  149894. */
  149895. removeImpostor(impostor: PhysicsImpostor): void;
  149896. /**
  149897. * Add a joint to the physics engine
  149898. * @param mainImpostor defines the main impostor to which the joint is added.
  149899. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  149900. * @param joint defines the joint that will connect both impostors.
  149901. */
  149902. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149903. /**
  149904. * Removes a joint from the simulation
  149905. * @param mainImpostor defines the impostor used with the joint
  149906. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  149907. * @param joint defines the joint to remove
  149908. */
  149909. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149910. /**
  149911. * Called by the scene. No need to call it.
  149912. * @param delta defines the timespam between frames
  149913. */
  149914. _step(delta: number): void;
  149915. /**
  149916. * Gets the current plugin used to run the simulation
  149917. * @returns current plugin
  149918. */
  149919. getPhysicsPlugin(): IPhysicsEnginePlugin;
  149920. /**
  149921. * Gets the list of physic impostors
  149922. * @returns an array of PhysicsImpostor
  149923. */
  149924. getImpostors(): Array<PhysicsImpostor>;
  149925. /**
  149926. * Gets the impostor for a physics enabled object
  149927. * @param object defines the object impersonated by the impostor
  149928. * @returns the PhysicsImpostor or null if not found
  149929. */
  149930. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  149931. /**
  149932. * Gets the impostor for a physics body object
  149933. * @param body defines physics body used by the impostor
  149934. * @returns the PhysicsImpostor or null if not found
  149935. */
  149936. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  149937. /**
  149938. * Does a raycast in the physics world
  149939. * @param from when should the ray start?
  149940. * @param to when should the ray end?
  149941. * @returns PhysicsRaycastResult
  149942. */
  149943. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149944. }
  149945. }
  149946. declare module BABYLON {
  149947. /** @hidden */
  149948. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  149949. private _useDeltaForWorldStep;
  149950. world: any;
  149951. name: string;
  149952. private _physicsMaterials;
  149953. private _fixedTimeStep;
  149954. private _cannonRaycastResult;
  149955. private _raycastResult;
  149956. private _physicsBodysToRemoveAfterStep;
  149957. private _firstFrame;
  149958. BJSCANNON: any;
  149959. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  149960. setGravity(gravity: Vector3): void;
  149961. setTimeStep(timeStep: number): void;
  149962. getTimeStep(): number;
  149963. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149964. private _removeMarkedPhysicsBodiesFromWorld;
  149965. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149966. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149967. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149968. private _processChildMeshes;
  149969. removePhysicsBody(impostor: PhysicsImpostor): void;
  149970. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149971. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149972. private _addMaterial;
  149973. private _checkWithEpsilon;
  149974. private _createShape;
  149975. private _createHeightmap;
  149976. private _minus90X;
  149977. private _plus90X;
  149978. private _tmpPosition;
  149979. private _tmpDeltaPosition;
  149980. private _tmpUnityRotation;
  149981. private _updatePhysicsBodyTransformation;
  149982. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149984. isSupported(): boolean;
  149985. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149987. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149989. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149990. getBodyMass(impostor: PhysicsImpostor): number;
  149991. getBodyFriction(impostor: PhysicsImpostor): number;
  149992. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149993. getBodyRestitution(impostor: PhysicsImpostor): number;
  149994. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149995. sleepBody(impostor: PhysicsImpostor): void;
  149996. wakeUpBody(impostor: PhysicsImpostor): void;
  149997. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  149998. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  149999. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  150000. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150001. getRadius(impostor: PhysicsImpostor): number;
  150002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150003. dispose(): void;
  150004. private _extendNamespace;
  150005. /**
  150006. * Does a raycast in the physics world
  150007. * @param from when should the ray start?
  150008. * @param to when should the ray end?
  150009. * @returns PhysicsRaycastResult
  150010. */
  150011. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150012. }
  150013. }
  150014. declare module BABYLON {
  150015. /** @hidden */
  150016. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  150017. private _useDeltaForWorldStep;
  150018. world: any;
  150019. name: string;
  150020. BJSOIMO: any;
  150021. private _raycastResult;
  150022. private _fixedTimeStep;
  150023. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  150024. setGravity(gravity: Vector3): void;
  150025. setTimeStep(timeStep: number): void;
  150026. getTimeStep(): number;
  150027. private _tmpImpostorsArray;
  150028. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  150029. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150030. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150031. generatePhysicsBody(impostor: PhysicsImpostor): void;
  150032. private _tmpPositionVector;
  150033. removePhysicsBody(impostor: PhysicsImpostor): void;
  150034. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  150035. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  150036. isSupported(): boolean;
  150037. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  150038. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  150039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  150044. getBodyMass(impostor: PhysicsImpostor): number;
  150045. getBodyFriction(impostor: PhysicsImpostor): number;
  150046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  150047. getBodyRestitution(impostor: PhysicsImpostor): number;
  150048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  150049. sleepBody(impostor: PhysicsImpostor): void;
  150050. wakeUpBody(impostor: PhysicsImpostor): void;
  150051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  150052. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  150053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  150054. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150055. getRadius(impostor: PhysicsImpostor): number;
  150056. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150057. dispose(): void;
  150058. /**
  150059. * Does a raycast in the physics world
  150060. * @param from when should the ray start?
  150061. * @param to when should the ray end?
  150062. * @returns PhysicsRaycastResult
  150063. */
  150064. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150065. }
  150066. }
  150067. declare module BABYLON {
  150068. /**
  150069. * AmmoJS Physics plugin
  150070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150071. * @see https://github.com/kripken/ammo.js/
  150072. */
  150073. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  150074. private _useDeltaForWorldStep;
  150075. /**
  150076. * Reference to the Ammo library
  150077. */
  150078. bjsAMMO: any;
  150079. /**
  150080. * Created ammoJS world which physics bodies are added to
  150081. */
  150082. world: any;
  150083. /**
  150084. * Name of the plugin
  150085. */
  150086. name: string;
  150087. private _timeStep;
  150088. private _fixedTimeStep;
  150089. private _maxSteps;
  150090. private _tmpQuaternion;
  150091. private _tmpAmmoTransform;
  150092. private _tmpAmmoQuaternion;
  150093. private _tmpAmmoConcreteContactResultCallback;
  150094. private _collisionConfiguration;
  150095. private _dispatcher;
  150096. private _overlappingPairCache;
  150097. private _solver;
  150098. private _softBodySolver;
  150099. private _tmpAmmoVectorA;
  150100. private _tmpAmmoVectorB;
  150101. private _tmpAmmoVectorC;
  150102. private _tmpAmmoVectorD;
  150103. private _tmpContactCallbackResult;
  150104. private _tmpAmmoVectorRCA;
  150105. private _tmpAmmoVectorRCB;
  150106. private _raycastResult;
  150107. private _tmpContactPoint;
  150108. private static readonly DISABLE_COLLISION_FLAG;
  150109. private static readonly KINEMATIC_FLAG;
  150110. private static readonly DISABLE_DEACTIVATION_FLAG;
  150111. /**
  150112. * Initializes the ammoJS plugin
  150113. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  150114. * @param ammoInjection can be used to inject your own ammo reference
  150115. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  150116. */
  150117. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  150118. /**
  150119. * Sets the gravity of the physics world (m/(s^2))
  150120. * @param gravity Gravity to set
  150121. */
  150122. setGravity(gravity: Vector3): void;
  150123. /**
  150124. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  150125. * @param timeStep timestep to use in seconds
  150126. */
  150127. setTimeStep(timeStep: number): void;
  150128. /**
  150129. * 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)
  150130. * @param fixedTimeStep fixedTimeStep to use in seconds
  150131. */
  150132. setFixedTimeStep(fixedTimeStep: number): void;
  150133. /**
  150134. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  150135. * @param maxSteps the maximum number of steps by the physics engine per frame
  150136. */
  150137. setMaxSteps(maxSteps: number): void;
  150138. /**
  150139. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  150140. * @returns the current timestep in seconds
  150141. */
  150142. getTimeStep(): number;
  150143. /**
  150144. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  150145. */
  150146. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  150147. private _isImpostorInContact;
  150148. private _isImpostorPairInContact;
  150149. private _stepSimulation;
  150150. /**
  150151. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  150152. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  150153. * After the step the babylon meshes are set to the position of the physics imposters
  150154. * @param delta amount of time to step forward
  150155. * @param impostors array of imposters to update before/after the step
  150156. */
  150157. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  150158. /**
  150159. * Update babylon mesh to match physics world object
  150160. * @param impostor imposter to match
  150161. */
  150162. private _afterSoftStep;
  150163. /**
  150164. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  150165. * @param impostor imposter to match
  150166. */
  150167. private _ropeStep;
  150168. /**
  150169. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  150170. * @param impostor imposter to match
  150171. */
  150172. private _softbodyOrClothStep;
  150173. private _tmpMatrix;
  150174. /**
  150175. * Applies an impulse on the imposter
  150176. * @param impostor imposter to apply impulse to
  150177. * @param force amount of force to be applied to the imposter
  150178. * @param contactPoint the location to apply the impulse on the imposter
  150179. */
  150180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150181. /**
  150182. * Applies a force on the imposter
  150183. * @param impostor imposter to apply force
  150184. * @param force amount of force to be applied to the imposter
  150185. * @param contactPoint the location to apply the force on the imposter
  150186. */
  150187. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150188. /**
  150189. * Creates a physics body using the plugin
  150190. * @param impostor the imposter to create the physics body on
  150191. */
  150192. generatePhysicsBody(impostor: PhysicsImpostor): void;
  150193. /**
  150194. * Removes the physics body from the imposter and disposes of the body's memory
  150195. * @param impostor imposter to remove the physics body from
  150196. */
  150197. removePhysicsBody(impostor: PhysicsImpostor): void;
  150198. /**
  150199. * Generates a joint
  150200. * @param impostorJoint the imposter joint to create the joint with
  150201. */
  150202. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  150203. /**
  150204. * Removes a joint
  150205. * @param impostorJoint the imposter joint to remove the joint from
  150206. */
  150207. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  150208. private _addMeshVerts;
  150209. /**
  150210. * Initialise the soft body vertices to match its object's (mesh) vertices
  150211. * Softbody vertices (nodes) are in world space and to match this
  150212. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  150213. * @param impostor to create the softbody for
  150214. */
  150215. private _softVertexData;
  150216. /**
  150217. * Create an impostor's soft body
  150218. * @param impostor to create the softbody for
  150219. */
  150220. private _createSoftbody;
  150221. /**
  150222. * Create cloth for an impostor
  150223. * @param impostor to create the softbody for
  150224. */
  150225. private _createCloth;
  150226. /**
  150227. * Create rope for an impostor
  150228. * @param impostor to create the softbody for
  150229. */
  150230. private _createRope;
  150231. /**
  150232. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  150233. * @param impostor to create the custom physics shape for
  150234. */
  150235. private _createCustom;
  150236. private _addHullVerts;
  150237. private _createShape;
  150238. /**
  150239. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  150240. * @param impostor imposter containing the physics body and babylon object
  150241. */
  150242. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  150243. /**
  150244. * Sets the babylon object's position/rotation from the physics body's position/rotation
  150245. * @param impostor imposter containing the physics body and babylon object
  150246. * @param newPosition new position
  150247. * @param newRotation new rotation
  150248. */
  150249. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  150250. /**
  150251. * If this plugin is supported
  150252. * @returns true if its supported
  150253. */
  150254. isSupported(): boolean;
  150255. /**
  150256. * Sets the linear velocity of the physics body
  150257. * @param impostor imposter to set the velocity on
  150258. * @param velocity velocity to set
  150259. */
  150260. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150261. /**
  150262. * Sets the angular velocity of the physics body
  150263. * @param impostor imposter to set the velocity on
  150264. * @param velocity velocity to set
  150265. */
  150266. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150267. /**
  150268. * gets the linear velocity
  150269. * @param impostor imposter to get linear velocity from
  150270. * @returns linear velocity
  150271. */
  150272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150273. /**
  150274. * gets the angular velocity
  150275. * @param impostor imposter to get angular velocity from
  150276. * @returns angular velocity
  150277. */
  150278. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150279. /**
  150280. * Sets the mass of physics body
  150281. * @param impostor imposter to set the mass on
  150282. * @param mass mass to set
  150283. */
  150284. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  150285. /**
  150286. * Gets the mass of the physics body
  150287. * @param impostor imposter to get the mass from
  150288. * @returns mass
  150289. */
  150290. getBodyMass(impostor: PhysicsImpostor): number;
  150291. /**
  150292. * Gets friction of the impostor
  150293. * @param impostor impostor to get friction from
  150294. * @returns friction value
  150295. */
  150296. getBodyFriction(impostor: PhysicsImpostor): number;
  150297. /**
  150298. * Sets friction of the impostor
  150299. * @param impostor impostor to set friction on
  150300. * @param friction friction value
  150301. */
  150302. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  150303. /**
  150304. * Gets restitution of the impostor
  150305. * @param impostor impostor to get restitution from
  150306. * @returns restitution value
  150307. */
  150308. getBodyRestitution(impostor: PhysicsImpostor): number;
  150309. /**
  150310. * Sets resitution of the impostor
  150311. * @param impostor impostor to set resitution on
  150312. * @param restitution resitution value
  150313. */
  150314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  150315. /**
  150316. * Gets pressure inside the impostor
  150317. * @param impostor impostor to get pressure from
  150318. * @returns pressure value
  150319. */
  150320. getBodyPressure(impostor: PhysicsImpostor): number;
  150321. /**
  150322. * Sets pressure inside a soft body impostor
  150323. * Cloth and rope must remain 0 pressure
  150324. * @param impostor impostor to set pressure on
  150325. * @param pressure pressure value
  150326. */
  150327. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  150328. /**
  150329. * Gets stiffness of the impostor
  150330. * @param impostor impostor to get stiffness from
  150331. * @returns pressure value
  150332. */
  150333. getBodyStiffness(impostor: PhysicsImpostor): number;
  150334. /**
  150335. * Sets stiffness of the impostor
  150336. * @param impostor impostor to set stiffness on
  150337. * @param stiffness stiffness value from 0 to 1
  150338. */
  150339. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  150340. /**
  150341. * Gets velocityIterations of the impostor
  150342. * @param impostor impostor to get velocity iterations from
  150343. * @returns velocityIterations value
  150344. */
  150345. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  150346. /**
  150347. * Sets velocityIterations of the impostor
  150348. * @param impostor impostor to set velocity iterations on
  150349. * @param velocityIterations velocityIterations value
  150350. */
  150351. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  150352. /**
  150353. * Gets positionIterations of the impostor
  150354. * @param impostor impostor to get position iterations from
  150355. * @returns positionIterations value
  150356. */
  150357. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  150358. /**
  150359. * Sets positionIterations of the impostor
  150360. * @param impostor impostor to set position on
  150361. * @param positionIterations positionIterations value
  150362. */
  150363. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  150364. /**
  150365. * Append an anchor to a cloth object
  150366. * @param impostor is the cloth impostor to add anchor to
  150367. * @param otherImpostor is the rigid impostor to anchor to
  150368. * @param width ratio across width from 0 to 1
  150369. * @param height ratio up height from 0 to 1
  150370. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  150371. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  150372. */
  150373. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  150374. /**
  150375. * Append an hook to a rope object
  150376. * @param impostor is the rope impostor to add hook to
  150377. * @param otherImpostor is the rigid impostor to hook to
  150378. * @param length ratio along the rope from 0 to 1
  150379. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  150380. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  150381. */
  150382. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  150383. /**
  150384. * Sleeps the physics body and stops it from being active
  150385. * @param impostor impostor to sleep
  150386. */
  150387. sleepBody(impostor: PhysicsImpostor): void;
  150388. /**
  150389. * Activates the physics body
  150390. * @param impostor impostor to activate
  150391. */
  150392. wakeUpBody(impostor: PhysicsImpostor): void;
  150393. /**
  150394. * Updates the distance parameters of the joint
  150395. * @param joint joint to update
  150396. * @param maxDistance maximum distance of the joint
  150397. * @param minDistance minimum distance of the joint
  150398. */
  150399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  150400. /**
  150401. * Sets a motor on the joint
  150402. * @param joint joint to set motor on
  150403. * @param speed speed of the motor
  150404. * @param maxForce maximum force of the motor
  150405. * @param motorIndex index of the motor
  150406. */
  150407. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  150408. /**
  150409. * Sets the motors limit
  150410. * @param joint joint to set limit on
  150411. * @param upperLimit upper limit
  150412. * @param lowerLimit lower limit
  150413. */
  150414. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  150415. /**
  150416. * Syncs the position and rotation of a mesh with the impostor
  150417. * @param mesh mesh to sync
  150418. * @param impostor impostor to update the mesh with
  150419. */
  150420. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150421. /**
  150422. * Gets the radius of the impostor
  150423. * @param impostor impostor to get radius from
  150424. * @returns the radius
  150425. */
  150426. getRadius(impostor: PhysicsImpostor): number;
  150427. /**
  150428. * Gets the box size of the impostor
  150429. * @param impostor impostor to get box size from
  150430. * @param result the resulting box size
  150431. */
  150432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150433. /**
  150434. * Disposes of the impostor
  150435. */
  150436. dispose(): void;
  150437. /**
  150438. * Does a raycast in the physics world
  150439. * @param from when should the ray start?
  150440. * @param to when should the ray end?
  150441. * @returns PhysicsRaycastResult
  150442. */
  150443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150444. }
  150445. }
  150446. declare module BABYLON {
  150447. interface AbstractScene {
  150448. /**
  150449. * The list of reflection probes added to the scene
  150450. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  150451. */
  150452. reflectionProbes: Array<ReflectionProbe>;
  150453. /**
  150454. * Removes the given reflection probe from this scene.
  150455. * @param toRemove The reflection probe to remove
  150456. * @returns The index of the removed reflection probe
  150457. */
  150458. removeReflectionProbe(toRemove: ReflectionProbe): number;
  150459. /**
  150460. * Adds the given reflection probe to this scene.
  150461. * @param newReflectionProbe The reflection probe to add
  150462. */
  150463. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  150464. }
  150465. /**
  150466. * Class used to generate realtime reflection / refraction cube textures
  150467. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  150468. */
  150469. export class ReflectionProbe {
  150470. /** defines the name of the probe */
  150471. name: string;
  150472. private _scene;
  150473. private _renderTargetTexture;
  150474. private _projectionMatrix;
  150475. private _viewMatrix;
  150476. private _target;
  150477. private _add;
  150478. private _attachedMesh;
  150479. private _invertYAxis;
  150480. /** Gets or sets probe position (center of the cube map) */
  150481. position: Vector3;
  150482. /**
  150483. * Creates a new reflection probe
  150484. * @param name defines the name of the probe
  150485. * @param size defines the texture resolution (for each face)
  150486. * @param scene defines the hosting scene
  150487. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  150488. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  150489. */
  150490. constructor(
  150491. /** defines the name of the probe */
  150492. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  150493. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  150494. get samples(): number;
  150495. set samples(value: number);
  150496. /** Gets or sets the refresh rate to use (on every frame by default) */
  150497. get refreshRate(): number;
  150498. set refreshRate(value: number);
  150499. /**
  150500. * Gets the hosting scene
  150501. * @returns a Scene
  150502. */
  150503. getScene(): Scene;
  150504. /** Gets the internal CubeTexture used to render to */
  150505. get cubeTexture(): RenderTargetTexture;
  150506. /** Gets the list of meshes to render */
  150507. get renderList(): Nullable<AbstractMesh[]>;
  150508. /**
  150509. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  150510. * @param mesh defines the mesh to attach to
  150511. */
  150512. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  150513. /**
  150514. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  150515. * @param renderingGroupId The rendering group id corresponding to its index
  150516. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  150517. */
  150518. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  150519. /**
  150520. * Clean all associated resources
  150521. */
  150522. dispose(): void;
  150523. /**
  150524. * Converts the reflection probe information to a readable string for debug purpose.
  150525. * @param fullDetails Supports for multiple levels of logging within scene loading
  150526. * @returns the human readable reflection probe info
  150527. */
  150528. toString(fullDetails?: boolean): string;
  150529. /**
  150530. * Get the class name of the relfection probe.
  150531. * @returns "ReflectionProbe"
  150532. */
  150533. getClassName(): string;
  150534. /**
  150535. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  150536. * @returns The JSON representation of the texture
  150537. */
  150538. serialize(): any;
  150539. /**
  150540. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  150541. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  150542. * @param scene Define the scene the parsed reflection probe should be instantiated in
  150543. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  150544. * @returns The parsed reflection probe if successful
  150545. */
  150546. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  150547. }
  150548. }
  150549. declare module BABYLON {
  150550. /** @hidden */
  150551. export var _BabylonLoaderRegistered: boolean;
  150552. /**
  150553. * Helps setting up some configuration for the babylon file loader.
  150554. */
  150555. export class BabylonFileLoaderConfiguration {
  150556. /**
  150557. * The loader does not allow injecting custom physix engine into the plugins.
  150558. * Unfortunately in ES6, we need to manually inject them into the plugin.
  150559. * So you could set this variable to your engine import to make it work.
  150560. */
  150561. static LoaderInjectedPhysicsEngine: any;
  150562. }
  150563. }
  150564. declare module BABYLON {
  150565. /**
  150566. * A material to use for fast depth-only rendering.
  150567. */
  150568. export class OcclusionMaterial extends ShaderMaterial {
  150569. constructor(name: string, scene: Scene);
  150570. }
  150571. }
  150572. declare module BABYLON {
  150573. /**
  150574. * The Physically based simple base material of BJS.
  150575. *
  150576. * This enables better naming and convention enforcements on top of the pbrMaterial.
  150577. * It is used as the base class for both the specGloss and metalRough conventions.
  150578. */
  150579. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  150580. /**
  150581. * Number of Simultaneous lights allowed on the material.
  150582. */
  150583. maxSimultaneousLights: number;
  150584. /**
  150585. * If sets to true, disables all the lights affecting the material.
  150586. */
  150587. disableLighting: boolean;
  150588. /**
  150589. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  150590. */
  150591. environmentTexture: BaseTexture;
  150592. /**
  150593. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  150594. */
  150595. invertNormalMapX: boolean;
  150596. /**
  150597. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  150598. */
  150599. invertNormalMapY: boolean;
  150600. /**
  150601. * Normal map used in the model.
  150602. */
  150603. normalTexture: BaseTexture;
  150604. /**
  150605. * Emissivie color used to self-illuminate the model.
  150606. */
  150607. emissiveColor: Color3;
  150608. /**
  150609. * Emissivie texture used to self-illuminate the model.
  150610. */
  150611. emissiveTexture: BaseTexture;
  150612. /**
  150613. * Occlusion Channel Strenght.
  150614. */
  150615. occlusionStrength: number;
  150616. /**
  150617. * Occlusion Texture of the material (adding extra occlusion effects).
  150618. */
  150619. occlusionTexture: BaseTexture;
  150620. /**
  150621. * Defines the alpha limits in alpha test mode.
  150622. */
  150623. alphaCutOff: number;
  150624. /**
  150625. * Gets the current double sided mode.
  150626. */
  150627. get doubleSided(): boolean;
  150628. /**
  150629. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  150630. */
  150631. set doubleSided(value: boolean);
  150632. /**
  150633. * Stores the pre-calculated light information of a mesh in a texture.
  150634. */
  150635. lightmapTexture: BaseTexture;
  150636. /**
  150637. * If true, the light map contains occlusion information instead of lighting info.
  150638. */
  150639. useLightmapAsShadowmap: boolean;
  150640. /**
  150641. * Instantiates a new PBRMaterial instance.
  150642. *
  150643. * @param name The material name
  150644. * @param scene The scene the material will be use in.
  150645. */
  150646. constructor(name: string, scene: Scene);
  150647. getClassName(): string;
  150648. }
  150649. }
  150650. declare module BABYLON {
  150651. /**
  150652. * The PBR material of BJS following the metal roughness convention.
  150653. *
  150654. * This fits to the PBR convention in the GLTF definition:
  150655. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  150656. */
  150657. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  150658. /**
  150659. * The base color has two different interpretations depending on the value of metalness.
  150660. * When the material is a metal, the base color is the specific measured reflectance value
  150661. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  150662. * of the material.
  150663. */
  150664. baseColor: Color3;
  150665. /**
  150666. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  150667. * well as opacity information in the alpha channel.
  150668. */
  150669. baseTexture: BaseTexture;
  150670. /**
  150671. * Specifies the metallic scalar value of the material.
  150672. * Can also be used to scale the metalness values of the metallic texture.
  150673. */
  150674. metallic: number;
  150675. /**
  150676. * Specifies the roughness scalar value of the material.
  150677. * Can also be used to scale the roughness values of the metallic texture.
  150678. */
  150679. roughness: number;
  150680. /**
  150681. * Texture containing both the metallic value in the B channel and the
  150682. * roughness value in the G channel to keep better precision.
  150683. */
  150684. metallicRoughnessTexture: BaseTexture;
  150685. /**
  150686. * Instantiates a new PBRMetalRoughnessMaterial instance.
  150687. *
  150688. * @param name The material name
  150689. * @param scene The scene the material will be use in.
  150690. */
  150691. constructor(name: string, scene: Scene);
  150692. /**
  150693. * Return the currrent class name of the material.
  150694. */
  150695. getClassName(): string;
  150696. /**
  150697. * Makes a duplicate of the current material.
  150698. * @param name - name to use for the new material.
  150699. */
  150700. clone(name: string): PBRMetallicRoughnessMaterial;
  150701. /**
  150702. * Serialize the material to a parsable JSON object.
  150703. */
  150704. serialize(): any;
  150705. /**
  150706. * Parses a JSON object correponding to the serialize function.
  150707. */
  150708. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  150709. }
  150710. }
  150711. declare module BABYLON {
  150712. /**
  150713. * The PBR material of BJS following the specular glossiness convention.
  150714. *
  150715. * This fits to the PBR convention in the GLTF definition:
  150716. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  150717. */
  150718. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  150719. /**
  150720. * Specifies the diffuse color of the material.
  150721. */
  150722. diffuseColor: Color3;
  150723. /**
  150724. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  150725. * channel.
  150726. */
  150727. diffuseTexture: BaseTexture;
  150728. /**
  150729. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  150730. */
  150731. specularColor: Color3;
  150732. /**
  150733. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  150734. */
  150735. glossiness: number;
  150736. /**
  150737. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  150738. */
  150739. specularGlossinessTexture: BaseTexture;
  150740. /**
  150741. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  150742. */
  150743. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  150744. /**
  150745. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  150746. *
  150747. * @param name The material name
  150748. * @param scene The scene the material will be use in.
  150749. */
  150750. constructor(name: string, scene: Scene);
  150751. /**
  150752. * Return the currrent class name of the material.
  150753. */
  150754. getClassName(): string;
  150755. /**
  150756. * Makes a duplicate of the current material.
  150757. * @param name - name to use for the new material.
  150758. */
  150759. clone(name: string): PBRSpecularGlossinessMaterial;
  150760. /**
  150761. * Serialize the material to a parsable JSON object.
  150762. */
  150763. serialize(): any;
  150764. /**
  150765. * Parses a JSON object correponding to the serialize function.
  150766. */
  150767. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  150768. }
  150769. }
  150770. declare module BABYLON {
  150771. /**
  150772. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  150773. * It can help converting any input color in a desired output one. This can then be used to create effects
  150774. * from sepia, black and white to sixties or futuristic rendering...
  150775. *
  150776. * The only supported format is currently 3dl.
  150777. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  150778. */
  150779. export class ColorGradingTexture extends BaseTexture {
  150780. /**
  150781. * The texture URL.
  150782. */
  150783. url: string;
  150784. /**
  150785. * Empty line regex stored for GC.
  150786. */
  150787. private static _noneEmptyLineRegex;
  150788. private _textureMatrix;
  150789. private _onLoad;
  150790. /**
  150791. * Instantiates a ColorGradingTexture from the following parameters.
  150792. *
  150793. * @param url The location of the color gradind data (currently only supporting 3dl)
  150794. * @param sceneOrEngine The scene or engine the texture will be used in
  150795. * @param onLoad defines a callback triggered when the texture has been loaded
  150796. */
  150797. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  150798. /**
  150799. * Fires the onload event from the constructor if requested.
  150800. */
  150801. private _triggerOnLoad;
  150802. /**
  150803. * Returns the texture matrix used in most of the material.
  150804. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  150805. */
  150806. getTextureMatrix(): Matrix;
  150807. /**
  150808. * Occurs when the file being loaded is a .3dl LUT file.
  150809. */
  150810. private load3dlTexture;
  150811. /**
  150812. * Starts the loading process of the texture.
  150813. */
  150814. private loadTexture;
  150815. /**
  150816. * Clones the color gradind texture.
  150817. */
  150818. clone(): ColorGradingTexture;
  150819. /**
  150820. * Called during delayed load for textures.
  150821. */
  150822. delayLoad(): void;
  150823. /**
  150824. * Parses a color grading texture serialized by Babylon.
  150825. * @param parsedTexture The texture information being parsedTexture
  150826. * @param scene The scene to load the texture in
  150827. * @param rootUrl The root url of the data assets to load
  150828. * @return A color gradind texture
  150829. */
  150830. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  150831. /**
  150832. * Serializes the LUT texture to json format.
  150833. */
  150834. serialize(): any;
  150835. }
  150836. }
  150837. declare module BABYLON {
  150838. /**
  150839. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  150840. */
  150841. export class EquiRectangularCubeTexture extends BaseTexture {
  150842. /** The six faces of the cube. */
  150843. private static _FacesMapping;
  150844. private _noMipmap;
  150845. private _onLoad;
  150846. private _onError;
  150847. /** The size of the cubemap. */
  150848. private _size;
  150849. /** The buffer of the image. */
  150850. private _buffer;
  150851. /** The width of the input image. */
  150852. private _width;
  150853. /** The height of the input image. */
  150854. private _height;
  150855. /** The URL to the image. */
  150856. url: string;
  150857. /**
  150858. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  150859. * @param url The location of the image
  150860. * @param scene The scene the texture will be used in
  150861. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  150862. * @param noMipmap Forces to not generate the mipmap if true
  150863. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150864. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150865. * @param onLoad — defines a callback called when texture is loaded
  150866. * @param onError — defines a callback called if there is an error
  150867. */
  150868. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  150869. /**
  150870. * Load the image data, by putting the image on a canvas and extracting its buffer.
  150871. */
  150872. private loadImage;
  150873. /**
  150874. * Convert the image buffer into a cubemap and create a CubeTexture.
  150875. */
  150876. private loadTexture;
  150877. /**
  150878. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  150879. * @param buffer The ArrayBuffer that should be converted.
  150880. * @returns The buffer as Float32Array.
  150881. */
  150882. private getFloat32ArrayFromArrayBuffer;
  150883. /**
  150884. * Get the current class name of the texture useful for serialization or dynamic coding.
  150885. * @returns "EquiRectangularCubeTexture"
  150886. */
  150887. getClassName(): string;
  150888. /**
  150889. * Create a clone of the current EquiRectangularCubeTexture and return it.
  150890. * @returns A clone of the current EquiRectangularCubeTexture.
  150891. */
  150892. clone(): EquiRectangularCubeTexture;
  150893. }
  150894. }
  150895. declare module BABYLON {
  150896. /**
  150897. * Defines the options related to the creation of an HtmlElementTexture
  150898. */
  150899. export interface IHtmlElementTextureOptions {
  150900. /**
  150901. * Defines wether mip maps should be created or not.
  150902. */
  150903. generateMipMaps?: boolean;
  150904. /**
  150905. * Defines the sampling mode of the texture.
  150906. */
  150907. samplingMode?: number;
  150908. /**
  150909. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  150910. */
  150911. engine: Nullable<ThinEngine>;
  150912. /**
  150913. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  150914. */
  150915. scene: Nullable<Scene>;
  150916. }
  150917. /**
  150918. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  150919. * To be as efficient as possible depending on your constraints nothing aside the first upload
  150920. * is automatically managed.
  150921. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  150922. * in your application.
  150923. *
  150924. * As the update is not automatic, you need to call them manually.
  150925. */
  150926. export class HtmlElementTexture extends BaseTexture {
  150927. /**
  150928. * The texture URL.
  150929. */
  150930. element: HTMLVideoElement | HTMLCanvasElement;
  150931. private static readonly DefaultOptions;
  150932. private _textureMatrix;
  150933. private _isVideo;
  150934. private _generateMipMaps;
  150935. private _samplingMode;
  150936. /**
  150937. * Instantiates a HtmlElementTexture from the following parameters.
  150938. *
  150939. * @param name Defines the name of the texture
  150940. * @param element Defines the video or canvas the texture is filled with
  150941. * @param options Defines the other none mandatory texture creation options
  150942. */
  150943. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  150944. private _createInternalTexture;
  150945. /**
  150946. * Returns the texture matrix used in most of the material.
  150947. */
  150948. getTextureMatrix(): Matrix;
  150949. /**
  150950. * Updates the content of the texture.
  150951. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  150952. */
  150953. update(invertY?: Nullable<boolean>): void;
  150954. }
  150955. }
  150956. declare module BABYLON {
  150957. /**
  150958. * Based on jsTGALoader - Javascript loader for TGA file
  150959. * By Vincent Thibault
  150960. * @see http://blog.robrowser.com/javascript-tga-loader.html
  150961. */
  150962. export class TGATools {
  150963. private static _TYPE_INDEXED;
  150964. private static _TYPE_RGB;
  150965. private static _TYPE_GREY;
  150966. private static _TYPE_RLE_INDEXED;
  150967. private static _TYPE_RLE_RGB;
  150968. private static _TYPE_RLE_GREY;
  150969. private static _ORIGIN_MASK;
  150970. private static _ORIGIN_SHIFT;
  150971. private static _ORIGIN_BL;
  150972. private static _ORIGIN_BR;
  150973. private static _ORIGIN_UL;
  150974. private static _ORIGIN_UR;
  150975. /**
  150976. * Gets the header of a TGA file
  150977. * @param data defines the TGA data
  150978. * @returns the header
  150979. */
  150980. static GetTGAHeader(data: Uint8Array): any;
  150981. /**
  150982. * Uploads TGA content to a Babylon Texture
  150983. * @hidden
  150984. */
  150985. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  150986. /** @hidden */
  150987. 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;
  150988. /** @hidden */
  150989. 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;
  150990. /** @hidden */
  150991. 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;
  150992. /** @hidden */
  150993. 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;
  150994. /** @hidden */
  150995. 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;
  150996. /** @hidden */
  150997. 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;
  150998. }
  150999. }
  151000. declare module BABYLON {
  151001. /**
  151002. * Implementation of the TGA Texture Loader.
  151003. * @hidden
  151004. */
  151005. export class _TGATextureLoader implements IInternalTextureLoader {
  151006. /**
  151007. * Defines wether the loader supports cascade loading the different faces.
  151008. */
  151009. readonly supportCascades: boolean;
  151010. /**
  151011. * This returns if the loader support the current file information.
  151012. * @param extension defines the file extension of the file being loaded
  151013. * @returns true if the loader can load the specified file
  151014. */
  151015. canLoad(extension: string): boolean;
  151016. /**
  151017. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151018. * @param data contains the texture data
  151019. * @param texture defines the BabylonJS internal texture
  151020. * @param createPolynomials will be true if polynomials have been requested
  151021. * @param onLoad defines the callback to trigger once the texture is ready
  151022. * @param onError defines the callback to trigger in case of error
  151023. */
  151024. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151025. /**
  151026. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151027. * @param data contains the texture data
  151028. * @param texture defines the BabylonJS internal texture
  151029. * @param callback defines the method to call once ready to upload
  151030. */
  151031. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151032. }
  151033. }
  151034. declare module BABYLON {
  151035. /**
  151036. * Implementation of the HDR Texture Loader.
  151037. * @hidden
  151038. */
  151039. export class _HDRTextureLoader implements IInternalTextureLoader {
  151040. /**
  151041. * Defines wether the loader supports cascade loading the different faces.
  151042. */
  151043. readonly supportCascades: boolean;
  151044. /**
  151045. * This returns if the loader support the current file information.
  151046. * @param extension defines the file extension of the file being loaded
  151047. * @returns true if the loader can load the specified file
  151048. */
  151049. canLoad(extension: string): boolean;
  151050. /**
  151051. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151052. * @param data contains the texture data
  151053. * @param texture defines the BabylonJS internal texture
  151054. * @param createPolynomials will be true if polynomials have been requested
  151055. * @param onLoad defines the callback to trigger once the texture is ready
  151056. * @param onError defines the callback to trigger in case of error
  151057. */
  151058. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151059. /**
  151060. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151061. * @param data contains the texture data
  151062. * @param texture defines the BabylonJS internal texture
  151063. * @param callback defines the method to call once ready to upload
  151064. */
  151065. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151066. }
  151067. }
  151068. declare module BABYLON {
  151069. /**
  151070. * Info about the .basis files
  151071. */
  151072. class BasisFileInfo {
  151073. /**
  151074. * If the file has alpha
  151075. */
  151076. hasAlpha: boolean;
  151077. /**
  151078. * Info about each image of the basis file
  151079. */
  151080. images: Array<{
  151081. levels: Array<{
  151082. width: number;
  151083. height: number;
  151084. transcodedPixels: ArrayBufferView;
  151085. }>;
  151086. }>;
  151087. }
  151088. /**
  151089. * Result of transcoding a basis file
  151090. */
  151091. class TranscodeResult {
  151092. /**
  151093. * Info about the .basis file
  151094. */
  151095. fileInfo: BasisFileInfo;
  151096. /**
  151097. * Format to use when loading the file
  151098. */
  151099. format: number;
  151100. }
  151101. /**
  151102. * Configuration options for the Basis transcoder
  151103. */
  151104. export class BasisTranscodeConfiguration {
  151105. /**
  151106. * Supported compression formats used to determine the supported output format of the transcoder
  151107. */
  151108. supportedCompressionFormats?: {
  151109. /**
  151110. * etc1 compression format
  151111. */
  151112. etc1?: boolean;
  151113. /**
  151114. * s3tc compression format
  151115. */
  151116. s3tc?: boolean;
  151117. /**
  151118. * pvrtc compression format
  151119. */
  151120. pvrtc?: boolean;
  151121. /**
  151122. * etc2 compression format
  151123. */
  151124. etc2?: boolean;
  151125. };
  151126. /**
  151127. * If mipmap levels should be loaded for transcoded images (Default: true)
  151128. */
  151129. loadMipmapLevels?: boolean;
  151130. /**
  151131. * Index of a single image to load (Default: all images)
  151132. */
  151133. loadSingleImage?: number;
  151134. }
  151135. /**
  151136. * Used to load .Basis files
  151137. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  151138. */
  151139. export class BasisTools {
  151140. private static _IgnoreSupportedFormats;
  151141. /**
  151142. * URL to use when loading the basis transcoder
  151143. */
  151144. static JSModuleURL: string;
  151145. /**
  151146. * URL to use when loading the wasm module for the transcoder
  151147. */
  151148. static WasmModuleURL: string;
  151149. /**
  151150. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  151151. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  151152. * @returns internal format corresponding to the Basis format
  151153. */
  151154. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  151155. private static _WorkerPromise;
  151156. private static _Worker;
  151157. private static _actionId;
  151158. private static _CreateWorkerAsync;
  151159. /**
  151160. * Transcodes a loaded image file to compressed pixel data
  151161. * @param data image data to transcode
  151162. * @param config configuration options for the transcoding
  151163. * @returns a promise resulting in the transcoded image
  151164. */
  151165. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  151166. /**
  151167. * Loads a texture from the transcode result
  151168. * @param texture texture load to
  151169. * @param transcodeResult the result of transcoding the basis file to load from
  151170. */
  151171. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  151172. }
  151173. }
  151174. declare module BABYLON {
  151175. /**
  151176. * Loader for .basis file format
  151177. */
  151178. export class _BasisTextureLoader implements IInternalTextureLoader {
  151179. /**
  151180. * Defines whether the loader supports cascade loading the different faces.
  151181. */
  151182. readonly supportCascades: boolean;
  151183. /**
  151184. * This returns if the loader support the current file information.
  151185. * @param extension defines the file extension of the file being loaded
  151186. * @returns true if the loader can load the specified file
  151187. */
  151188. canLoad(extension: string): boolean;
  151189. /**
  151190. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151191. * @param data contains the texture data
  151192. * @param texture defines the BabylonJS internal texture
  151193. * @param createPolynomials will be true if polynomials have been requested
  151194. * @param onLoad defines the callback to trigger once the texture is ready
  151195. * @param onError defines the callback to trigger in case of error
  151196. */
  151197. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151198. /**
  151199. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151200. * @param data contains the texture data
  151201. * @param texture defines the BabylonJS internal texture
  151202. * @param callback defines the method to call once ready to upload
  151203. */
  151204. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151205. }
  151206. }
  151207. declare module BABYLON {
  151208. /**
  151209. * Defines the basic options interface of a TexturePacker Frame
  151210. */
  151211. export interface ITexturePackerFrame {
  151212. /**
  151213. * The frame ID
  151214. */
  151215. id: number;
  151216. /**
  151217. * The frames Scale
  151218. */
  151219. scale: Vector2;
  151220. /**
  151221. * The Frames offset
  151222. */
  151223. offset: Vector2;
  151224. }
  151225. /**
  151226. * This is a support class for frame Data on texture packer sets.
  151227. */
  151228. export class TexturePackerFrame implements ITexturePackerFrame {
  151229. /**
  151230. * The frame ID
  151231. */
  151232. id: number;
  151233. /**
  151234. * The frames Scale
  151235. */
  151236. scale: Vector2;
  151237. /**
  151238. * The Frames offset
  151239. */
  151240. offset: Vector2;
  151241. /**
  151242. * Initializes a texture package frame.
  151243. * @param id The numerical frame identifier
  151244. * @param scale Scalar Vector2 for UV frame
  151245. * @param offset Vector2 for the frame position in UV units.
  151246. * @returns TexturePackerFrame
  151247. */
  151248. constructor(id: number, scale: Vector2, offset: Vector2);
  151249. }
  151250. }
  151251. declare module BABYLON {
  151252. /**
  151253. * Defines the basic options interface of a TexturePacker
  151254. */
  151255. export interface ITexturePackerOptions {
  151256. /**
  151257. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  151258. */
  151259. map?: string[];
  151260. /**
  151261. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  151262. */
  151263. uvsIn?: string;
  151264. /**
  151265. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  151266. */
  151267. uvsOut?: string;
  151268. /**
  151269. * number representing the layout style. Defaults to LAYOUT_STRIP
  151270. */
  151271. layout?: number;
  151272. /**
  151273. * number of columns if using custom column count layout(2). This defaults to 4.
  151274. */
  151275. colnum?: number;
  151276. /**
  151277. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  151278. */
  151279. updateInputMeshes?: boolean;
  151280. /**
  151281. * boolean flag to dispose all the source textures. Defaults to true.
  151282. */
  151283. disposeSources?: boolean;
  151284. /**
  151285. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  151286. */
  151287. fillBlanks?: boolean;
  151288. /**
  151289. * string value representing the context fill style color. Defaults to 'black'.
  151290. */
  151291. customFillColor?: string;
  151292. /**
  151293. * Width and Height Value of each Frame in the TexturePacker Sets
  151294. */
  151295. frameSize?: number;
  151296. /**
  151297. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  151298. */
  151299. paddingRatio?: number;
  151300. /**
  151301. * Number that declares the fill method for the padding gutter.
  151302. */
  151303. paddingMode?: number;
  151304. /**
  151305. * If in SUBUV_COLOR padding mode what color to use.
  151306. */
  151307. paddingColor?: Color3 | Color4;
  151308. }
  151309. /**
  151310. * Defines the basic interface of a TexturePacker JSON File
  151311. */
  151312. export interface ITexturePackerJSON {
  151313. /**
  151314. * The frame ID
  151315. */
  151316. name: string;
  151317. /**
  151318. * The base64 channel data
  151319. */
  151320. sets: any;
  151321. /**
  151322. * The options of the Packer
  151323. */
  151324. options: ITexturePackerOptions;
  151325. /**
  151326. * The frame data of the Packer
  151327. */
  151328. frames: Array<number>;
  151329. }
  151330. /**
  151331. * This is a support class that generates a series of packed texture sets.
  151332. * @see https://doc.babylonjs.com/babylon101/materials
  151333. */
  151334. export class TexturePacker {
  151335. /** Packer Layout Constant 0 */
  151336. static readonly LAYOUT_STRIP: number;
  151337. /** Packer Layout Constant 1 */
  151338. static readonly LAYOUT_POWER2: number;
  151339. /** Packer Layout Constant 2 */
  151340. static readonly LAYOUT_COLNUM: number;
  151341. /** Packer Layout Constant 0 */
  151342. static readonly SUBUV_WRAP: number;
  151343. /** Packer Layout Constant 1 */
  151344. static readonly SUBUV_EXTEND: number;
  151345. /** Packer Layout Constant 2 */
  151346. static readonly SUBUV_COLOR: number;
  151347. /** The Name of the Texture Package */
  151348. name: string;
  151349. /** The scene scope of the TexturePacker */
  151350. scene: Scene;
  151351. /** The Meshes to target */
  151352. meshes: AbstractMesh[];
  151353. /** Arguments passed with the Constructor */
  151354. options: ITexturePackerOptions;
  151355. /** The promise that is started upon initialization */
  151356. promise: Nullable<Promise<TexturePacker | string>>;
  151357. /** The Container object for the channel sets that are generated */
  151358. sets: object;
  151359. /** The Container array for the frames that are generated */
  151360. frames: TexturePackerFrame[];
  151361. /** The expected number of textures the system is parsing. */
  151362. private _expecting;
  151363. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  151364. private _paddingValue;
  151365. /**
  151366. * Initializes a texture package series from an array of meshes or a single mesh.
  151367. * @param name The name of the package
  151368. * @param meshes The target meshes to compose the package from
  151369. * @param options The arguments that texture packer should follow while building.
  151370. * @param scene The scene which the textures are scoped to.
  151371. * @returns TexturePacker
  151372. */
  151373. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  151374. /**
  151375. * Starts the package process
  151376. * @param resolve The promises resolution function
  151377. * @returns TexturePacker
  151378. */
  151379. private _createFrames;
  151380. /**
  151381. * Calculates the Size of the Channel Sets
  151382. * @returns Vector2
  151383. */
  151384. private _calculateSize;
  151385. /**
  151386. * Calculates the UV data for the frames.
  151387. * @param baseSize the base frameSize
  151388. * @param padding the base frame padding
  151389. * @param dtSize size of the Dynamic Texture for that channel
  151390. * @param dtUnits is 1/dtSize
  151391. * @param update flag to update the input meshes
  151392. */
  151393. private _calculateMeshUVFrames;
  151394. /**
  151395. * Calculates the frames Offset.
  151396. * @param index of the frame
  151397. * @returns Vector2
  151398. */
  151399. private _getFrameOffset;
  151400. /**
  151401. * Updates a Mesh to the frame data
  151402. * @param mesh that is the target
  151403. * @param frameID or the frame index
  151404. */
  151405. private _updateMeshUV;
  151406. /**
  151407. * Updates a Meshes materials to use the texture packer channels
  151408. * @param m is the mesh to target
  151409. * @param force all channels on the packer to be set.
  151410. */
  151411. private _updateTextureReferences;
  151412. /**
  151413. * Public method to set a Mesh to a frame
  151414. * @param m that is the target
  151415. * @param frameID or the frame index
  151416. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  151417. */
  151418. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  151419. /**
  151420. * Starts the async promise to compile the texture packer.
  151421. * @returns Promise<void>
  151422. */
  151423. processAsync(): Promise<void>;
  151424. /**
  151425. * Disposes all textures associated with this packer
  151426. */
  151427. dispose(): void;
  151428. /**
  151429. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  151430. * @param imageType is the image type to use.
  151431. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  151432. */
  151433. download(imageType?: string, quality?: number): void;
  151434. /**
  151435. * Public method to load a texturePacker JSON file.
  151436. * @param data of the JSON file in string format.
  151437. */
  151438. updateFromJSON(data: string): void;
  151439. }
  151440. }
  151441. declare module BABYLON {
  151442. /**
  151443. * 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.
  151444. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  151445. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  151446. */
  151447. export class CustomProceduralTexture extends ProceduralTexture {
  151448. private _animate;
  151449. private _time;
  151450. private _config;
  151451. private _texturePath;
  151452. /**
  151453. * Instantiates a new Custom Procedural Texture.
  151454. * 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.
  151455. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  151456. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  151457. * @param name Define the name of the texture
  151458. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  151459. * @param size Define the size of the texture to create
  151460. * @param scene Define the scene the texture belongs to
  151461. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  151462. * @param generateMipMaps Define if the texture should creates mip maps or not
  151463. */
  151464. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  151465. private _loadJson;
  151466. /**
  151467. * Is the texture ready to be used ? (rendered at least once)
  151468. * @returns true if ready, otherwise, false.
  151469. */
  151470. isReady(): boolean;
  151471. /**
  151472. * Render the texture to its associated render target.
  151473. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  151474. */
  151475. render(useCameraPostProcess?: boolean): void;
  151476. /**
  151477. * Update the list of dependant textures samplers in the shader.
  151478. */
  151479. updateTextures(): void;
  151480. /**
  151481. * Update the uniform values of the procedural texture in the shader.
  151482. */
  151483. updateShaderUniforms(): void;
  151484. /**
  151485. * Define if the texture animates or not.
  151486. */
  151487. get animate(): boolean;
  151488. set animate(value: boolean);
  151489. }
  151490. }
  151491. declare module BABYLON {
  151492. /** @hidden */
  151493. export var noisePixelShader: {
  151494. name: string;
  151495. shader: string;
  151496. };
  151497. }
  151498. declare module BABYLON {
  151499. /**
  151500. * Class used to generate noise procedural textures
  151501. */
  151502. export class NoiseProceduralTexture extends ProceduralTexture {
  151503. /** Gets or sets the start time (default is 0) */
  151504. time: number;
  151505. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  151506. brightness: number;
  151507. /** Defines the number of octaves to process */
  151508. octaves: number;
  151509. /** Defines the level of persistence (0.8 by default) */
  151510. persistence: number;
  151511. /** Gets or sets animation speed factor (default is 1) */
  151512. animationSpeedFactor: number;
  151513. /**
  151514. * Creates a new NoiseProceduralTexture
  151515. * @param name defines the name fo the texture
  151516. * @param size defines the size of the texture (default is 256)
  151517. * @param scene defines the hosting scene
  151518. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  151519. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  151520. */
  151521. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  151522. private _updateShaderUniforms;
  151523. protected _getDefines(): string;
  151524. /** Generate the current state of the procedural texture */
  151525. render(useCameraPostProcess?: boolean): void;
  151526. /**
  151527. * Serializes this noise procedural texture
  151528. * @returns a serialized noise procedural texture object
  151529. */
  151530. serialize(): any;
  151531. /**
  151532. * Clone the texture.
  151533. * @returns the cloned texture
  151534. */
  151535. clone(): NoiseProceduralTexture;
  151536. /**
  151537. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  151538. * @param parsedTexture defines parsed texture data
  151539. * @param scene defines the current scene
  151540. * @param rootUrl defines the root URL containing noise procedural texture information
  151541. * @returns a parsed NoiseProceduralTexture
  151542. */
  151543. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  151544. }
  151545. }
  151546. declare module BABYLON {
  151547. /**
  151548. * Raw cube texture where the raw buffers are passed in
  151549. */
  151550. export class RawCubeTexture extends CubeTexture {
  151551. /**
  151552. * Creates a cube texture where the raw buffers are passed in.
  151553. * @param scene defines the scene the texture is attached to
  151554. * @param data defines the array of data to use to create each face
  151555. * @param size defines the size of the textures
  151556. * @param format defines the format of the data
  151557. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  151558. * @param generateMipMaps defines if the engine should generate the mip levels
  151559. * @param invertY defines if data must be stored with Y axis inverted
  151560. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  151561. * @param compression defines the compression used (null by default)
  151562. */
  151563. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  151564. /**
  151565. * Updates the raw cube texture.
  151566. * @param data defines the data to store
  151567. * @param format defines the data format
  151568. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151569. * @param invertY defines if data must be stored with Y axis inverted
  151570. * @param compression defines the compression used (null by default)
  151571. * @param level defines which level of the texture to update
  151572. */
  151573. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  151574. /**
  151575. * Updates a raw cube texture with RGBD encoded data.
  151576. * @param data defines the array of data [mipmap][face] to use to create each face
  151577. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  151578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  151579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  151580. * @returns a promsie that resolves when the operation is complete
  151581. */
  151582. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  151583. /**
  151584. * Clones the raw cube texture.
  151585. * @return a new cube texture
  151586. */
  151587. clone(): CubeTexture;
  151588. /** @hidden */
  151589. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  151590. }
  151591. }
  151592. declare module BABYLON {
  151593. /**
  151594. * Class used to store 2D array textures containing user data
  151595. */
  151596. export class RawTexture2DArray extends Texture {
  151597. /** Gets or sets the texture format to use */
  151598. format: number;
  151599. /**
  151600. * Create a new RawTexture2DArray
  151601. * @param data defines the data of the texture
  151602. * @param width defines the width of the texture
  151603. * @param height defines the height of the texture
  151604. * @param depth defines the number of layers of the texture
  151605. * @param format defines the texture format to use
  151606. * @param scene defines the hosting scene
  151607. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  151608. * @param invertY defines if texture must be stored with Y axis inverted
  151609. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151610. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  151611. */
  151612. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  151613. /** Gets or sets the texture format to use */
  151614. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  151615. /**
  151616. * Update the texture with new data
  151617. * @param data defines the data to store in the texture
  151618. */
  151619. update(data: ArrayBufferView): void;
  151620. }
  151621. }
  151622. declare module BABYLON {
  151623. /**
  151624. * Class used to store 3D textures containing user data
  151625. */
  151626. export class RawTexture3D extends Texture {
  151627. /** Gets or sets the texture format to use */
  151628. format: number;
  151629. /**
  151630. * Create a new RawTexture3D
  151631. * @param data defines the data of the texture
  151632. * @param width defines the width of the texture
  151633. * @param height defines the height of the texture
  151634. * @param depth defines the depth of the texture
  151635. * @param format defines the texture format to use
  151636. * @param scene defines the hosting scene
  151637. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  151638. * @param invertY defines if texture must be stored with Y axis inverted
  151639. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151640. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  151641. */
  151642. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  151643. /** Gets or sets the texture format to use */
  151644. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  151645. /**
  151646. * Update the texture with new data
  151647. * @param data defines the data to store in the texture
  151648. */
  151649. update(data: ArrayBufferView): void;
  151650. }
  151651. }
  151652. declare module BABYLON {
  151653. /**
  151654. * Creates a refraction texture used by refraction channel of the standard material.
  151655. * It is like a mirror but to see through a material.
  151656. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151657. */
  151658. export class RefractionTexture extends RenderTargetTexture {
  151659. /**
  151660. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  151661. * 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.
  151662. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151663. */
  151664. refractionPlane: Plane;
  151665. /**
  151666. * Define how deep under the surface we should see.
  151667. */
  151668. depth: number;
  151669. /**
  151670. * Creates a refraction texture used by refraction channel of the standard material.
  151671. * It is like a mirror but to see through a material.
  151672. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151673. * @param name Define the texture name
  151674. * @param size Define the size of the underlying texture
  151675. * @param scene Define the scene the refraction belongs to
  151676. * @param generateMipMaps Define if we need to generate mips level for the refraction
  151677. */
  151678. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  151679. /**
  151680. * Clone the refraction texture.
  151681. * @returns the cloned texture
  151682. */
  151683. clone(): RefractionTexture;
  151684. /**
  151685. * Serialize the texture to a JSON representation you could use in Parse later on
  151686. * @returns the serialized JSON representation
  151687. */
  151688. serialize(): any;
  151689. }
  151690. }
  151691. declare module BABYLON {
  151692. /**
  151693. * Block used to add support for vertex skinning (bones)
  151694. */
  151695. export class BonesBlock extends NodeMaterialBlock {
  151696. /**
  151697. * Creates a new BonesBlock
  151698. * @param name defines the block name
  151699. */
  151700. constructor(name: string);
  151701. /**
  151702. * Initialize the block and prepare the context for build
  151703. * @param state defines the state that will be used for the build
  151704. */
  151705. initialize(state: NodeMaterialBuildState): void;
  151706. /**
  151707. * Gets the current class name
  151708. * @returns the class name
  151709. */
  151710. getClassName(): string;
  151711. /**
  151712. * Gets the matrix indices input component
  151713. */
  151714. get matricesIndices(): NodeMaterialConnectionPoint;
  151715. /**
  151716. * Gets the matrix weights input component
  151717. */
  151718. get matricesWeights(): NodeMaterialConnectionPoint;
  151719. /**
  151720. * Gets the extra matrix indices input component
  151721. */
  151722. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  151723. /**
  151724. * Gets the extra matrix weights input component
  151725. */
  151726. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  151727. /**
  151728. * Gets the world input component
  151729. */
  151730. get world(): NodeMaterialConnectionPoint;
  151731. /**
  151732. * Gets the output component
  151733. */
  151734. get output(): NodeMaterialConnectionPoint;
  151735. autoConfigure(material: NodeMaterial): void;
  151736. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  151737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151739. protected _buildBlock(state: NodeMaterialBuildState): this;
  151740. }
  151741. }
  151742. declare module BABYLON {
  151743. /**
  151744. * Block used to add support for instances
  151745. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  151746. */
  151747. export class InstancesBlock extends NodeMaterialBlock {
  151748. /**
  151749. * Creates a new InstancesBlock
  151750. * @param name defines the block name
  151751. */
  151752. constructor(name: string);
  151753. /**
  151754. * Gets the current class name
  151755. * @returns the class name
  151756. */
  151757. getClassName(): string;
  151758. /**
  151759. * Gets the first world row input component
  151760. */
  151761. get world0(): NodeMaterialConnectionPoint;
  151762. /**
  151763. * Gets the second world row input component
  151764. */
  151765. get world1(): NodeMaterialConnectionPoint;
  151766. /**
  151767. * Gets the third world row input component
  151768. */
  151769. get world2(): NodeMaterialConnectionPoint;
  151770. /**
  151771. * Gets the forth world row input component
  151772. */
  151773. get world3(): NodeMaterialConnectionPoint;
  151774. /**
  151775. * Gets the world input component
  151776. */
  151777. get world(): NodeMaterialConnectionPoint;
  151778. /**
  151779. * Gets the output component
  151780. */
  151781. get output(): NodeMaterialConnectionPoint;
  151782. /**
  151783. * Gets the isntanceID component
  151784. */
  151785. get instanceID(): NodeMaterialConnectionPoint;
  151786. autoConfigure(material: NodeMaterial): void;
  151787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  151788. protected _buildBlock(state: NodeMaterialBuildState): this;
  151789. }
  151790. }
  151791. declare module BABYLON {
  151792. /**
  151793. * Block used to add morph targets support to vertex shader
  151794. */
  151795. export class MorphTargetsBlock extends NodeMaterialBlock {
  151796. private _repeatableContentAnchor;
  151797. /**
  151798. * Create a new MorphTargetsBlock
  151799. * @param name defines the block name
  151800. */
  151801. constructor(name: string);
  151802. /**
  151803. * Gets the current class name
  151804. * @returns the class name
  151805. */
  151806. getClassName(): string;
  151807. /**
  151808. * Gets the position input component
  151809. */
  151810. get position(): NodeMaterialConnectionPoint;
  151811. /**
  151812. * Gets the normal input component
  151813. */
  151814. get normal(): NodeMaterialConnectionPoint;
  151815. /**
  151816. * Gets the tangent input component
  151817. */
  151818. get tangent(): NodeMaterialConnectionPoint;
  151819. /**
  151820. * Gets the tangent input component
  151821. */
  151822. get uv(): NodeMaterialConnectionPoint;
  151823. /**
  151824. * Gets the position output component
  151825. */
  151826. get positionOutput(): NodeMaterialConnectionPoint;
  151827. /**
  151828. * Gets the normal output component
  151829. */
  151830. get normalOutput(): NodeMaterialConnectionPoint;
  151831. /**
  151832. * Gets the tangent output component
  151833. */
  151834. get tangentOutput(): NodeMaterialConnectionPoint;
  151835. /**
  151836. * Gets the tangent output component
  151837. */
  151838. get uvOutput(): NodeMaterialConnectionPoint;
  151839. initialize(state: NodeMaterialBuildState): void;
  151840. autoConfigure(material: NodeMaterial): void;
  151841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151843. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  151844. protected _buildBlock(state: NodeMaterialBuildState): this;
  151845. }
  151846. }
  151847. declare module BABYLON {
  151848. /**
  151849. * Block used to get data information from a light
  151850. */
  151851. export class LightInformationBlock extends NodeMaterialBlock {
  151852. private _lightDataUniformName;
  151853. private _lightColorUniformName;
  151854. private _lightTypeDefineName;
  151855. /**
  151856. * Gets or sets the light associated with this block
  151857. */
  151858. light: Nullable<Light>;
  151859. /**
  151860. * Creates a new LightInformationBlock
  151861. * @param name defines the block name
  151862. */
  151863. constructor(name: string);
  151864. /**
  151865. * Gets the current class name
  151866. * @returns the class name
  151867. */
  151868. getClassName(): string;
  151869. /**
  151870. * Gets the world position input component
  151871. */
  151872. get worldPosition(): NodeMaterialConnectionPoint;
  151873. /**
  151874. * Gets the direction output component
  151875. */
  151876. get direction(): NodeMaterialConnectionPoint;
  151877. /**
  151878. * Gets the direction output component
  151879. */
  151880. get color(): NodeMaterialConnectionPoint;
  151881. /**
  151882. * Gets the direction output component
  151883. */
  151884. get intensity(): NodeMaterialConnectionPoint;
  151885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151887. protected _buildBlock(state: NodeMaterialBuildState): this;
  151888. serialize(): any;
  151889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151890. }
  151891. }
  151892. declare module BABYLON {
  151893. /**
  151894. * Block used to add image processing support to fragment shader
  151895. */
  151896. export class ImageProcessingBlock extends NodeMaterialBlock {
  151897. /**
  151898. * Create a new ImageProcessingBlock
  151899. * @param name defines the block name
  151900. */
  151901. constructor(name: string);
  151902. /**
  151903. * Gets the current class name
  151904. * @returns the class name
  151905. */
  151906. getClassName(): string;
  151907. /**
  151908. * Gets the color input component
  151909. */
  151910. get color(): NodeMaterialConnectionPoint;
  151911. /**
  151912. * Gets the output component
  151913. */
  151914. get output(): NodeMaterialConnectionPoint;
  151915. /**
  151916. * Initialize the block and prepare the context for build
  151917. * @param state defines the state that will be used for the build
  151918. */
  151919. initialize(state: NodeMaterialBuildState): void;
  151920. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  151921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151923. protected _buildBlock(state: NodeMaterialBuildState): this;
  151924. }
  151925. }
  151926. declare module BABYLON {
  151927. /**
  151928. * Block used to pertub normals based on a normal map
  151929. */
  151930. export class PerturbNormalBlock extends NodeMaterialBlock {
  151931. private _tangentSpaceParameterName;
  151932. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  151933. invertX: boolean;
  151934. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  151935. invertY: boolean;
  151936. /**
  151937. * Create a new PerturbNormalBlock
  151938. * @param name defines the block name
  151939. */
  151940. constructor(name: string);
  151941. /**
  151942. * Gets the current class name
  151943. * @returns the class name
  151944. */
  151945. getClassName(): string;
  151946. /**
  151947. * Gets the world position input component
  151948. */
  151949. get worldPosition(): NodeMaterialConnectionPoint;
  151950. /**
  151951. * Gets the world normal input component
  151952. */
  151953. get worldNormal(): NodeMaterialConnectionPoint;
  151954. /**
  151955. * Gets the world tangent input component
  151956. */
  151957. get worldTangent(): NodeMaterialConnectionPoint;
  151958. /**
  151959. * Gets the uv input component
  151960. */
  151961. get uv(): NodeMaterialConnectionPoint;
  151962. /**
  151963. * Gets the normal map color input component
  151964. */
  151965. get normalMapColor(): NodeMaterialConnectionPoint;
  151966. /**
  151967. * Gets the strength input component
  151968. */
  151969. get strength(): NodeMaterialConnectionPoint;
  151970. /**
  151971. * Gets the output component
  151972. */
  151973. get output(): NodeMaterialConnectionPoint;
  151974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151976. autoConfigure(material: NodeMaterial): void;
  151977. protected _buildBlock(state: NodeMaterialBuildState): this;
  151978. protected _dumpPropertiesCode(): string;
  151979. serialize(): any;
  151980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151981. }
  151982. }
  151983. declare module BABYLON {
  151984. /**
  151985. * Block used to discard a pixel if a value is smaller than a cutoff
  151986. */
  151987. export class DiscardBlock extends NodeMaterialBlock {
  151988. /**
  151989. * Create a new DiscardBlock
  151990. * @param name defines the block name
  151991. */
  151992. constructor(name: string);
  151993. /**
  151994. * Gets the current class name
  151995. * @returns the class name
  151996. */
  151997. getClassName(): string;
  151998. /**
  151999. * Gets the color input component
  152000. */
  152001. get value(): NodeMaterialConnectionPoint;
  152002. /**
  152003. * Gets the cutoff input component
  152004. */
  152005. get cutoff(): NodeMaterialConnectionPoint;
  152006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152007. }
  152008. }
  152009. declare module BABYLON {
  152010. /**
  152011. * Block used to test if the fragment shader is front facing
  152012. */
  152013. export class FrontFacingBlock extends NodeMaterialBlock {
  152014. /**
  152015. * Creates a new FrontFacingBlock
  152016. * @param name defines the block name
  152017. */
  152018. constructor(name: string);
  152019. /**
  152020. * Gets the current class name
  152021. * @returns the class name
  152022. */
  152023. getClassName(): string;
  152024. /**
  152025. * Gets the output component
  152026. */
  152027. get output(): NodeMaterialConnectionPoint;
  152028. protected _buildBlock(state: NodeMaterialBuildState): this;
  152029. }
  152030. }
  152031. declare module BABYLON {
  152032. /**
  152033. * Block used to get the derivative value on x and y of a given input
  152034. */
  152035. export class DerivativeBlock extends NodeMaterialBlock {
  152036. /**
  152037. * Create a new DerivativeBlock
  152038. * @param name defines the block name
  152039. */
  152040. constructor(name: string);
  152041. /**
  152042. * Gets the current class name
  152043. * @returns the class name
  152044. */
  152045. getClassName(): string;
  152046. /**
  152047. * Gets the input component
  152048. */
  152049. get input(): NodeMaterialConnectionPoint;
  152050. /**
  152051. * Gets the derivative output on x
  152052. */
  152053. get dx(): NodeMaterialConnectionPoint;
  152054. /**
  152055. * Gets the derivative output on y
  152056. */
  152057. get dy(): NodeMaterialConnectionPoint;
  152058. protected _buildBlock(state: NodeMaterialBuildState): this;
  152059. }
  152060. }
  152061. declare module BABYLON {
  152062. /**
  152063. * Block used to make gl_FragCoord available
  152064. */
  152065. export class FragCoordBlock extends NodeMaterialBlock {
  152066. /**
  152067. * Creates a new FragCoordBlock
  152068. * @param name defines the block name
  152069. */
  152070. constructor(name: string);
  152071. /**
  152072. * Gets the current class name
  152073. * @returns the class name
  152074. */
  152075. getClassName(): string;
  152076. /**
  152077. * Gets the xy component
  152078. */
  152079. get xy(): NodeMaterialConnectionPoint;
  152080. /**
  152081. * Gets the xyz component
  152082. */
  152083. get xyz(): NodeMaterialConnectionPoint;
  152084. /**
  152085. * Gets the xyzw component
  152086. */
  152087. get xyzw(): NodeMaterialConnectionPoint;
  152088. /**
  152089. * Gets the x component
  152090. */
  152091. get x(): NodeMaterialConnectionPoint;
  152092. /**
  152093. * Gets the y component
  152094. */
  152095. get y(): NodeMaterialConnectionPoint;
  152096. /**
  152097. * Gets the z component
  152098. */
  152099. get z(): NodeMaterialConnectionPoint;
  152100. /**
  152101. * Gets the w component
  152102. */
  152103. get output(): NodeMaterialConnectionPoint;
  152104. protected writeOutputs(state: NodeMaterialBuildState): string;
  152105. protected _buildBlock(state: NodeMaterialBuildState): this;
  152106. }
  152107. }
  152108. declare module BABYLON {
  152109. /**
  152110. * Block used to get the screen sizes
  152111. */
  152112. export class ScreenSizeBlock extends NodeMaterialBlock {
  152113. private _varName;
  152114. private _scene;
  152115. /**
  152116. * Creates a new ScreenSizeBlock
  152117. * @param name defines the block name
  152118. */
  152119. constructor(name: string);
  152120. /**
  152121. * Gets the current class name
  152122. * @returns the class name
  152123. */
  152124. getClassName(): string;
  152125. /**
  152126. * Gets the xy component
  152127. */
  152128. get xy(): NodeMaterialConnectionPoint;
  152129. /**
  152130. * Gets the x component
  152131. */
  152132. get x(): NodeMaterialConnectionPoint;
  152133. /**
  152134. * Gets the y component
  152135. */
  152136. get y(): NodeMaterialConnectionPoint;
  152137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152138. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  152139. protected _buildBlock(state: NodeMaterialBuildState): this;
  152140. }
  152141. }
  152142. declare module BABYLON {
  152143. /**
  152144. * Block used to add support for scene fog
  152145. */
  152146. export class FogBlock extends NodeMaterialBlock {
  152147. private _fogDistanceName;
  152148. private _fogParameters;
  152149. /**
  152150. * Create a new FogBlock
  152151. * @param name defines the block name
  152152. */
  152153. constructor(name: string);
  152154. /**
  152155. * Gets the current class name
  152156. * @returns the class name
  152157. */
  152158. getClassName(): string;
  152159. /**
  152160. * Gets the world position input component
  152161. */
  152162. get worldPosition(): NodeMaterialConnectionPoint;
  152163. /**
  152164. * Gets the view input component
  152165. */
  152166. get view(): NodeMaterialConnectionPoint;
  152167. /**
  152168. * Gets the color input component
  152169. */
  152170. get input(): NodeMaterialConnectionPoint;
  152171. /**
  152172. * Gets the fog color input component
  152173. */
  152174. get fogColor(): NodeMaterialConnectionPoint;
  152175. /**
  152176. * Gets the output component
  152177. */
  152178. get output(): NodeMaterialConnectionPoint;
  152179. autoConfigure(material: NodeMaterial): void;
  152180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152182. protected _buildBlock(state: NodeMaterialBuildState): this;
  152183. }
  152184. }
  152185. declare module BABYLON {
  152186. /**
  152187. * Block used to add light in the fragment shader
  152188. */
  152189. export class LightBlock extends NodeMaterialBlock {
  152190. private _lightId;
  152191. /**
  152192. * Gets or sets the light associated with this block
  152193. */
  152194. light: Nullable<Light>;
  152195. /**
  152196. * Create a new LightBlock
  152197. * @param name defines the block name
  152198. */
  152199. constructor(name: string);
  152200. /**
  152201. * Gets the current class name
  152202. * @returns the class name
  152203. */
  152204. getClassName(): string;
  152205. /**
  152206. * Gets the world position input component
  152207. */
  152208. get worldPosition(): NodeMaterialConnectionPoint;
  152209. /**
  152210. * Gets the world normal input component
  152211. */
  152212. get worldNormal(): NodeMaterialConnectionPoint;
  152213. /**
  152214. * Gets the camera (or eye) position component
  152215. */
  152216. get cameraPosition(): NodeMaterialConnectionPoint;
  152217. /**
  152218. * Gets the glossiness component
  152219. */
  152220. get glossiness(): NodeMaterialConnectionPoint;
  152221. /**
  152222. * Gets the glossinness power component
  152223. */
  152224. get glossPower(): NodeMaterialConnectionPoint;
  152225. /**
  152226. * Gets the diffuse color component
  152227. */
  152228. get diffuseColor(): NodeMaterialConnectionPoint;
  152229. /**
  152230. * Gets the specular color component
  152231. */
  152232. get specularColor(): NodeMaterialConnectionPoint;
  152233. /**
  152234. * Gets the view matrix component
  152235. */
  152236. get view(): NodeMaterialConnectionPoint;
  152237. /**
  152238. * Gets the diffuse output component
  152239. */
  152240. get diffuseOutput(): NodeMaterialConnectionPoint;
  152241. /**
  152242. * Gets the specular output component
  152243. */
  152244. get specularOutput(): NodeMaterialConnectionPoint;
  152245. /**
  152246. * Gets the shadow output component
  152247. */
  152248. get shadow(): NodeMaterialConnectionPoint;
  152249. autoConfigure(material: NodeMaterial): void;
  152250. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152251. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  152252. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152253. private _injectVertexCode;
  152254. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152255. serialize(): any;
  152256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152257. }
  152258. }
  152259. declare module BABYLON {
  152260. /**
  152261. * Block used to read a reflection texture from a sampler
  152262. */
  152263. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  152264. /**
  152265. * Create a new ReflectionTextureBlock
  152266. * @param name defines the block name
  152267. */
  152268. constructor(name: string);
  152269. /**
  152270. * Gets the current class name
  152271. * @returns the class name
  152272. */
  152273. getClassName(): string;
  152274. /**
  152275. * Gets the world position input component
  152276. */
  152277. get position(): NodeMaterialConnectionPoint;
  152278. /**
  152279. * Gets the world position input component
  152280. */
  152281. get worldPosition(): NodeMaterialConnectionPoint;
  152282. /**
  152283. * Gets the world normal input component
  152284. */
  152285. get worldNormal(): NodeMaterialConnectionPoint;
  152286. /**
  152287. * Gets the world input component
  152288. */
  152289. get world(): NodeMaterialConnectionPoint;
  152290. /**
  152291. * Gets the camera (or eye) position component
  152292. */
  152293. get cameraPosition(): NodeMaterialConnectionPoint;
  152294. /**
  152295. * Gets the view input component
  152296. */
  152297. get view(): NodeMaterialConnectionPoint;
  152298. /**
  152299. * Gets the rgb output component
  152300. */
  152301. get rgb(): NodeMaterialConnectionPoint;
  152302. /**
  152303. * Gets the rgba output component
  152304. */
  152305. get rgba(): NodeMaterialConnectionPoint;
  152306. /**
  152307. * Gets the r output component
  152308. */
  152309. get r(): NodeMaterialConnectionPoint;
  152310. /**
  152311. * Gets the g output component
  152312. */
  152313. get g(): NodeMaterialConnectionPoint;
  152314. /**
  152315. * Gets the b output component
  152316. */
  152317. get b(): NodeMaterialConnectionPoint;
  152318. /**
  152319. * Gets the a output component
  152320. */
  152321. get a(): NodeMaterialConnectionPoint;
  152322. autoConfigure(material: NodeMaterial): void;
  152323. protected _buildBlock(state: NodeMaterialBuildState): this;
  152324. }
  152325. }
  152326. declare module BABYLON {
  152327. /**
  152328. * Block used to add 2 vectors
  152329. */
  152330. export class AddBlock extends NodeMaterialBlock {
  152331. /**
  152332. * Creates a new AddBlock
  152333. * @param name defines the block name
  152334. */
  152335. constructor(name: string);
  152336. /**
  152337. * Gets the current class name
  152338. * @returns the class name
  152339. */
  152340. getClassName(): string;
  152341. /**
  152342. * Gets the left operand input component
  152343. */
  152344. get left(): NodeMaterialConnectionPoint;
  152345. /**
  152346. * Gets the right operand input component
  152347. */
  152348. get right(): NodeMaterialConnectionPoint;
  152349. /**
  152350. * Gets the output component
  152351. */
  152352. get output(): NodeMaterialConnectionPoint;
  152353. protected _buildBlock(state: NodeMaterialBuildState): this;
  152354. }
  152355. }
  152356. declare module BABYLON {
  152357. /**
  152358. * Block used to scale a vector by a float
  152359. */
  152360. export class ScaleBlock extends NodeMaterialBlock {
  152361. /**
  152362. * Creates a new ScaleBlock
  152363. * @param name defines the block name
  152364. */
  152365. constructor(name: string);
  152366. /**
  152367. * Gets the current class name
  152368. * @returns the class name
  152369. */
  152370. getClassName(): string;
  152371. /**
  152372. * Gets the input component
  152373. */
  152374. get input(): NodeMaterialConnectionPoint;
  152375. /**
  152376. * Gets the factor input component
  152377. */
  152378. get factor(): NodeMaterialConnectionPoint;
  152379. /**
  152380. * Gets the output component
  152381. */
  152382. get output(): NodeMaterialConnectionPoint;
  152383. protected _buildBlock(state: NodeMaterialBuildState): this;
  152384. }
  152385. }
  152386. declare module BABYLON {
  152387. /**
  152388. * Block used to clamp a float
  152389. */
  152390. export class ClampBlock extends NodeMaterialBlock {
  152391. /** Gets or sets the minimum range */
  152392. minimum: number;
  152393. /** Gets or sets the maximum range */
  152394. maximum: number;
  152395. /**
  152396. * Creates a new ClampBlock
  152397. * @param name defines the block name
  152398. */
  152399. constructor(name: string);
  152400. /**
  152401. * Gets the current class name
  152402. * @returns the class name
  152403. */
  152404. getClassName(): string;
  152405. /**
  152406. * Gets the value input component
  152407. */
  152408. get value(): NodeMaterialConnectionPoint;
  152409. /**
  152410. * Gets the output component
  152411. */
  152412. get output(): NodeMaterialConnectionPoint;
  152413. protected _buildBlock(state: NodeMaterialBuildState): this;
  152414. protected _dumpPropertiesCode(): string;
  152415. serialize(): any;
  152416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152417. }
  152418. }
  152419. declare module BABYLON {
  152420. /**
  152421. * Block used to apply a cross product between 2 vectors
  152422. */
  152423. export class CrossBlock extends NodeMaterialBlock {
  152424. /**
  152425. * Creates a new CrossBlock
  152426. * @param name defines the block name
  152427. */
  152428. constructor(name: string);
  152429. /**
  152430. * Gets the current class name
  152431. * @returns the class name
  152432. */
  152433. getClassName(): string;
  152434. /**
  152435. * Gets the left operand input component
  152436. */
  152437. get left(): NodeMaterialConnectionPoint;
  152438. /**
  152439. * Gets the right operand input component
  152440. */
  152441. get right(): NodeMaterialConnectionPoint;
  152442. /**
  152443. * Gets the output component
  152444. */
  152445. get output(): NodeMaterialConnectionPoint;
  152446. protected _buildBlock(state: NodeMaterialBuildState): this;
  152447. }
  152448. }
  152449. declare module BABYLON {
  152450. /**
  152451. * Block used to apply a dot product between 2 vectors
  152452. */
  152453. export class DotBlock extends NodeMaterialBlock {
  152454. /**
  152455. * Creates a new DotBlock
  152456. * @param name defines the block name
  152457. */
  152458. constructor(name: string);
  152459. /**
  152460. * Gets the current class name
  152461. * @returns the class name
  152462. */
  152463. getClassName(): string;
  152464. /**
  152465. * Gets the left operand input component
  152466. */
  152467. get left(): NodeMaterialConnectionPoint;
  152468. /**
  152469. * Gets the right operand input component
  152470. */
  152471. get right(): NodeMaterialConnectionPoint;
  152472. /**
  152473. * Gets the output component
  152474. */
  152475. get output(): NodeMaterialConnectionPoint;
  152476. protected _buildBlock(state: NodeMaterialBuildState): this;
  152477. }
  152478. }
  152479. declare module BABYLON {
  152480. /**
  152481. * Block used to normalize a vector
  152482. */
  152483. export class NormalizeBlock extends NodeMaterialBlock {
  152484. /**
  152485. * Creates a new NormalizeBlock
  152486. * @param name defines the block name
  152487. */
  152488. constructor(name: string);
  152489. /**
  152490. * Gets the current class name
  152491. * @returns the class name
  152492. */
  152493. getClassName(): string;
  152494. /**
  152495. * Gets the input component
  152496. */
  152497. get input(): NodeMaterialConnectionPoint;
  152498. /**
  152499. * Gets the output component
  152500. */
  152501. get output(): NodeMaterialConnectionPoint;
  152502. protected _buildBlock(state: NodeMaterialBuildState): this;
  152503. }
  152504. }
  152505. declare module BABYLON {
  152506. /**
  152507. * Block used to create a Color3/4 out of individual inputs (one for each component)
  152508. */
  152509. export class ColorMergerBlock extends NodeMaterialBlock {
  152510. /**
  152511. * Create a new ColorMergerBlock
  152512. * @param name defines the block name
  152513. */
  152514. constructor(name: string);
  152515. /**
  152516. * Gets the current class name
  152517. * @returns the class name
  152518. */
  152519. getClassName(): string;
  152520. /**
  152521. * Gets the rgb component (input)
  152522. */
  152523. get rgbIn(): NodeMaterialConnectionPoint;
  152524. /**
  152525. * Gets the r component (input)
  152526. */
  152527. get r(): NodeMaterialConnectionPoint;
  152528. /**
  152529. * Gets the g component (input)
  152530. */
  152531. get g(): NodeMaterialConnectionPoint;
  152532. /**
  152533. * Gets the b component (input)
  152534. */
  152535. get b(): NodeMaterialConnectionPoint;
  152536. /**
  152537. * Gets the a component (input)
  152538. */
  152539. get a(): NodeMaterialConnectionPoint;
  152540. /**
  152541. * Gets the rgba component (output)
  152542. */
  152543. get rgba(): NodeMaterialConnectionPoint;
  152544. /**
  152545. * Gets the rgb component (output)
  152546. */
  152547. get rgbOut(): NodeMaterialConnectionPoint;
  152548. /**
  152549. * Gets the rgb component (output)
  152550. * @deprecated Please use rgbOut instead.
  152551. */
  152552. get rgb(): NodeMaterialConnectionPoint;
  152553. protected _buildBlock(state: NodeMaterialBuildState): this;
  152554. }
  152555. }
  152556. declare module BABYLON {
  152557. /**
  152558. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  152559. */
  152560. export class VectorSplitterBlock extends NodeMaterialBlock {
  152561. /**
  152562. * Create a new VectorSplitterBlock
  152563. * @param name defines the block name
  152564. */
  152565. constructor(name: string);
  152566. /**
  152567. * Gets the current class name
  152568. * @returns the class name
  152569. */
  152570. getClassName(): string;
  152571. /**
  152572. * Gets the xyzw component (input)
  152573. */
  152574. get xyzw(): NodeMaterialConnectionPoint;
  152575. /**
  152576. * Gets the xyz component (input)
  152577. */
  152578. get xyzIn(): NodeMaterialConnectionPoint;
  152579. /**
  152580. * Gets the xy component (input)
  152581. */
  152582. get xyIn(): NodeMaterialConnectionPoint;
  152583. /**
  152584. * Gets the xyz component (output)
  152585. */
  152586. get xyzOut(): NodeMaterialConnectionPoint;
  152587. /**
  152588. * Gets the xy component (output)
  152589. */
  152590. get xyOut(): NodeMaterialConnectionPoint;
  152591. /**
  152592. * Gets the x component (output)
  152593. */
  152594. get x(): NodeMaterialConnectionPoint;
  152595. /**
  152596. * Gets the y component (output)
  152597. */
  152598. get y(): NodeMaterialConnectionPoint;
  152599. /**
  152600. * Gets the z component (output)
  152601. */
  152602. get z(): NodeMaterialConnectionPoint;
  152603. /**
  152604. * Gets the w component (output)
  152605. */
  152606. get w(): NodeMaterialConnectionPoint;
  152607. protected _inputRename(name: string): string;
  152608. protected _outputRename(name: string): string;
  152609. protected _buildBlock(state: NodeMaterialBuildState): this;
  152610. }
  152611. }
  152612. declare module BABYLON {
  152613. /**
  152614. * Block used to lerp between 2 values
  152615. */
  152616. export class LerpBlock extends NodeMaterialBlock {
  152617. /**
  152618. * Creates a new LerpBlock
  152619. * @param name defines the block name
  152620. */
  152621. constructor(name: string);
  152622. /**
  152623. * Gets the current class name
  152624. * @returns the class name
  152625. */
  152626. getClassName(): string;
  152627. /**
  152628. * Gets the left operand input component
  152629. */
  152630. get left(): NodeMaterialConnectionPoint;
  152631. /**
  152632. * Gets the right operand input component
  152633. */
  152634. get right(): NodeMaterialConnectionPoint;
  152635. /**
  152636. * Gets the gradient operand input component
  152637. */
  152638. get gradient(): NodeMaterialConnectionPoint;
  152639. /**
  152640. * Gets the output component
  152641. */
  152642. get output(): NodeMaterialConnectionPoint;
  152643. protected _buildBlock(state: NodeMaterialBuildState): this;
  152644. }
  152645. }
  152646. declare module BABYLON {
  152647. /**
  152648. * Block used to divide 2 vectors
  152649. */
  152650. export class DivideBlock extends NodeMaterialBlock {
  152651. /**
  152652. * Creates a new DivideBlock
  152653. * @param name defines the block name
  152654. */
  152655. constructor(name: string);
  152656. /**
  152657. * Gets the current class name
  152658. * @returns the class name
  152659. */
  152660. getClassName(): string;
  152661. /**
  152662. * Gets the left operand input component
  152663. */
  152664. get left(): NodeMaterialConnectionPoint;
  152665. /**
  152666. * Gets the right operand input component
  152667. */
  152668. get right(): NodeMaterialConnectionPoint;
  152669. /**
  152670. * Gets the output component
  152671. */
  152672. get output(): NodeMaterialConnectionPoint;
  152673. protected _buildBlock(state: NodeMaterialBuildState): this;
  152674. }
  152675. }
  152676. declare module BABYLON {
  152677. /**
  152678. * Block used to subtract 2 vectors
  152679. */
  152680. export class SubtractBlock extends NodeMaterialBlock {
  152681. /**
  152682. * Creates a new SubtractBlock
  152683. * @param name defines the block name
  152684. */
  152685. constructor(name: string);
  152686. /**
  152687. * Gets the current class name
  152688. * @returns the class name
  152689. */
  152690. getClassName(): string;
  152691. /**
  152692. * Gets the left operand input component
  152693. */
  152694. get left(): NodeMaterialConnectionPoint;
  152695. /**
  152696. * Gets the right operand input component
  152697. */
  152698. get right(): NodeMaterialConnectionPoint;
  152699. /**
  152700. * Gets the output component
  152701. */
  152702. get output(): NodeMaterialConnectionPoint;
  152703. protected _buildBlock(state: NodeMaterialBuildState): this;
  152704. }
  152705. }
  152706. declare module BABYLON {
  152707. /**
  152708. * Block used to step a value
  152709. */
  152710. export class StepBlock extends NodeMaterialBlock {
  152711. /**
  152712. * Creates a new StepBlock
  152713. * @param name defines the block name
  152714. */
  152715. constructor(name: string);
  152716. /**
  152717. * Gets the current class name
  152718. * @returns the class name
  152719. */
  152720. getClassName(): string;
  152721. /**
  152722. * Gets the value operand input component
  152723. */
  152724. get value(): NodeMaterialConnectionPoint;
  152725. /**
  152726. * Gets the edge operand input component
  152727. */
  152728. get edge(): NodeMaterialConnectionPoint;
  152729. /**
  152730. * Gets the output component
  152731. */
  152732. get output(): NodeMaterialConnectionPoint;
  152733. protected _buildBlock(state: NodeMaterialBuildState): this;
  152734. }
  152735. }
  152736. declare module BABYLON {
  152737. /**
  152738. * Block used to get the opposite (1 - x) of a value
  152739. */
  152740. export class OneMinusBlock extends NodeMaterialBlock {
  152741. /**
  152742. * Creates a new OneMinusBlock
  152743. * @param name defines the block name
  152744. */
  152745. constructor(name: string);
  152746. /**
  152747. * Gets the current class name
  152748. * @returns the class name
  152749. */
  152750. getClassName(): string;
  152751. /**
  152752. * Gets the input component
  152753. */
  152754. get input(): NodeMaterialConnectionPoint;
  152755. /**
  152756. * Gets the output component
  152757. */
  152758. get output(): NodeMaterialConnectionPoint;
  152759. protected _buildBlock(state: NodeMaterialBuildState): this;
  152760. }
  152761. }
  152762. declare module BABYLON {
  152763. /**
  152764. * Block used to get the view direction
  152765. */
  152766. export class ViewDirectionBlock extends NodeMaterialBlock {
  152767. /**
  152768. * Creates a new ViewDirectionBlock
  152769. * @param name defines the block name
  152770. */
  152771. constructor(name: string);
  152772. /**
  152773. * Gets the current class name
  152774. * @returns the class name
  152775. */
  152776. getClassName(): string;
  152777. /**
  152778. * Gets the world position component
  152779. */
  152780. get worldPosition(): NodeMaterialConnectionPoint;
  152781. /**
  152782. * Gets the camera position component
  152783. */
  152784. get cameraPosition(): NodeMaterialConnectionPoint;
  152785. /**
  152786. * Gets the output component
  152787. */
  152788. get output(): NodeMaterialConnectionPoint;
  152789. autoConfigure(material: NodeMaterial): void;
  152790. protected _buildBlock(state: NodeMaterialBuildState): this;
  152791. }
  152792. }
  152793. declare module BABYLON {
  152794. /**
  152795. * Block used to compute fresnel value
  152796. */
  152797. export class FresnelBlock extends NodeMaterialBlock {
  152798. /**
  152799. * Create a new FresnelBlock
  152800. * @param name defines the block name
  152801. */
  152802. constructor(name: string);
  152803. /**
  152804. * Gets the current class name
  152805. * @returns the class name
  152806. */
  152807. getClassName(): string;
  152808. /**
  152809. * Gets the world normal input component
  152810. */
  152811. get worldNormal(): NodeMaterialConnectionPoint;
  152812. /**
  152813. * Gets the view direction input component
  152814. */
  152815. get viewDirection(): NodeMaterialConnectionPoint;
  152816. /**
  152817. * Gets the bias input component
  152818. */
  152819. get bias(): NodeMaterialConnectionPoint;
  152820. /**
  152821. * Gets the camera (or eye) position component
  152822. */
  152823. get power(): NodeMaterialConnectionPoint;
  152824. /**
  152825. * Gets the fresnel output component
  152826. */
  152827. get fresnel(): NodeMaterialConnectionPoint;
  152828. autoConfigure(material: NodeMaterial): void;
  152829. protected _buildBlock(state: NodeMaterialBuildState): this;
  152830. }
  152831. }
  152832. declare module BABYLON {
  152833. /**
  152834. * Block used to get the max of 2 values
  152835. */
  152836. export class MaxBlock extends NodeMaterialBlock {
  152837. /**
  152838. * Creates a new MaxBlock
  152839. * @param name defines the block name
  152840. */
  152841. constructor(name: string);
  152842. /**
  152843. * Gets the current class name
  152844. * @returns the class name
  152845. */
  152846. getClassName(): string;
  152847. /**
  152848. * Gets the left operand input component
  152849. */
  152850. get left(): NodeMaterialConnectionPoint;
  152851. /**
  152852. * Gets the right operand input component
  152853. */
  152854. get right(): NodeMaterialConnectionPoint;
  152855. /**
  152856. * Gets the output component
  152857. */
  152858. get output(): NodeMaterialConnectionPoint;
  152859. protected _buildBlock(state: NodeMaterialBuildState): this;
  152860. }
  152861. }
  152862. declare module BABYLON {
  152863. /**
  152864. * Block used to get the min of 2 values
  152865. */
  152866. export class MinBlock extends NodeMaterialBlock {
  152867. /**
  152868. * Creates a new MinBlock
  152869. * @param name defines the block name
  152870. */
  152871. constructor(name: string);
  152872. /**
  152873. * Gets the current class name
  152874. * @returns the class name
  152875. */
  152876. getClassName(): string;
  152877. /**
  152878. * Gets the left operand input component
  152879. */
  152880. get left(): NodeMaterialConnectionPoint;
  152881. /**
  152882. * Gets the right operand input component
  152883. */
  152884. get right(): NodeMaterialConnectionPoint;
  152885. /**
  152886. * Gets the output component
  152887. */
  152888. get output(): NodeMaterialConnectionPoint;
  152889. protected _buildBlock(state: NodeMaterialBuildState): this;
  152890. }
  152891. }
  152892. declare module BABYLON {
  152893. /**
  152894. * Block used to get the distance between 2 values
  152895. */
  152896. export class DistanceBlock extends NodeMaterialBlock {
  152897. /**
  152898. * Creates a new DistanceBlock
  152899. * @param name defines the block name
  152900. */
  152901. constructor(name: string);
  152902. /**
  152903. * Gets the current class name
  152904. * @returns the class name
  152905. */
  152906. getClassName(): string;
  152907. /**
  152908. * Gets the left operand input component
  152909. */
  152910. get left(): NodeMaterialConnectionPoint;
  152911. /**
  152912. * Gets the right operand input component
  152913. */
  152914. get right(): NodeMaterialConnectionPoint;
  152915. /**
  152916. * Gets the output component
  152917. */
  152918. get output(): NodeMaterialConnectionPoint;
  152919. protected _buildBlock(state: NodeMaterialBuildState): this;
  152920. }
  152921. }
  152922. declare module BABYLON {
  152923. /**
  152924. * Block used to get the length of a vector
  152925. */
  152926. export class LengthBlock extends NodeMaterialBlock {
  152927. /**
  152928. * Creates a new LengthBlock
  152929. * @param name defines the block name
  152930. */
  152931. constructor(name: string);
  152932. /**
  152933. * Gets the current class name
  152934. * @returns the class name
  152935. */
  152936. getClassName(): string;
  152937. /**
  152938. * Gets the value input component
  152939. */
  152940. get value(): NodeMaterialConnectionPoint;
  152941. /**
  152942. * Gets the output component
  152943. */
  152944. get output(): NodeMaterialConnectionPoint;
  152945. protected _buildBlock(state: NodeMaterialBuildState): this;
  152946. }
  152947. }
  152948. declare module BABYLON {
  152949. /**
  152950. * Block used to get negative version of a value (i.e. x * -1)
  152951. */
  152952. export class NegateBlock extends NodeMaterialBlock {
  152953. /**
  152954. * Creates a new NegateBlock
  152955. * @param name defines the block name
  152956. */
  152957. constructor(name: string);
  152958. /**
  152959. * Gets the current class name
  152960. * @returns the class name
  152961. */
  152962. getClassName(): string;
  152963. /**
  152964. * Gets the value input component
  152965. */
  152966. get value(): NodeMaterialConnectionPoint;
  152967. /**
  152968. * Gets the output component
  152969. */
  152970. get output(): NodeMaterialConnectionPoint;
  152971. protected _buildBlock(state: NodeMaterialBuildState): this;
  152972. }
  152973. }
  152974. declare module BABYLON {
  152975. /**
  152976. * Block used to get the value of the first parameter raised to the power of the second
  152977. */
  152978. export class PowBlock extends NodeMaterialBlock {
  152979. /**
  152980. * Creates a new PowBlock
  152981. * @param name defines the block name
  152982. */
  152983. constructor(name: string);
  152984. /**
  152985. * Gets the current class name
  152986. * @returns the class name
  152987. */
  152988. getClassName(): string;
  152989. /**
  152990. * Gets the value operand input component
  152991. */
  152992. get value(): NodeMaterialConnectionPoint;
  152993. /**
  152994. * Gets the power operand input component
  152995. */
  152996. get power(): NodeMaterialConnectionPoint;
  152997. /**
  152998. * Gets the output component
  152999. */
  153000. get output(): NodeMaterialConnectionPoint;
  153001. protected _buildBlock(state: NodeMaterialBuildState): this;
  153002. }
  153003. }
  153004. declare module BABYLON {
  153005. /**
  153006. * Block used to get a random number
  153007. */
  153008. export class RandomNumberBlock extends NodeMaterialBlock {
  153009. /**
  153010. * Creates a new RandomNumberBlock
  153011. * @param name defines the block name
  153012. */
  153013. constructor(name: string);
  153014. /**
  153015. * Gets the current class name
  153016. * @returns the class name
  153017. */
  153018. getClassName(): string;
  153019. /**
  153020. * Gets the seed input component
  153021. */
  153022. get seed(): NodeMaterialConnectionPoint;
  153023. /**
  153024. * Gets the output component
  153025. */
  153026. get output(): NodeMaterialConnectionPoint;
  153027. protected _buildBlock(state: NodeMaterialBuildState): this;
  153028. }
  153029. }
  153030. declare module BABYLON {
  153031. /**
  153032. * Block used to compute arc tangent of 2 values
  153033. */
  153034. export class ArcTan2Block extends NodeMaterialBlock {
  153035. /**
  153036. * Creates a new ArcTan2Block
  153037. * @param name defines the block name
  153038. */
  153039. constructor(name: string);
  153040. /**
  153041. * Gets the current class name
  153042. * @returns the class name
  153043. */
  153044. getClassName(): string;
  153045. /**
  153046. * Gets the x operand input component
  153047. */
  153048. get x(): NodeMaterialConnectionPoint;
  153049. /**
  153050. * Gets the y operand input component
  153051. */
  153052. get y(): NodeMaterialConnectionPoint;
  153053. /**
  153054. * Gets the output component
  153055. */
  153056. get output(): NodeMaterialConnectionPoint;
  153057. protected _buildBlock(state: NodeMaterialBuildState): this;
  153058. }
  153059. }
  153060. declare module BABYLON {
  153061. /**
  153062. * Block used to smooth step a value
  153063. */
  153064. export class SmoothStepBlock extends NodeMaterialBlock {
  153065. /**
  153066. * Creates a new SmoothStepBlock
  153067. * @param name defines the block name
  153068. */
  153069. constructor(name: string);
  153070. /**
  153071. * Gets the current class name
  153072. * @returns the class name
  153073. */
  153074. getClassName(): string;
  153075. /**
  153076. * Gets the value operand input component
  153077. */
  153078. get value(): NodeMaterialConnectionPoint;
  153079. /**
  153080. * Gets the first edge operand input component
  153081. */
  153082. get edge0(): NodeMaterialConnectionPoint;
  153083. /**
  153084. * Gets the second edge operand input component
  153085. */
  153086. get edge1(): NodeMaterialConnectionPoint;
  153087. /**
  153088. * Gets the output component
  153089. */
  153090. get output(): NodeMaterialConnectionPoint;
  153091. protected _buildBlock(state: NodeMaterialBuildState): this;
  153092. }
  153093. }
  153094. declare module BABYLON {
  153095. /**
  153096. * Block used to get the reciprocal (1 / x) of a value
  153097. */
  153098. export class ReciprocalBlock extends NodeMaterialBlock {
  153099. /**
  153100. * Creates a new ReciprocalBlock
  153101. * @param name defines the block name
  153102. */
  153103. constructor(name: string);
  153104. /**
  153105. * Gets the current class name
  153106. * @returns the class name
  153107. */
  153108. getClassName(): string;
  153109. /**
  153110. * Gets the input component
  153111. */
  153112. get input(): NodeMaterialConnectionPoint;
  153113. /**
  153114. * Gets the output component
  153115. */
  153116. get output(): NodeMaterialConnectionPoint;
  153117. protected _buildBlock(state: NodeMaterialBuildState): this;
  153118. }
  153119. }
  153120. declare module BABYLON {
  153121. /**
  153122. * Block used to replace a color by another one
  153123. */
  153124. export class ReplaceColorBlock extends NodeMaterialBlock {
  153125. /**
  153126. * Creates a new ReplaceColorBlock
  153127. * @param name defines the block name
  153128. */
  153129. constructor(name: string);
  153130. /**
  153131. * Gets the current class name
  153132. * @returns the class name
  153133. */
  153134. getClassName(): string;
  153135. /**
  153136. * Gets the value input component
  153137. */
  153138. get value(): NodeMaterialConnectionPoint;
  153139. /**
  153140. * Gets the reference input component
  153141. */
  153142. get reference(): NodeMaterialConnectionPoint;
  153143. /**
  153144. * Gets the distance input component
  153145. */
  153146. get distance(): NodeMaterialConnectionPoint;
  153147. /**
  153148. * Gets the replacement input component
  153149. */
  153150. get replacement(): NodeMaterialConnectionPoint;
  153151. /**
  153152. * Gets the output component
  153153. */
  153154. get output(): NodeMaterialConnectionPoint;
  153155. protected _buildBlock(state: NodeMaterialBuildState): this;
  153156. }
  153157. }
  153158. declare module BABYLON {
  153159. /**
  153160. * Block used to posterize a value
  153161. * @see https://en.wikipedia.org/wiki/Posterization
  153162. */
  153163. export class PosterizeBlock extends NodeMaterialBlock {
  153164. /**
  153165. * Creates a new PosterizeBlock
  153166. * @param name defines the block name
  153167. */
  153168. constructor(name: string);
  153169. /**
  153170. * Gets the current class name
  153171. * @returns the class name
  153172. */
  153173. getClassName(): string;
  153174. /**
  153175. * Gets the value input component
  153176. */
  153177. get value(): NodeMaterialConnectionPoint;
  153178. /**
  153179. * Gets the steps input component
  153180. */
  153181. get steps(): NodeMaterialConnectionPoint;
  153182. /**
  153183. * Gets the output component
  153184. */
  153185. get output(): NodeMaterialConnectionPoint;
  153186. protected _buildBlock(state: NodeMaterialBuildState): this;
  153187. }
  153188. }
  153189. declare module BABYLON {
  153190. /**
  153191. * Operations supported by the Wave block
  153192. */
  153193. export enum WaveBlockKind {
  153194. /** SawTooth */
  153195. SawTooth = 0,
  153196. /** Square */
  153197. Square = 1,
  153198. /** Triangle */
  153199. Triangle = 2
  153200. }
  153201. /**
  153202. * Block used to apply wave operation to floats
  153203. */
  153204. export class WaveBlock extends NodeMaterialBlock {
  153205. /**
  153206. * Gets or sets the kibnd of wave to be applied by the block
  153207. */
  153208. kind: WaveBlockKind;
  153209. /**
  153210. * Creates a new WaveBlock
  153211. * @param name defines the block name
  153212. */
  153213. constructor(name: string);
  153214. /**
  153215. * Gets the current class name
  153216. * @returns the class name
  153217. */
  153218. getClassName(): string;
  153219. /**
  153220. * Gets the input component
  153221. */
  153222. get input(): NodeMaterialConnectionPoint;
  153223. /**
  153224. * Gets the output component
  153225. */
  153226. get output(): NodeMaterialConnectionPoint;
  153227. protected _buildBlock(state: NodeMaterialBuildState): this;
  153228. serialize(): any;
  153229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153230. }
  153231. }
  153232. declare module BABYLON {
  153233. /**
  153234. * Class used to store a color step for the GradientBlock
  153235. */
  153236. export class GradientBlockColorStep {
  153237. private _step;
  153238. /**
  153239. * Gets value indicating which step this color is associated with (between 0 and 1)
  153240. */
  153241. get step(): number;
  153242. /**
  153243. * Sets a value indicating which step this color is associated with (between 0 and 1)
  153244. */
  153245. set step(val: number);
  153246. private _color;
  153247. /**
  153248. * Gets the color associated with this step
  153249. */
  153250. get color(): Color3;
  153251. /**
  153252. * Sets the color associated with this step
  153253. */
  153254. set color(val: Color3);
  153255. /**
  153256. * Creates a new GradientBlockColorStep
  153257. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  153258. * @param color defines the color associated with this step
  153259. */
  153260. constructor(step: number, color: Color3);
  153261. }
  153262. /**
  153263. * Block used to return a color from a gradient based on an input value between 0 and 1
  153264. */
  153265. export class GradientBlock extends NodeMaterialBlock {
  153266. /**
  153267. * Gets or sets the list of color steps
  153268. */
  153269. colorSteps: GradientBlockColorStep[];
  153270. /** Gets an observable raised when the value is changed */
  153271. onValueChangedObservable: Observable<GradientBlock>;
  153272. /** calls observable when the value is changed*/
  153273. colorStepsUpdated(): void;
  153274. /**
  153275. * Creates a new GradientBlock
  153276. * @param name defines the block name
  153277. */
  153278. constructor(name: string);
  153279. /**
  153280. * Gets the current class name
  153281. * @returns the class name
  153282. */
  153283. getClassName(): string;
  153284. /**
  153285. * Gets the gradient input component
  153286. */
  153287. get gradient(): NodeMaterialConnectionPoint;
  153288. /**
  153289. * Gets the output component
  153290. */
  153291. get output(): NodeMaterialConnectionPoint;
  153292. private _writeColorConstant;
  153293. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153294. serialize(): any;
  153295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153296. protected _dumpPropertiesCode(): string;
  153297. }
  153298. }
  153299. declare module BABYLON {
  153300. /**
  153301. * Block used to normalize lerp between 2 values
  153302. */
  153303. export class NLerpBlock extends NodeMaterialBlock {
  153304. /**
  153305. * Creates a new NLerpBlock
  153306. * @param name defines the block name
  153307. */
  153308. constructor(name: string);
  153309. /**
  153310. * Gets the current class name
  153311. * @returns the class name
  153312. */
  153313. getClassName(): string;
  153314. /**
  153315. * Gets the left operand input component
  153316. */
  153317. get left(): NodeMaterialConnectionPoint;
  153318. /**
  153319. * Gets the right operand input component
  153320. */
  153321. get right(): NodeMaterialConnectionPoint;
  153322. /**
  153323. * Gets the gradient operand input component
  153324. */
  153325. get gradient(): NodeMaterialConnectionPoint;
  153326. /**
  153327. * Gets the output component
  153328. */
  153329. get output(): NodeMaterialConnectionPoint;
  153330. protected _buildBlock(state: NodeMaterialBuildState): this;
  153331. }
  153332. }
  153333. declare module BABYLON {
  153334. /**
  153335. * block used to Generate a Worley Noise 3D Noise Pattern
  153336. */
  153337. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  153338. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  153339. manhattanDistance: boolean;
  153340. /**
  153341. * Creates a new WorleyNoise3DBlock
  153342. * @param name defines the block name
  153343. */
  153344. constructor(name: string);
  153345. /**
  153346. * Gets the current class name
  153347. * @returns the class name
  153348. */
  153349. getClassName(): string;
  153350. /**
  153351. * Gets the seed input component
  153352. */
  153353. get seed(): NodeMaterialConnectionPoint;
  153354. /**
  153355. * Gets the jitter input component
  153356. */
  153357. get jitter(): NodeMaterialConnectionPoint;
  153358. /**
  153359. * Gets the output component
  153360. */
  153361. get output(): NodeMaterialConnectionPoint;
  153362. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153363. /**
  153364. * Exposes the properties to the UI?
  153365. */
  153366. protected _dumpPropertiesCode(): string;
  153367. /**
  153368. * Exposes the properties to the Seralize?
  153369. */
  153370. serialize(): any;
  153371. /**
  153372. * Exposes the properties to the deseralize?
  153373. */
  153374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153375. }
  153376. }
  153377. declare module BABYLON {
  153378. /**
  153379. * block used to Generate a Simplex Perlin 3d Noise Pattern
  153380. */
  153381. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  153382. /**
  153383. * Creates a new SimplexPerlin3DBlock
  153384. * @param name defines the block name
  153385. */
  153386. constructor(name: string);
  153387. /**
  153388. * Gets the current class name
  153389. * @returns the class name
  153390. */
  153391. getClassName(): string;
  153392. /**
  153393. * Gets the seed operand input component
  153394. */
  153395. get seed(): NodeMaterialConnectionPoint;
  153396. /**
  153397. * Gets the output component
  153398. */
  153399. get output(): NodeMaterialConnectionPoint;
  153400. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153401. }
  153402. }
  153403. declare module BABYLON {
  153404. /**
  153405. * Block used to blend normals
  153406. */
  153407. export class NormalBlendBlock extends NodeMaterialBlock {
  153408. /**
  153409. * Creates a new NormalBlendBlock
  153410. * @param name defines the block name
  153411. */
  153412. constructor(name: string);
  153413. /**
  153414. * Gets the current class name
  153415. * @returns the class name
  153416. */
  153417. getClassName(): string;
  153418. /**
  153419. * Gets the first input component
  153420. */
  153421. get normalMap0(): NodeMaterialConnectionPoint;
  153422. /**
  153423. * Gets the second input component
  153424. */
  153425. get normalMap1(): NodeMaterialConnectionPoint;
  153426. /**
  153427. * Gets the output component
  153428. */
  153429. get output(): NodeMaterialConnectionPoint;
  153430. protected _buildBlock(state: NodeMaterialBuildState): this;
  153431. }
  153432. }
  153433. declare module BABYLON {
  153434. /**
  153435. * Block used to rotate a 2d vector by a given angle
  153436. */
  153437. export class Rotate2dBlock extends NodeMaterialBlock {
  153438. /**
  153439. * Creates a new Rotate2dBlock
  153440. * @param name defines the block name
  153441. */
  153442. constructor(name: string);
  153443. /**
  153444. * Gets the current class name
  153445. * @returns the class name
  153446. */
  153447. getClassName(): string;
  153448. /**
  153449. * Gets the input vector
  153450. */
  153451. get input(): NodeMaterialConnectionPoint;
  153452. /**
  153453. * Gets the input angle
  153454. */
  153455. get angle(): NodeMaterialConnectionPoint;
  153456. /**
  153457. * Gets the output component
  153458. */
  153459. get output(): NodeMaterialConnectionPoint;
  153460. autoConfigure(material: NodeMaterial): void;
  153461. protected _buildBlock(state: NodeMaterialBuildState): this;
  153462. }
  153463. }
  153464. declare module BABYLON {
  153465. /**
  153466. * Block used to get the reflected vector from a direction and a normal
  153467. */
  153468. export class ReflectBlock extends NodeMaterialBlock {
  153469. /**
  153470. * Creates a new ReflectBlock
  153471. * @param name defines the block name
  153472. */
  153473. constructor(name: string);
  153474. /**
  153475. * Gets the current class name
  153476. * @returns the class name
  153477. */
  153478. getClassName(): string;
  153479. /**
  153480. * Gets the incident component
  153481. */
  153482. get incident(): NodeMaterialConnectionPoint;
  153483. /**
  153484. * Gets the normal component
  153485. */
  153486. get normal(): NodeMaterialConnectionPoint;
  153487. /**
  153488. * Gets the output component
  153489. */
  153490. get output(): NodeMaterialConnectionPoint;
  153491. protected _buildBlock(state: NodeMaterialBuildState): this;
  153492. }
  153493. }
  153494. declare module BABYLON {
  153495. /**
  153496. * Block used to get the refracted vector from a direction and a normal
  153497. */
  153498. export class RefractBlock extends NodeMaterialBlock {
  153499. /**
  153500. * Creates a new RefractBlock
  153501. * @param name defines the block name
  153502. */
  153503. constructor(name: string);
  153504. /**
  153505. * Gets the current class name
  153506. * @returns the class name
  153507. */
  153508. getClassName(): string;
  153509. /**
  153510. * Gets the incident component
  153511. */
  153512. get incident(): NodeMaterialConnectionPoint;
  153513. /**
  153514. * Gets the normal component
  153515. */
  153516. get normal(): NodeMaterialConnectionPoint;
  153517. /**
  153518. * Gets the index of refraction component
  153519. */
  153520. get ior(): NodeMaterialConnectionPoint;
  153521. /**
  153522. * Gets the output component
  153523. */
  153524. get output(): NodeMaterialConnectionPoint;
  153525. protected _buildBlock(state: NodeMaterialBuildState): this;
  153526. }
  153527. }
  153528. declare module BABYLON {
  153529. /**
  153530. * Block used to desaturate a color
  153531. */
  153532. export class DesaturateBlock extends NodeMaterialBlock {
  153533. /**
  153534. * Creates a new DesaturateBlock
  153535. * @param name defines the block name
  153536. */
  153537. constructor(name: string);
  153538. /**
  153539. * Gets the current class name
  153540. * @returns the class name
  153541. */
  153542. getClassName(): string;
  153543. /**
  153544. * Gets the color operand input component
  153545. */
  153546. get color(): NodeMaterialConnectionPoint;
  153547. /**
  153548. * Gets the level operand input component
  153549. */
  153550. get level(): NodeMaterialConnectionPoint;
  153551. /**
  153552. * Gets the output component
  153553. */
  153554. get output(): NodeMaterialConnectionPoint;
  153555. protected _buildBlock(state: NodeMaterialBuildState): this;
  153556. }
  153557. }
  153558. declare module BABYLON {
  153559. /**
  153560. * Block used to implement the reflection module of the PBR material
  153561. */
  153562. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  153563. /** @hidden */
  153564. _defineLODReflectionAlpha: string;
  153565. /** @hidden */
  153566. _defineLinearSpecularReflection: string;
  153567. private _vEnvironmentIrradianceName;
  153568. /** @hidden */
  153569. _vReflectionMicrosurfaceInfosName: string;
  153570. /** @hidden */
  153571. _vReflectionInfosName: string;
  153572. /** @hidden */
  153573. _vReflectionFilteringInfoName: string;
  153574. private _scene;
  153575. /**
  153576. * The properties below are set by the main PBR block prior to calling methods of this class.
  153577. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153578. * It's less burden on the user side in the editor part.
  153579. */
  153580. /** @hidden */
  153581. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153582. /** @hidden */
  153583. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153584. /** @hidden */
  153585. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  153586. /** @hidden */
  153587. viewConnectionPoint: NodeMaterialConnectionPoint;
  153588. /**
  153589. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  153590. * diffuse part of the IBL.
  153591. */
  153592. useSphericalHarmonics: boolean;
  153593. /**
  153594. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  153595. */
  153596. forceIrradianceInFragment: boolean;
  153597. /**
  153598. * Create a new ReflectionBlock
  153599. * @param name defines the block name
  153600. */
  153601. constructor(name: string);
  153602. /**
  153603. * Gets the current class name
  153604. * @returns the class name
  153605. */
  153606. getClassName(): string;
  153607. /**
  153608. * Gets the position input component
  153609. */
  153610. get position(): NodeMaterialConnectionPoint;
  153611. /**
  153612. * Gets the world position input component
  153613. */
  153614. get worldPosition(): NodeMaterialConnectionPoint;
  153615. /**
  153616. * Gets the world normal input component
  153617. */
  153618. get worldNormal(): NodeMaterialConnectionPoint;
  153619. /**
  153620. * Gets the world input component
  153621. */
  153622. get world(): NodeMaterialConnectionPoint;
  153623. /**
  153624. * Gets the camera (or eye) position component
  153625. */
  153626. get cameraPosition(): NodeMaterialConnectionPoint;
  153627. /**
  153628. * Gets the view input component
  153629. */
  153630. get view(): NodeMaterialConnectionPoint;
  153631. /**
  153632. * Gets the color input component
  153633. */
  153634. get color(): NodeMaterialConnectionPoint;
  153635. /**
  153636. * Gets the reflection object output component
  153637. */
  153638. get reflection(): NodeMaterialConnectionPoint;
  153639. /**
  153640. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  153641. */
  153642. get hasTexture(): boolean;
  153643. /**
  153644. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  153645. */
  153646. get reflectionColor(): string;
  153647. protected _getTexture(): Nullable<BaseTexture>;
  153648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153649. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  153650. /**
  153651. * Gets the code to inject in the vertex shader
  153652. * @param state current state of the node material building
  153653. * @returns the shader code
  153654. */
  153655. handleVertexSide(state: NodeMaterialBuildState): string;
  153656. /**
  153657. * Gets the main code of the block (fragment side)
  153658. * @param state current state of the node material building
  153659. * @param normalVarName name of the existing variable corresponding to the normal
  153660. * @returns the shader code
  153661. */
  153662. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  153663. protected _buildBlock(state: NodeMaterialBuildState): this;
  153664. protected _dumpPropertiesCode(): string;
  153665. serialize(): any;
  153666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153667. }
  153668. }
  153669. declare module BABYLON {
  153670. /**
  153671. * Block used to implement the sheen module of the PBR material
  153672. */
  153673. export class SheenBlock extends NodeMaterialBlock {
  153674. /**
  153675. * Create a new SheenBlock
  153676. * @param name defines the block name
  153677. */
  153678. constructor(name: string);
  153679. /**
  153680. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  153681. * It allows the strength of the sheen effect to not depend on the base color of the material,
  153682. * making it easier to setup and tweak the effect
  153683. */
  153684. albedoScaling: boolean;
  153685. /**
  153686. * Defines if the sheen is linked to the sheen color.
  153687. */
  153688. linkSheenWithAlbedo: boolean;
  153689. /**
  153690. * Initialize the block and prepare the context for build
  153691. * @param state defines the state that will be used for the build
  153692. */
  153693. initialize(state: NodeMaterialBuildState): void;
  153694. /**
  153695. * Gets the current class name
  153696. * @returns the class name
  153697. */
  153698. getClassName(): string;
  153699. /**
  153700. * Gets the intensity input component
  153701. */
  153702. get intensity(): NodeMaterialConnectionPoint;
  153703. /**
  153704. * Gets the color input component
  153705. */
  153706. get color(): NodeMaterialConnectionPoint;
  153707. /**
  153708. * Gets the roughness input component
  153709. */
  153710. get roughness(): NodeMaterialConnectionPoint;
  153711. /**
  153712. * Gets the sheen object output component
  153713. */
  153714. get sheen(): NodeMaterialConnectionPoint;
  153715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153716. /**
  153717. * Gets the main code of the block (fragment side)
  153718. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153719. * @returns the shader code
  153720. */
  153721. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  153722. protected _buildBlock(state: NodeMaterialBuildState): this;
  153723. protected _dumpPropertiesCode(): string;
  153724. serialize(): any;
  153725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153726. }
  153727. }
  153728. declare module BABYLON {
  153729. /**
  153730. * Block used to implement the anisotropy module of the PBR material
  153731. */
  153732. export class AnisotropyBlock extends NodeMaterialBlock {
  153733. /**
  153734. * The two properties below are set by the main PBR block prior to calling methods of this class.
  153735. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153736. * It's less burden on the user side in the editor part.
  153737. */
  153738. /** @hidden */
  153739. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153740. /** @hidden */
  153741. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153742. /**
  153743. * Create a new AnisotropyBlock
  153744. * @param name defines the block name
  153745. */
  153746. constructor(name: string);
  153747. /**
  153748. * Initialize the block and prepare the context for build
  153749. * @param state defines the state that will be used for the build
  153750. */
  153751. initialize(state: NodeMaterialBuildState): void;
  153752. /**
  153753. * Gets the current class name
  153754. * @returns the class name
  153755. */
  153756. getClassName(): string;
  153757. /**
  153758. * Gets the intensity input component
  153759. */
  153760. get intensity(): NodeMaterialConnectionPoint;
  153761. /**
  153762. * Gets the direction input component
  153763. */
  153764. get direction(): NodeMaterialConnectionPoint;
  153765. /**
  153766. * Gets the uv input component
  153767. */
  153768. get uv(): NodeMaterialConnectionPoint;
  153769. /**
  153770. * Gets the worldTangent input component
  153771. */
  153772. get worldTangent(): NodeMaterialConnectionPoint;
  153773. /**
  153774. * Gets the anisotropy object output component
  153775. */
  153776. get anisotropy(): NodeMaterialConnectionPoint;
  153777. private _generateTBNSpace;
  153778. /**
  153779. * Gets the main code of the block (fragment side)
  153780. * @param state current state of the node material building
  153781. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153782. * @returns the shader code
  153783. */
  153784. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  153785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153786. protected _buildBlock(state: NodeMaterialBuildState): this;
  153787. }
  153788. }
  153789. declare module BABYLON {
  153790. /**
  153791. * Block used to implement the clear coat module of the PBR material
  153792. */
  153793. export class ClearCoatBlock extends NodeMaterialBlock {
  153794. private _scene;
  153795. /**
  153796. * Create a new ClearCoatBlock
  153797. * @param name defines the block name
  153798. */
  153799. constructor(name: string);
  153800. /**
  153801. * Defines if the F0 value should be remapped to account for the interface change in the material.
  153802. */
  153803. remapF0OnInterfaceChange: boolean;
  153804. /**
  153805. * Initialize the block and prepare the context for build
  153806. * @param state defines the state that will be used for the build
  153807. */
  153808. initialize(state: NodeMaterialBuildState): void;
  153809. /**
  153810. * Gets the current class name
  153811. * @returns the class name
  153812. */
  153813. getClassName(): string;
  153814. /**
  153815. * Gets the intensity input component
  153816. */
  153817. get intensity(): NodeMaterialConnectionPoint;
  153818. /**
  153819. * Gets the roughness input component
  153820. */
  153821. get roughness(): NodeMaterialConnectionPoint;
  153822. /**
  153823. * Gets the ior input component
  153824. */
  153825. get indexOfRefraction(): NodeMaterialConnectionPoint;
  153826. /**
  153827. * Gets the bump texture input component
  153828. */
  153829. get normalMapColor(): NodeMaterialConnectionPoint;
  153830. /**
  153831. * Gets the uv input component
  153832. */
  153833. get uv(): NodeMaterialConnectionPoint;
  153834. /**
  153835. * Gets the tint color input component
  153836. */
  153837. get tintColor(): NodeMaterialConnectionPoint;
  153838. /**
  153839. * Gets the tint "at distance" input component
  153840. */
  153841. get tintAtDistance(): NodeMaterialConnectionPoint;
  153842. /**
  153843. * Gets the tint thickness input component
  153844. */
  153845. get tintThickness(): NodeMaterialConnectionPoint;
  153846. /**
  153847. * Gets the world tangent input component
  153848. */
  153849. get worldTangent(): NodeMaterialConnectionPoint;
  153850. /**
  153851. * Gets the clear coat object output component
  153852. */
  153853. get clearcoat(): NodeMaterialConnectionPoint;
  153854. autoConfigure(material: NodeMaterial): void;
  153855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  153857. private _generateTBNSpace;
  153858. /**
  153859. * Gets the main code of the block (fragment side)
  153860. * @param state current state of the node material building
  153861. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  153862. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153863. * @param worldPosVarName name of the variable holding the world position
  153864. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153865. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  153866. * @param worldNormalVarName name of the variable holding the world normal
  153867. * @returns the shader code
  153868. */
  153869. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  153870. protected _buildBlock(state: NodeMaterialBuildState): this;
  153871. protected _dumpPropertiesCode(): string;
  153872. serialize(): any;
  153873. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153874. }
  153875. }
  153876. declare module BABYLON {
  153877. /**
  153878. * Block used to implement the sub surface module of the PBR material
  153879. */
  153880. export class SubSurfaceBlock extends NodeMaterialBlock {
  153881. /**
  153882. * Create a new SubSurfaceBlock
  153883. * @param name defines the block name
  153884. */
  153885. constructor(name: string);
  153886. /**
  153887. * Initialize the block and prepare the context for build
  153888. * @param state defines the state that will be used for the build
  153889. */
  153890. initialize(state: NodeMaterialBuildState): void;
  153891. /**
  153892. * Gets the current class name
  153893. * @returns the class name
  153894. */
  153895. getClassName(): string;
  153896. /**
  153897. * Gets the thickness component
  153898. */
  153899. get thickness(): NodeMaterialConnectionPoint;
  153900. /**
  153901. * Gets the tint color input component
  153902. */
  153903. get tintColor(): NodeMaterialConnectionPoint;
  153904. /**
  153905. * Gets the translucency intensity input component
  153906. */
  153907. get translucencyIntensity(): NodeMaterialConnectionPoint;
  153908. /**
  153909. * Gets the translucency diffusion distance input component
  153910. */
  153911. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  153912. /**
  153913. * Gets the refraction object parameters
  153914. */
  153915. get refraction(): NodeMaterialConnectionPoint;
  153916. /**
  153917. * Gets the sub surface object output component
  153918. */
  153919. get subsurface(): NodeMaterialConnectionPoint;
  153920. autoConfigure(material: NodeMaterial): void;
  153921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153922. /**
  153923. * Gets the main code of the block (fragment side)
  153924. * @param state current state of the node material building
  153925. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  153926. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153927. * @param worldPosVarName name of the variable holding the world position
  153928. * @returns the shader code
  153929. */
  153930. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  153931. protected _buildBlock(state: NodeMaterialBuildState): this;
  153932. }
  153933. }
  153934. declare module BABYLON {
  153935. /**
  153936. * Block used to implement the PBR metallic/roughness model
  153937. */
  153938. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  153939. /**
  153940. * Gets or sets the light associated with this block
  153941. */
  153942. light: Nullable<Light>;
  153943. private _lightId;
  153944. private _scene;
  153945. private _environmentBRDFTexture;
  153946. private _environmentBrdfSamplerName;
  153947. private _vNormalWName;
  153948. private _invertNormalName;
  153949. private _metallicReflectanceColor;
  153950. private _metallicF0Factor;
  153951. private _vMetallicReflectanceFactorsName;
  153952. /**
  153953. * Create a new ReflectionBlock
  153954. * @param name defines the block name
  153955. */
  153956. constructor(name: string);
  153957. /**
  153958. * Intensity of the direct lights e.g. the four lights available in your scene.
  153959. * This impacts both the direct diffuse and specular highlights.
  153960. */
  153961. directIntensity: number;
  153962. /**
  153963. * Intensity of the environment e.g. how much the environment will light the object
  153964. * either through harmonics for rough material or through the refelction for shiny ones.
  153965. */
  153966. environmentIntensity: number;
  153967. /**
  153968. * This is a special control allowing the reduction of the specular highlights coming from the
  153969. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  153970. */
  153971. specularIntensity: number;
  153972. /**
  153973. * Defines the falloff type used in this material.
  153974. * It by default is Physical.
  153975. */
  153976. lightFalloff: number;
  153977. /**
  153978. * Specifies that alpha test should be used
  153979. */
  153980. useAlphaTest: boolean;
  153981. /**
  153982. * Defines the alpha limits in alpha test mode.
  153983. */
  153984. alphaTestCutoff: number;
  153985. /**
  153986. * Specifies that alpha blending should be used
  153987. */
  153988. useAlphaBlending: boolean;
  153989. /**
  153990. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  153991. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  153992. */
  153993. useRadianceOverAlpha: boolean;
  153994. /**
  153995. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  153996. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  153997. */
  153998. useSpecularOverAlpha: boolean;
  153999. /**
  154000. * Enables specular anti aliasing in the PBR shader.
  154001. * It will both interacts on the Geometry for analytical and IBL lighting.
  154002. * It also prefilter the roughness map based on the bump values.
  154003. */
  154004. enableSpecularAntiAliasing: boolean;
  154005. /**
  154006. * Enables realtime filtering on the texture.
  154007. */
  154008. realTimeFiltering: boolean;
  154009. /**
  154010. * Quality switch for realtime filtering
  154011. */
  154012. realTimeFilteringQuality: number;
  154013. /**
  154014. * Defines if the material uses energy conservation.
  154015. */
  154016. useEnergyConservation: boolean;
  154017. /**
  154018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  154019. * too much the area relying on ambient texture to define their ambient occlusion.
  154020. */
  154021. useRadianceOcclusion: boolean;
  154022. /**
  154023. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  154024. * makes the reflect vector face the model (under horizon).
  154025. */
  154026. useHorizonOcclusion: boolean;
  154027. /**
  154028. * If set to true, no lighting calculations will be applied.
  154029. */
  154030. unlit: boolean;
  154031. /**
  154032. * Force normal to face away from face.
  154033. */
  154034. forceNormalForward: boolean;
  154035. /**
  154036. * Defines the material debug mode.
  154037. * It helps seeing only some components of the material while troubleshooting.
  154038. */
  154039. debugMode: number;
  154040. /**
  154041. * Specify from where on screen the debug mode should start.
  154042. * The value goes from -1 (full screen) to 1 (not visible)
  154043. * It helps with side by side comparison against the final render
  154044. * This defaults to 0
  154045. */
  154046. debugLimit: number;
  154047. /**
  154048. * As the default viewing range might not be enough (if the ambient is really small for instance)
  154049. * You can use the factor to better multiply the final value.
  154050. */
  154051. debugFactor: number;
  154052. /**
  154053. * Initialize the block and prepare the context for build
  154054. * @param state defines the state that will be used for the build
  154055. */
  154056. initialize(state: NodeMaterialBuildState): void;
  154057. /**
  154058. * Gets the current class name
  154059. * @returns the class name
  154060. */
  154061. getClassName(): string;
  154062. /**
  154063. * Gets the world position input component
  154064. */
  154065. get worldPosition(): NodeMaterialConnectionPoint;
  154066. /**
  154067. * Gets the world normal input component
  154068. */
  154069. get worldNormal(): NodeMaterialConnectionPoint;
  154070. /**
  154071. * Gets the view matrix parameter
  154072. */
  154073. get view(): NodeMaterialConnectionPoint;
  154074. /**
  154075. * Gets the camera position input component
  154076. */
  154077. get cameraPosition(): NodeMaterialConnectionPoint;
  154078. /**
  154079. * Gets the perturbed normal input component
  154080. */
  154081. get perturbedNormal(): NodeMaterialConnectionPoint;
  154082. /**
  154083. * Gets the base color input component
  154084. */
  154085. get baseColor(): NodeMaterialConnectionPoint;
  154086. /**
  154087. * Gets the metallic input component
  154088. */
  154089. get metallic(): NodeMaterialConnectionPoint;
  154090. /**
  154091. * Gets the roughness input component
  154092. */
  154093. get roughness(): NodeMaterialConnectionPoint;
  154094. /**
  154095. * Gets the ambient occlusion input component
  154096. */
  154097. get ambientOcc(): NodeMaterialConnectionPoint;
  154098. /**
  154099. * Gets the opacity input component
  154100. */
  154101. get opacity(): NodeMaterialConnectionPoint;
  154102. /**
  154103. * Gets the index of refraction input component
  154104. */
  154105. get indexOfRefraction(): NodeMaterialConnectionPoint;
  154106. /**
  154107. * Gets the ambient color input component
  154108. */
  154109. get ambientColor(): NodeMaterialConnectionPoint;
  154110. /**
  154111. * Gets the reflection object parameters
  154112. */
  154113. get reflection(): NodeMaterialConnectionPoint;
  154114. /**
  154115. * Gets the clear coat object parameters
  154116. */
  154117. get clearcoat(): NodeMaterialConnectionPoint;
  154118. /**
  154119. * Gets the sheen object parameters
  154120. */
  154121. get sheen(): NodeMaterialConnectionPoint;
  154122. /**
  154123. * Gets the sub surface object parameters
  154124. */
  154125. get subsurface(): NodeMaterialConnectionPoint;
  154126. /**
  154127. * Gets the anisotropy object parameters
  154128. */
  154129. get anisotropy(): NodeMaterialConnectionPoint;
  154130. /**
  154131. * Gets the ambient output component
  154132. */
  154133. get ambientClr(): NodeMaterialConnectionPoint;
  154134. /**
  154135. * Gets the diffuse output component
  154136. */
  154137. get diffuseDir(): NodeMaterialConnectionPoint;
  154138. /**
  154139. * Gets the specular output component
  154140. */
  154141. get specularDir(): NodeMaterialConnectionPoint;
  154142. /**
  154143. * Gets the clear coat output component
  154144. */
  154145. get clearcoatDir(): NodeMaterialConnectionPoint;
  154146. /**
  154147. * Gets the sheen output component
  154148. */
  154149. get sheenDir(): NodeMaterialConnectionPoint;
  154150. /**
  154151. * Gets the indirect diffuse output component
  154152. */
  154153. get diffuseIndirect(): NodeMaterialConnectionPoint;
  154154. /**
  154155. * Gets the indirect specular output component
  154156. */
  154157. get specularIndirect(): NodeMaterialConnectionPoint;
  154158. /**
  154159. * Gets the indirect clear coat output component
  154160. */
  154161. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  154162. /**
  154163. * Gets the indirect sheen output component
  154164. */
  154165. get sheenIndirect(): NodeMaterialConnectionPoint;
  154166. /**
  154167. * Gets the refraction output component
  154168. */
  154169. get refraction(): NodeMaterialConnectionPoint;
  154170. /**
  154171. * Gets the global lighting output component
  154172. */
  154173. get lighting(): NodeMaterialConnectionPoint;
  154174. /**
  154175. * Gets the shadow output component
  154176. */
  154177. get shadow(): NodeMaterialConnectionPoint;
  154178. /**
  154179. * Gets the alpha output component
  154180. */
  154181. get alpha(): NodeMaterialConnectionPoint;
  154182. autoConfigure(material: NodeMaterial): void;
  154183. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154184. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  154185. isReady(): boolean;
  154186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  154187. private _injectVertexCode;
  154188. private _getAlbedoOpacityCode;
  154189. private _getAmbientOcclusionCode;
  154190. private _getReflectivityCode;
  154191. protected _buildBlock(state: NodeMaterialBuildState): this;
  154192. protected _dumpPropertiesCode(): string;
  154193. serialize(): any;
  154194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154195. }
  154196. }
  154197. declare module BABYLON {
  154198. /**
  154199. * Block used to compute value of one parameter modulo another
  154200. */
  154201. export class ModBlock extends NodeMaterialBlock {
  154202. /**
  154203. * Creates a new ModBlock
  154204. * @param name defines the block name
  154205. */
  154206. constructor(name: string);
  154207. /**
  154208. * Gets the current class name
  154209. * @returns the class name
  154210. */
  154211. getClassName(): string;
  154212. /**
  154213. * Gets the left operand input component
  154214. */
  154215. get left(): NodeMaterialConnectionPoint;
  154216. /**
  154217. * Gets the right operand input component
  154218. */
  154219. get right(): NodeMaterialConnectionPoint;
  154220. /**
  154221. * Gets the output component
  154222. */
  154223. get output(): NodeMaterialConnectionPoint;
  154224. protected _buildBlock(state: NodeMaterialBuildState): this;
  154225. }
  154226. }
  154227. declare module BABYLON {
  154228. /**
  154229. * Configuration for Draco compression
  154230. */
  154231. export interface IDracoCompressionConfiguration {
  154232. /**
  154233. * Configuration for the decoder.
  154234. */
  154235. decoder: {
  154236. /**
  154237. * The url to the WebAssembly module.
  154238. */
  154239. wasmUrl?: string;
  154240. /**
  154241. * The url to the WebAssembly binary.
  154242. */
  154243. wasmBinaryUrl?: string;
  154244. /**
  154245. * The url to the fallback JavaScript module.
  154246. */
  154247. fallbackUrl?: string;
  154248. };
  154249. }
  154250. /**
  154251. * Draco compression (https://google.github.io/draco/)
  154252. *
  154253. * This class wraps the Draco module.
  154254. *
  154255. * **Encoder**
  154256. *
  154257. * The encoder is not currently implemented.
  154258. *
  154259. * **Decoder**
  154260. *
  154261. * 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.
  154262. *
  154263. * To update the configuration, use the following code:
  154264. * ```javascript
  154265. * DracoCompression.Configuration = {
  154266. * decoder: {
  154267. * wasmUrl: "<url to the WebAssembly library>",
  154268. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  154269. * fallbackUrl: "<url to the fallback JavaScript library>",
  154270. * }
  154271. * };
  154272. * ```
  154273. *
  154274. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  154275. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  154276. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  154277. *
  154278. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  154279. * ```javascript
  154280. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  154281. * ```
  154282. *
  154283. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  154284. */
  154285. export class DracoCompression implements IDisposable {
  154286. private _workerPoolPromise?;
  154287. private _decoderModulePromise?;
  154288. /**
  154289. * The configuration. Defaults to the following urls:
  154290. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  154291. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  154292. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  154293. */
  154294. static Configuration: IDracoCompressionConfiguration;
  154295. /**
  154296. * Returns true if the decoder configuration is available.
  154297. */
  154298. static get DecoderAvailable(): boolean;
  154299. /**
  154300. * Default number of workers to create when creating the draco compression object.
  154301. */
  154302. static DefaultNumWorkers: number;
  154303. private static GetDefaultNumWorkers;
  154304. private static _Default;
  154305. /**
  154306. * Default instance for the draco compression object.
  154307. */
  154308. static get Default(): DracoCompression;
  154309. /**
  154310. * Constructor
  154311. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  154312. */
  154313. constructor(numWorkers?: number);
  154314. /**
  154315. * Stop all async operations and release resources.
  154316. */
  154317. dispose(): void;
  154318. /**
  154319. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  154320. * @returns a promise that resolves when ready
  154321. */
  154322. whenReadyAsync(): Promise<void>;
  154323. /**
  154324. * Decode Draco compressed mesh data to vertex data.
  154325. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  154326. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  154327. * @returns A promise that resolves with the decoded vertex data
  154328. */
  154329. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  154330. [kind: string]: number;
  154331. }): Promise<VertexData>;
  154332. }
  154333. }
  154334. declare module BABYLON {
  154335. /**
  154336. * Class for building Constructive Solid Geometry
  154337. */
  154338. export class CSG {
  154339. private polygons;
  154340. /**
  154341. * The world matrix
  154342. */
  154343. matrix: Matrix;
  154344. /**
  154345. * Stores the position
  154346. */
  154347. position: Vector3;
  154348. /**
  154349. * Stores the rotation
  154350. */
  154351. rotation: Vector3;
  154352. /**
  154353. * Stores the rotation quaternion
  154354. */
  154355. rotationQuaternion: Nullable<Quaternion>;
  154356. /**
  154357. * Stores the scaling vector
  154358. */
  154359. scaling: Vector3;
  154360. /**
  154361. * Convert the Mesh to CSG
  154362. * @param mesh The Mesh to convert to CSG
  154363. * @returns A new CSG from the Mesh
  154364. */
  154365. static FromMesh(mesh: Mesh): CSG;
  154366. /**
  154367. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  154368. * @param polygons Polygons used to construct a CSG solid
  154369. */
  154370. private static FromPolygons;
  154371. /**
  154372. * Clones, or makes a deep copy, of the CSG
  154373. * @returns A new CSG
  154374. */
  154375. clone(): CSG;
  154376. /**
  154377. * Unions this CSG with another CSG
  154378. * @param csg The CSG to union against this CSG
  154379. * @returns The unioned CSG
  154380. */
  154381. union(csg: CSG): CSG;
  154382. /**
  154383. * Unions this CSG with another CSG in place
  154384. * @param csg The CSG to union against this CSG
  154385. */
  154386. unionInPlace(csg: CSG): void;
  154387. /**
  154388. * Subtracts this CSG with another CSG
  154389. * @param csg The CSG to subtract against this CSG
  154390. * @returns A new CSG
  154391. */
  154392. subtract(csg: CSG): CSG;
  154393. /**
  154394. * Subtracts this CSG with another CSG in place
  154395. * @param csg The CSG to subtact against this CSG
  154396. */
  154397. subtractInPlace(csg: CSG): void;
  154398. /**
  154399. * Intersect this CSG with another CSG
  154400. * @param csg The CSG to intersect against this CSG
  154401. * @returns A new CSG
  154402. */
  154403. intersect(csg: CSG): CSG;
  154404. /**
  154405. * Intersects this CSG with another CSG in place
  154406. * @param csg The CSG to intersect against this CSG
  154407. */
  154408. intersectInPlace(csg: CSG): void;
  154409. /**
  154410. * Return a new CSG solid with solid and empty space switched. This solid is
  154411. * not modified.
  154412. * @returns A new CSG solid with solid and empty space switched
  154413. */
  154414. inverse(): CSG;
  154415. /**
  154416. * Inverses the CSG in place
  154417. */
  154418. inverseInPlace(): void;
  154419. /**
  154420. * This is used to keep meshes transformations so they can be restored
  154421. * when we build back a Babylon Mesh
  154422. * NB : All CSG operations are performed in world coordinates
  154423. * @param csg The CSG to copy the transform attributes from
  154424. * @returns This CSG
  154425. */
  154426. copyTransformAttributes(csg: CSG): CSG;
  154427. /**
  154428. * Build Raw mesh from CSG
  154429. * Coordinates here are in world space
  154430. * @param name The name of the mesh geometry
  154431. * @param scene The Scene
  154432. * @param keepSubMeshes Specifies if the submeshes should be kept
  154433. * @returns A new Mesh
  154434. */
  154435. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  154436. /**
  154437. * Build Mesh from CSG taking material and transforms into account
  154438. * @param name The name of the Mesh
  154439. * @param material The material of the Mesh
  154440. * @param scene The Scene
  154441. * @param keepSubMeshes Specifies if submeshes should be kept
  154442. * @returns The new Mesh
  154443. */
  154444. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  154445. }
  154446. }
  154447. declare module BABYLON {
  154448. /**
  154449. * Class used to create a trail following a mesh
  154450. */
  154451. export class TrailMesh extends Mesh {
  154452. private _generator;
  154453. private _autoStart;
  154454. private _running;
  154455. private _diameter;
  154456. private _length;
  154457. private _sectionPolygonPointsCount;
  154458. private _sectionVectors;
  154459. private _sectionNormalVectors;
  154460. private _beforeRenderObserver;
  154461. /**
  154462. * @constructor
  154463. * @param name The value used by scene.getMeshByName() to do a lookup.
  154464. * @param generator The mesh or transform node to generate a trail.
  154465. * @param scene The scene to add this mesh to.
  154466. * @param diameter Diameter of trailing mesh. Default is 1.
  154467. * @param length Length of trailing mesh. Default is 60.
  154468. * @param autoStart Automatically start trailing mesh. Default true.
  154469. */
  154470. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  154471. /**
  154472. * "TrailMesh"
  154473. * @returns "TrailMesh"
  154474. */
  154475. getClassName(): string;
  154476. private _createMesh;
  154477. /**
  154478. * Start trailing mesh.
  154479. */
  154480. start(): void;
  154481. /**
  154482. * Stop trailing mesh.
  154483. */
  154484. stop(): void;
  154485. /**
  154486. * Update trailing mesh geometry.
  154487. */
  154488. update(): void;
  154489. /**
  154490. * Returns a new TrailMesh object.
  154491. * @param name is a string, the name given to the new mesh
  154492. * @param newGenerator use new generator object for cloned trail mesh
  154493. * @returns a new mesh
  154494. */
  154495. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  154496. /**
  154497. * Serializes this trail mesh
  154498. * @param serializationObject object to write serialization to
  154499. */
  154500. serialize(serializationObject: any): void;
  154501. /**
  154502. * Parses a serialized trail mesh
  154503. * @param parsedMesh the serialized mesh
  154504. * @param scene the scene to create the trail mesh in
  154505. * @returns the created trail mesh
  154506. */
  154507. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  154508. }
  154509. }
  154510. declare module BABYLON {
  154511. /**
  154512. * Class containing static functions to help procedurally build meshes
  154513. */
  154514. export class TiledBoxBuilder {
  154515. /**
  154516. * Creates a box mesh
  154517. * 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)
  154518. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154522. * @param name defines the name of the mesh
  154523. * @param options defines the options used to create the mesh
  154524. * @param scene defines the hosting scene
  154525. * @returns the box mesh
  154526. */
  154527. static CreateTiledBox(name: string, options: {
  154528. pattern?: number;
  154529. width?: number;
  154530. height?: number;
  154531. depth?: number;
  154532. tileSize?: number;
  154533. tileWidth?: number;
  154534. tileHeight?: number;
  154535. alignHorizontal?: number;
  154536. alignVertical?: number;
  154537. faceUV?: Vector4[];
  154538. faceColors?: Color4[];
  154539. sideOrientation?: number;
  154540. updatable?: boolean;
  154541. }, scene?: Nullable<Scene>): Mesh;
  154542. }
  154543. }
  154544. declare module BABYLON {
  154545. /**
  154546. * Class containing static functions to help procedurally build meshes
  154547. */
  154548. export class TorusKnotBuilder {
  154549. /**
  154550. * Creates a torus knot mesh
  154551. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  154552. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  154553. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  154554. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  154555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154558. * @param name defines the name of the mesh
  154559. * @param options defines the options used to create the mesh
  154560. * @param scene defines the hosting scene
  154561. * @returns the torus knot mesh
  154562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  154563. */
  154564. static CreateTorusKnot(name: string, options: {
  154565. radius?: number;
  154566. tube?: number;
  154567. radialSegments?: number;
  154568. tubularSegments?: number;
  154569. p?: number;
  154570. q?: number;
  154571. updatable?: boolean;
  154572. sideOrientation?: number;
  154573. frontUVs?: Vector4;
  154574. backUVs?: Vector4;
  154575. }, scene: any): Mesh;
  154576. }
  154577. }
  154578. declare module BABYLON {
  154579. /**
  154580. * Polygon
  154581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  154582. */
  154583. export class Polygon {
  154584. /**
  154585. * Creates a rectangle
  154586. * @param xmin bottom X coord
  154587. * @param ymin bottom Y coord
  154588. * @param xmax top X coord
  154589. * @param ymax top Y coord
  154590. * @returns points that make the resulting rectation
  154591. */
  154592. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  154593. /**
  154594. * Creates a circle
  154595. * @param radius radius of circle
  154596. * @param cx scale in x
  154597. * @param cy scale in y
  154598. * @param numberOfSides number of sides that make up the circle
  154599. * @returns points that make the resulting circle
  154600. */
  154601. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  154602. /**
  154603. * Creates a polygon from input string
  154604. * @param input Input polygon data
  154605. * @returns the parsed points
  154606. */
  154607. static Parse(input: string): Vector2[];
  154608. /**
  154609. * Starts building a polygon from x and y coordinates
  154610. * @param x x coordinate
  154611. * @param y y coordinate
  154612. * @returns the started path2
  154613. */
  154614. static StartingAt(x: number, y: number): Path2;
  154615. }
  154616. /**
  154617. * Builds a polygon
  154618. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  154619. */
  154620. export class PolygonMeshBuilder {
  154621. private _points;
  154622. private _outlinepoints;
  154623. private _holes;
  154624. private _name;
  154625. private _scene;
  154626. private _epoints;
  154627. private _eholes;
  154628. private _addToepoint;
  154629. /**
  154630. * Babylon reference to the earcut plugin.
  154631. */
  154632. bjsEarcut: any;
  154633. /**
  154634. * Creates a PolygonMeshBuilder
  154635. * @param name name of the builder
  154636. * @param contours Path of the polygon
  154637. * @param scene scene to add to when creating the mesh
  154638. * @param earcutInjection can be used to inject your own earcut reference
  154639. */
  154640. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  154641. /**
  154642. * Adds a hole within the polygon
  154643. * @param hole Array of points defining the hole
  154644. * @returns this
  154645. */
  154646. addHole(hole: Vector2[]): PolygonMeshBuilder;
  154647. /**
  154648. * Creates the polygon
  154649. * @param updatable If the mesh should be updatable
  154650. * @param depth The depth of the mesh created
  154651. * @param smoothingThreshold Dot product threshold for smoothed normals
  154652. * @returns the created mesh
  154653. */
  154654. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  154655. /**
  154656. * Creates the polygon
  154657. * @param depth The depth of the mesh created
  154658. * @param smoothingThreshold Dot product threshold for smoothed normals
  154659. * @returns the created VertexData
  154660. */
  154661. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  154662. /**
  154663. * Adds a side to the polygon
  154664. * @param positions points that make the polygon
  154665. * @param normals normals of the polygon
  154666. * @param uvs uvs of the polygon
  154667. * @param indices indices of the polygon
  154668. * @param bounds bounds of the polygon
  154669. * @param points points of the polygon
  154670. * @param depth depth of the polygon
  154671. * @param flip flip of the polygon
  154672. */
  154673. private addSide;
  154674. }
  154675. }
  154676. declare module BABYLON {
  154677. /**
  154678. * Class containing static functions to help procedurally build meshes
  154679. */
  154680. export class PolygonBuilder {
  154681. /**
  154682. * Creates a polygon mesh
  154683. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  154684. * * 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
  154685. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  154688. * * Remember you can only change the shape positions, not their number when updating a polygon
  154689. * @param name defines the name of the mesh
  154690. * @param options defines the options used to create the mesh
  154691. * @param scene defines the hosting scene
  154692. * @param earcutInjection can be used to inject your own earcut reference
  154693. * @returns the polygon mesh
  154694. */
  154695. static CreatePolygon(name: string, options: {
  154696. shape: Vector3[];
  154697. holes?: Vector3[][];
  154698. depth?: number;
  154699. smoothingThreshold?: number;
  154700. faceUV?: Vector4[];
  154701. faceColors?: Color4[];
  154702. updatable?: boolean;
  154703. sideOrientation?: number;
  154704. frontUVs?: Vector4;
  154705. backUVs?: Vector4;
  154706. wrap?: boolean;
  154707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154708. /**
  154709. * Creates an extruded polygon mesh, with depth in the Y direction.
  154710. * * 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)
  154711. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154712. * @param name defines the name of the mesh
  154713. * @param options defines the options used to create the mesh
  154714. * @param scene defines the hosting scene
  154715. * @param earcutInjection can be used to inject your own earcut reference
  154716. * @returns the polygon mesh
  154717. */
  154718. static ExtrudePolygon(name: string, options: {
  154719. shape: Vector3[];
  154720. holes?: Vector3[][];
  154721. depth?: number;
  154722. faceUV?: Vector4[];
  154723. faceColors?: Color4[];
  154724. updatable?: boolean;
  154725. sideOrientation?: number;
  154726. frontUVs?: Vector4;
  154727. backUVs?: Vector4;
  154728. wrap?: boolean;
  154729. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154730. }
  154731. }
  154732. declare module BABYLON {
  154733. /**
  154734. * Class containing static functions to help procedurally build meshes
  154735. */
  154736. export class LatheBuilder {
  154737. /**
  154738. * Creates lathe mesh.
  154739. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154740. * * 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
  154741. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154742. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154743. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154744. * * 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
  154745. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154746. * * 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
  154747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154751. * @param name defines the name of the mesh
  154752. * @param options defines the options used to create the mesh
  154753. * @param scene defines the hosting scene
  154754. * @returns the lathe mesh
  154755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154756. */
  154757. static CreateLathe(name: string, options: {
  154758. shape: Vector3[];
  154759. radius?: number;
  154760. tessellation?: number;
  154761. clip?: number;
  154762. arc?: number;
  154763. closed?: boolean;
  154764. updatable?: boolean;
  154765. sideOrientation?: number;
  154766. frontUVs?: Vector4;
  154767. backUVs?: Vector4;
  154768. cap?: number;
  154769. invertUV?: boolean;
  154770. }, scene?: Nullable<Scene>): Mesh;
  154771. }
  154772. }
  154773. declare module BABYLON {
  154774. /**
  154775. * Class containing static functions to help procedurally build meshes
  154776. */
  154777. export class TiledPlaneBuilder {
  154778. /**
  154779. * Creates a tiled plane mesh
  154780. * * The parameter `pattern` will, depending on value, do nothing or
  154781. * * * flip (reflect about central vertical) alternate tiles across and up
  154782. * * * flip every tile on alternate rows
  154783. * * * rotate (180 degs) alternate tiles across and up
  154784. * * * rotate every tile on alternate rows
  154785. * * * flip and rotate alternate tiles across and up
  154786. * * * flip and rotate every tile on alternate rows
  154787. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  154788. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  154789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154790. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154791. * * 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)
  154792. * * 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)
  154793. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154794. * @param name defines the name of the mesh
  154795. * @param options defines the options used to create the mesh
  154796. * @param scene defines the hosting scene
  154797. * @returns the box mesh
  154798. */
  154799. static CreateTiledPlane(name: string, options: {
  154800. pattern?: number;
  154801. tileSize?: number;
  154802. tileWidth?: number;
  154803. tileHeight?: number;
  154804. size?: number;
  154805. width?: number;
  154806. height?: number;
  154807. alignHorizontal?: number;
  154808. alignVertical?: number;
  154809. sideOrientation?: number;
  154810. frontUVs?: Vector4;
  154811. backUVs?: Vector4;
  154812. updatable?: boolean;
  154813. }, scene?: Nullable<Scene>): Mesh;
  154814. }
  154815. }
  154816. declare module BABYLON {
  154817. /**
  154818. * Class containing static functions to help procedurally build meshes
  154819. */
  154820. export class TubeBuilder {
  154821. /**
  154822. * Creates a tube mesh.
  154823. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154824. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  154825. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  154826. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  154827. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  154828. * * 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)
  154829. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  154830. * * 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
  154831. * * 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
  154832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154836. * @param name defines the name of the mesh
  154837. * @param options defines the options used to create the mesh
  154838. * @param scene defines the hosting scene
  154839. * @returns the tube mesh
  154840. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154841. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  154842. */
  154843. static CreateTube(name: string, options: {
  154844. path: Vector3[];
  154845. radius?: number;
  154846. tessellation?: number;
  154847. radiusFunction?: {
  154848. (i: number, distance: number): number;
  154849. };
  154850. cap?: number;
  154851. arc?: number;
  154852. updatable?: boolean;
  154853. sideOrientation?: number;
  154854. frontUVs?: Vector4;
  154855. backUVs?: Vector4;
  154856. instance?: Mesh;
  154857. invertUV?: boolean;
  154858. }, scene?: Nullable<Scene>): Mesh;
  154859. }
  154860. }
  154861. declare module BABYLON {
  154862. /**
  154863. * Class containing static functions to help procedurally build meshes
  154864. */
  154865. export class IcoSphereBuilder {
  154866. /**
  154867. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  154868. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  154869. * * 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`)
  154870. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  154871. * * 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
  154872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154875. * @param name defines the name of the mesh
  154876. * @param options defines the options used to create the mesh
  154877. * @param scene defines the hosting scene
  154878. * @returns the icosahedron mesh
  154879. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  154880. */
  154881. static CreateIcoSphere(name: string, options: {
  154882. radius?: number;
  154883. radiusX?: number;
  154884. radiusY?: number;
  154885. radiusZ?: number;
  154886. flat?: boolean;
  154887. subdivisions?: number;
  154888. sideOrientation?: number;
  154889. frontUVs?: Vector4;
  154890. backUVs?: Vector4;
  154891. updatable?: boolean;
  154892. }, scene?: Nullable<Scene>): Mesh;
  154893. }
  154894. }
  154895. declare module BABYLON {
  154896. /**
  154897. * Class containing static functions to help procedurally build meshes
  154898. */
  154899. export class DecalBuilder {
  154900. /**
  154901. * Creates a decal mesh.
  154902. * 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
  154903. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  154904. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  154905. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  154906. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  154907. * @param name defines the name of the mesh
  154908. * @param sourceMesh defines the mesh where the decal must be applied
  154909. * @param options defines the options used to create the mesh
  154910. * @param scene defines the hosting scene
  154911. * @returns the decal mesh
  154912. * @see https://doc.babylonjs.com/how_to/decals
  154913. */
  154914. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  154915. position?: Vector3;
  154916. normal?: Vector3;
  154917. size?: Vector3;
  154918. angle?: number;
  154919. }): Mesh;
  154920. }
  154921. }
  154922. declare module BABYLON {
  154923. /**
  154924. * Class containing static functions to help procedurally build meshes
  154925. */
  154926. export class MeshBuilder {
  154927. /**
  154928. * Creates a box mesh
  154929. * * The parameter `size` sets the size (float) of each box side (default 1)
  154930. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  154931. * * 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)
  154932. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154936. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154937. * @param name defines the name of the mesh
  154938. * @param options defines the options used to create the mesh
  154939. * @param scene defines the hosting scene
  154940. * @returns the box mesh
  154941. */
  154942. static CreateBox(name: string, options: {
  154943. size?: number;
  154944. width?: number;
  154945. height?: number;
  154946. depth?: number;
  154947. faceUV?: Vector4[];
  154948. faceColors?: Color4[];
  154949. sideOrientation?: number;
  154950. frontUVs?: Vector4;
  154951. backUVs?: Vector4;
  154952. wrap?: boolean;
  154953. topBaseAt?: number;
  154954. bottomBaseAt?: number;
  154955. updatable?: boolean;
  154956. }, scene?: Nullable<Scene>): Mesh;
  154957. /**
  154958. * Creates a tiled box mesh
  154959. * * faceTiles sets the pattern, tile size and number of tiles for a face
  154960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154961. * @param name defines the name of the mesh
  154962. * @param options defines the options used to create the mesh
  154963. * @param scene defines the hosting scene
  154964. * @returns the tiled box mesh
  154965. */
  154966. static CreateTiledBox(name: string, options: {
  154967. pattern?: number;
  154968. size?: number;
  154969. width?: number;
  154970. height?: number;
  154971. depth: number;
  154972. tileSize?: number;
  154973. tileWidth?: number;
  154974. tileHeight?: number;
  154975. faceUV?: Vector4[];
  154976. faceColors?: Color4[];
  154977. alignHorizontal?: number;
  154978. alignVertical?: number;
  154979. sideOrientation?: number;
  154980. updatable?: boolean;
  154981. }, scene?: Nullable<Scene>): Mesh;
  154982. /**
  154983. * Creates a sphere mesh
  154984. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  154985. * * 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`)
  154986. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  154987. * * 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
  154988. * * 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)
  154989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154992. * @param name defines the name of the mesh
  154993. * @param options defines the options used to create the mesh
  154994. * @param scene defines the hosting scene
  154995. * @returns the sphere mesh
  154996. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  154997. */
  154998. static CreateSphere(name: string, options: {
  154999. segments?: number;
  155000. diameter?: number;
  155001. diameterX?: number;
  155002. diameterY?: number;
  155003. diameterZ?: number;
  155004. arc?: number;
  155005. slice?: number;
  155006. sideOrientation?: number;
  155007. frontUVs?: Vector4;
  155008. backUVs?: Vector4;
  155009. updatable?: boolean;
  155010. }, scene?: Nullable<Scene>): Mesh;
  155011. /**
  155012. * Creates a plane polygonal mesh. By default, this is a disc
  155013. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  155014. * * 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
  155015. * * 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
  155016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155019. * @param name defines the name of the mesh
  155020. * @param options defines the options used to create the mesh
  155021. * @param scene defines the hosting scene
  155022. * @returns the plane polygonal mesh
  155023. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  155024. */
  155025. static CreateDisc(name: string, options: {
  155026. radius?: number;
  155027. tessellation?: number;
  155028. arc?: number;
  155029. updatable?: boolean;
  155030. sideOrientation?: number;
  155031. frontUVs?: Vector4;
  155032. backUVs?: Vector4;
  155033. }, scene?: Nullable<Scene>): Mesh;
  155034. /**
  155035. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  155036. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  155037. * * 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`)
  155038. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  155039. * * 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
  155040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155043. * @param name defines the name of the mesh
  155044. * @param options defines the options used to create the mesh
  155045. * @param scene defines the hosting scene
  155046. * @returns the icosahedron mesh
  155047. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  155048. */
  155049. static CreateIcoSphere(name: string, options: {
  155050. radius?: number;
  155051. radiusX?: number;
  155052. radiusY?: number;
  155053. radiusZ?: number;
  155054. flat?: boolean;
  155055. subdivisions?: number;
  155056. sideOrientation?: number;
  155057. frontUVs?: Vector4;
  155058. backUVs?: Vector4;
  155059. updatable?: boolean;
  155060. }, scene?: Nullable<Scene>): Mesh;
  155061. /**
  155062. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155063. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  155064. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  155065. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  155066. * * 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
  155067. * * 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
  155068. * * 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
  155069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155071. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155072. * * 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
  155073. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  155074. * * 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
  155075. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  155076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155077. * @param name defines the name of the mesh
  155078. * @param options defines the options used to create the mesh
  155079. * @param scene defines the hosting scene
  155080. * @returns the ribbon mesh
  155081. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  155082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155083. */
  155084. static CreateRibbon(name: string, options: {
  155085. pathArray: Vector3[][];
  155086. closeArray?: boolean;
  155087. closePath?: boolean;
  155088. offset?: number;
  155089. updatable?: boolean;
  155090. sideOrientation?: number;
  155091. frontUVs?: Vector4;
  155092. backUVs?: Vector4;
  155093. instance?: Mesh;
  155094. invertUV?: boolean;
  155095. uvs?: Vector2[];
  155096. colors?: Color4[];
  155097. }, scene?: Nullable<Scene>): Mesh;
  155098. /**
  155099. * Creates a cylinder or a cone mesh
  155100. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  155101. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  155102. * * 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.
  155103. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  155104. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  155105. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  155106. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  155107. * * 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).
  155108. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  155109. * * 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).
  155110. * * 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
  155111. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  155112. * * 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
  155113. * * 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.
  155114. * * If `enclose` is false, a ring surface is one element.
  155115. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  155116. * * 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
  155117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155120. * @param name defines the name of the mesh
  155121. * @param options defines the options used to create the mesh
  155122. * @param scene defines the hosting scene
  155123. * @returns the cylinder mesh
  155124. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  155125. */
  155126. static CreateCylinder(name: string, options: {
  155127. height?: number;
  155128. diameterTop?: number;
  155129. diameterBottom?: number;
  155130. diameter?: number;
  155131. tessellation?: number;
  155132. subdivisions?: number;
  155133. arc?: number;
  155134. faceColors?: Color4[];
  155135. faceUV?: Vector4[];
  155136. updatable?: boolean;
  155137. hasRings?: boolean;
  155138. enclose?: boolean;
  155139. cap?: number;
  155140. sideOrientation?: number;
  155141. frontUVs?: Vector4;
  155142. backUVs?: Vector4;
  155143. }, scene?: Nullable<Scene>): Mesh;
  155144. /**
  155145. * Creates a torus mesh
  155146. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  155147. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  155148. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  155149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155152. * @param name defines the name of the mesh
  155153. * @param options defines the options used to create the mesh
  155154. * @param scene defines the hosting scene
  155155. * @returns the torus mesh
  155156. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  155157. */
  155158. static CreateTorus(name: string, options: {
  155159. diameter?: number;
  155160. thickness?: number;
  155161. tessellation?: number;
  155162. updatable?: boolean;
  155163. sideOrientation?: number;
  155164. frontUVs?: Vector4;
  155165. backUVs?: Vector4;
  155166. }, scene?: Nullable<Scene>): Mesh;
  155167. /**
  155168. * Creates a torus knot mesh
  155169. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  155170. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  155171. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  155172. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  155173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155176. * @param name defines the name of the mesh
  155177. * @param options defines the options used to create the mesh
  155178. * @param scene defines the hosting scene
  155179. * @returns the torus knot mesh
  155180. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  155181. */
  155182. static CreateTorusKnot(name: string, options: {
  155183. radius?: number;
  155184. tube?: number;
  155185. radialSegments?: number;
  155186. tubularSegments?: number;
  155187. p?: number;
  155188. q?: number;
  155189. updatable?: boolean;
  155190. sideOrientation?: number;
  155191. frontUVs?: Vector4;
  155192. backUVs?: Vector4;
  155193. }, scene?: Nullable<Scene>): Mesh;
  155194. /**
  155195. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  155196. * * 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
  155197. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  155198. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  155199. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  155200. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  155201. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  155202. * * 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
  155203. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  155204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  155206. * @param name defines the name of the new line system
  155207. * @param options defines the options used to create the line system
  155208. * @param scene defines the hosting scene
  155209. * @returns a new line system mesh
  155210. */
  155211. static CreateLineSystem(name: string, options: {
  155212. lines: Vector3[][];
  155213. updatable?: boolean;
  155214. instance?: Nullable<LinesMesh>;
  155215. colors?: Nullable<Color4[][]>;
  155216. useVertexAlpha?: boolean;
  155217. }, scene: Nullable<Scene>): LinesMesh;
  155218. /**
  155219. * Creates a line mesh
  155220. * 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
  155221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  155222. * * The parameter `points` is an array successive Vector3
  155223. * * 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
  155224. * * The optional parameter `colors` is an array of successive Color4, one per line point
  155225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  155226. * * When updating an instance, remember that only point positions can change, not the number of points
  155227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  155229. * @param name defines the name of the new line system
  155230. * @param options defines the options used to create the line system
  155231. * @param scene defines the hosting scene
  155232. * @returns a new line mesh
  155233. */
  155234. static CreateLines(name: string, options: {
  155235. points: Vector3[];
  155236. updatable?: boolean;
  155237. instance?: Nullable<LinesMesh>;
  155238. colors?: Color4[];
  155239. useVertexAlpha?: boolean;
  155240. }, scene?: Nullable<Scene>): LinesMesh;
  155241. /**
  155242. * Creates a dashed line mesh
  155243. * * 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
  155244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  155245. * * The parameter `points` is an array successive Vector3
  155246. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  155247. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  155248. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  155249. * * 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
  155250. * * When updating an instance, remember that only point positions can change, not the number of points
  155251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155252. * @param name defines the name of the mesh
  155253. * @param options defines the options used to create the mesh
  155254. * @param scene defines the hosting scene
  155255. * @returns the dashed line mesh
  155256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  155257. */
  155258. static CreateDashedLines(name: string, options: {
  155259. points: Vector3[];
  155260. dashSize?: number;
  155261. gapSize?: number;
  155262. dashNb?: number;
  155263. updatable?: boolean;
  155264. instance?: LinesMesh;
  155265. }, scene?: Nullable<Scene>): LinesMesh;
  155266. /**
  155267. * 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.
  155268. * * 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.
  155269. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  155270. * * 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.
  155271. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  155272. * * 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
  155273. * * 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
  155274. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  155275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  155278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155279. * @param name defines the name of the mesh
  155280. * @param options defines the options used to create the mesh
  155281. * @param scene defines the hosting scene
  155282. * @returns the extruded shape mesh
  155283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  155285. */
  155286. static ExtrudeShape(name: string, options: {
  155287. shape: Vector3[];
  155288. path: Vector3[];
  155289. scale?: number;
  155290. rotation?: number;
  155291. cap?: number;
  155292. updatable?: boolean;
  155293. sideOrientation?: number;
  155294. frontUVs?: Vector4;
  155295. backUVs?: Vector4;
  155296. instance?: Mesh;
  155297. invertUV?: boolean;
  155298. }, scene?: Nullable<Scene>): Mesh;
  155299. /**
  155300. * Creates an custom extruded shape mesh.
  155301. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  155302. * * 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.
  155303. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  155304. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  155305. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  155306. * * 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
  155307. * * It must returns a float value that will be the scale value applied to the shape on each path point
  155308. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  155309. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  155310. * * 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
  155311. * * 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
  155312. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  155313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155317. * @param name defines the name of the mesh
  155318. * @param options defines the options used to create the mesh
  155319. * @param scene defines the hosting scene
  155320. * @returns the custom extruded shape mesh
  155321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  155322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  155324. */
  155325. static ExtrudeShapeCustom(name: string, options: {
  155326. shape: Vector3[];
  155327. path: Vector3[];
  155328. scaleFunction?: any;
  155329. rotationFunction?: any;
  155330. ribbonCloseArray?: boolean;
  155331. ribbonClosePath?: boolean;
  155332. cap?: number;
  155333. updatable?: boolean;
  155334. sideOrientation?: number;
  155335. frontUVs?: Vector4;
  155336. backUVs?: Vector4;
  155337. instance?: Mesh;
  155338. invertUV?: boolean;
  155339. }, scene?: Nullable<Scene>): Mesh;
  155340. /**
  155341. * Creates lathe mesh.
  155342. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  155343. * * 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
  155344. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  155345. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  155346. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  155347. * * 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
  155348. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  155349. * * 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
  155350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155354. * @param name defines the name of the mesh
  155355. * @param options defines the options used to create the mesh
  155356. * @param scene defines the hosting scene
  155357. * @returns the lathe mesh
  155358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  155359. */
  155360. static CreateLathe(name: string, options: {
  155361. shape: Vector3[];
  155362. radius?: number;
  155363. tessellation?: number;
  155364. clip?: number;
  155365. arc?: number;
  155366. closed?: boolean;
  155367. updatable?: boolean;
  155368. sideOrientation?: number;
  155369. frontUVs?: Vector4;
  155370. backUVs?: Vector4;
  155371. cap?: number;
  155372. invertUV?: boolean;
  155373. }, scene?: Nullable<Scene>): Mesh;
  155374. /**
  155375. * Creates a tiled plane mesh
  155376. * * You can set a limited pattern arrangement with the tiles
  155377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155380. * @param name defines the name of the mesh
  155381. * @param options defines the options used to create the mesh
  155382. * @param scene defines the hosting scene
  155383. * @returns the plane mesh
  155384. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  155385. */
  155386. static CreateTiledPlane(name: string, options: {
  155387. pattern?: number;
  155388. tileSize?: number;
  155389. tileWidth?: number;
  155390. tileHeight?: number;
  155391. size?: number;
  155392. width?: number;
  155393. height?: number;
  155394. alignHorizontal?: number;
  155395. alignVertical?: number;
  155396. sideOrientation?: number;
  155397. frontUVs?: Vector4;
  155398. backUVs?: Vector4;
  155399. updatable?: boolean;
  155400. }, scene?: Nullable<Scene>): Mesh;
  155401. /**
  155402. * Creates a plane mesh
  155403. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  155404. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  155405. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  155406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155409. * @param name defines the name of the mesh
  155410. * @param options defines the options used to create the mesh
  155411. * @param scene defines the hosting scene
  155412. * @returns the plane mesh
  155413. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  155414. */
  155415. static CreatePlane(name: string, options: {
  155416. size?: number;
  155417. width?: number;
  155418. height?: number;
  155419. sideOrientation?: number;
  155420. frontUVs?: Vector4;
  155421. backUVs?: Vector4;
  155422. updatable?: boolean;
  155423. sourcePlane?: Plane;
  155424. }, scene?: Nullable<Scene>): Mesh;
  155425. /**
  155426. * Creates a ground mesh
  155427. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  155428. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  155429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155430. * @param name defines the name of the mesh
  155431. * @param options defines the options used to create the mesh
  155432. * @param scene defines the hosting scene
  155433. * @returns the ground mesh
  155434. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  155435. */
  155436. static CreateGround(name: string, options: {
  155437. width?: number;
  155438. height?: number;
  155439. subdivisions?: number;
  155440. subdivisionsX?: number;
  155441. subdivisionsY?: number;
  155442. updatable?: boolean;
  155443. }, scene?: Nullable<Scene>): Mesh;
  155444. /**
  155445. * Creates a tiled ground mesh
  155446. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  155447. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  155448. * * 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
  155449. * * 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
  155450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155451. * @param name defines the name of the mesh
  155452. * @param options defines the options used to create the mesh
  155453. * @param scene defines the hosting scene
  155454. * @returns the tiled ground mesh
  155455. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  155456. */
  155457. static CreateTiledGround(name: string, options: {
  155458. xmin: number;
  155459. zmin: number;
  155460. xmax: number;
  155461. zmax: number;
  155462. subdivisions?: {
  155463. w: number;
  155464. h: number;
  155465. };
  155466. precision?: {
  155467. w: number;
  155468. h: number;
  155469. };
  155470. updatable?: boolean;
  155471. }, scene?: Nullable<Scene>): Mesh;
  155472. /**
  155473. * Creates a ground mesh from a height map
  155474. * * The parameter `url` sets the URL of the height map image resource.
  155475. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  155476. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  155477. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  155478. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  155479. * * 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.
  155480. * * 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).
  155481. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  155482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155483. * @param name defines the name of the mesh
  155484. * @param url defines the url to the height map
  155485. * @param options defines the options used to create the mesh
  155486. * @param scene defines the hosting scene
  155487. * @returns the ground mesh
  155488. * @see https://doc.babylonjs.com/babylon101/height_map
  155489. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  155490. */
  155491. static CreateGroundFromHeightMap(name: string, url: string, options: {
  155492. width?: number;
  155493. height?: number;
  155494. subdivisions?: number;
  155495. minHeight?: number;
  155496. maxHeight?: number;
  155497. colorFilter?: Color3;
  155498. alphaFilter?: number;
  155499. updatable?: boolean;
  155500. onReady?: (mesh: GroundMesh) => void;
  155501. }, scene?: Nullable<Scene>): GroundMesh;
  155502. /**
  155503. * Creates a polygon mesh
  155504. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  155505. * * 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
  155506. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  155507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  155509. * * Remember you can only change the shape positions, not their number when updating a polygon
  155510. * @param name defines the name of the mesh
  155511. * @param options defines the options used to create the mesh
  155512. * @param scene defines the hosting scene
  155513. * @param earcutInjection can be used to inject your own earcut reference
  155514. * @returns the polygon mesh
  155515. */
  155516. static CreatePolygon(name: string, options: {
  155517. shape: Vector3[];
  155518. holes?: Vector3[][];
  155519. depth?: number;
  155520. faceUV?: Vector4[];
  155521. faceColors?: Color4[];
  155522. updatable?: boolean;
  155523. sideOrientation?: number;
  155524. frontUVs?: Vector4;
  155525. backUVs?: Vector4;
  155526. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155527. /**
  155528. * Creates an extruded polygon mesh, with depth in the Y direction.
  155529. * * 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)
  155530. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155531. * @param name defines the name of the mesh
  155532. * @param options defines the options used to create the mesh
  155533. * @param scene defines the hosting scene
  155534. * @param earcutInjection can be used to inject your own earcut reference
  155535. * @returns the polygon mesh
  155536. */
  155537. static ExtrudePolygon(name: string, options: {
  155538. shape: Vector3[];
  155539. holes?: Vector3[][];
  155540. depth?: number;
  155541. faceUV?: Vector4[];
  155542. faceColors?: Color4[];
  155543. updatable?: boolean;
  155544. sideOrientation?: number;
  155545. frontUVs?: Vector4;
  155546. backUVs?: Vector4;
  155547. wrap?: boolean;
  155548. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155549. /**
  155550. * Creates a tube mesh.
  155551. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155552. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  155553. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  155554. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  155555. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  155556. * * 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)
  155557. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  155558. * * 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
  155559. * * 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
  155560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155564. * @param name defines the name of the mesh
  155565. * @param options defines the options used to create the mesh
  155566. * @param scene defines the hosting scene
  155567. * @returns the tube mesh
  155568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155569. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  155570. */
  155571. static CreateTube(name: string, options: {
  155572. path: Vector3[];
  155573. radius?: number;
  155574. tessellation?: number;
  155575. radiusFunction?: {
  155576. (i: number, distance: number): number;
  155577. };
  155578. cap?: number;
  155579. arc?: number;
  155580. updatable?: boolean;
  155581. sideOrientation?: number;
  155582. frontUVs?: Vector4;
  155583. backUVs?: Vector4;
  155584. instance?: Mesh;
  155585. invertUV?: boolean;
  155586. }, scene?: Nullable<Scene>): Mesh;
  155587. /**
  155588. * Creates a polyhedron mesh
  155589. * * 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
  155590. * * The parameter `size` (positive float, default 1) sets the polygon size
  155591. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  155592. * * 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`
  155593. * * 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
  155594. * * 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)`)
  155595. * * 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
  155596. * * 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
  155597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155600. * @param name defines the name of the mesh
  155601. * @param options defines the options used to create the mesh
  155602. * @param scene defines the hosting scene
  155603. * @returns the polyhedron mesh
  155604. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  155605. */
  155606. static CreatePolyhedron(name: string, options: {
  155607. type?: number;
  155608. size?: number;
  155609. sizeX?: number;
  155610. sizeY?: number;
  155611. sizeZ?: number;
  155612. custom?: any;
  155613. faceUV?: Vector4[];
  155614. faceColors?: Color4[];
  155615. flat?: boolean;
  155616. updatable?: boolean;
  155617. sideOrientation?: number;
  155618. frontUVs?: Vector4;
  155619. backUVs?: Vector4;
  155620. }, scene?: Nullable<Scene>): Mesh;
  155621. /**
  155622. * Creates a decal mesh.
  155623. * 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
  155624. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  155625. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  155626. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  155627. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  155628. * @param name defines the name of the mesh
  155629. * @param sourceMesh defines the mesh where the decal must be applied
  155630. * @param options defines the options used to create the mesh
  155631. * @param scene defines the hosting scene
  155632. * @returns the decal mesh
  155633. * @see https://doc.babylonjs.com/how_to/decals
  155634. */
  155635. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  155636. position?: Vector3;
  155637. normal?: Vector3;
  155638. size?: Vector3;
  155639. angle?: number;
  155640. }): Mesh;
  155641. /**
  155642. * Creates a Capsule Mesh
  155643. * @param name defines the name of the mesh.
  155644. * @param options the constructors options used to shape the mesh.
  155645. * @param scene defines the scene the mesh is scoped to.
  155646. * @returns the capsule mesh
  155647. * @see https://doc.babylonjs.com/how_to/capsule_shape
  155648. */
  155649. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  155650. }
  155651. }
  155652. declare module BABYLON {
  155653. /**
  155654. * A simplifier interface for future simplification implementations
  155655. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155656. */
  155657. export interface ISimplifier {
  155658. /**
  155659. * Simplification of a given mesh according to the given settings.
  155660. * Since this requires computation, it is assumed that the function runs async.
  155661. * @param settings The settings of the simplification, including quality and distance
  155662. * @param successCallback A callback that will be called after the mesh was simplified.
  155663. * @param errorCallback in case of an error, this callback will be called. optional.
  155664. */
  155665. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  155666. }
  155667. /**
  155668. * Expected simplification settings.
  155669. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  155670. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155671. */
  155672. export interface ISimplificationSettings {
  155673. /**
  155674. * Gets or sets the expected quality
  155675. */
  155676. quality: number;
  155677. /**
  155678. * Gets or sets the distance when this optimized version should be used
  155679. */
  155680. distance: number;
  155681. /**
  155682. * Gets an already optimized mesh
  155683. */
  155684. optimizeMesh?: boolean;
  155685. }
  155686. /**
  155687. * Class used to specify simplification options
  155688. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155689. */
  155690. export class SimplificationSettings implements ISimplificationSettings {
  155691. /** expected quality */
  155692. quality: number;
  155693. /** distance when this optimized version should be used */
  155694. distance: number;
  155695. /** already optimized mesh */
  155696. optimizeMesh?: boolean | undefined;
  155697. /**
  155698. * Creates a SimplificationSettings
  155699. * @param quality expected quality
  155700. * @param distance distance when this optimized version should be used
  155701. * @param optimizeMesh already optimized mesh
  155702. */
  155703. constructor(
  155704. /** expected quality */
  155705. quality: number,
  155706. /** distance when this optimized version should be used */
  155707. distance: number,
  155708. /** already optimized mesh */
  155709. optimizeMesh?: boolean | undefined);
  155710. }
  155711. /**
  155712. * Interface used to define a simplification task
  155713. */
  155714. export interface ISimplificationTask {
  155715. /**
  155716. * Array of settings
  155717. */
  155718. settings: Array<ISimplificationSettings>;
  155719. /**
  155720. * Simplification type
  155721. */
  155722. simplificationType: SimplificationType;
  155723. /**
  155724. * Mesh to simplify
  155725. */
  155726. mesh: Mesh;
  155727. /**
  155728. * Callback called on success
  155729. */
  155730. successCallback?: () => void;
  155731. /**
  155732. * Defines if parallel processing can be used
  155733. */
  155734. parallelProcessing: boolean;
  155735. }
  155736. /**
  155737. * Queue used to order the simplification tasks
  155738. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155739. */
  155740. export class SimplificationQueue {
  155741. private _simplificationArray;
  155742. /**
  155743. * Gets a boolean indicating that the process is still running
  155744. */
  155745. running: boolean;
  155746. /**
  155747. * Creates a new queue
  155748. */
  155749. constructor();
  155750. /**
  155751. * Adds a new simplification task
  155752. * @param task defines a task to add
  155753. */
  155754. addTask(task: ISimplificationTask): void;
  155755. /**
  155756. * Execute next task
  155757. */
  155758. executeNext(): void;
  155759. /**
  155760. * Execute a simplification task
  155761. * @param task defines the task to run
  155762. */
  155763. runSimplification(task: ISimplificationTask): void;
  155764. private getSimplifier;
  155765. }
  155766. /**
  155767. * The implemented types of simplification
  155768. * At the moment only Quadratic Error Decimation is implemented
  155769. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155770. */
  155771. export enum SimplificationType {
  155772. /** Quadratic error decimation */
  155773. QUADRATIC = 0
  155774. }
  155775. /**
  155776. * An implementation of the Quadratic Error simplification algorithm.
  155777. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  155778. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  155779. * @author RaananW
  155780. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155781. */
  155782. export class QuadraticErrorSimplification implements ISimplifier {
  155783. private _mesh;
  155784. private triangles;
  155785. private vertices;
  155786. private references;
  155787. private _reconstructedMesh;
  155788. /** Gets or sets the number pf sync interations */
  155789. syncIterations: number;
  155790. /** Gets or sets the aggressiveness of the simplifier */
  155791. aggressiveness: number;
  155792. /** Gets or sets the number of allowed iterations for decimation */
  155793. decimationIterations: number;
  155794. /** Gets or sets the espilon to use for bounding box computation */
  155795. boundingBoxEpsilon: number;
  155796. /**
  155797. * Creates a new QuadraticErrorSimplification
  155798. * @param _mesh defines the target mesh
  155799. */
  155800. constructor(_mesh: Mesh);
  155801. /**
  155802. * Simplification of a given mesh according to the given settings.
  155803. * Since this requires computation, it is assumed that the function runs async.
  155804. * @param settings The settings of the simplification, including quality and distance
  155805. * @param successCallback A callback that will be called after the mesh was simplified.
  155806. */
  155807. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  155808. private runDecimation;
  155809. private initWithMesh;
  155810. private init;
  155811. private reconstructMesh;
  155812. private initDecimatedMesh;
  155813. private isFlipped;
  155814. private updateTriangles;
  155815. private identifyBorder;
  155816. private updateMesh;
  155817. private vertexError;
  155818. private calculateError;
  155819. }
  155820. }
  155821. declare module BABYLON {
  155822. interface Scene {
  155823. /** @hidden (Backing field) */
  155824. _simplificationQueue: SimplificationQueue;
  155825. /**
  155826. * Gets or sets the simplification queue attached to the scene
  155827. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155828. */
  155829. simplificationQueue: SimplificationQueue;
  155830. }
  155831. interface Mesh {
  155832. /**
  155833. * Simplify the mesh according to the given array of settings.
  155834. * Function will return immediately and will simplify async
  155835. * @param settings a collection of simplification settings
  155836. * @param parallelProcessing should all levels calculate parallel or one after the other
  155837. * @param simplificationType the type of simplification to run
  155838. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  155839. * @returns the current mesh
  155840. */
  155841. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  155842. }
  155843. /**
  155844. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  155845. * created in a scene
  155846. */
  155847. export class SimplicationQueueSceneComponent implements ISceneComponent {
  155848. /**
  155849. * The component name helpfull to identify the component in the list of scene components.
  155850. */
  155851. readonly name: string;
  155852. /**
  155853. * The scene the component belongs to.
  155854. */
  155855. scene: Scene;
  155856. /**
  155857. * Creates a new instance of the component for the given scene
  155858. * @param scene Defines the scene to register the component in
  155859. */
  155860. constructor(scene: Scene);
  155861. /**
  155862. * Registers the component in a given scene
  155863. */
  155864. register(): void;
  155865. /**
  155866. * Rebuilds the elements related to this component in case of
  155867. * context lost for instance.
  155868. */
  155869. rebuild(): void;
  155870. /**
  155871. * Disposes the component and the associated ressources
  155872. */
  155873. dispose(): void;
  155874. private _beforeCameraUpdate;
  155875. }
  155876. }
  155877. declare module BABYLON {
  155878. interface Mesh {
  155879. /**
  155880. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  155881. */
  155882. thinInstanceEnablePicking: boolean;
  155883. /**
  155884. * Creates a new thin instance
  155885. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  155886. * @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
  155887. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  155888. */
  155889. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  155890. /**
  155891. * Adds the transformation (matrix) of the current mesh as a thin instance
  155892. * @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
  155893. * @returns the thin instance index number
  155894. */
  155895. thinInstanceAddSelf(refresh: boolean): number;
  155896. /**
  155897. * Registers a custom attribute to be used with thin instances
  155898. * @param kind name of the attribute
  155899. * @param stride size in floats of the attribute
  155900. */
  155901. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  155902. /**
  155903. * Sets the matrix of a thin instance
  155904. * @param index index of the thin instance
  155905. * @param matrix matrix to set
  155906. * @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
  155907. */
  155908. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  155909. /**
  155910. * Sets the value of a custom attribute for a thin instance
  155911. * @param kind name of the attribute
  155912. * @param index index of the thin instance
  155913. * @param value value to set
  155914. * @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
  155915. */
  155916. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  155917. /**
  155918. * 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.
  155919. */
  155920. thinInstanceCount: number;
  155921. /**
  155922. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  155923. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  155924. * @param buffer buffer to set
  155925. * @param stride size in floats of each value of the buffer
  155926. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  155927. */
  155928. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  155929. /**
  155930. * Gets the list of world matrices
  155931. * @return an array containing all the world matrices from the thin instances
  155932. */
  155933. thinInstanceGetWorldMatrices(): Matrix[];
  155934. /**
  155935. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  155936. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155937. */
  155938. thinInstanceBufferUpdated(kind: string): void;
  155939. /**
  155940. * Applies a partial update to a buffer directly on the GPU
  155941. * 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
  155942. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155943. * @param data the data to set in the GPU buffer
  155944. * @param offset the offset in the GPU buffer where to update the data
  155945. */
  155946. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  155947. /**
  155948. * Refreshes the bounding info, taking into account all the thin instances defined
  155949. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  155950. */
  155951. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  155952. /** @hidden */
  155953. _thinInstanceInitializeUserStorage(): void;
  155954. /** @hidden */
  155955. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  155956. /** @hidden */
  155957. _userThinInstanceBuffersStorage: {
  155958. data: {
  155959. [key: string]: Float32Array;
  155960. };
  155961. sizes: {
  155962. [key: string]: number;
  155963. };
  155964. vertexBuffers: {
  155965. [key: string]: Nullable<VertexBuffer>;
  155966. };
  155967. strides: {
  155968. [key: string]: number;
  155969. };
  155970. };
  155971. }
  155972. }
  155973. declare module BABYLON {
  155974. /**
  155975. * Navigation plugin interface to add navigation constrained by a navigation mesh
  155976. */
  155977. export interface INavigationEnginePlugin {
  155978. /**
  155979. * plugin name
  155980. */
  155981. name: string;
  155982. /**
  155983. * Creates a navigation mesh
  155984. * @param meshes array of all the geometry used to compute the navigatio mesh
  155985. * @param parameters bunch of parameters used to filter geometry
  155986. */
  155987. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  155988. /**
  155989. * Create a navigation mesh debug mesh
  155990. * @param scene is where the mesh will be added
  155991. * @returns debug display mesh
  155992. */
  155993. createDebugNavMesh(scene: Scene): Mesh;
  155994. /**
  155995. * Get a navigation mesh constrained position, closest to the parameter position
  155996. * @param position world position
  155997. * @returns the closest point to position constrained by the navigation mesh
  155998. */
  155999. getClosestPoint(position: Vector3): Vector3;
  156000. /**
  156001. * Get a navigation mesh constrained position, closest to the parameter position
  156002. * @param position world position
  156003. * @param result output the closest point to position constrained by the navigation mesh
  156004. */
  156005. getClosestPointToRef(position: Vector3, result: Vector3): void;
  156006. /**
  156007. * Get a navigation mesh constrained position, within a particular radius
  156008. * @param position world position
  156009. * @param maxRadius the maximum distance to the constrained world position
  156010. * @returns the closest point to position constrained by the navigation mesh
  156011. */
  156012. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  156013. /**
  156014. * Get a navigation mesh constrained position, within a particular radius
  156015. * @param position world position
  156016. * @param maxRadius the maximum distance to the constrained world position
  156017. * @param result output the closest point to position constrained by the navigation mesh
  156018. */
  156019. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  156020. /**
  156021. * Compute the final position from a segment made of destination-position
  156022. * @param position world position
  156023. * @param destination world position
  156024. * @returns the resulting point along the navmesh
  156025. */
  156026. moveAlong(position: Vector3, destination: Vector3): Vector3;
  156027. /**
  156028. * Compute the final position from a segment made of destination-position
  156029. * @param position world position
  156030. * @param destination world position
  156031. * @param result output the resulting point along the navmesh
  156032. */
  156033. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  156034. /**
  156035. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  156036. * @param start world position
  156037. * @param end world position
  156038. * @returns array containing world position composing the path
  156039. */
  156040. computePath(start: Vector3, end: Vector3): Vector3[];
  156041. /**
  156042. * If this plugin is supported
  156043. * @returns true if plugin is supported
  156044. */
  156045. isSupported(): boolean;
  156046. /**
  156047. * Create a new Crowd so you can add agents
  156048. * @param maxAgents the maximum agent count in the crowd
  156049. * @param maxAgentRadius the maximum radius an agent can have
  156050. * @param scene to attach the crowd to
  156051. * @returns the crowd you can add agents to
  156052. */
  156053. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  156054. /**
  156055. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156056. * The queries will try to find a solution within those bounds
  156057. * default is (1,1,1)
  156058. * @param extent x,y,z value that define the extent around the queries point of reference
  156059. */
  156060. setDefaultQueryExtent(extent: Vector3): void;
  156061. /**
  156062. * Get the Bounding box extent specified by setDefaultQueryExtent
  156063. * @returns the box extent values
  156064. */
  156065. getDefaultQueryExtent(): Vector3;
  156066. /**
  156067. * build the navmesh from a previously saved state using getNavmeshData
  156068. * @param data the Uint8Array returned by getNavmeshData
  156069. */
  156070. buildFromNavmeshData(data: Uint8Array): void;
  156071. /**
  156072. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  156073. * @returns data the Uint8Array that can be saved and reused
  156074. */
  156075. getNavmeshData(): Uint8Array;
  156076. /**
  156077. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156078. * @param result output the box extent values
  156079. */
  156080. getDefaultQueryExtentToRef(result: Vector3): void;
  156081. /**
  156082. * Set the time step of the navigation tick update.
  156083. * Default is 1/60.
  156084. * A value of 0 will disable fixed time update
  156085. * @param newTimeStep the new timestep to apply to this world.
  156086. */
  156087. setTimeStep(newTimeStep: number): void;
  156088. /**
  156089. * Get the time step of the navigation tick update.
  156090. * @returns the current time step
  156091. */
  156092. getTimeStep(): number;
  156093. /**
  156094. * If delta time in navigation tick update is greater than the time step
  156095. * a number of sub iterations are done. If more iterations are need to reach deltatime
  156096. * they will be discarded.
  156097. * A value of 0 will set to no maximum and update will use as many substeps as needed
  156098. * @param newStepCount the maximum number of iterations
  156099. */
  156100. setMaximumSubStepCount(newStepCount: number): void;
  156101. /**
  156102. * Get the maximum number of iterations per navigation tick update
  156103. * @returns the maximum number of iterations
  156104. */
  156105. getMaximumSubStepCount(): number;
  156106. /**
  156107. * Release all resources
  156108. */
  156109. dispose(): void;
  156110. }
  156111. /**
  156112. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  156113. */
  156114. export interface ICrowd {
  156115. /**
  156116. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  156117. * You can attach anything to that node. The node position is updated in the scene update tick.
  156118. * @param pos world position that will be constrained by the navigation mesh
  156119. * @param parameters agent parameters
  156120. * @param transform hooked to the agent that will be update by the scene
  156121. * @returns agent index
  156122. */
  156123. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  156124. /**
  156125. * Returns the agent position in world space
  156126. * @param index agent index returned by addAgent
  156127. * @returns world space position
  156128. */
  156129. getAgentPosition(index: number): Vector3;
  156130. /**
  156131. * Gets the agent position result in world space
  156132. * @param index agent index returned by addAgent
  156133. * @param result output world space position
  156134. */
  156135. getAgentPositionToRef(index: number, result: Vector3): void;
  156136. /**
  156137. * Gets the agent velocity in world space
  156138. * @param index agent index returned by addAgent
  156139. * @returns world space velocity
  156140. */
  156141. getAgentVelocity(index: number): Vector3;
  156142. /**
  156143. * Gets the agent velocity result in world space
  156144. * @param index agent index returned by addAgent
  156145. * @param result output world space velocity
  156146. */
  156147. getAgentVelocityToRef(index: number, result: Vector3): void;
  156148. /**
  156149. * Gets the agent next target point on the path
  156150. * @param index agent index returned by addAgent
  156151. * @returns world space position
  156152. */
  156153. getAgentNextTargetPath(index: number): Vector3;
  156154. /**
  156155. * Gets the agent state
  156156. * @param index agent index returned by addAgent
  156157. * @returns agent state
  156158. */
  156159. getAgentState(index: number): number;
  156160. /**
  156161. * returns true if the agent in over an off mesh link connection
  156162. * @param index agent index returned by addAgent
  156163. * @returns true if over an off mesh link connection
  156164. */
  156165. overOffmeshConnection(index: number): boolean;
  156166. /**
  156167. * Gets the agent next target point on the path
  156168. * @param index agent index returned by addAgent
  156169. * @param result output world space position
  156170. */
  156171. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  156172. /**
  156173. * remove a particular agent previously created
  156174. * @param index agent index returned by addAgent
  156175. */
  156176. removeAgent(index: number): void;
  156177. /**
  156178. * get the list of all agents attached to this crowd
  156179. * @returns list of agent indices
  156180. */
  156181. getAgents(): number[];
  156182. /**
  156183. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  156184. * @param deltaTime in seconds
  156185. */
  156186. update(deltaTime: number): void;
  156187. /**
  156188. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  156189. * @param index agent index returned by addAgent
  156190. * @param destination targeted world position
  156191. */
  156192. agentGoto(index: number, destination: Vector3): void;
  156193. /**
  156194. * Teleport the agent to a new position
  156195. * @param index agent index returned by addAgent
  156196. * @param destination targeted world position
  156197. */
  156198. agentTeleport(index: number, destination: Vector3): void;
  156199. /**
  156200. * Update agent parameters
  156201. * @param index agent index returned by addAgent
  156202. * @param parameters agent parameters
  156203. */
  156204. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  156205. /**
  156206. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156207. * The queries will try to find a solution within those bounds
  156208. * default is (1,1,1)
  156209. * @param extent x,y,z value that define the extent around the queries point of reference
  156210. */
  156211. setDefaultQueryExtent(extent: Vector3): void;
  156212. /**
  156213. * Get the Bounding box extent specified by setDefaultQueryExtent
  156214. * @returns the box extent values
  156215. */
  156216. getDefaultQueryExtent(): Vector3;
  156217. /**
  156218. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156219. * @param result output the box extent values
  156220. */
  156221. getDefaultQueryExtentToRef(result: Vector3): void;
  156222. /**
  156223. * Release all resources
  156224. */
  156225. dispose(): void;
  156226. }
  156227. /**
  156228. * Configures an agent
  156229. */
  156230. export interface IAgentParameters {
  156231. /**
  156232. * Agent radius. [Limit: >= 0]
  156233. */
  156234. radius: number;
  156235. /**
  156236. * Agent height. [Limit: > 0]
  156237. */
  156238. height: number;
  156239. /**
  156240. * Maximum allowed acceleration. [Limit: >= 0]
  156241. */
  156242. maxAcceleration: number;
  156243. /**
  156244. * Maximum allowed speed. [Limit: >= 0]
  156245. */
  156246. maxSpeed: number;
  156247. /**
  156248. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  156249. */
  156250. collisionQueryRange: number;
  156251. /**
  156252. * The path visibility optimization range. [Limit: > 0]
  156253. */
  156254. pathOptimizationRange: number;
  156255. /**
  156256. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  156257. */
  156258. separationWeight: number;
  156259. }
  156260. /**
  156261. * Configures the navigation mesh creation
  156262. */
  156263. export interface INavMeshParameters {
  156264. /**
  156265. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  156266. */
  156267. cs: number;
  156268. /**
  156269. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  156270. */
  156271. ch: number;
  156272. /**
  156273. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  156274. */
  156275. walkableSlopeAngle: number;
  156276. /**
  156277. * Minimum floor to 'ceiling' height that will still allow the floor area to
  156278. * be considered walkable. [Limit: >= 3] [Units: vx]
  156279. */
  156280. walkableHeight: number;
  156281. /**
  156282. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  156283. */
  156284. walkableClimb: number;
  156285. /**
  156286. * The distance to erode/shrink the walkable area of the heightfield away from
  156287. * obstructions. [Limit: >=0] [Units: vx]
  156288. */
  156289. walkableRadius: number;
  156290. /**
  156291. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  156292. */
  156293. maxEdgeLen: number;
  156294. /**
  156295. * The maximum distance a simplfied contour's border edges should deviate
  156296. * the original raw contour. [Limit: >=0] [Units: vx]
  156297. */
  156298. maxSimplificationError: number;
  156299. /**
  156300. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  156301. */
  156302. minRegionArea: number;
  156303. /**
  156304. * Any regions with a span count smaller than this value will, if possible,
  156305. * be merged with larger regions. [Limit: >=0] [Units: vx]
  156306. */
  156307. mergeRegionArea: number;
  156308. /**
  156309. * The maximum number of vertices allowed for polygons generated during the
  156310. * contour to polygon conversion process. [Limit: >= 3]
  156311. */
  156312. maxVertsPerPoly: number;
  156313. /**
  156314. * Sets the sampling distance to use when generating the detail mesh.
  156315. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  156316. */
  156317. detailSampleDist: number;
  156318. /**
  156319. * The maximum distance the detail mesh surface should deviate from heightfield
  156320. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  156321. */
  156322. detailSampleMaxError: number;
  156323. }
  156324. }
  156325. declare module BABYLON {
  156326. /**
  156327. * RecastJS navigation plugin
  156328. */
  156329. export class RecastJSPlugin implements INavigationEnginePlugin {
  156330. /**
  156331. * Reference to the Recast library
  156332. */
  156333. bjsRECAST: any;
  156334. /**
  156335. * plugin name
  156336. */
  156337. name: string;
  156338. /**
  156339. * the first navmesh created. We might extend this to support multiple navmeshes
  156340. */
  156341. navMesh: any;
  156342. private _maximumSubStepCount;
  156343. private _timeStep;
  156344. /**
  156345. * Initializes the recastJS plugin
  156346. * @param recastInjection can be used to inject your own recast reference
  156347. */
  156348. constructor(recastInjection?: any);
  156349. /**
  156350. * Set the time step of the navigation tick update.
  156351. * Default is 1/60.
  156352. * A value of 0 will disable fixed time update
  156353. * @param newTimeStep the new timestep to apply to this world.
  156354. */
  156355. setTimeStep(newTimeStep?: number): void;
  156356. /**
  156357. * Get the time step of the navigation tick update.
  156358. * @returns the current time step
  156359. */
  156360. getTimeStep(): number;
  156361. /**
  156362. * If delta time in navigation tick update is greater than the time step
  156363. * a number of sub iterations are done. If more iterations are need to reach deltatime
  156364. * they will be discarded.
  156365. * A value of 0 will set to no maximum and update will use as many substeps as needed
  156366. * @param newStepCount the maximum number of iterations
  156367. */
  156368. setMaximumSubStepCount(newStepCount?: number): void;
  156369. /**
  156370. * Get the maximum number of iterations per navigation tick update
  156371. * @returns the maximum number of iterations
  156372. */
  156373. getMaximumSubStepCount(): number;
  156374. /**
  156375. * Creates a navigation mesh
  156376. * @param meshes array of all the geometry used to compute the navigatio mesh
  156377. * @param parameters bunch of parameters used to filter geometry
  156378. */
  156379. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  156380. /**
  156381. * Create a navigation mesh debug mesh
  156382. * @param scene is where the mesh will be added
  156383. * @returns debug display mesh
  156384. */
  156385. createDebugNavMesh(scene: Scene): Mesh;
  156386. /**
  156387. * Get a navigation mesh constrained position, closest to the parameter position
  156388. * @param position world position
  156389. * @returns the closest point to position constrained by the navigation mesh
  156390. */
  156391. getClosestPoint(position: Vector3): Vector3;
  156392. /**
  156393. * Get a navigation mesh constrained position, closest to the parameter position
  156394. * @param position world position
  156395. * @param result output the closest point to position constrained by the navigation mesh
  156396. */
  156397. getClosestPointToRef(position: Vector3, result: Vector3): void;
  156398. /**
  156399. * Get a navigation mesh constrained position, within a particular radius
  156400. * @param position world position
  156401. * @param maxRadius the maximum distance to the constrained world position
  156402. * @returns the closest point to position constrained by the navigation mesh
  156403. */
  156404. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  156405. /**
  156406. * Get a navigation mesh constrained position, within a particular radius
  156407. * @param position world position
  156408. * @param maxRadius the maximum distance to the constrained world position
  156409. * @param result output the closest point to position constrained by the navigation mesh
  156410. */
  156411. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  156412. /**
  156413. * Compute the final position from a segment made of destination-position
  156414. * @param position world position
  156415. * @param destination world position
  156416. * @returns the resulting point along the navmesh
  156417. */
  156418. moveAlong(position: Vector3, destination: Vector3): Vector3;
  156419. /**
  156420. * Compute the final position from a segment made of destination-position
  156421. * @param position world position
  156422. * @param destination world position
  156423. * @param result output the resulting point along the navmesh
  156424. */
  156425. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  156426. /**
  156427. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  156428. * @param start world position
  156429. * @param end world position
  156430. * @returns array containing world position composing the path
  156431. */
  156432. computePath(start: Vector3, end: Vector3): Vector3[];
  156433. /**
  156434. * Create a new Crowd so you can add agents
  156435. * @param maxAgents the maximum agent count in the crowd
  156436. * @param maxAgentRadius the maximum radius an agent can have
  156437. * @param scene to attach the crowd to
  156438. * @returns the crowd you can add agents to
  156439. */
  156440. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  156441. /**
  156442. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156443. * The queries will try to find a solution within those bounds
  156444. * default is (1,1,1)
  156445. * @param extent x,y,z value that define the extent around the queries point of reference
  156446. */
  156447. setDefaultQueryExtent(extent: Vector3): void;
  156448. /**
  156449. * Get the Bounding box extent specified by setDefaultQueryExtent
  156450. * @returns the box extent values
  156451. */
  156452. getDefaultQueryExtent(): Vector3;
  156453. /**
  156454. * build the navmesh from a previously saved state using getNavmeshData
  156455. * @param data the Uint8Array returned by getNavmeshData
  156456. */
  156457. buildFromNavmeshData(data: Uint8Array): void;
  156458. /**
  156459. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  156460. * @returns data the Uint8Array that can be saved and reused
  156461. */
  156462. getNavmeshData(): Uint8Array;
  156463. /**
  156464. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156465. * @param result output the box extent values
  156466. */
  156467. getDefaultQueryExtentToRef(result: Vector3): void;
  156468. /**
  156469. * Disposes
  156470. */
  156471. dispose(): void;
  156472. /**
  156473. * If this plugin is supported
  156474. * @returns true if plugin is supported
  156475. */
  156476. isSupported(): boolean;
  156477. }
  156478. /**
  156479. * Recast detour crowd implementation
  156480. */
  156481. export class RecastJSCrowd implements ICrowd {
  156482. /**
  156483. * Recast/detour plugin
  156484. */
  156485. bjsRECASTPlugin: RecastJSPlugin;
  156486. /**
  156487. * Link to the detour crowd
  156488. */
  156489. recastCrowd: any;
  156490. /**
  156491. * One transform per agent
  156492. */
  156493. transforms: TransformNode[];
  156494. /**
  156495. * All agents created
  156496. */
  156497. agents: number[];
  156498. /**
  156499. * Link to the scene is kept to unregister the crowd from the scene
  156500. */
  156501. private _scene;
  156502. /**
  156503. * Observer for crowd updates
  156504. */
  156505. private _onBeforeAnimationsObserver;
  156506. /**
  156507. * Constructor
  156508. * @param plugin recastJS plugin
  156509. * @param maxAgents the maximum agent count in the crowd
  156510. * @param maxAgentRadius the maximum radius an agent can have
  156511. * @param scene to attach the crowd to
  156512. * @returns the crowd you can add agents to
  156513. */
  156514. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  156515. /**
  156516. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  156517. * You can attach anything to that node. The node position is updated in the scene update tick.
  156518. * @param pos world position that will be constrained by the navigation mesh
  156519. * @param parameters agent parameters
  156520. * @param transform hooked to the agent that will be update by the scene
  156521. * @returns agent index
  156522. */
  156523. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  156524. /**
  156525. * Returns the agent position in world space
  156526. * @param index agent index returned by addAgent
  156527. * @returns world space position
  156528. */
  156529. getAgentPosition(index: number): Vector3;
  156530. /**
  156531. * Returns the agent position result in world space
  156532. * @param index agent index returned by addAgent
  156533. * @param result output world space position
  156534. */
  156535. getAgentPositionToRef(index: number, result: Vector3): void;
  156536. /**
  156537. * Returns the agent velocity in world space
  156538. * @param index agent index returned by addAgent
  156539. * @returns world space velocity
  156540. */
  156541. getAgentVelocity(index: number): Vector3;
  156542. /**
  156543. * Returns the agent velocity result in world space
  156544. * @param index agent index returned by addAgent
  156545. * @param result output world space velocity
  156546. */
  156547. getAgentVelocityToRef(index: number, result: Vector3): void;
  156548. /**
  156549. * Returns the agent next target point on the path
  156550. * @param index agent index returned by addAgent
  156551. * @returns world space position
  156552. */
  156553. getAgentNextTargetPath(index: number): Vector3;
  156554. /**
  156555. * Returns the agent next target point on the path
  156556. * @param index agent index returned by addAgent
  156557. * @param result output world space position
  156558. */
  156559. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  156560. /**
  156561. * Gets the agent state
  156562. * @param index agent index returned by addAgent
  156563. * @returns agent state
  156564. */
  156565. getAgentState(index: number): number;
  156566. /**
  156567. * returns true if the agent in over an off mesh link connection
  156568. * @param index agent index returned by addAgent
  156569. * @returns true if over an off mesh link connection
  156570. */
  156571. overOffmeshConnection(index: number): boolean;
  156572. /**
  156573. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  156574. * @param index agent index returned by addAgent
  156575. * @param destination targeted world position
  156576. */
  156577. agentGoto(index: number, destination: Vector3): void;
  156578. /**
  156579. * Teleport the agent to a new position
  156580. * @param index agent index returned by addAgent
  156581. * @param destination targeted world position
  156582. */
  156583. agentTeleport(index: number, destination: Vector3): void;
  156584. /**
  156585. * Update agent parameters
  156586. * @param index agent index returned by addAgent
  156587. * @param parameters agent parameters
  156588. */
  156589. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  156590. /**
  156591. * remove a particular agent previously created
  156592. * @param index agent index returned by addAgent
  156593. */
  156594. removeAgent(index: number): void;
  156595. /**
  156596. * get the list of all agents attached to this crowd
  156597. * @returns list of agent indices
  156598. */
  156599. getAgents(): number[];
  156600. /**
  156601. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  156602. * @param deltaTime in seconds
  156603. */
  156604. update(deltaTime: number): void;
  156605. /**
  156606. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156607. * The queries will try to find a solution within those bounds
  156608. * default is (1,1,1)
  156609. * @param extent x,y,z value that define the extent around the queries point of reference
  156610. */
  156611. setDefaultQueryExtent(extent: Vector3): void;
  156612. /**
  156613. * Get the Bounding box extent specified by setDefaultQueryExtent
  156614. * @returns the box extent values
  156615. */
  156616. getDefaultQueryExtent(): Vector3;
  156617. /**
  156618. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156619. * @param result output the box extent values
  156620. */
  156621. getDefaultQueryExtentToRef(result: Vector3): void;
  156622. /**
  156623. * Release all resources
  156624. */
  156625. dispose(): void;
  156626. }
  156627. }
  156628. declare module BABYLON {
  156629. /**
  156630. * Class used to enable access to IndexedDB
  156631. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  156632. */
  156633. export class Database implements IOfflineProvider {
  156634. private _callbackManifestChecked;
  156635. private _currentSceneUrl;
  156636. private _db;
  156637. private _enableSceneOffline;
  156638. private _enableTexturesOffline;
  156639. private _manifestVersionFound;
  156640. private _mustUpdateRessources;
  156641. private _hasReachedQuota;
  156642. private _isSupported;
  156643. private _idbFactory;
  156644. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  156645. private static IsUASupportingBlobStorage;
  156646. /**
  156647. * Gets a boolean indicating if Database storate is enabled (off by default)
  156648. */
  156649. static IDBStorageEnabled: boolean;
  156650. /**
  156651. * Gets a boolean indicating if scene must be saved in the database
  156652. */
  156653. get enableSceneOffline(): boolean;
  156654. /**
  156655. * Gets a boolean indicating if textures must be saved in the database
  156656. */
  156657. get enableTexturesOffline(): boolean;
  156658. /**
  156659. * Creates a new Database
  156660. * @param urlToScene defines the url to load the scene
  156661. * @param callbackManifestChecked defines the callback to use when manifest is checked
  156662. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  156663. */
  156664. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  156665. private static _ParseURL;
  156666. private static _ReturnFullUrlLocation;
  156667. private _checkManifestFile;
  156668. /**
  156669. * Open the database and make it available
  156670. * @param successCallback defines the callback to call on success
  156671. * @param errorCallback defines the callback to call on error
  156672. */
  156673. open(successCallback: () => void, errorCallback: () => void): void;
  156674. /**
  156675. * Loads an image from the database
  156676. * @param url defines the url to load from
  156677. * @param image defines the target DOM image
  156678. */
  156679. loadImage(url: string, image: HTMLImageElement): void;
  156680. private _loadImageFromDBAsync;
  156681. private _saveImageIntoDBAsync;
  156682. private _checkVersionFromDB;
  156683. private _loadVersionFromDBAsync;
  156684. private _saveVersionIntoDBAsync;
  156685. /**
  156686. * Loads a file from database
  156687. * @param url defines the URL to load from
  156688. * @param sceneLoaded defines a callback to call on success
  156689. * @param progressCallBack defines a callback to call when progress changed
  156690. * @param errorCallback defines a callback to call on error
  156691. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  156692. */
  156693. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  156694. private _loadFileAsync;
  156695. private _saveFileAsync;
  156696. /**
  156697. * Validates if xhr data is correct
  156698. * @param xhr defines the request to validate
  156699. * @param dataType defines the expected data type
  156700. * @returns true if data is correct
  156701. */
  156702. private static _ValidateXHRData;
  156703. }
  156704. }
  156705. declare module BABYLON {
  156706. /** @hidden */
  156707. export var gpuUpdateParticlesPixelShader: {
  156708. name: string;
  156709. shader: string;
  156710. };
  156711. }
  156712. declare module BABYLON {
  156713. /** @hidden */
  156714. export var gpuUpdateParticlesVertexShader: {
  156715. name: string;
  156716. shader: string;
  156717. };
  156718. }
  156719. declare module BABYLON {
  156720. /** @hidden */
  156721. export var clipPlaneFragmentDeclaration2: {
  156722. name: string;
  156723. shader: string;
  156724. };
  156725. }
  156726. declare module BABYLON {
  156727. /** @hidden */
  156728. export var gpuRenderParticlesPixelShader: {
  156729. name: string;
  156730. shader: string;
  156731. };
  156732. }
  156733. declare module BABYLON {
  156734. /** @hidden */
  156735. export var clipPlaneVertexDeclaration2: {
  156736. name: string;
  156737. shader: string;
  156738. };
  156739. }
  156740. declare module BABYLON {
  156741. /** @hidden */
  156742. export var gpuRenderParticlesVertexShader: {
  156743. name: string;
  156744. shader: string;
  156745. };
  156746. }
  156747. declare module BABYLON {
  156748. /**
  156749. * This represents a GPU particle system in Babylon
  156750. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  156751. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  156752. */
  156753. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  156754. /**
  156755. * The layer mask we are rendering the particles through.
  156756. */
  156757. layerMask: number;
  156758. private _capacity;
  156759. private _activeCount;
  156760. private _currentActiveCount;
  156761. private _accumulatedCount;
  156762. private _renderEffect;
  156763. private _updateEffect;
  156764. private _buffer0;
  156765. private _buffer1;
  156766. private _spriteBuffer;
  156767. private _updateVAO;
  156768. private _renderVAO;
  156769. private _targetIndex;
  156770. private _sourceBuffer;
  156771. private _targetBuffer;
  156772. private _currentRenderId;
  156773. private _started;
  156774. private _stopped;
  156775. private _timeDelta;
  156776. private _randomTexture;
  156777. private _randomTexture2;
  156778. private _attributesStrideSize;
  156779. private _updateEffectOptions;
  156780. private _randomTextureSize;
  156781. private _actualFrame;
  156782. private _customEffect;
  156783. private readonly _rawTextureWidth;
  156784. /**
  156785. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  156786. */
  156787. static get IsSupported(): boolean;
  156788. /**
  156789. * An event triggered when the system is disposed.
  156790. */
  156791. onDisposeObservable: Observable<IParticleSystem>;
  156792. /**
  156793. * An event triggered when the system is stopped
  156794. */
  156795. onStoppedObservable: Observable<IParticleSystem>;
  156796. /**
  156797. * Gets the maximum number of particles active at the same time.
  156798. * @returns The max number of active particles.
  156799. */
  156800. getCapacity(): number;
  156801. /**
  156802. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  156803. * to override the particles.
  156804. */
  156805. forceDepthWrite: boolean;
  156806. /**
  156807. * Gets or set the number of active particles
  156808. */
  156809. get activeParticleCount(): number;
  156810. set activeParticleCount(value: number);
  156811. private _preWarmDone;
  156812. /**
  156813. * Specifies if the particles are updated in emitter local space or world space.
  156814. */
  156815. isLocal: boolean;
  156816. /** Gets or sets a matrix to use to compute projection */
  156817. defaultProjectionMatrix: Matrix;
  156818. /**
  156819. * Is this system ready to be used/rendered
  156820. * @return true if the system is ready
  156821. */
  156822. isReady(): boolean;
  156823. /**
  156824. * Gets if the system has been started. (Note: this will still be true after stop is called)
  156825. * @returns True if it has been started, otherwise false.
  156826. */
  156827. isStarted(): boolean;
  156828. /**
  156829. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  156830. * @returns True if it has been stopped, otherwise false.
  156831. */
  156832. isStopped(): boolean;
  156833. /**
  156834. * Gets a boolean indicating that the system is stopping
  156835. * @returns true if the system is currently stopping
  156836. */
  156837. isStopping(): boolean;
  156838. /**
  156839. * Gets the number of particles active at the same time.
  156840. * @returns The number of active particles.
  156841. */
  156842. getActiveCount(): number;
  156843. /**
  156844. * Starts the particle system and begins to emit
  156845. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  156846. */
  156847. start(delay?: number): void;
  156848. /**
  156849. * Stops the particle system.
  156850. */
  156851. stop(): void;
  156852. /**
  156853. * Remove all active particles
  156854. */
  156855. reset(): void;
  156856. /**
  156857. * Returns the string "GPUParticleSystem"
  156858. * @returns a string containing the class name
  156859. */
  156860. getClassName(): string;
  156861. /**
  156862. * Gets the custom effect used to render the particles
  156863. * @param blendMode Blend mode for which the effect should be retrieved
  156864. * @returns The effect
  156865. */
  156866. getCustomEffect(blendMode?: number): Nullable<Effect>;
  156867. /**
  156868. * Sets the custom effect used to render the particles
  156869. * @param effect The effect to set
  156870. * @param blendMode Blend mode for which the effect should be set
  156871. */
  156872. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  156873. /** @hidden */
  156874. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  156875. /**
  156876. * Observable that will be called just before the particles are drawn
  156877. */
  156878. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  156879. /**
  156880. * Gets the name of the particle vertex shader
  156881. */
  156882. get vertexShaderName(): string;
  156883. private _colorGradientsTexture;
  156884. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  156885. /**
  156886. * Adds a new color gradient
  156887. * @param gradient defines the gradient to use (between 0 and 1)
  156888. * @param color1 defines the color to affect to the specified gradient
  156889. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  156890. * @returns the current particle system
  156891. */
  156892. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  156893. private _refreshColorGradient;
  156894. /** Force the system to rebuild all gradients that need to be resync */
  156895. forceRefreshGradients(): void;
  156896. /**
  156897. * Remove a specific color gradient
  156898. * @param gradient defines the gradient to remove
  156899. * @returns the current particle system
  156900. */
  156901. removeColorGradient(gradient: number): GPUParticleSystem;
  156902. private _angularSpeedGradientsTexture;
  156903. private _sizeGradientsTexture;
  156904. private _velocityGradientsTexture;
  156905. private _limitVelocityGradientsTexture;
  156906. private _dragGradientsTexture;
  156907. private _addFactorGradient;
  156908. /**
  156909. * Adds a new size gradient
  156910. * @param gradient defines the gradient to use (between 0 and 1)
  156911. * @param factor defines the size factor to affect to the specified gradient
  156912. * @returns the current particle system
  156913. */
  156914. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  156915. /**
  156916. * Remove a specific size gradient
  156917. * @param gradient defines the gradient to remove
  156918. * @returns the current particle system
  156919. */
  156920. removeSizeGradient(gradient: number): GPUParticleSystem;
  156921. private _refreshFactorGradient;
  156922. /**
  156923. * Adds a new angular speed gradient
  156924. * @param gradient defines the gradient to use (between 0 and 1)
  156925. * @param factor defines the angular speed to affect to the specified gradient
  156926. * @returns the current particle system
  156927. */
  156928. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  156929. /**
  156930. * Remove a specific angular speed gradient
  156931. * @param gradient defines the gradient to remove
  156932. * @returns the current particle system
  156933. */
  156934. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  156935. /**
  156936. * Adds a new velocity gradient
  156937. * @param gradient defines the gradient to use (between 0 and 1)
  156938. * @param factor defines the velocity to affect to the specified gradient
  156939. * @returns the current particle system
  156940. */
  156941. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156942. /**
  156943. * Remove a specific velocity gradient
  156944. * @param gradient defines the gradient to remove
  156945. * @returns the current particle system
  156946. */
  156947. removeVelocityGradient(gradient: number): GPUParticleSystem;
  156948. /**
  156949. * Adds a new limit velocity gradient
  156950. * @param gradient defines the gradient to use (between 0 and 1)
  156951. * @param factor defines the limit velocity value to affect to the specified gradient
  156952. * @returns the current particle system
  156953. */
  156954. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156955. /**
  156956. * Remove a specific limit velocity gradient
  156957. * @param gradient defines the gradient to remove
  156958. * @returns the current particle system
  156959. */
  156960. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  156961. /**
  156962. * Adds a new drag gradient
  156963. * @param gradient defines the gradient to use (between 0 and 1)
  156964. * @param factor defines the drag value to affect to the specified gradient
  156965. * @returns the current particle system
  156966. */
  156967. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  156968. /**
  156969. * Remove a specific drag gradient
  156970. * @param gradient defines the gradient to remove
  156971. * @returns the current particle system
  156972. */
  156973. removeDragGradient(gradient: number): GPUParticleSystem;
  156974. /**
  156975. * Not supported by GPUParticleSystem
  156976. * @param gradient defines the gradient to use (between 0 and 1)
  156977. * @param factor defines the emit rate value to affect to the specified gradient
  156978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156979. * @returns the current particle system
  156980. */
  156981. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156982. /**
  156983. * Not supported by GPUParticleSystem
  156984. * @param gradient defines the gradient to remove
  156985. * @returns the current particle system
  156986. */
  156987. removeEmitRateGradient(gradient: number): IParticleSystem;
  156988. /**
  156989. * Not supported by GPUParticleSystem
  156990. * @param gradient defines the gradient to use (between 0 and 1)
  156991. * @param factor defines the start size value to affect to the specified gradient
  156992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156993. * @returns the current particle system
  156994. */
  156995. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156996. /**
  156997. * Not supported by GPUParticleSystem
  156998. * @param gradient defines the gradient to remove
  156999. * @returns the current particle system
  157000. */
  157001. removeStartSizeGradient(gradient: number): IParticleSystem;
  157002. /**
  157003. * Not supported by GPUParticleSystem
  157004. * @param gradient defines the gradient to use (between 0 and 1)
  157005. * @param min defines the color remap minimal range
  157006. * @param max defines the color remap maximal range
  157007. * @returns the current particle system
  157008. */
  157009. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  157010. /**
  157011. * Not supported by GPUParticleSystem
  157012. * @param gradient defines the gradient to remove
  157013. * @returns the current particle system
  157014. */
  157015. removeColorRemapGradient(): IParticleSystem;
  157016. /**
  157017. * Not supported by GPUParticleSystem
  157018. * @param gradient defines the gradient to use (between 0 and 1)
  157019. * @param min defines the alpha remap minimal range
  157020. * @param max defines the alpha remap maximal range
  157021. * @returns the current particle system
  157022. */
  157023. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  157024. /**
  157025. * Not supported by GPUParticleSystem
  157026. * @param gradient defines the gradient to remove
  157027. * @returns the current particle system
  157028. */
  157029. removeAlphaRemapGradient(): IParticleSystem;
  157030. /**
  157031. * Not supported by GPUParticleSystem
  157032. * @param gradient defines the gradient to use (between 0 and 1)
  157033. * @param color defines the color to affect to the specified gradient
  157034. * @returns the current particle system
  157035. */
  157036. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  157037. /**
  157038. * Not supported by GPUParticleSystem
  157039. * @param gradient defines the gradient to remove
  157040. * @returns the current particle system
  157041. */
  157042. removeRampGradient(): IParticleSystem;
  157043. /**
  157044. * Not supported by GPUParticleSystem
  157045. * @returns the list of ramp gradients
  157046. */
  157047. getRampGradients(): Nullable<Array<Color3Gradient>>;
  157048. /**
  157049. * Not supported by GPUParticleSystem
  157050. * Gets or sets a boolean indicating that ramp gradients must be used
  157051. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  157052. */
  157053. get useRampGradients(): boolean;
  157054. set useRampGradients(value: boolean);
  157055. /**
  157056. * Not supported by GPUParticleSystem
  157057. * @param gradient defines the gradient to use (between 0 and 1)
  157058. * @param factor defines the life time factor to affect to the specified gradient
  157059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  157060. * @returns the current particle system
  157061. */
  157062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  157063. /**
  157064. * Not supported by GPUParticleSystem
  157065. * @param gradient defines the gradient to remove
  157066. * @returns the current particle system
  157067. */
  157068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  157069. /**
  157070. * Instantiates a GPU particle system.
  157071. * 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.
  157072. * @param name The name of the particle system
  157073. * @param options The options used to create the system
  157074. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  157075. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  157076. * @param customEffect a custom effect used to change the way particles are rendered by default
  157077. */
  157078. constructor(name: string, options: Partial<{
  157079. capacity: number;
  157080. randomTextureSize: number;
  157081. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  157082. protected _reset(): void;
  157083. private _createUpdateVAO;
  157084. private _createRenderVAO;
  157085. private _initialize;
  157086. /** @hidden */
  157087. _recreateUpdateEffect(): void;
  157088. private _getEffect;
  157089. /**
  157090. * Fill the defines array according to the current settings of the particle system
  157091. * @param defines Array to be updated
  157092. * @param blendMode blend mode to take into account when updating the array
  157093. */
  157094. fillDefines(defines: Array<string>, blendMode?: number): void;
  157095. /**
  157096. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  157097. * @param uniforms Uniforms array to fill
  157098. * @param attributes Attributes array to fill
  157099. * @param samplers Samplers array to fill
  157100. */
  157101. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  157102. /** @hidden */
  157103. _recreateRenderEffect(): Effect;
  157104. /**
  157105. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  157106. * @param preWarm defines if we are in the pre-warmimg phase
  157107. */
  157108. animate(preWarm?: boolean): void;
  157109. private _createFactorGradientTexture;
  157110. private _createSizeGradientTexture;
  157111. private _createAngularSpeedGradientTexture;
  157112. private _createVelocityGradientTexture;
  157113. private _createLimitVelocityGradientTexture;
  157114. private _createDragGradientTexture;
  157115. private _createColorGradientTexture;
  157116. /**
  157117. * Renders the particle system in its current state
  157118. * @param preWarm defines if the system should only update the particles but not render them
  157119. * @returns the current number of particles
  157120. */
  157121. render(preWarm?: boolean): number;
  157122. /**
  157123. * Rebuilds the particle system
  157124. */
  157125. rebuild(): void;
  157126. private _releaseBuffers;
  157127. private _releaseVAOs;
  157128. /**
  157129. * Disposes the particle system and free the associated resources
  157130. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  157131. */
  157132. dispose(disposeTexture?: boolean): void;
  157133. /**
  157134. * Clones the particle system.
  157135. * @param name The name of the cloned object
  157136. * @param newEmitter The new emitter to use
  157137. * @returns the cloned particle system
  157138. */
  157139. clone(name: string, newEmitter: any): GPUParticleSystem;
  157140. /**
  157141. * Serializes the particle system to a JSON object
  157142. * @param serializeTexture defines if the texture must be serialized as well
  157143. * @returns the JSON object
  157144. */
  157145. serialize(serializeTexture?: boolean): any;
  157146. /**
  157147. * Parses a JSON object to create a GPU particle system.
  157148. * @param parsedParticleSystem The JSON object to parse
  157149. * @param sceneOrEngine The scene or the engine to create the particle system in
  157150. * @param rootUrl The root url to use to load external dependencies like texture
  157151. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  157152. * @returns the parsed GPU particle system
  157153. */
  157154. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  157155. }
  157156. }
  157157. declare module BABYLON {
  157158. /**
  157159. * Represents a set of particle systems working together to create a specific effect
  157160. */
  157161. export class ParticleSystemSet implements IDisposable {
  157162. /**
  157163. * Gets or sets base Assets URL
  157164. */
  157165. static BaseAssetsUrl: string;
  157166. private _emitterCreationOptions;
  157167. private _emitterNode;
  157168. /**
  157169. * Gets the particle system list
  157170. */
  157171. systems: IParticleSystem[];
  157172. /**
  157173. * Gets the emitter node used with this set
  157174. */
  157175. get emitterNode(): Nullable<TransformNode>;
  157176. /**
  157177. * Creates a new emitter mesh as a sphere
  157178. * @param options defines the options used to create the sphere
  157179. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  157180. * @param scene defines the hosting scene
  157181. */
  157182. setEmitterAsSphere(options: {
  157183. diameter: number;
  157184. segments: number;
  157185. color: Color3;
  157186. }, renderingGroupId: number, scene: Scene): void;
  157187. /**
  157188. * Starts all particle systems of the set
  157189. * @param emitter defines an optional mesh to use as emitter for the particle systems
  157190. */
  157191. start(emitter?: AbstractMesh): void;
  157192. /**
  157193. * Release all associated resources
  157194. */
  157195. dispose(): void;
  157196. /**
  157197. * Serialize the set into a JSON compatible object
  157198. * @param serializeTexture defines if the texture must be serialized as well
  157199. * @returns a JSON compatible representation of the set
  157200. */
  157201. serialize(serializeTexture?: boolean): any;
  157202. /**
  157203. * Parse a new ParticleSystemSet from a serialized source
  157204. * @param data defines a JSON compatible representation of the set
  157205. * @param scene defines the hosting scene
  157206. * @param gpu defines if we want GPU particles or CPU particles
  157207. * @returns a new ParticleSystemSet
  157208. */
  157209. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  157210. }
  157211. }
  157212. declare module BABYLON {
  157213. /**
  157214. * This class is made for on one-liner static method to help creating particle system set.
  157215. */
  157216. export class ParticleHelper {
  157217. /**
  157218. * Gets or sets base Assets URL
  157219. */
  157220. static BaseAssetsUrl: string;
  157221. /** Define the Url to load snippets */
  157222. static SnippetUrl: string;
  157223. /**
  157224. * Create a default particle system that you can tweak
  157225. * @param emitter defines the emitter to use
  157226. * @param capacity defines the system capacity (default is 500 particles)
  157227. * @param scene defines the hosting scene
  157228. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  157229. * @returns the new Particle system
  157230. */
  157231. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  157232. /**
  157233. * This is the main static method (one-liner) of this helper to create different particle systems
  157234. * @param type This string represents the type to the particle system to create
  157235. * @param scene The scene where the particle system should live
  157236. * @param gpu If the system will use gpu
  157237. * @returns the ParticleSystemSet created
  157238. */
  157239. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  157240. /**
  157241. * Static function used to export a particle system to a ParticleSystemSet variable.
  157242. * Please note that the emitter shape is not exported
  157243. * @param systems defines the particle systems to export
  157244. * @returns the created particle system set
  157245. */
  157246. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  157247. /**
  157248. * Creates a particle system from a snippet saved in a remote file
  157249. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  157250. * @param url defines the url to load from
  157251. * @param scene defines the hosting scene
  157252. * @param gpu If the system will use gpu
  157253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  157254. * @returns a promise that will resolve to the new particle system
  157255. */
  157256. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  157257. /**
  157258. * Creates a particle system from a snippet saved by the particle system editor
  157259. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  157260. * @param scene defines the hosting scene
  157261. * @param gpu If the system will use gpu
  157262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  157263. * @returns a promise that will resolve to the new particle system
  157264. */
  157265. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  157266. }
  157267. }
  157268. declare module BABYLON {
  157269. interface Engine {
  157270. /**
  157271. * Create an effect to use with particle systems.
  157272. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  157273. * the particle system for which you want to create a custom effect in the last parameter
  157274. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  157275. * @param uniformsNames defines a list of attribute names
  157276. * @param samplers defines an array of string used to represent textures
  157277. * @param defines defines the string containing the defines to use to compile the shaders
  157278. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  157279. * @param onCompiled defines a function to call when the effect creation is successful
  157280. * @param onError defines a function to call when the effect creation has failed
  157281. * @param particleSystem the particle system you want to create the effect for
  157282. * @returns the new Effect
  157283. */
  157284. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  157285. }
  157286. interface Mesh {
  157287. /**
  157288. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  157289. * @returns an array of IParticleSystem
  157290. */
  157291. getEmittedParticleSystems(): IParticleSystem[];
  157292. /**
  157293. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  157294. * @returns an array of IParticleSystem
  157295. */
  157296. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  157297. }
  157298. }
  157299. declare module BABYLON {
  157300. /** Defines the 4 color options */
  157301. export enum PointColor {
  157302. /** color value */
  157303. Color = 2,
  157304. /** uv value */
  157305. UV = 1,
  157306. /** random value */
  157307. Random = 0,
  157308. /** stated value */
  157309. Stated = 3
  157310. }
  157311. /**
  157312. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  157313. * 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.
  157314. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  157315. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  157316. *
  157317. * Full documentation here : TO BE ENTERED
  157318. */
  157319. export class PointsCloudSystem implements IDisposable {
  157320. /**
  157321. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  157322. * Example : var p = SPS.particles[i];
  157323. */
  157324. particles: CloudPoint[];
  157325. /**
  157326. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  157327. */
  157328. nbParticles: number;
  157329. /**
  157330. * This a counter for your own usage. It's not set by any SPS functions.
  157331. */
  157332. counter: number;
  157333. /**
  157334. * The PCS name. This name is also given to the underlying mesh.
  157335. */
  157336. name: string;
  157337. /**
  157338. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  157339. */
  157340. mesh: Mesh;
  157341. /**
  157342. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  157343. * Please read :
  157344. */
  157345. vars: any;
  157346. /**
  157347. * @hidden
  157348. */
  157349. _size: number;
  157350. private _scene;
  157351. private _promises;
  157352. private _positions;
  157353. private _indices;
  157354. private _normals;
  157355. private _colors;
  157356. private _uvs;
  157357. private _indices32;
  157358. private _positions32;
  157359. private _colors32;
  157360. private _uvs32;
  157361. private _updatable;
  157362. private _isVisibilityBoxLocked;
  157363. private _alwaysVisible;
  157364. private _groups;
  157365. private _groupCounter;
  157366. private _computeParticleColor;
  157367. private _computeParticleTexture;
  157368. private _computeParticleRotation;
  157369. private _computeBoundingBox;
  157370. private _isReady;
  157371. /**
  157372. * Creates a PCS (Points Cloud System) object
  157373. * @param name (String) is the PCS name, this will be the underlying mesh name
  157374. * @param pointSize (number) is the size for each point
  157375. * @param scene (Scene) is the scene in which the PCS is added
  157376. * @param options defines the options of the PCS e.g.
  157377. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  157378. */
  157379. constructor(name: string, pointSize: number, scene: Scene, options?: {
  157380. updatable?: boolean;
  157381. });
  157382. /**
  157383. * Builds the PCS underlying mesh. Returns a standard Mesh.
  157384. * If no points were added to the PCS, the returned mesh is just a single point.
  157385. * @returns a promise for the created mesh
  157386. */
  157387. buildMeshAsync(): Promise<Mesh>;
  157388. /**
  157389. * @hidden
  157390. */
  157391. private _buildMesh;
  157392. private _addParticle;
  157393. private _randomUnitVector;
  157394. private _getColorIndicesForCoord;
  157395. private _setPointsColorOrUV;
  157396. private _colorFromTexture;
  157397. private _calculateDensity;
  157398. /**
  157399. * Adds points to the PCS in random positions within a unit sphere
  157400. * @param nb (positive integer) the number of particles to be created from this model
  157401. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  157402. * @returns the number of groups in the system
  157403. */
  157404. addPoints(nb: number, pointFunction?: any): number;
  157405. /**
  157406. * Adds points to the PCS from the surface of the model shape
  157407. * @param mesh is any Mesh object that will be used as a surface model for the points
  157408. * @param nb (positive integer) the number of particles to be created from this model
  157409. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  157410. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  157411. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  157412. * @returns the number of groups in the system
  157413. */
  157414. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  157415. /**
  157416. * Adds points to the PCS inside the model shape
  157417. * @param mesh is any Mesh object that will be used as a surface model for the points
  157418. * @param nb (positive integer) the number of particles to be created from this model
  157419. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  157420. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  157421. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  157422. * @returns the number of groups in the system
  157423. */
  157424. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  157425. /**
  157426. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  157427. * This method calls `updateParticle()` for each particle of the SPS.
  157428. * For an animated SPS, it is usually called within the render loop.
  157429. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  157430. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  157431. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  157432. * @returns the PCS.
  157433. */
  157434. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  157435. /**
  157436. * Disposes the PCS.
  157437. */
  157438. dispose(): void;
  157439. /**
  157440. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  157441. * doc :
  157442. * @returns the PCS.
  157443. */
  157444. refreshVisibleSize(): PointsCloudSystem;
  157445. /**
  157446. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  157447. * @param size the size (float) of the visibility box
  157448. * note : this doesn't lock the PCS mesh bounding box.
  157449. * doc :
  157450. */
  157451. setVisibilityBox(size: number): void;
  157452. /**
  157453. * Gets whether the PCS is always visible or not
  157454. * doc :
  157455. */
  157456. get isAlwaysVisible(): boolean;
  157457. /**
  157458. * Sets the PCS as always visible or not
  157459. * doc :
  157460. */
  157461. set isAlwaysVisible(val: boolean);
  157462. /**
  157463. * Tells to `setParticles()` to compute the particle rotations or not
  157464. * Default value : false. The PCS is faster when it's set to false
  157465. * Note : particle rotations are only applied to parent particles
  157466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  157467. */
  157468. set computeParticleRotation(val: boolean);
  157469. /**
  157470. * Tells to `setParticles()` to compute the particle colors or not.
  157471. * Default value : true. The PCS is faster when it's set to false.
  157472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  157473. */
  157474. set computeParticleColor(val: boolean);
  157475. set computeParticleTexture(val: boolean);
  157476. /**
  157477. * Gets if `setParticles()` computes the particle colors or not.
  157478. * Default value : false. The PCS is faster when it's set to false.
  157479. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  157480. */
  157481. get computeParticleColor(): boolean;
  157482. /**
  157483. * Gets if `setParticles()` computes the particle textures or not.
  157484. * Default value : false. The PCS is faster when it's set to false.
  157485. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  157486. */
  157487. get computeParticleTexture(): boolean;
  157488. /**
  157489. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  157490. */
  157491. set computeBoundingBox(val: boolean);
  157492. /**
  157493. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  157494. */
  157495. get computeBoundingBox(): boolean;
  157496. /**
  157497. * This function does nothing. It may be overwritten to set all the particle first values.
  157498. * The PCS doesn't call this function, you may have to call it by your own.
  157499. * doc :
  157500. */
  157501. initParticles(): void;
  157502. /**
  157503. * This function does nothing. It may be overwritten to recycle a particle
  157504. * The PCS doesn't call this function, you can to call it
  157505. * doc :
  157506. * @param particle The particle to recycle
  157507. * @returns the recycled particle
  157508. */
  157509. recycleParticle(particle: CloudPoint): CloudPoint;
  157510. /**
  157511. * Updates a particle : this function should be overwritten by the user.
  157512. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  157513. * doc :
  157514. * @example : just set a particle position or velocity and recycle conditions
  157515. * @param particle The particle to update
  157516. * @returns the updated particle
  157517. */
  157518. updateParticle(particle: CloudPoint): CloudPoint;
  157519. /**
  157520. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  157521. * This does nothing and may be overwritten by the user.
  157522. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  157523. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  157524. * @param update the boolean update value actually passed to setParticles()
  157525. */
  157526. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  157527. /**
  157528. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  157529. * This will be passed three parameters.
  157530. * This does nothing and may be overwritten by the user.
  157531. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  157532. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  157533. * @param update the boolean update value actually passed to setParticles()
  157534. */
  157535. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  157536. }
  157537. }
  157538. declare module BABYLON {
  157539. /**
  157540. * Represents one particle of a points cloud system.
  157541. */
  157542. export class CloudPoint {
  157543. /**
  157544. * particle global index
  157545. */
  157546. idx: number;
  157547. /**
  157548. * The color of the particle
  157549. */
  157550. color: Nullable<Color4>;
  157551. /**
  157552. * The world space position of the particle.
  157553. */
  157554. position: Vector3;
  157555. /**
  157556. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  157557. */
  157558. rotation: Vector3;
  157559. /**
  157560. * The world space rotation quaternion of the particle.
  157561. */
  157562. rotationQuaternion: Nullable<Quaternion>;
  157563. /**
  157564. * The uv of the particle.
  157565. */
  157566. uv: Nullable<Vector2>;
  157567. /**
  157568. * The current speed of the particle.
  157569. */
  157570. velocity: Vector3;
  157571. /**
  157572. * The pivot point in the particle local space.
  157573. */
  157574. pivot: Vector3;
  157575. /**
  157576. * Must the particle be translated from its pivot point in its local space ?
  157577. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  157578. * Default : false
  157579. */
  157580. translateFromPivot: boolean;
  157581. /**
  157582. * Index of this particle in the global "positions" array (Internal use)
  157583. * @hidden
  157584. */
  157585. _pos: number;
  157586. /**
  157587. * @hidden Index of this particle in the global "indices" array (Internal use)
  157588. */
  157589. _ind: number;
  157590. /**
  157591. * Group this particle belongs to
  157592. */
  157593. _group: PointsGroup;
  157594. /**
  157595. * Group id of this particle
  157596. */
  157597. groupId: number;
  157598. /**
  157599. * Index of the particle in its group id (Internal use)
  157600. */
  157601. idxInGroup: number;
  157602. /**
  157603. * @hidden Particle BoundingInfo object (Internal use)
  157604. */
  157605. _boundingInfo: BoundingInfo;
  157606. /**
  157607. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  157608. */
  157609. _pcs: PointsCloudSystem;
  157610. /**
  157611. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  157612. */
  157613. _stillInvisible: boolean;
  157614. /**
  157615. * @hidden Last computed particle rotation matrix
  157616. */
  157617. _rotationMatrix: number[];
  157618. /**
  157619. * Parent particle Id, if any.
  157620. * Default null.
  157621. */
  157622. parentId: Nullable<number>;
  157623. /**
  157624. * @hidden Internal global position in the PCS.
  157625. */
  157626. _globalPosition: Vector3;
  157627. /**
  157628. * Creates a Point Cloud object.
  157629. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  157630. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  157631. * @param group (PointsGroup) is the group the particle belongs to
  157632. * @param groupId (integer) is the group identifier in the PCS.
  157633. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  157634. * @param pcs defines the PCS it is associated to
  157635. */
  157636. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  157637. /**
  157638. * get point size
  157639. */
  157640. get size(): Vector3;
  157641. /**
  157642. * Set point size
  157643. */
  157644. set size(scale: Vector3);
  157645. /**
  157646. * Legacy support, changed quaternion to rotationQuaternion
  157647. */
  157648. get quaternion(): Nullable<Quaternion>;
  157649. /**
  157650. * Legacy support, changed quaternion to rotationQuaternion
  157651. */
  157652. set quaternion(q: Nullable<Quaternion>);
  157653. /**
  157654. * Returns a boolean. True if the particle intersects a mesh, else false
  157655. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  157656. * @param target is the object (point or mesh) what the intersection is computed against
  157657. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  157658. * @returns true if it intersects
  157659. */
  157660. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  157661. /**
  157662. * get the rotation matrix of the particle
  157663. * @hidden
  157664. */
  157665. getRotationMatrix(m: Matrix): void;
  157666. }
  157667. /**
  157668. * Represents a group of points in a points cloud system
  157669. * * PCS internal tool, don't use it manually.
  157670. */
  157671. export class PointsGroup {
  157672. /**
  157673. * The group id
  157674. * @hidden
  157675. */
  157676. groupID: number;
  157677. /**
  157678. * image data for group (internal use)
  157679. * @hidden
  157680. */
  157681. _groupImageData: Nullable<ArrayBufferView>;
  157682. /**
  157683. * Image Width (internal use)
  157684. * @hidden
  157685. */
  157686. _groupImgWidth: number;
  157687. /**
  157688. * Image Height (internal use)
  157689. * @hidden
  157690. */
  157691. _groupImgHeight: number;
  157692. /**
  157693. * Custom position function (internal use)
  157694. * @hidden
  157695. */
  157696. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  157697. /**
  157698. * density per facet for surface points
  157699. * @hidden
  157700. */
  157701. _groupDensity: number[];
  157702. /**
  157703. * Only when points are colored by texture carries pointer to texture list array
  157704. * @hidden
  157705. */
  157706. _textureNb: number;
  157707. /**
  157708. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  157709. * PCS internal tool, don't use it manually.
  157710. * @hidden
  157711. */
  157712. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  157713. }
  157714. }
  157715. declare module BABYLON {
  157716. interface Scene {
  157717. /** @hidden (Backing field) */
  157718. _physicsEngine: Nullable<IPhysicsEngine>;
  157719. /** @hidden */
  157720. _physicsTimeAccumulator: number;
  157721. /**
  157722. * Gets the current physics engine
  157723. * @returns a IPhysicsEngine or null if none attached
  157724. */
  157725. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  157726. /**
  157727. * Enables physics to the current scene
  157728. * @param gravity defines the scene's gravity for the physics engine
  157729. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  157730. * @return a boolean indicating if the physics engine was initialized
  157731. */
  157732. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  157733. /**
  157734. * Disables and disposes the physics engine associated with the scene
  157735. */
  157736. disablePhysicsEngine(): void;
  157737. /**
  157738. * Gets a boolean indicating if there is an active physics engine
  157739. * @returns a boolean indicating if there is an active physics engine
  157740. */
  157741. isPhysicsEnabled(): boolean;
  157742. /**
  157743. * Deletes a physics compound impostor
  157744. * @param compound defines the compound to delete
  157745. */
  157746. deleteCompoundImpostor(compound: any): void;
  157747. /**
  157748. * An event triggered when physic simulation is about to be run
  157749. */
  157750. onBeforePhysicsObservable: Observable<Scene>;
  157751. /**
  157752. * An event triggered when physic simulation has been done
  157753. */
  157754. onAfterPhysicsObservable: Observable<Scene>;
  157755. }
  157756. interface AbstractMesh {
  157757. /** @hidden */
  157758. _physicsImpostor: Nullable<PhysicsImpostor>;
  157759. /**
  157760. * Gets or sets impostor used for physic simulation
  157761. * @see https://doc.babylonjs.com/features/physics_engine
  157762. */
  157763. physicsImpostor: Nullable<PhysicsImpostor>;
  157764. /**
  157765. * Gets the current physics impostor
  157766. * @see https://doc.babylonjs.com/features/physics_engine
  157767. * @returns a physics impostor or null
  157768. */
  157769. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  157770. /** Apply a physic impulse to the mesh
  157771. * @param force defines the force to apply
  157772. * @param contactPoint defines where to apply the force
  157773. * @returns the current mesh
  157774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  157775. */
  157776. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  157777. /**
  157778. * Creates a physic joint between two meshes
  157779. * @param otherMesh defines the other mesh to use
  157780. * @param pivot1 defines the pivot to use on this mesh
  157781. * @param pivot2 defines the pivot to use on the other mesh
  157782. * @param options defines additional options (can be plugin dependent)
  157783. * @returns the current mesh
  157784. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  157785. */
  157786. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  157787. /** @hidden */
  157788. _disposePhysicsObserver: Nullable<Observer<Node>>;
  157789. }
  157790. /**
  157791. * Defines the physics engine scene component responsible to manage a physics engine
  157792. */
  157793. export class PhysicsEngineSceneComponent implements ISceneComponent {
  157794. /**
  157795. * The component name helpful to identify the component in the list of scene components.
  157796. */
  157797. readonly name: string;
  157798. /**
  157799. * The scene the component belongs to.
  157800. */
  157801. scene: Scene;
  157802. /**
  157803. * Creates a new instance of the component for the given scene
  157804. * @param scene Defines the scene to register the component in
  157805. */
  157806. constructor(scene: Scene);
  157807. /**
  157808. * Registers the component in a given scene
  157809. */
  157810. register(): void;
  157811. /**
  157812. * Rebuilds the elements related to this component in case of
  157813. * context lost for instance.
  157814. */
  157815. rebuild(): void;
  157816. /**
  157817. * Disposes the component and the associated ressources
  157818. */
  157819. dispose(): void;
  157820. }
  157821. }
  157822. declare module BABYLON {
  157823. /**
  157824. * A helper for physics simulations
  157825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157826. */
  157827. export class PhysicsHelper {
  157828. private _scene;
  157829. private _physicsEngine;
  157830. /**
  157831. * Initializes the Physics helper
  157832. * @param scene Babylon.js scene
  157833. */
  157834. constructor(scene: Scene);
  157835. /**
  157836. * Applies a radial explosion impulse
  157837. * @param origin the origin of the explosion
  157838. * @param radiusOrEventOptions the radius or the options of radial explosion
  157839. * @param strength the explosion strength
  157840. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157841. * @returns A physics radial explosion event, or null
  157842. */
  157843. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157844. /**
  157845. * Applies a radial explosion force
  157846. * @param origin the origin of the explosion
  157847. * @param radiusOrEventOptions the radius or the options of radial explosion
  157848. * @param strength the explosion strength
  157849. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157850. * @returns A physics radial explosion event, or null
  157851. */
  157852. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157853. /**
  157854. * Creates a gravitational field
  157855. * @param origin the origin of the explosion
  157856. * @param radiusOrEventOptions the radius or the options of radial explosion
  157857. * @param strength the explosion strength
  157858. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157859. * @returns A physics gravitational field event, or null
  157860. */
  157861. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  157862. /**
  157863. * Creates a physics updraft event
  157864. * @param origin the origin of the updraft
  157865. * @param radiusOrEventOptions the radius or the options of the updraft
  157866. * @param strength the strength of the updraft
  157867. * @param height the height of the updraft
  157868. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  157869. * @returns A physics updraft event, or null
  157870. */
  157871. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  157872. /**
  157873. * Creates a physics vortex event
  157874. * @param origin the of the vortex
  157875. * @param radiusOrEventOptions the radius or the options of the vortex
  157876. * @param strength the strength of the vortex
  157877. * @param height the height of the vortex
  157878. * @returns a Physics vortex event, or null
  157879. * A physics vortex event or null
  157880. */
  157881. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  157882. }
  157883. /**
  157884. * Represents a physics radial explosion event
  157885. */
  157886. class PhysicsRadialExplosionEvent {
  157887. private _scene;
  157888. private _options;
  157889. private _sphere;
  157890. private _dataFetched;
  157891. /**
  157892. * Initializes a radial explosioin event
  157893. * @param _scene BabylonJS scene
  157894. * @param _options The options for the vortex event
  157895. */
  157896. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  157897. /**
  157898. * Returns the data related to the radial explosion event (sphere).
  157899. * @returns The radial explosion event data
  157900. */
  157901. getData(): PhysicsRadialExplosionEventData;
  157902. /**
  157903. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  157904. * @param impostor A physics imposter
  157905. * @param origin the origin of the explosion
  157906. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  157907. */
  157908. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  157909. /**
  157910. * Triggers affecterd impostors callbacks
  157911. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  157912. */
  157913. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  157914. /**
  157915. * Disposes the sphere.
  157916. * @param force Specifies if the sphere should be disposed by force
  157917. */
  157918. dispose(force?: boolean): void;
  157919. /*** Helpers ***/
  157920. private _prepareSphere;
  157921. private _intersectsWithSphere;
  157922. }
  157923. /**
  157924. * Represents a gravitational field event
  157925. */
  157926. class PhysicsGravitationalFieldEvent {
  157927. private _physicsHelper;
  157928. private _scene;
  157929. private _origin;
  157930. private _options;
  157931. private _tickCallback;
  157932. private _sphere;
  157933. private _dataFetched;
  157934. /**
  157935. * Initializes the physics gravitational field event
  157936. * @param _physicsHelper A physics helper
  157937. * @param _scene BabylonJS scene
  157938. * @param _origin The origin position of the gravitational field event
  157939. * @param _options The options for the vortex event
  157940. */
  157941. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  157942. /**
  157943. * Returns the data related to the gravitational field event (sphere).
  157944. * @returns A gravitational field event
  157945. */
  157946. getData(): PhysicsGravitationalFieldEventData;
  157947. /**
  157948. * Enables the gravitational field.
  157949. */
  157950. enable(): void;
  157951. /**
  157952. * Disables the gravitational field.
  157953. */
  157954. disable(): void;
  157955. /**
  157956. * Disposes the sphere.
  157957. * @param force The force to dispose from the gravitational field event
  157958. */
  157959. dispose(force?: boolean): void;
  157960. private _tick;
  157961. }
  157962. /**
  157963. * Represents a physics updraft event
  157964. */
  157965. class PhysicsUpdraftEvent {
  157966. private _scene;
  157967. private _origin;
  157968. private _options;
  157969. private _physicsEngine;
  157970. private _originTop;
  157971. private _originDirection;
  157972. private _tickCallback;
  157973. private _cylinder;
  157974. private _cylinderPosition;
  157975. private _dataFetched;
  157976. /**
  157977. * Initializes the physics updraft event
  157978. * @param _scene BabylonJS scene
  157979. * @param _origin The origin position of the updraft
  157980. * @param _options The options for the updraft event
  157981. */
  157982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  157983. /**
  157984. * Returns the data related to the updraft event (cylinder).
  157985. * @returns A physics updraft event
  157986. */
  157987. getData(): PhysicsUpdraftEventData;
  157988. /**
  157989. * Enables the updraft.
  157990. */
  157991. enable(): void;
  157992. /**
  157993. * Disables the updraft.
  157994. */
  157995. disable(): void;
  157996. /**
  157997. * Disposes the cylinder.
  157998. * @param force Specifies if the updraft should be disposed by force
  157999. */
  158000. dispose(force?: boolean): void;
  158001. private getImpostorHitData;
  158002. private _tick;
  158003. /*** Helpers ***/
  158004. private _prepareCylinder;
  158005. private _intersectsWithCylinder;
  158006. }
  158007. /**
  158008. * Represents a physics vortex event
  158009. */
  158010. class PhysicsVortexEvent {
  158011. private _scene;
  158012. private _origin;
  158013. private _options;
  158014. private _physicsEngine;
  158015. private _originTop;
  158016. private _tickCallback;
  158017. private _cylinder;
  158018. private _cylinderPosition;
  158019. private _dataFetched;
  158020. /**
  158021. * Initializes the physics vortex event
  158022. * @param _scene The BabylonJS scene
  158023. * @param _origin The origin position of the vortex
  158024. * @param _options The options for the vortex event
  158025. */
  158026. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  158027. /**
  158028. * Returns the data related to the vortex event (cylinder).
  158029. * @returns The physics vortex event data
  158030. */
  158031. getData(): PhysicsVortexEventData;
  158032. /**
  158033. * Enables the vortex.
  158034. */
  158035. enable(): void;
  158036. /**
  158037. * Disables the cortex.
  158038. */
  158039. disable(): void;
  158040. /**
  158041. * Disposes the sphere.
  158042. * @param force
  158043. */
  158044. dispose(force?: boolean): void;
  158045. private getImpostorHitData;
  158046. private _tick;
  158047. /*** Helpers ***/
  158048. private _prepareCylinder;
  158049. private _intersectsWithCylinder;
  158050. }
  158051. /**
  158052. * Options fot the radial explosion event
  158053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158054. */
  158055. export class PhysicsRadialExplosionEventOptions {
  158056. /**
  158057. * The radius of the sphere for the radial explosion.
  158058. */
  158059. radius: number;
  158060. /**
  158061. * The strenth of the explosion.
  158062. */
  158063. strength: number;
  158064. /**
  158065. * The strenght of the force in correspondence to the distance of the affected object
  158066. */
  158067. falloff: PhysicsRadialImpulseFalloff;
  158068. /**
  158069. * Sphere options for the radial explosion.
  158070. */
  158071. sphere: {
  158072. segments: number;
  158073. diameter: number;
  158074. };
  158075. /**
  158076. * Sphere options for the radial explosion.
  158077. */
  158078. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  158079. }
  158080. /**
  158081. * Options fot the updraft event
  158082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158083. */
  158084. export class PhysicsUpdraftEventOptions {
  158085. /**
  158086. * The radius of the cylinder for the vortex
  158087. */
  158088. radius: number;
  158089. /**
  158090. * The strenth of the updraft.
  158091. */
  158092. strength: number;
  158093. /**
  158094. * The height of the cylinder for the updraft.
  158095. */
  158096. height: number;
  158097. /**
  158098. * The mode for the the updraft.
  158099. */
  158100. updraftMode: PhysicsUpdraftMode;
  158101. }
  158102. /**
  158103. * Options fot the vortex event
  158104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158105. */
  158106. export class PhysicsVortexEventOptions {
  158107. /**
  158108. * The radius of the cylinder for the vortex
  158109. */
  158110. radius: number;
  158111. /**
  158112. * The strenth of the vortex.
  158113. */
  158114. strength: number;
  158115. /**
  158116. * The height of the cylinder for the vortex.
  158117. */
  158118. height: number;
  158119. /**
  158120. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  158121. */
  158122. centripetalForceThreshold: number;
  158123. /**
  158124. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  158125. */
  158126. centripetalForceMultiplier: number;
  158127. /**
  158128. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  158129. */
  158130. centrifugalForceMultiplier: number;
  158131. /**
  158132. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  158133. */
  158134. updraftForceMultiplier: number;
  158135. }
  158136. /**
  158137. * The strenght of the force in correspondence to the distance of the affected object
  158138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158139. */
  158140. export enum PhysicsRadialImpulseFalloff {
  158141. /** Defines that impulse is constant in strength across it's whole radius */
  158142. Constant = 0,
  158143. /** Defines that impulse gets weaker if it's further from the origin */
  158144. Linear = 1
  158145. }
  158146. /**
  158147. * The strength of the force in correspondence to the distance of the affected object
  158148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158149. */
  158150. export enum PhysicsUpdraftMode {
  158151. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  158152. Center = 0,
  158153. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  158154. Perpendicular = 1
  158155. }
  158156. /**
  158157. * Interface for a physics hit data
  158158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158159. */
  158160. export interface PhysicsHitData {
  158161. /**
  158162. * The force applied at the contact point
  158163. */
  158164. force: Vector3;
  158165. /**
  158166. * The contact point
  158167. */
  158168. contactPoint: Vector3;
  158169. /**
  158170. * The distance from the origin to the contact point
  158171. */
  158172. distanceFromOrigin: number;
  158173. }
  158174. /**
  158175. * Interface for radial explosion event data
  158176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158177. */
  158178. export interface PhysicsRadialExplosionEventData {
  158179. /**
  158180. * A sphere used for the radial explosion event
  158181. */
  158182. sphere: Mesh;
  158183. }
  158184. /**
  158185. * Interface for gravitational field event data
  158186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158187. */
  158188. export interface PhysicsGravitationalFieldEventData {
  158189. /**
  158190. * A sphere mesh used for the gravitational field event
  158191. */
  158192. sphere: Mesh;
  158193. }
  158194. /**
  158195. * Interface for updraft event data
  158196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158197. */
  158198. export interface PhysicsUpdraftEventData {
  158199. /**
  158200. * A cylinder used for the updraft event
  158201. */
  158202. cylinder: Mesh;
  158203. }
  158204. /**
  158205. * Interface for vortex event data
  158206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158207. */
  158208. export interface PhysicsVortexEventData {
  158209. /**
  158210. * A cylinder used for the vortex event
  158211. */
  158212. cylinder: Mesh;
  158213. }
  158214. /**
  158215. * Interface for an affected physics impostor
  158216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158217. */
  158218. export interface PhysicsAffectedImpostorWithData {
  158219. /**
  158220. * The impostor affected by the effect
  158221. */
  158222. impostor: PhysicsImpostor;
  158223. /**
  158224. * The data about the hit/horce from the explosion
  158225. */
  158226. hitData: PhysicsHitData;
  158227. }
  158228. }
  158229. declare module BABYLON {
  158230. /** @hidden */
  158231. export var blackAndWhitePixelShader: {
  158232. name: string;
  158233. shader: string;
  158234. };
  158235. }
  158236. declare module BABYLON {
  158237. /**
  158238. * Post process used to render in black and white
  158239. */
  158240. export class BlackAndWhitePostProcess extends PostProcess {
  158241. /**
  158242. * Linear about to convert he result to black and white (default: 1)
  158243. */
  158244. degree: number;
  158245. /**
  158246. * Gets a string identifying the name of the class
  158247. * @returns "BlackAndWhitePostProcess" string
  158248. */
  158249. getClassName(): string;
  158250. /**
  158251. * Creates a black and white post process
  158252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  158253. * @param name The name of the effect.
  158254. * @param options The required width/height ratio to downsize to before computing the render pass.
  158255. * @param camera The camera to apply the render pass to.
  158256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158257. * @param engine The engine which the post process will be applied. (default: current engine)
  158258. * @param reusable If the post process can be reused on the same frame. (default: false)
  158259. */
  158260. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158261. /** @hidden */
  158262. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  158263. }
  158264. }
  158265. declare module BABYLON {
  158266. /**
  158267. * This represents a set of one or more post processes in Babylon.
  158268. * A post process can be used to apply a shader to a texture after it is rendered.
  158269. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158270. */
  158271. export class PostProcessRenderEffect {
  158272. private _postProcesses;
  158273. private _getPostProcesses;
  158274. private _singleInstance;
  158275. private _cameras;
  158276. private _indicesForCamera;
  158277. /**
  158278. * Name of the effect
  158279. * @hidden
  158280. */
  158281. _name: string;
  158282. /**
  158283. * Instantiates a post process render effect.
  158284. * A post process can be used to apply a shader to a texture after it is rendered.
  158285. * @param engine The engine the effect is tied to
  158286. * @param name The name of the effect
  158287. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  158288. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  158289. */
  158290. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  158291. /**
  158292. * Checks if all the post processes in the effect are supported.
  158293. */
  158294. get isSupported(): boolean;
  158295. /**
  158296. * Updates the current state of the effect
  158297. * @hidden
  158298. */
  158299. _update(): void;
  158300. /**
  158301. * Attaches the effect on cameras
  158302. * @param cameras The camera to attach to.
  158303. * @hidden
  158304. */
  158305. _attachCameras(cameras: Camera): void;
  158306. /**
  158307. * Attaches the effect on cameras
  158308. * @param cameras The camera to attach to.
  158309. * @hidden
  158310. */
  158311. _attachCameras(cameras: Camera[]): void;
  158312. /**
  158313. * Detaches the effect on cameras
  158314. * @param cameras The camera to detatch from.
  158315. * @hidden
  158316. */
  158317. _detachCameras(cameras: Camera): void;
  158318. /**
  158319. * Detatches the effect on cameras
  158320. * @param cameras The camera to detatch from.
  158321. * @hidden
  158322. */
  158323. _detachCameras(cameras: Camera[]): void;
  158324. /**
  158325. * Enables the effect on given cameras
  158326. * @param cameras The camera to enable.
  158327. * @hidden
  158328. */
  158329. _enable(cameras: Camera): void;
  158330. /**
  158331. * Enables the effect on given cameras
  158332. * @param cameras The camera to enable.
  158333. * @hidden
  158334. */
  158335. _enable(cameras: Nullable<Camera[]>): void;
  158336. /**
  158337. * Disables the effect on the given cameras
  158338. * @param cameras The camera to disable.
  158339. * @hidden
  158340. */
  158341. _disable(cameras: Camera): void;
  158342. /**
  158343. * Disables the effect on the given cameras
  158344. * @param cameras The camera to disable.
  158345. * @hidden
  158346. */
  158347. _disable(cameras: Nullable<Camera[]>): void;
  158348. /**
  158349. * Gets a list of the post processes contained in the effect.
  158350. * @param camera The camera to get the post processes on.
  158351. * @returns The list of the post processes in the effect.
  158352. */
  158353. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  158354. }
  158355. }
  158356. declare module BABYLON {
  158357. /** @hidden */
  158358. export var extractHighlightsPixelShader: {
  158359. name: string;
  158360. shader: string;
  158361. };
  158362. }
  158363. declare module BABYLON {
  158364. /**
  158365. * 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.
  158366. */
  158367. export class ExtractHighlightsPostProcess extends PostProcess {
  158368. /**
  158369. * The luminance threshold, pixels below this value will be set to black.
  158370. */
  158371. threshold: number;
  158372. /** @hidden */
  158373. _exposure: number;
  158374. /**
  158375. * Post process which has the input texture to be used when performing highlight extraction
  158376. * @hidden
  158377. */
  158378. _inputPostProcess: Nullable<PostProcess>;
  158379. /**
  158380. * Gets a string identifying the name of the class
  158381. * @returns "ExtractHighlightsPostProcess" string
  158382. */
  158383. getClassName(): string;
  158384. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158385. }
  158386. }
  158387. declare module BABYLON {
  158388. /** @hidden */
  158389. export var bloomMergePixelShader: {
  158390. name: string;
  158391. shader: string;
  158392. };
  158393. }
  158394. declare module BABYLON {
  158395. /**
  158396. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  158397. */
  158398. export class BloomMergePostProcess extends PostProcess {
  158399. /** Weight of the bloom to be added to the original input. */
  158400. weight: number;
  158401. /**
  158402. * Gets a string identifying the name of the class
  158403. * @returns "BloomMergePostProcess" string
  158404. */
  158405. getClassName(): string;
  158406. /**
  158407. * Creates a new instance of @see BloomMergePostProcess
  158408. * @param name The name of the effect.
  158409. * @param originalFromInput Post process which's input will be used for the merge.
  158410. * @param blurred Blurred highlights post process which's output will be used.
  158411. * @param weight Weight of the bloom to be added to the original input.
  158412. * @param options The required width/height ratio to downsize to before computing the render pass.
  158413. * @param camera The camera to apply the render pass to.
  158414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158415. * @param engine The engine which the post process will be applied. (default: current engine)
  158416. * @param reusable If the post process can be reused on the same frame. (default: false)
  158417. * @param textureType Type of textures used when performing the post process. (default: 0)
  158418. * @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)
  158419. */
  158420. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  158421. /** Weight of the bloom to be added to the original input. */
  158422. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158423. }
  158424. }
  158425. declare module BABYLON {
  158426. /**
  158427. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  158428. */
  158429. export class BloomEffect extends PostProcessRenderEffect {
  158430. private bloomScale;
  158431. /**
  158432. * @hidden Internal
  158433. */
  158434. _effects: Array<PostProcess>;
  158435. /**
  158436. * @hidden Internal
  158437. */
  158438. _downscale: ExtractHighlightsPostProcess;
  158439. private _blurX;
  158440. private _blurY;
  158441. private _merge;
  158442. /**
  158443. * The luminance threshold to find bright areas of the image to bloom.
  158444. */
  158445. get threshold(): number;
  158446. set threshold(value: number);
  158447. /**
  158448. * The strength of the bloom.
  158449. */
  158450. get weight(): number;
  158451. set weight(value: number);
  158452. /**
  158453. * Specifies the size of the bloom blur kernel, relative to the final output size
  158454. */
  158455. get kernel(): number;
  158456. set kernel(value: number);
  158457. /**
  158458. * Creates a new instance of @see BloomEffect
  158459. * @param scene The scene the effect belongs to.
  158460. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  158461. * @param bloomKernel The size of the kernel to be used when applying the blur.
  158462. * @param bloomWeight The the strength of bloom.
  158463. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  158464. * @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)
  158465. */
  158466. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  158467. /**
  158468. * Disposes each of the internal effects for a given camera.
  158469. * @param camera The camera to dispose the effect on.
  158470. */
  158471. disposeEffects(camera: Camera): void;
  158472. /**
  158473. * @hidden Internal
  158474. */
  158475. _updateEffects(): void;
  158476. /**
  158477. * Internal
  158478. * @returns if all the contained post processes are ready.
  158479. * @hidden
  158480. */
  158481. _isReady(): boolean;
  158482. }
  158483. }
  158484. declare module BABYLON {
  158485. /** @hidden */
  158486. export var chromaticAberrationPixelShader: {
  158487. name: string;
  158488. shader: string;
  158489. };
  158490. }
  158491. declare module BABYLON {
  158492. /**
  158493. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  158494. */
  158495. export class ChromaticAberrationPostProcess extends PostProcess {
  158496. /**
  158497. * The amount of seperation of rgb channels (default: 30)
  158498. */
  158499. aberrationAmount: number;
  158500. /**
  158501. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  158502. */
  158503. radialIntensity: number;
  158504. /**
  158505. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  158506. */
  158507. direction: Vector2;
  158508. /**
  158509. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  158510. */
  158511. centerPosition: Vector2;
  158512. /** The width of the screen to apply the effect on */
  158513. screenWidth: number;
  158514. /** The height of the screen to apply the effect on */
  158515. screenHeight: number;
  158516. /**
  158517. * Gets a string identifying the name of the class
  158518. * @returns "ChromaticAberrationPostProcess" string
  158519. */
  158520. getClassName(): string;
  158521. /**
  158522. * Creates a new instance ChromaticAberrationPostProcess
  158523. * @param name The name of the effect.
  158524. * @param screenWidth The width of the screen to apply the effect on.
  158525. * @param screenHeight The height of the screen to apply the effect on.
  158526. * @param options The required width/height ratio to downsize to before computing the render pass.
  158527. * @param camera The camera to apply the render pass to.
  158528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158529. * @param engine The engine which the post process will be applied. (default: current engine)
  158530. * @param reusable If the post process can be reused on the same frame. (default: false)
  158531. * @param textureType Type of textures used when performing the post process. (default: 0)
  158532. * @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)
  158533. */
  158534. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158535. /** @hidden */
  158536. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  158537. }
  158538. }
  158539. declare module BABYLON {
  158540. /** @hidden */
  158541. export var circleOfConfusionPixelShader: {
  158542. name: string;
  158543. shader: string;
  158544. };
  158545. }
  158546. declare module BABYLON {
  158547. /**
  158548. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  158549. */
  158550. export class CircleOfConfusionPostProcess extends PostProcess {
  158551. /**
  158552. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  158553. */
  158554. lensSize: number;
  158555. /**
  158556. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  158557. */
  158558. fStop: number;
  158559. /**
  158560. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  158561. */
  158562. focusDistance: number;
  158563. /**
  158564. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  158565. */
  158566. focalLength: number;
  158567. /**
  158568. * Gets a string identifying the name of the class
  158569. * @returns "CircleOfConfusionPostProcess" string
  158570. */
  158571. getClassName(): string;
  158572. private _depthTexture;
  158573. /**
  158574. * Creates a new instance CircleOfConfusionPostProcess
  158575. * @param name The name of the effect.
  158576. * @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.
  158577. * @param options The required width/height ratio to downsize to before computing the render pass.
  158578. * @param camera The camera to apply the render pass to.
  158579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158580. * @param engine The engine which the post process will be applied. (default: current engine)
  158581. * @param reusable If the post process can be reused on the same frame. (default: false)
  158582. * @param textureType Type of textures used when performing the post process. (default: 0)
  158583. * @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)
  158584. */
  158585. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158586. /**
  158587. * 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.
  158588. */
  158589. set depthTexture(value: RenderTargetTexture);
  158590. }
  158591. }
  158592. declare module BABYLON {
  158593. /** @hidden */
  158594. export var colorCorrectionPixelShader: {
  158595. name: string;
  158596. shader: string;
  158597. };
  158598. }
  158599. declare module BABYLON {
  158600. /**
  158601. *
  158602. * This post-process allows the modification of rendered colors by using
  158603. * a 'look-up table' (LUT). This effect is also called Color Grading.
  158604. *
  158605. * The object needs to be provided an url to a texture containing the color
  158606. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  158607. * Use an image editing software to tweak the LUT to match your needs.
  158608. *
  158609. * For an example of a color LUT, see here:
  158610. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  158611. * For explanations on color grading, see here:
  158612. * @see http://udn.epicgames.com/Three/ColorGrading.html
  158613. *
  158614. */
  158615. export class ColorCorrectionPostProcess extends PostProcess {
  158616. private _colorTableTexture;
  158617. /**
  158618. * Gets the color table url used to create the LUT texture
  158619. */
  158620. colorTableUrl: string;
  158621. /**
  158622. * Gets a string identifying the name of the class
  158623. * @returns "ColorCorrectionPostProcess" string
  158624. */
  158625. getClassName(): string;
  158626. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158627. /** @hidden */
  158628. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  158629. }
  158630. }
  158631. declare module BABYLON {
  158632. /** @hidden */
  158633. export var convolutionPixelShader: {
  158634. name: string;
  158635. shader: string;
  158636. };
  158637. }
  158638. declare module BABYLON {
  158639. /**
  158640. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  158641. * input texture to perform effects such as edge detection or sharpening
  158642. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  158643. */
  158644. export class ConvolutionPostProcess extends PostProcess {
  158645. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  158646. kernel: number[];
  158647. /**
  158648. * Gets a string identifying the name of the class
  158649. * @returns "ConvolutionPostProcess" string
  158650. */
  158651. getClassName(): string;
  158652. /**
  158653. * Creates a new instance ConvolutionPostProcess
  158654. * @param name The name of the effect.
  158655. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  158656. * @param options The required width/height ratio to downsize to before computing the render pass.
  158657. * @param camera The camera to apply the render pass to.
  158658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158659. * @param engine The engine which the post process will be applied. (default: current engine)
  158660. * @param reusable If the post process can be reused on the same frame. (default: false)
  158661. * @param textureType Type of textures used when performing the post process. (default: 0)
  158662. */
  158663. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158664. /** @hidden */
  158665. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  158666. /**
  158667. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158668. */
  158669. static EdgeDetect0Kernel: number[];
  158670. /**
  158671. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158672. */
  158673. static EdgeDetect1Kernel: number[];
  158674. /**
  158675. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158676. */
  158677. static EdgeDetect2Kernel: number[];
  158678. /**
  158679. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158680. */
  158681. static SharpenKernel: number[];
  158682. /**
  158683. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158684. */
  158685. static EmbossKernel: number[];
  158686. /**
  158687. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158688. */
  158689. static GaussianKernel: number[];
  158690. }
  158691. }
  158692. declare module BABYLON {
  158693. /**
  158694. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  158695. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  158696. * based on samples that have a large difference in distance than the center pixel.
  158697. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  158698. */
  158699. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  158700. /**
  158701. * The direction the blur should be applied
  158702. */
  158703. direction: Vector2;
  158704. /**
  158705. * Gets a string identifying the name of the class
  158706. * @returns "DepthOfFieldBlurPostProcess" string
  158707. */
  158708. getClassName(): string;
  158709. /**
  158710. * Creates a new instance CircleOfConfusionPostProcess
  158711. * @param name The name of the effect.
  158712. * @param scene The scene the effect belongs to.
  158713. * @param direction The direction the blur should be applied.
  158714. * @param kernel The size of the kernel used to blur.
  158715. * @param options The required width/height ratio to downsize to before computing the render pass.
  158716. * @param camera The camera to apply the render pass to.
  158717. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  158718. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  158719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158720. * @param engine The engine which the post process will be applied. (default: current engine)
  158721. * @param reusable If the post process can be reused on the same frame. (default: false)
  158722. * @param textureType Type of textures used when performing the post process. (default: 0)
  158723. * @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)
  158724. */
  158725. 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);
  158726. }
  158727. }
  158728. declare module BABYLON {
  158729. /** @hidden */
  158730. export var depthOfFieldMergePixelShader: {
  158731. name: string;
  158732. shader: string;
  158733. };
  158734. }
  158735. declare module BABYLON {
  158736. /**
  158737. * Options to be set when merging outputs from the default pipeline.
  158738. */
  158739. export class DepthOfFieldMergePostProcessOptions {
  158740. /**
  158741. * The original image to merge on top of
  158742. */
  158743. originalFromInput: PostProcess;
  158744. /**
  158745. * Parameters to perform the merge of the depth of field effect
  158746. */
  158747. depthOfField?: {
  158748. circleOfConfusion: PostProcess;
  158749. blurSteps: Array<PostProcess>;
  158750. };
  158751. /**
  158752. * Parameters to perform the merge of bloom effect
  158753. */
  158754. bloom?: {
  158755. blurred: PostProcess;
  158756. weight: number;
  158757. };
  158758. }
  158759. /**
  158760. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  158761. */
  158762. export class DepthOfFieldMergePostProcess extends PostProcess {
  158763. private blurSteps;
  158764. /**
  158765. * Gets a string identifying the name of the class
  158766. * @returns "DepthOfFieldMergePostProcess" string
  158767. */
  158768. getClassName(): string;
  158769. /**
  158770. * Creates a new instance of DepthOfFieldMergePostProcess
  158771. * @param name The name of the effect.
  158772. * @param originalFromInput Post process which's input will be used for the merge.
  158773. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  158774. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  158775. * @param options The required width/height ratio to downsize to before computing the render pass.
  158776. * @param camera The camera to apply the render pass to.
  158777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158778. * @param engine The engine which the post process will be applied. (default: current engine)
  158779. * @param reusable If the post process can be reused on the same frame. (default: false)
  158780. * @param textureType Type of textures used when performing the post process. (default: 0)
  158781. * @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)
  158782. */
  158783. 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);
  158784. /**
  158785. * Updates the effect with the current post process compile time values and recompiles the shader.
  158786. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  158787. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  158788. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  158789. * @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
  158790. * @param onCompiled Called when the shader has been compiled.
  158791. * @param onError Called if there is an error when compiling a shader.
  158792. */
  158793. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  158794. }
  158795. }
  158796. declare module BABYLON {
  158797. /**
  158798. * Specifies the level of max blur that should be applied when using the depth of field effect
  158799. */
  158800. export enum DepthOfFieldEffectBlurLevel {
  158801. /**
  158802. * Subtle blur
  158803. */
  158804. Low = 0,
  158805. /**
  158806. * Medium blur
  158807. */
  158808. Medium = 1,
  158809. /**
  158810. * Large blur
  158811. */
  158812. High = 2
  158813. }
  158814. /**
  158815. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  158816. */
  158817. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  158818. private _circleOfConfusion;
  158819. /**
  158820. * @hidden Internal, blurs from high to low
  158821. */
  158822. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  158823. private _depthOfFieldBlurY;
  158824. private _dofMerge;
  158825. /**
  158826. * @hidden Internal post processes in depth of field effect
  158827. */
  158828. _effects: Array<PostProcess>;
  158829. /**
  158830. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  158831. */
  158832. set focalLength(value: number);
  158833. get focalLength(): number;
  158834. /**
  158835. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  158836. */
  158837. set fStop(value: number);
  158838. get fStop(): number;
  158839. /**
  158840. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  158841. */
  158842. set focusDistance(value: number);
  158843. get focusDistance(): number;
  158844. /**
  158845. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  158846. */
  158847. set lensSize(value: number);
  158848. get lensSize(): number;
  158849. /**
  158850. * Creates a new instance DepthOfFieldEffect
  158851. * @param scene The scene the effect belongs to.
  158852. * @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.
  158853. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  158854. * @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)
  158855. */
  158856. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  158857. /**
  158858. * Get the current class name of the current effet
  158859. * @returns "DepthOfFieldEffect"
  158860. */
  158861. getClassName(): string;
  158862. /**
  158863. * 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.
  158864. */
  158865. set depthTexture(value: RenderTargetTexture);
  158866. /**
  158867. * Disposes each of the internal effects for a given camera.
  158868. * @param camera The camera to dispose the effect on.
  158869. */
  158870. disposeEffects(camera: Camera): void;
  158871. /**
  158872. * @hidden Internal
  158873. */
  158874. _updateEffects(): void;
  158875. /**
  158876. * Internal
  158877. * @returns if all the contained post processes are ready.
  158878. * @hidden
  158879. */
  158880. _isReady(): boolean;
  158881. }
  158882. }
  158883. declare module BABYLON {
  158884. /** @hidden */
  158885. export var displayPassPixelShader: {
  158886. name: string;
  158887. shader: string;
  158888. };
  158889. }
  158890. declare module BABYLON {
  158891. /**
  158892. * DisplayPassPostProcess which produces an output the same as it's input
  158893. */
  158894. export class DisplayPassPostProcess extends PostProcess {
  158895. /**
  158896. * Gets a string identifying the name of the class
  158897. * @returns "DisplayPassPostProcess" string
  158898. */
  158899. getClassName(): string;
  158900. /**
  158901. * Creates the DisplayPassPostProcess
  158902. * @param name The name of the effect.
  158903. * @param options The required width/height ratio to downsize to before computing the render pass.
  158904. * @param camera The camera to apply the render pass to.
  158905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158906. * @param engine The engine which the post process will be applied. (default: current engine)
  158907. * @param reusable If the post process can be reused on the same frame. (default: false)
  158908. */
  158909. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158910. /** @hidden */
  158911. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  158912. }
  158913. }
  158914. declare module BABYLON {
  158915. /** @hidden */
  158916. export var filterPixelShader: {
  158917. name: string;
  158918. shader: string;
  158919. };
  158920. }
  158921. declare module BABYLON {
  158922. /**
  158923. * Applies a kernel filter to the image
  158924. */
  158925. export class FilterPostProcess extends PostProcess {
  158926. /** The matrix to be applied to the image */
  158927. kernelMatrix: Matrix;
  158928. /**
  158929. * Gets a string identifying the name of the class
  158930. * @returns "FilterPostProcess" string
  158931. */
  158932. getClassName(): string;
  158933. /**
  158934. *
  158935. * @param name The name of the effect.
  158936. * @param kernelMatrix The matrix to be applied to the image
  158937. * @param options The required width/height ratio to downsize to before computing the render pass.
  158938. * @param camera The camera to apply the render pass to.
  158939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158940. * @param engine The engine which the post process will be applied. (default: current engine)
  158941. * @param reusable If the post process can be reused on the same frame. (default: false)
  158942. */
  158943. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158944. /** @hidden */
  158945. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  158946. }
  158947. }
  158948. declare module BABYLON {
  158949. /** @hidden */
  158950. export var fxaaPixelShader: {
  158951. name: string;
  158952. shader: string;
  158953. };
  158954. }
  158955. declare module BABYLON {
  158956. /** @hidden */
  158957. export var fxaaVertexShader: {
  158958. name: string;
  158959. shader: string;
  158960. };
  158961. }
  158962. declare module BABYLON {
  158963. /**
  158964. * Fxaa post process
  158965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  158966. */
  158967. export class FxaaPostProcess extends PostProcess {
  158968. /**
  158969. * Gets a string identifying the name of the class
  158970. * @returns "FxaaPostProcess" string
  158971. */
  158972. getClassName(): string;
  158973. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158974. private _getDefines;
  158975. /** @hidden */
  158976. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  158977. }
  158978. }
  158979. declare module BABYLON {
  158980. /** @hidden */
  158981. export var grainPixelShader: {
  158982. name: string;
  158983. shader: string;
  158984. };
  158985. }
  158986. declare module BABYLON {
  158987. /**
  158988. * The GrainPostProcess adds noise to the image at mid luminance levels
  158989. */
  158990. export class GrainPostProcess extends PostProcess {
  158991. /**
  158992. * The intensity of the grain added (default: 30)
  158993. */
  158994. intensity: number;
  158995. /**
  158996. * If the grain should be randomized on every frame
  158997. */
  158998. animated: boolean;
  158999. /**
  159000. * Gets a string identifying the name of the class
  159001. * @returns "GrainPostProcess" string
  159002. */
  159003. getClassName(): string;
  159004. /**
  159005. * Creates a new instance of @see GrainPostProcess
  159006. * @param name The name of the effect.
  159007. * @param options The required width/height ratio to downsize to before computing the render pass.
  159008. * @param camera The camera to apply the render pass to.
  159009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159010. * @param engine The engine which the post process will be applied. (default: current engine)
  159011. * @param reusable If the post process can be reused on the same frame. (default: false)
  159012. * @param textureType Type of textures used when performing the post process. (default: 0)
  159013. * @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)
  159014. */
  159015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159016. /** @hidden */
  159017. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  159018. }
  159019. }
  159020. declare module BABYLON {
  159021. /** @hidden */
  159022. export var highlightsPixelShader: {
  159023. name: string;
  159024. shader: string;
  159025. };
  159026. }
  159027. declare module BABYLON {
  159028. /**
  159029. * Extracts highlights from the image
  159030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  159031. */
  159032. export class HighlightsPostProcess extends PostProcess {
  159033. /**
  159034. * Gets a string identifying the name of the class
  159035. * @returns "HighlightsPostProcess" string
  159036. */
  159037. getClassName(): string;
  159038. /**
  159039. * Extracts highlights from the image
  159040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  159041. * @param name The name of the effect.
  159042. * @param options The required width/height ratio to downsize to before computing the render pass.
  159043. * @param camera The camera to apply the render pass to.
  159044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159045. * @param engine The engine which the post process will be applied. (default: current engine)
  159046. * @param reusable If the post process can be reused on the same frame. (default: false)
  159047. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  159048. */
  159049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  159050. }
  159051. }
  159052. declare module BABYLON {
  159053. /**
  159054. * Contains all parameters needed for the prepass to perform
  159055. * motion blur
  159056. */
  159057. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  159058. /**
  159059. * Is motion blur enabled
  159060. */
  159061. enabled: boolean;
  159062. /**
  159063. * Name of the configuration
  159064. */
  159065. name: string;
  159066. /**
  159067. * Textures that should be present in the MRT for this effect to work
  159068. */
  159069. readonly texturesRequired: number[];
  159070. }
  159071. }
  159072. declare module BABYLON {
  159073. interface Scene {
  159074. /** @hidden (Backing field) */
  159075. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  159076. /**
  159077. * Gets or Sets the current geometry buffer associated to the scene.
  159078. */
  159079. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  159080. /**
  159081. * Enables a GeometryBufferRender and associates it with the scene
  159082. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  159083. * @returns the GeometryBufferRenderer
  159084. */
  159085. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  159086. /**
  159087. * Disables the GeometryBufferRender associated with the scene
  159088. */
  159089. disableGeometryBufferRenderer(): void;
  159090. }
  159091. /**
  159092. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  159093. * in several rendering techniques.
  159094. */
  159095. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  159096. /**
  159097. * The component name helpful to identify the component in the list of scene components.
  159098. */
  159099. readonly name: string;
  159100. /**
  159101. * The scene the component belongs to.
  159102. */
  159103. scene: Scene;
  159104. /**
  159105. * Creates a new instance of the component for the given scene
  159106. * @param scene Defines the scene to register the component in
  159107. */
  159108. constructor(scene: Scene);
  159109. /**
  159110. * Registers the component in a given scene
  159111. */
  159112. register(): void;
  159113. /**
  159114. * Rebuilds the elements related to this component in case of
  159115. * context lost for instance.
  159116. */
  159117. rebuild(): void;
  159118. /**
  159119. * Disposes the component and the associated ressources
  159120. */
  159121. dispose(): void;
  159122. private _gatherRenderTargets;
  159123. }
  159124. }
  159125. declare module BABYLON {
  159126. /** @hidden */
  159127. export var motionBlurPixelShader: {
  159128. name: string;
  159129. shader: string;
  159130. };
  159131. }
  159132. declare module BABYLON {
  159133. /**
  159134. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  159135. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  159136. * As an example, all you have to do is to create the post-process:
  159137. * var mb = new BABYLON.MotionBlurPostProcess(
  159138. * 'mb', // The name of the effect.
  159139. * scene, // The scene containing the objects to blur according to their velocity.
  159140. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  159141. * camera // The camera to apply the render pass to.
  159142. * );
  159143. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  159144. */
  159145. export class MotionBlurPostProcess extends PostProcess {
  159146. /**
  159147. * Defines how much the image is blurred by the movement. Default value is equal to 1
  159148. */
  159149. motionStrength: number;
  159150. /**
  159151. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  159152. */
  159153. get motionBlurSamples(): number;
  159154. /**
  159155. * Sets the number of iterations to be used for motion blur quality
  159156. */
  159157. set motionBlurSamples(samples: number);
  159158. private _motionBlurSamples;
  159159. /**
  159160. * Gets wether or not the motion blur post-process is in object based mode.
  159161. */
  159162. get isObjectBased(): boolean;
  159163. /**
  159164. * Sets wether or not the motion blur post-process is in object based mode.
  159165. */
  159166. set isObjectBased(value: boolean);
  159167. private _isObjectBased;
  159168. private _forceGeometryBuffer;
  159169. private _geometryBufferRenderer;
  159170. private _prePassRenderer;
  159171. private _invViewProjection;
  159172. private _previousViewProjection;
  159173. /**
  159174. * Gets a string identifying the name of the class
  159175. * @returns "MotionBlurPostProcess" string
  159176. */
  159177. getClassName(): string;
  159178. /**
  159179. * Creates a new instance MotionBlurPostProcess
  159180. * @param name The name of the effect.
  159181. * @param scene The scene containing the objects to blur according to their velocity.
  159182. * @param options The required width/height ratio to downsize to before computing the render pass.
  159183. * @param camera The camera to apply the render pass to.
  159184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159185. * @param engine The engine which the post process will be applied. (default: current engine)
  159186. * @param reusable If the post process can be reused on the same frame. (default: false)
  159187. * @param textureType Type of textures used when performing the post process. (default: 0)
  159188. * @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)
  159189. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  159190. */
  159191. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  159192. /**
  159193. * Excludes the given skinned mesh from computing bones velocities.
  159194. * 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.
  159195. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  159196. */
  159197. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  159198. /**
  159199. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  159200. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  159201. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  159202. */
  159203. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  159204. /**
  159205. * Disposes the post process.
  159206. * @param camera The camera to dispose the post process on.
  159207. */
  159208. dispose(camera?: Camera): void;
  159209. /**
  159210. * Called on the mode changed (object based or screen based).
  159211. */
  159212. private _applyMode;
  159213. /**
  159214. * Called on the effect is applied when the motion blur post-process is in object based mode.
  159215. */
  159216. private _onApplyObjectBased;
  159217. /**
  159218. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  159219. */
  159220. private _onApplyScreenBased;
  159221. /**
  159222. * Called on the effect must be updated (changed mode, samples count, etc.).
  159223. */
  159224. private _updateEffect;
  159225. /** @hidden */
  159226. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  159227. }
  159228. }
  159229. declare module BABYLON {
  159230. /** @hidden */
  159231. export var refractionPixelShader: {
  159232. name: string;
  159233. shader: string;
  159234. };
  159235. }
  159236. declare module BABYLON {
  159237. /**
  159238. * Post process which applies a refractin texture
  159239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  159240. */
  159241. export class RefractionPostProcess extends PostProcess {
  159242. private _refTexture;
  159243. private _ownRefractionTexture;
  159244. /** the base color of the refraction (used to taint the rendering) */
  159245. color: Color3;
  159246. /** simulated refraction depth */
  159247. depth: number;
  159248. /** the coefficient of the base color (0 to remove base color tainting) */
  159249. colorLevel: number;
  159250. /** Gets the url used to load the refraction texture */
  159251. refractionTextureUrl: string;
  159252. /**
  159253. * Gets or sets the refraction texture
  159254. * Please note that you are responsible for disposing the texture if you set it manually
  159255. */
  159256. get refractionTexture(): Texture;
  159257. set refractionTexture(value: Texture);
  159258. /**
  159259. * Gets a string identifying the name of the class
  159260. * @returns "RefractionPostProcess" string
  159261. */
  159262. getClassName(): string;
  159263. /**
  159264. * Initializes the RefractionPostProcess
  159265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  159266. * @param name The name of the effect.
  159267. * @param refractionTextureUrl Url of the refraction texture to use
  159268. * @param color the base color of the refraction (used to taint the rendering)
  159269. * @param depth simulated refraction depth
  159270. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  159271. * @param camera The camera to apply the render pass to.
  159272. * @param options The required width/height ratio to downsize to before computing the render pass.
  159273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159274. * @param engine The engine which the post process will be applied. (default: current engine)
  159275. * @param reusable If the post process can be reused on the same frame. (default: false)
  159276. */
  159277. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159278. /**
  159279. * Disposes of the post process
  159280. * @param camera Camera to dispose post process on
  159281. */
  159282. dispose(camera: Camera): void;
  159283. /** @hidden */
  159284. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  159285. }
  159286. }
  159287. declare module BABYLON {
  159288. /** @hidden */
  159289. export var sharpenPixelShader: {
  159290. name: string;
  159291. shader: string;
  159292. };
  159293. }
  159294. declare module BABYLON {
  159295. /**
  159296. * The SharpenPostProcess applies a sharpen kernel to every pixel
  159297. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  159298. */
  159299. export class SharpenPostProcess extends PostProcess {
  159300. /**
  159301. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  159302. */
  159303. colorAmount: number;
  159304. /**
  159305. * How much sharpness should be applied (default: 0.3)
  159306. */
  159307. edgeAmount: number;
  159308. /**
  159309. * Gets a string identifying the name of the class
  159310. * @returns "SharpenPostProcess" string
  159311. */
  159312. getClassName(): string;
  159313. /**
  159314. * Creates a new instance ConvolutionPostProcess
  159315. * @param name The name of the effect.
  159316. * @param options The required width/height ratio to downsize to before computing the render pass.
  159317. * @param camera The camera to apply the render pass to.
  159318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159319. * @param engine The engine which the post process will be applied. (default: current engine)
  159320. * @param reusable If the post process can be reused on the same frame. (default: false)
  159321. * @param textureType Type of textures used when performing the post process. (default: 0)
  159322. * @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)
  159323. */
  159324. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159325. /** @hidden */
  159326. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  159327. }
  159328. }
  159329. declare module BABYLON {
  159330. /**
  159331. * PostProcessRenderPipeline
  159332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159333. */
  159334. export class PostProcessRenderPipeline {
  159335. private engine;
  159336. private _renderEffects;
  159337. private _renderEffectsForIsolatedPass;
  159338. /**
  159339. * List of inspectable custom properties (used by the Inspector)
  159340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  159341. */
  159342. inspectableCustomProperties: IInspectable[];
  159343. /**
  159344. * @hidden
  159345. */
  159346. protected _cameras: Camera[];
  159347. /** @hidden */
  159348. _name: string;
  159349. /**
  159350. * Gets pipeline name
  159351. */
  159352. get name(): string;
  159353. /** Gets the list of attached cameras */
  159354. get cameras(): Camera[];
  159355. /**
  159356. * Initializes a PostProcessRenderPipeline
  159357. * @param engine engine to add the pipeline to
  159358. * @param name name of the pipeline
  159359. */
  159360. constructor(engine: Engine, name: string);
  159361. /**
  159362. * Gets the class name
  159363. * @returns "PostProcessRenderPipeline"
  159364. */
  159365. getClassName(): string;
  159366. /**
  159367. * If all the render effects in the pipeline are supported
  159368. */
  159369. get isSupported(): boolean;
  159370. /**
  159371. * Adds an effect to the pipeline
  159372. * @param renderEffect the effect to add
  159373. */
  159374. addEffect(renderEffect: PostProcessRenderEffect): void;
  159375. /** @hidden */
  159376. _rebuild(): void;
  159377. /** @hidden */
  159378. _enableEffect(renderEffectName: string, cameras: Camera): void;
  159379. /** @hidden */
  159380. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  159381. /** @hidden */
  159382. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  159383. /** @hidden */
  159384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  159385. /** @hidden */
  159386. _attachCameras(cameras: Camera, unique: boolean): void;
  159387. /** @hidden */
  159388. _attachCameras(cameras: Camera[], unique: boolean): void;
  159389. /** @hidden */
  159390. _detachCameras(cameras: Camera): void;
  159391. /** @hidden */
  159392. _detachCameras(cameras: Nullable<Camera[]>): void;
  159393. /** @hidden */
  159394. _update(): void;
  159395. /** @hidden */
  159396. _reset(): void;
  159397. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  159398. /**
  159399. * Sets the required values to the prepass renderer.
  159400. * @param prePassRenderer defines the prepass renderer to setup.
  159401. * @returns true if the pre pass is needed.
  159402. */
  159403. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  159404. /**
  159405. * Disposes of the pipeline
  159406. */
  159407. dispose(): void;
  159408. }
  159409. }
  159410. declare module BABYLON {
  159411. /**
  159412. * PostProcessRenderPipelineManager class
  159413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159414. */
  159415. export class PostProcessRenderPipelineManager {
  159416. private _renderPipelines;
  159417. /**
  159418. * Initializes a PostProcessRenderPipelineManager
  159419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159420. */
  159421. constructor();
  159422. /**
  159423. * Gets the list of supported render pipelines
  159424. */
  159425. get supportedPipelines(): PostProcessRenderPipeline[];
  159426. /**
  159427. * Adds a pipeline to the manager
  159428. * @param renderPipeline The pipeline to add
  159429. */
  159430. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  159431. /**
  159432. * Attaches a camera to the pipeline
  159433. * @param renderPipelineName The name of the pipeline to attach to
  159434. * @param cameras the camera to attach
  159435. * @param unique if the camera can be attached multiple times to the pipeline
  159436. */
  159437. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  159438. /**
  159439. * Detaches a camera from the pipeline
  159440. * @param renderPipelineName The name of the pipeline to detach from
  159441. * @param cameras the camera to detach
  159442. */
  159443. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  159444. /**
  159445. * Enables an effect by name on a pipeline
  159446. * @param renderPipelineName the name of the pipeline to enable the effect in
  159447. * @param renderEffectName the name of the effect to enable
  159448. * @param cameras the cameras that the effect should be enabled on
  159449. */
  159450. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  159451. /**
  159452. * Disables an effect by name on a pipeline
  159453. * @param renderPipelineName the name of the pipeline to disable the effect in
  159454. * @param renderEffectName the name of the effect to disable
  159455. * @param cameras the cameras that the effect should be disabled on
  159456. */
  159457. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  159458. /**
  159459. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  159460. */
  159461. update(): void;
  159462. /** @hidden */
  159463. _rebuild(): void;
  159464. /**
  159465. * Disposes of the manager and pipelines
  159466. */
  159467. dispose(): void;
  159468. }
  159469. }
  159470. declare module BABYLON {
  159471. interface Scene {
  159472. /** @hidden (Backing field) */
  159473. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  159474. /**
  159475. * Gets the postprocess render pipeline manager
  159476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159477. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  159478. */
  159479. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  159480. }
  159481. /**
  159482. * Defines the Render Pipeline scene component responsible to rendering pipelines
  159483. */
  159484. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  159485. /**
  159486. * The component name helpfull to identify the component in the list of scene components.
  159487. */
  159488. readonly name: string;
  159489. /**
  159490. * The scene the component belongs to.
  159491. */
  159492. scene: Scene;
  159493. /**
  159494. * Creates a new instance of the component for the given scene
  159495. * @param scene Defines the scene to register the component in
  159496. */
  159497. constructor(scene: Scene);
  159498. /**
  159499. * Registers the component in a given scene
  159500. */
  159501. register(): void;
  159502. /**
  159503. * Rebuilds the elements related to this component in case of
  159504. * context lost for instance.
  159505. */
  159506. rebuild(): void;
  159507. /**
  159508. * Disposes the component and the associated ressources
  159509. */
  159510. dispose(): void;
  159511. private _gatherRenderTargets;
  159512. }
  159513. }
  159514. declare module BABYLON {
  159515. /**
  159516. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  159517. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  159518. */
  159519. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  159520. private _scene;
  159521. private _camerasToBeAttached;
  159522. /**
  159523. * ID of the sharpen post process,
  159524. */
  159525. private readonly SharpenPostProcessId;
  159526. /**
  159527. * @ignore
  159528. * ID of the image processing post process;
  159529. */
  159530. readonly ImageProcessingPostProcessId: string;
  159531. /**
  159532. * @ignore
  159533. * ID of the Fast Approximate Anti-Aliasing post process;
  159534. */
  159535. readonly FxaaPostProcessId: string;
  159536. /**
  159537. * ID of the chromatic aberration post process,
  159538. */
  159539. private readonly ChromaticAberrationPostProcessId;
  159540. /**
  159541. * ID of the grain post process
  159542. */
  159543. private readonly GrainPostProcessId;
  159544. /**
  159545. * Sharpen post process which will apply a sharpen convolution to enhance edges
  159546. */
  159547. sharpen: SharpenPostProcess;
  159548. private _sharpenEffect;
  159549. private bloom;
  159550. /**
  159551. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  159552. */
  159553. depthOfField: DepthOfFieldEffect;
  159554. /**
  159555. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  159556. */
  159557. fxaa: FxaaPostProcess;
  159558. /**
  159559. * Image post processing pass used to perform operations such as tone mapping or color grading.
  159560. */
  159561. imageProcessing: ImageProcessingPostProcess;
  159562. /**
  159563. * Chromatic aberration post process which will shift rgb colors in the image
  159564. */
  159565. chromaticAberration: ChromaticAberrationPostProcess;
  159566. private _chromaticAberrationEffect;
  159567. /**
  159568. * Grain post process which add noise to the image
  159569. */
  159570. grain: GrainPostProcess;
  159571. private _grainEffect;
  159572. /**
  159573. * Glow post process which adds a glow to emissive areas of the image
  159574. */
  159575. private _glowLayer;
  159576. /**
  159577. * Animations which can be used to tweak settings over a period of time
  159578. */
  159579. animations: Animation[];
  159580. private _imageProcessingConfigurationObserver;
  159581. private _sharpenEnabled;
  159582. private _bloomEnabled;
  159583. private _depthOfFieldEnabled;
  159584. private _depthOfFieldBlurLevel;
  159585. private _fxaaEnabled;
  159586. private _imageProcessingEnabled;
  159587. private _defaultPipelineTextureType;
  159588. private _bloomScale;
  159589. private _chromaticAberrationEnabled;
  159590. private _grainEnabled;
  159591. private _buildAllowed;
  159592. /**
  159593. * This is triggered each time the pipeline has been built.
  159594. */
  159595. onBuildObservable: Observable<DefaultRenderingPipeline>;
  159596. /**
  159597. * Gets active scene
  159598. */
  159599. get scene(): Scene;
  159600. /**
  159601. * Enable or disable the sharpen process from the pipeline
  159602. */
  159603. set sharpenEnabled(enabled: boolean);
  159604. get sharpenEnabled(): boolean;
  159605. private _resizeObserver;
  159606. private _hardwareScaleLevel;
  159607. private _bloomKernel;
  159608. /**
  159609. * Specifies the size of the bloom blur kernel, relative to the final output size
  159610. */
  159611. get bloomKernel(): number;
  159612. set bloomKernel(value: number);
  159613. /**
  159614. * Specifies the weight of the bloom in the final rendering
  159615. */
  159616. private _bloomWeight;
  159617. /**
  159618. * Specifies the luma threshold for the area that will be blurred by the bloom
  159619. */
  159620. private _bloomThreshold;
  159621. private _hdr;
  159622. /**
  159623. * The strength of the bloom.
  159624. */
  159625. set bloomWeight(value: number);
  159626. get bloomWeight(): number;
  159627. /**
  159628. * The strength of the bloom.
  159629. */
  159630. set bloomThreshold(value: number);
  159631. get bloomThreshold(): number;
  159632. /**
  159633. * The scale of the bloom, lower value will provide better performance.
  159634. */
  159635. set bloomScale(value: number);
  159636. get bloomScale(): number;
  159637. /**
  159638. * Enable or disable the bloom from the pipeline
  159639. */
  159640. set bloomEnabled(enabled: boolean);
  159641. get bloomEnabled(): boolean;
  159642. private _rebuildBloom;
  159643. /**
  159644. * If the depth of field is enabled.
  159645. */
  159646. get depthOfFieldEnabled(): boolean;
  159647. set depthOfFieldEnabled(enabled: boolean);
  159648. /**
  159649. * Blur level of the depth of field effect. (Higher blur will effect performance)
  159650. */
  159651. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  159652. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  159653. /**
  159654. * If the anti aliasing is enabled.
  159655. */
  159656. set fxaaEnabled(enabled: boolean);
  159657. get fxaaEnabled(): boolean;
  159658. private _samples;
  159659. /**
  159660. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  159661. */
  159662. set samples(sampleCount: number);
  159663. get samples(): number;
  159664. /**
  159665. * If image processing is enabled.
  159666. */
  159667. set imageProcessingEnabled(enabled: boolean);
  159668. get imageProcessingEnabled(): boolean;
  159669. /**
  159670. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  159671. */
  159672. set glowLayerEnabled(enabled: boolean);
  159673. get glowLayerEnabled(): boolean;
  159674. /**
  159675. * Gets the glow layer (or null if not defined)
  159676. */
  159677. get glowLayer(): Nullable<GlowLayer>;
  159678. /**
  159679. * Enable or disable the chromaticAberration process from the pipeline
  159680. */
  159681. set chromaticAberrationEnabled(enabled: boolean);
  159682. get chromaticAberrationEnabled(): boolean;
  159683. /**
  159684. * Enable or disable the grain process from the pipeline
  159685. */
  159686. set grainEnabled(enabled: boolean);
  159687. get grainEnabled(): boolean;
  159688. /**
  159689. * @constructor
  159690. * @param name - The rendering pipeline name (default: "")
  159691. * @param hdr - If high dynamic range textures should be used (default: true)
  159692. * @param scene - The scene linked to this pipeline (default: the last created scene)
  159693. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  159694. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  159695. */
  159696. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  159697. /**
  159698. * Get the class name
  159699. * @returns "DefaultRenderingPipeline"
  159700. */
  159701. getClassName(): string;
  159702. /**
  159703. * Force the compilation of the entire pipeline.
  159704. */
  159705. prepare(): void;
  159706. private _hasCleared;
  159707. private _prevPostProcess;
  159708. private _prevPrevPostProcess;
  159709. private _setAutoClearAndTextureSharing;
  159710. private _depthOfFieldSceneObserver;
  159711. private _buildPipeline;
  159712. private _disposePostProcesses;
  159713. /**
  159714. * Adds a camera to the pipeline
  159715. * @param camera the camera to be added
  159716. */
  159717. addCamera(camera: Camera): void;
  159718. /**
  159719. * Removes a camera from the pipeline
  159720. * @param camera the camera to remove
  159721. */
  159722. removeCamera(camera: Camera): void;
  159723. /**
  159724. * Dispose of the pipeline and stop all post processes
  159725. */
  159726. dispose(): void;
  159727. /**
  159728. * Serialize the rendering pipeline (Used when exporting)
  159729. * @returns the serialized object
  159730. */
  159731. serialize(): any;
  159732. /**
  159733. * Parse the serialized pipeline
  159734. * @param source Source pipeline.
  159735. * @param scene The scene to load the pipeline to.
  159736. * @param rootUrl The URL of the serialized pipeline.
  159737. * @returns An instantiated pipeline from the serialized object.
  159738. */
  159739. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  159740. }
  159741. }
  159742. declare module BABYLON {
  159743. /** @hidden */
  159744. export var lensHighlightsPixelShader: {
  159745. name: string;
  159746. shader: string;
  159747. };
  159748. }
  159749. declare module BABYLON {
  159750. /** @hidden */
  159751. export var depthOfFieldPixelShader: {
  159752. name: string;
  159753. shader: string;
  159754. };
  159755. }
  159756. declare module BABYLON {
  159757. /**
  159758. * BABYLON.JS Chromatic Aberration GLSL Shader
  159759. * Author: Olivier Guyot
  159760. * Separates very slightly R, G and B colors on the edges of the screen
  159761. * Inspired by Francois Tarlier & Martins Upitis
  159762. */
  159763. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  159764. /**
  159765. * @ignore
  159766. * The chromatic aberration PostProcess id in the pipeline
  159767. */
  159768. LensChromaticAberrationEffect: string;
  159769. /**
  159770. * @ignore
  159771. * The highlights enhancing PostProcess id in the pipeline
  159772. */
  159773. HighlightsEnhancingEffect: string;
  159774. /**
  159775. * @ignore
  159776. * The depth-of-field PostProcess id in the pipeline
  159777. */
  159778. LensDepthOfFieldEffect: string;
  159779. private _scene;
  159780. private _depthTexture;
  159781. private _grainTexture;
  159782. private _chromaticAberrationPostProcess;
  159783. private _highlightsPostProcess;
  159784. private _depthOfFieldPostProcess;
  159785. private _edgeBlur;
  159786. private _grainAmount;
  159787. private _chromaticAberration;
  159788. private _distortion;
  159789. private _highlightsGain;
  159790. private _highlightsThreshold;
  159791. private _dofDistance;
  159792. private _dofAperture;
  159793. private _dofDarken;
  159794. private _dofPentagon;
  159795. private _blurNoise;
  159796. /**
  159797. * @constructor
  159798. *
  159799. * Effect parameters are as follow:
  159800. * {
  159801. * chromatic_aberration: number; // from 0 to x (1 for realism)
  159802. * edge_blur: number; // from 0 to x (1 for realism)
  159803. * distortion: number; // from 0 to x (1 for realism)
  159804. * grain_amount: number; // from 0 to 1
  159805. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  159806. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  159807. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  159808. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  159809. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  159810. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  159811. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  159812. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  159813. * }
  159814. * Note: if an effect parameter is unset, effect is disabled
  159815. *
  159816. * @param name The rendering pipeline name
  159817. * @param parameters - An object containing all parameters (see above)
  159818. * @param scene The scene linked to this pipeline
  159819. * @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)
  159820. * @param cameras The array of cameras that the rendering pipeline will be attached to
  159821. */
  159822. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  159823. /**
  159824. * Get the class name
  159825. * @returns "LensRenderingPipeline"
  159826. */
  159827. getClassName(): string;
  159828. /**
  159829. * Gets associated scene
  159830. */
  159831. get scene(): Scene;
  159832. /**
  159833. * Gets or sets the edge blur
  159834. */
  159835. get edgeBlur(): number;
  159836. set edgeBlur(value: number);
  159837. /**
  159838. * Gets or sets the grain amount
  159839. */
  159840. get grainAmount(): number;
  159841. set grainAmount(value: number);
  159842. /**
  159843. * Gets or sets the chromatic aberration amount
  159844. */
  159845. get chromaticAberration(): number;
  159846. set chromaticAberration(value: number);
  159847. /**
  159848. * Gets or sets the depth of field aperture
  159849. */
  159850. get dofAperture(): number;
  159851. set dofAperture(value: number);
  159852. /**
  159853. * Gets or sets the edge distortion
  159854. */
  159855. get edgeDistortion(): number;
  159856. set edgeDistortion(value: number);
  159857. /**
  159858. * Gets or sets the depth of field distortion
  159859. */
  159860. get dofDistortion(): number;
  159861. set dofDistortion(value: number);
  159862. /**
  159863. * Gets or sets the darken out of focus amount
  159864. */
  159865. get darkenOutOfFocus(): number;
  159866. set darkenOutOfFocus(value: number);
  159867. /**
  159868. * Gets or sets a boolean indicating if blur noise is enabled
  159869. */
  159870. get blurNoise(): boolean;
  159871. set blurNoise(value: boolean);
  159872. /**
  159873. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  159874. */
  159875. get pentagonBokeh(): boolean;
  159876. set pentagonBokeh(value: boolean);
  159877. /**
  159878. * Gets or sets the highlight grain amount
  159879. */
  159880. get highlightsGain(): number;
  159881. set highlightsGain(value: number);
  159882. /**
  159883. * Gets or sets the highlight threshold
  159884. */
  159885. get highlightsThreshold(): number;
  159886. set highlightsThreshold(value: number);
  159887. /**
  159888. * Sets the amount of blur at the edges
  159889. * @param amount blur amount
  159890. */
  159891. setEdgeBlur(amount: number): void;
  159892. /**
  159893. * Sets edge blur to 0
  159894. */
  159895. disableEdgeBlur(): void;
  159896. /**
  159897. * Sets the amout of grain
  159898. * @param amount Amount of grain
  159899. */
  159900. setGrainAmount(amount: number): void;
  159901. /**
  159902. * Set grain amount to 0
  159903. */
  159904. disableGrain(): void;
  159905. /**
  159906. * Sets the chromatic aberration amount
  159907. * @param amount amount of chromatic aberration
  159908. */
  159909. setChromaticAberration(amount: number): void;
  159910. /**
  159911. * Sets chromatic aberration amount to 0
  159912. */
  159913. disableChromaticAberration(): void;
  159914. /**
  159915. * Sets the EdgeDistortion amount
  159916. * @param amount amount of EdgeDistortion
  159917. */
  159918. setEdgeDistortion(amount: number): void;
  159919. /**
  159920. * Sets edge distortion to 0
  159921. */
  159922. disableEdgeDistortion(): void;
  159923. /**
  159924. * Sets the FocusDistance amount
  159925. * @param amount amount of FocusDistance
  159926. */
  159927. setFocusDistance(amount: number): void;
  159928. /**
  159929. * Disables depth of field
  159930. */
  159931. disableDepthOfField(): void;
  159932. /**
  159933. * Sets the Aperture amount
  159934. * @param amount amount of Aperture
  159935. */
  159936. setAperture(amount: number): void;
  159937. /**
  159938. * Sets the DarkenOutOfFocus amount
  159939. * @param amount amount of DarkenOutOfFocus
  159940. */
  159941. setDarkenOutOfFocus(amount: number): void;
  159942. private _pentagonBokehIsEnabled;
  159943. /**
  159944. * Creates a pentagon bokeh effect
  159945. */
  159946. enablePentagonBokeh(): void;
  159947. /**
  159948. * Disables the pentagon bokeh effect
  159949. */
  159950. disablePentagonBokeh(): void;
  159951. /**
  159952. * Enables noise blur
  159953. */
  159954. enableNoiseBlur(): void;
  159955. /**
  159956. * Disables noise blur
  159957. */
  159958. disableNoiseBlur(): void;
  159959. /**
  159960. * Sets the HighlightsGain amount
  159961. * @param amount amount of HighlightsGain
  159962. */
  159963. setHighlightsGain(amount: number): void;
  159964. /**
  159965. * Sets the HighlightsThreshold amount
  159966. * @param amount amount of HighlightsThreshold
  159967. */
  159968. setHighlightsThreshold(amount: number): void;
  159969. /**
  159970. * Disables highlights
  159971. */
  159972. disableHighlights(): void;
  159973. /**
  159974. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  159975. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  159976. */
  159977. dispose(disableDepthRender?: boolean): void;
  159978. private _createChromaticAberrationPostProcess;
  159979. private _createHighlightsPostProcess;
  159980. private _createDepthOfFieldPostProcess;
  159981. private _createGrainTexture;
  159982. }
  159983. }
  159984. declare module BABYLON {
  159985. /**
  159986. * Contains all parameters needed for the prepass to perform
  159987. * screen space subsurface scattering
  159988. */
  159989. export class SSAO2Configuration implements PrePassEffectConfiguration {
  159990. /**
  159991. * Is subsurface enabled
  159992. */
  159993. enabled: boolean;
  159994. /**
  159995. * Name of the configuration
  159996. */
  159997. name: string;
  159998. /**
  159999. * Textures that should be present in the MRT for this effect to work
  160000. */
  160001. readonly texturesRequired: number[];
  160002. }
  160003. }
  160004. declare module BABYLON {
  160005. /** @hidden */
  160006. export var ssao2PixelShader: {
  160007. name: string;
  160008. shader: string;
  160009. };
  160010. }
  160011. declare module BABYLON {
  160012. /** @hidden */
  160013. export var ssaoCombinePixelShader: {
  160014. name: string;
  160015. shader: string;
  160016. };
  160017. }
  160018. declare module BABYLON {
  160019. /**
  160020. * Render pipeline to produce ssao effect
  160021. */
  160022. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  160023. /**
  160024. * @ignore
  160025. * The PassPostProcess id in the pipeline that contains the original scene color
  160026. */
  160027. SSAOOriginalSceneColorEffect: string;
  160028. /**
  160029. * @ignore
  160030. * The SSAO PostProcess id in the pipeline
  160031. */
  160032. SSAORenderEffect: string;
  160033. /**
  160034. * @ignore
  160035. * The horizontal blur PostProcess id in the pipeline
  160036. */
  160037. SSAOBlurHRenderEffect: string;
  160038. /**
  160039. * @ignore
  160040. * The vertical blur PostProcess id in the pipeline
  160041. */
  160042. SSAOBlurVRenderEffect: string;
  160043. /**
  160044. * @ignore
  160045. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  160046. */
  160047. SSAOCombineRenderEffect: string;
  160048. /**
  160049. * The output strength of the SSAO post-process. Default value is 1.0.
  160050. */
  160051. totalStrength: number;
  160052. /**
  160053. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  160054. */
  160055. maxZ: number;
  160056. /**
  160057. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  160058. */
  160059. minZAspect: number;
  160060. private _samples;
  160061. /**
  160062. * Number of samples used for the SSAO calculations. Default value is 8
  160063. */
  160064. set samples(n: number);
  160065. get samples(): number;
  160066. private _textureSamples;
  160067. /**
  160068. * Number of samples to use for antialiasing
  160069. */
  160070. set textureSamples(n: number);
  160071. get textureSamples(): number;
  160072. /**
  160073. * Force rendering the geometry through geometry buffer
  160074. */
  160075. private _forceGeometryBuffer;
  160076. /**
  160077. * Ratio object used for SSAO ratio and blur ratio
  160078. */
  160079. private _ratio;
  160080. /**
  160081. * Dynamically generated sphere sampler.
  160082. */
  160083. private _sampleSphere;
  160084. /**
  160085. * Blur filter offsets
  160086. */
  160087. private _samplerOffsets;
  160088. private _expensiveBlur;
  160089. /**
  160090. * If bilateral blur should be used
  160091. */
  160092. set expensiveBlur(b: boolean);
  160093. get expensiveBlur(): boolean;
  160094. /**
  160095. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  160096. */
  160097. radius: number;
  160098. /**
  160099. * The base color of the SSAO post-process
  160100. * The final result is "base + ssao" between [0, 1]
  160101. */
  160102. base: number;
  160103. /**
  160104. * Support test.
  160105. */
  160106. static get IsSupported(): boolean;
  160107. private _scene;
  160108. private _randomTexture;
  160109. private _originalColorPostProcess;
  160110. private _ssaoPostProcess;
  160111. private _blurHPostProcess;
  160112. private _blurVPostProcess;
  160113. private _ssaoCombinePostProcess;
  160114. private _prePassRenderer;
  160115. /**
  160116. * Gets active scene
  160117. */
  160118. get scene(): Scene;
  160119. /**
  160120. * @constructor
  160121. * @param name The rendering pipeline name
  160122. * @param scene The scene linked to this pipeline
  160123. * @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 }
  160124. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160125. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  160126. */
  160127. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  160128. /**
  160129. * Get the class name
  160130. * @returns "SSAO2RenderingPipeline"
  160131. */
  160132. getClassName(): string;
  160133. /**
  160134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  160135. */
  160136. dispose(disableGeometryBufferRenderer?: boolean): void;
  160137. private _createBlurPostProcess;
  160138. /** @hidden */
  160139. _rebuild(): void;
  160140. private _bits;
  160141. private _radicalInverse_VdC;
  160142. private _hammersley;
  160143. private _hemisphereSample_uniform;
  160144. private _generateHemisphere;
  160145. private _getDefinesForSSAO;
  160146. private static readonly ORTHO_DEPTH_PROJECTION;
  160147. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  160148. private _createSSAOPostProcess;
  160149. private _createSSAOCombinePostProcess;
  160150. private _createRandomTexture;
  160151. /**
  160152. * Serialize the rendering pipeline (Used when exporting)
  160153. * @returns the serialized object
  160154. */
  160155. serialize(): any;
  160156. /**
  160157. * Parse the serialized pipeline
  160158. * @param source Source pipeline.
  160159. * @param scene The scene to load the pipeline to.
  160160. * @param rootUrl The URL of the serialized pipeline.
  160161. * @returns An instantiated pipeline from the serialized object.
  160162. */
  160163. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  160164. }
  160165. }
  160166. declare module BABYLON {
  160167. /** @hidden */
  160168. export var ssaoPixelShader: {
  160169. name: string;
  160170. shader: string;
  160171. };
  160172. }
  160173. declare module BABYLON {
  160174. /**
  160175. * Render pipeline to produce ssao effect
  160176. */
  160177. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  160178. /**
  160179. * @ignore
  160180. * The PassPostProcess id in the pipeline that contains the original scene color
  160181. */
  160182. SSAOOriginalSceneColorEffect: string;
  160183. /**
  160184. * @ignore
  160185. * The SSAO PostProcess id in the pipeline
  160186. */
  160187. SSAORenderEffect: string;
  160188. /**
  160189. * @ignore
  160190. * The horizontal blur PostProcess id in the pipeline
  160191. */
  160192. SSAOBlurHRenderEffect: string;
  160193. /**
  160194. * @ignore
  160195. * The vertical blur PostProcess id in the pipeline
  160196. */
  160197. SSAOBlurVRenderEffect: string;
  160198. /**
  160199. * @ignore
  160200. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  160201. */
  160202. SSAOCombineRenderEffect: string;
  160203. /**
  160204. * The output strength of the SSAO post-process. Default value is 1.0.
  160205. */
  160206. totalStrength: number;
  160207. /**
  160208. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  160209. */
  160210. radius: number;
  160211. /**
  160212. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  160213. * Must not be equal to fallOff and superior to fallOff.
  160214. * Default value is 0.0075
  160215. */
  160216. area: number;
  160217. /**
  160218. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  160219. * Must not be equal to area and inferior to area.
  160220. * Default value is 0.000001
  160221. */
  160222. fallOff: number;
  160223. /**
  160224. * The base color of the SSAO post-process
  160225. * The final result is "base + ssao" between [0, 1]
  160226. */
  160227. base: number;
  160228. private _scene;
  160229. private _depthTexture;
  160230. private _randomTexture;
  160231. private _originalColorPostProcess;
  160232. private _ssaoPostProcess;
  160233. private _blurHPostProcess;
  160234. private _blurVPostProcess;
  160235. private _ssaoCombinePostProcess;
  160236. private _firstUpdate;
  160237. /**
  160238. * Gets active scene
  160239. */
  160240. get scene(): Scene;
  160241. /**
  160242. * @constructor
  160243. * @param name - The rendering pipeline name
  160244. * @param scene - The scene linked to this pipeline
  160245. * @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 }
  160246. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  160247. */
  160248. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  160249. /**
  160250. * Get the class name
  160251. * @returns "SSAORenderingPipeline"
  160252. */
  160253. getClassName(): string;
  160254. /**
  160255. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  160256. */
  160257. dispose(disableDepthRender?: boolean): void;
  160258. private _createBlurPostProcess;
  160259. /** @hidden */
  160260. _rebuild(): void;
  160261. private _createSSAOPostProcess;
  160262. private _createSSAOCombinePostProcess;
  160263. private _createRandomTexture;
  160264. }
  160265. }
  160266. declare module BABYLON {
  160267. /**
  160268. * Contains all parameters needed for the prepass to perform
  160269. * screen space reflections
  160270. */
  160271. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  160272. /**
  160273. * Is ssr enabled
  160274. */
  160275. enabled: boolean;
  160276. /**
  160277. * Name of the configuration
  160278. */
  160279. name: string;
  160280. /**
  160281. * Textures that should be present in the MRT for this effect to work
  160282. */
  160283. readonly texturesRequired: number[];
  160284. }
  160285. }
  160286. declare module BABYLON {
  160287. /** @hidden */
  160288. export var screenSpaceReflectionPixelShader: {
  160289. name: string;
  160290. shader: string;
  160291. };
  160292. }
  160293. declare module BABYLON {
  160294. /**
  160295. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  160296. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  160297. */
  160298. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  160299. /**
  160300. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  160301. */
  160302. threshold: number;
  160303. /**
  160304. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  160305. */
  160306. strength: number;
  160307. /**
  160308. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  160309. */
  160310. reflectionSpecularFalloffExponent: number;
  160311. /**
  160312. * 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]
  160313. */
  160314. step: number;
  160315. /**
  160316. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  160317. */
  160318. roughnessFactor: number;
  160319. private _forceGeometryBuffer;
  160320. private _geometryBufferRenderer;
  160321. private _prePassRenderer;
  160322. private _enableSmoothReflections;
  160323. private _reflectionSamples;
  160324. private _smoothSteps;
  160325. /**
  160326. * Gets a string identifying the name of the class
  160327. * @returns "ScreenSpaceReflectionPostProcess" string
  160328. */
  160329. getClassName(): string;
  160330. /**
  160331. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  160332. * @param name The name of the effect.
  160333. * @param scene The scene containing the objects to calculate reflections.
  160334. * @param options The required width/height ratio to downsize to before computing the render pass.
  160335. * @param camera The camera to apply the render pass to.
  160336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160337. * @param engine The engine which the post process will be applied. (default: current engine)
  160338. * @param reusable If the post process can be reused on the same frame. (default: false)
  160339. * @param textureType Type of textures used when performing the post process. (default: 0)
  160340. * @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)
  160341. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  160342. */
  160343. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  160344. /**
  160345. * Gets wether or not smoothing reflections is enabled.
  160346. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  160347. */
  160348. get enableSmoothReflections(): boolean;
  160349. /**
  160350. * Sets wether or not smoothing reflections is enabled.
  160351. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  160352. */
  160353. set enableSmoothReflections(enabled: boolean);
  160354. /**
  160355. * Gets the number of samples taken while computing reflections. More samples count is high,
  160356. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  160357. */
  160358. get reflectionSamples(): number;
  160359. /**
  160360. * Sets the number of samples taken while computing reflections. More samples count is high,
  160361. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  160362. */
  160363. set reflectionSamples(samples: number);
  160364. /**
  160365. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  160366. * more the post-process will require GPU power and can generate a drop in FPS.
  160367. * Default value (5.0) work pretty well in all cases but can be adjusted.
  160368. */
  160369. get smoothSteps(): number;
  160370. set smoothSteps(steps: number);
  160371. private _updateEffectDefines;
  160372. /** @hidden */
  160373. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  160374. }
  160375. }
  160376. declare module BABYLON {
  160377. /** @hidden */
  160378. export var standardPixelShader: {
  160379. name: string;
  160380. shader: string;
  160381. };
  160382. }
  160383. declare module BABYLON {
  160384. /**
  160385. * Standard rendering pipeline
  160386. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160387. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  160388. */
  160389. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  160390. /**
  160391. * Public members
  160392. */
  160393. /**
  160394. * Post-process which contains the original scene color before the pipeline applies all the effects
  160395. */
  160396. originalPostProcess: Nullable<PostProcess>;
  160397. /**
  160398. * Post-process used to down scale an image x4
  160399. */
  160400. downSampleX4PostProcess: Nullable<PostProcess>;
  160401. /**
  160402. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  160403. */
  160404. brightPassPostProcess: Nullable<PostProcess>;
  160405. /**
  160406. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  160407. */
  160408. blurHPostProcesses: PostProcess[];
  160409. /**
  160410. * Post-process array storing all the vertical blur post-processes used by the pipeline
  160411. */
  160412. blurVPostProcesses: PostProcess[];
  160413. /**
  160414. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  160415. */
  160416. textureAdderPostProcess: Nullable<PostProcess>;
  160417. /**
  160418. * Post-process used to create volumetric lighting effect
  160419. */
  160420. volumetricLightPostProcess: Nullable<PostProcess>;
  160421. /**
  160422. * Post-process used to smooth the previous volumetric light post-process on the X axis
  160423. */
  160424. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  160425. /**
  160426. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  160427. */
  160428. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  160429. /**
  160430. * Post-process used to merge the volumetric light effect and the real scene color
  160431. */
  160432. volumetricLightMergePostProces: Nullable<PostProcess>;
  160433. /**
  160434. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  160435. */
  160436. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  160437. /**
  160438. * Base post-process used to calculate the average luminance of the final image for HDR
  160439. */
  160440. luminancePostProcess: Nullable<PostProcess>;
  160441. /**
  160442. * Post-processes used to create down sample post-processes in order to get
  160443. * the average luminance of the final image for HDR
  160444. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  160445. */
  160446. luminanceDownSamplePostProcesses: PostProcess[];
  160447. /**
  160448. * Post-process used to create a HDR effect (light adaptation)
  160449. */
  160450. hdrPostProcess: Nullable<PostProcess>;
  160451. /**
  160452. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  160453. */
  160454. textureAdderFinalPostProcess: Nullable<PostProcess>;
  160455. /**
  160456. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  160457. */
  160458. lensFlareFinalPostProcess: Nullable<PostProcess>;
  160459. /**
  160460. * Post-process used to merge the final HDR post-process and the real scene color
  160461. */
  160462. hdrFinalPostProcess: Nullable<PostProcess>;
  160463. /**
  160464. * Post-process used to create a lens flare effect
  160465. */
  160466. lensFlarePostProcess: Nullable<PostProcess>;
  160467. /**
  160468. * Post-process that merges the result of the lens flare post-process and the real scene color
  160469. */
  160470. lensFlareComposePostProcess: Nullable<PostProcess>;
  160471. /**
  160472. * Post-process used to create a motion blur effect
  160473. */
  160474. motionBlurPostProcess: Nullable<PostProcess>;
  160475. /**
  160476. * Post-process used to create a depth of field effect
  160477. */
  160478. depthOfFieldPostProcess: Nullable<PostProcess>;
  160479. /**
  160480. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  160481. */
  160482. fxaaPostProcess: Nullable<FxaaPostProcess>;
  160483. /**
  160484. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  160485. */
  160486. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  160487. /**
  160488. * Represents the brightness threshold in order to configure the illuminated surfaces
  160489. */
  160490. brightThreshold: number;
  160491. /**
  160492. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  160493. */
  160494. blurWidth: number;
  160495. /**
  160496. * Sets if the blur for highlighted surfaces must be only horizontal
  160497. */
  160498. horizontalBlur: boolean;
  160499. /**
  160500. * Gets the overall exposure used by the pipeline
  160501. */
  160502. get exposure(): number;
  160503. /**
  160504. * Sets the overall exposure used by the pipeline
  160505. */
  160506. set exposure(value: number);
  160507. /**
  160508. * Texture used typically to simulate "dirty" on camera lens
  160509. */
  160510. lensTexture: Nullable<Texture>;
  160511. /**
  160512. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  160513. */
  160514. volumetricLightCoefficient: number;
  160515. /**
  160516. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  160517. */
  160518. volumetricLightPower: number;
  160519. /**
  160520. * Used the set the blur intensity to smooth the volumetric lights
  160521. */
  160522. volumetricLightBlurScale: number;
  160523. /**
  160524. * Light (spot or directional) used to generate the volumetric lights rays
  160525. * The source light must have a shadow generate so the pipeline can get its
  160526. * depth map
  160527. */
  160528. sourceLight: Nullable<SpotLight | DirectionalLight>;
  160529. /**
  160530. * For eye adaptation, represents the minimum luminance the eye can see
  160531. */
  160532. hdrMinimumLuminance: number;
  160533. /**
  160534. * For eye adaptation, represents the decrease luminance speed
  160535. */
  160536. hdrDecreaseRate: number;
  160537. /**
  160538. * For eye adaptation, represents the increase luminance speed
  160539. */
  160540. hdrIncreaseRate: number;
  160541. /**
  160542. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  160543. */
  160544. get hdrAutoExposure(): boolean;
  160545. /**
  160546. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  160547. */
  160548. set hdrAutoExposure(value: boolean);
  160549. /**
  160550. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  160551. */
  160552. lensColorTexture: Nullable<Texture>;
  160553. /**
  160554. * The overall strengh for the lens flare effect
  160555. */
  160556. lensFlareStrength: number;
  160557. /**
  160558. * Dispersion coefficient for lens flare ghosts
  160559. */
  160560. lensFlareGhostDispersal: number;
  160561. /**
  160562. * Main lens flare halo width
  160563. */
  160564. lensFlareHaloWidth: number;
  160565. /**
  160566. * Based on the lens distortion effect, defines how much the lens flare result
  160567. * is distorted
  160568. */
  160569. lensFlareDistortionStrength: number;
  160570. /**
  160571. * Configures the blur intensity used for for lens flare (halo)
  160572. */
  160573. lensFlareBlurWidth: number;
  160574. /**
  160575. * Lens star texture must be used to simulate rays on the flares and is available
  160576. * in the documentation
  160577. */
  160578. lensStarTexture: Nullable<Texture>;
  160579. /**
  160580. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  160581. * flare effect by taking account of the dirt texture
  160582. */
  160583. lensFlareDirtTexture: Nullable<Texture>;
  160584. /**
  160585. * Represents the focal length for the depth of field effect
  160586. */
  160587. depthOfFieldDistance: number;
  160588. /**
  160589. * Represents the blur intensity for the blurred part of the depth of field effect
  160590. */
  160591. depthOfFieldBlurWidth: number;
  160592. /**
  160593. * Gets how much the image is blurred by the movement while using the motion blur post-process
  160594. */
  160595. get motionStrength(): number;
  160596. /**
  160597. * Sets how much the image is blurred by the movement while using the motion blur post-process
  160598. */
  160599. set motionStrength(strength: number);
  160600. /**
  160601. * Gets wether or not the motion blur post-process is object based or screen based.
  160602. */
  160603. get objectBasedMotionBlur(): boolean;
  160604. /**
  160605. * Sets wether or not the motion blur post-process should be object based or screen based
  160606. */
  160607. set objectBasedMotionBlur(value: boolean);
  160608. /**
  160609. * List of animations for the pipeline (IAnimatable implementation)
  160610. */
  160611. animations: Animation[];
  160612. /**
  160613. * Private members
  160614. */
  160615. private _scene;
  160616. private _currentDepthOfFieldSource;
  160617. private _basePostProcess;
  160618. private _fixedExposure;
  160619. private _currentExposure;
  160620. private _hdrAutoExposure;
  160621. private _hdrCurrentLuminance;
  160622. private _motionStrength;
  160623. private _isObjectBasedMotionBlur;
  160624. private _floatTextureType;
  160625. private _camerasToBeAttached;
  160626. private _ratio;
  160627. private _bloomEnabled;
  160628. private _depthOfFieldEnabled;
  160629. private _vlsEnabled;
  160630. private _lensFlareEnabled;
  160631. private _hdrEnabled;
  160632. private _motionBlurEnabled;
  160633. private _fxaaEnabled;
  160634. private _screenSpaceReflectionsEnabled;
  160635. private _motionBlurSamples;
  160636. private _volumetricLightStepsCount;
  160637. private _samples;
  160638. /**
  160639. * @ignore
  160640. * Specifies if the bloom pipeline is enabled
  160641. */
  160642. get BloomEnabled(): boolean;
  160643. set BloomEnabled(enabled: boolean);
  160644. /**
  160645. * @ignore
  160646. * Specifies if the depth of field pipeline is enabed
  160647. */
  160648. get DepthOfFieldEnabled(): boolean;
  160649. set DepthOfFieldEnabled(enabled: boolean);
  160650. /**
  160651. * @ignore
  160652. * Specifies if the lens flare pipeline is enabed
  160653. */
  160654. get LensFlareEnabled(): boolean;
  160655. set LensFlareEnabled(enabled: boolean);
  160656. /**
  160657. * @ignore
  160658. * Specifies if the HDR pipeline is enabled
  160659. */
  160660. get HDREnabled(): boolean;
  160661. set HDREnabled(enabled: boolean);
  160662. /**
  160663. * @ignore
  160664. * Specifies if the volumetric lights scattering effect is enabled
  160665. */
  160666. get VLSEnabled(): boolean;
  160667. set VLSEnabled(enabled: boolean);
  160668. /**
  160669. * @ignore
  160670. * Specifies if the motion blur effect is enabled
  160671. */
  160672. get MotionBlurEnabled(): boolean;
  160673. set MotionBlurEnabled(enabled: boolean);
  160674. /**
  160675. * Specifies if anti-aliasing is enabled
  160676. */
  160677. get fxaaEnabled(): boolean;
  160678. set fxaaEnabled(enabled: boolean);
  160679. /**
  160680. * Specifies if screen space reflections are enabled.
  160681. */
  160682. get screenSpaceReflectionsEnabled(): boolean;
  160683. set screenSpaceReflectionsEnabled(enabled: boolean);
  160684. /**
  160685. * Specifies the number of steps used to calculate the volumetric lights
  160686. * Typically in interval [50, 200]
  160687. */
  160688. get volumetricLightStepsCount(): number;
  160689. set volumetricLightStepsCount(count: number);
  160690. /**
  160691. * Specifies the number of samples used for the motion blur effect
  160692. * Typically in interval [16, 64]
  160693. */
  160694. get motionBlurSamples(): number;
  160695. set motionBlurSamples(samples: number);
  160696. /**
  160697. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  160698. */
  160699. get samples(): number;
  160700. set samples(sampleCount: number);
  160701. /**
  160702. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160703. * @constructor
  160704. * @param name The rendering pipeline name
  160705. * @param scene The scene linked to this pipeline
  160706. * @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)
  160707. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  160708. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160709. */
  160710. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  160711. private _buildPipeline;
  160712. private _createDownSampleX4PostProcess;
  160713. private _createBrightPassPostProcess;
  160714. private _createBlurPostProcesses;
  160715. private _createTextureAdderPostProcess;
  160716. private _createVolumetricLightPostProcess;
  160717. private _createLuminancePostProcesses;
  160718. private _createHdrPostProcess;
  160719. private _createLensFlarePostProcess;
  160720. private _createDepthOfFieldPostProcess;
  160721. private _createMotionBlurPostProcess;
  160722. private _getDepthTexture;
  160723. private _disposePostProcesses;
  160724. /**
  160725. * Dispose of the pipeline and stop all post processes
  160726. */
  160727. dispose(): void;
  160728. /**
  160729. * Serialize the rendering pipeline (Used when exporting)
  160730. * @returns the serialized object
  160731. */
  160732. serialize(): any;
  160733. /**
  160734. * Parse the serialized pipeline
  160735. * @param source Source pipeline.
  160736. * @param scene The scene to load the pipeline to.
  160737. * @param rootUrl The URL of the serialized pipeline.
  160738. * @returns An instantiated pipeline from the serialized object.
  160739. */
  160740. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  160741. /**
  160742. * Luminance steps
  160743. */
  160744. static LuminanceSteps: number;
  160745. }
  160746. }
  160747. declare module BABYLON {
  160748. /** @hidden */
  160749. export var tonemapPixelShader: {
  160750. name: string;
  160751. shader: string;
  160752. };
  160753. }
  160754. declare module BABYLON {
  160755. /** Defines operator used for tonemapping */
  160756. export enum TonemappingOperator {
  160757. /** Hable */
  160758. Hable = 0,
  160759. /** Reinhard */
  160760. Reinhard = 1,
  160761. /** HejiDawson */
  160762. HejiDawson = 2,
  160763. /** Photographic */
  160764. Photographic = 3
  160765. }
  160766. /**
  160767. * Defines a post process to apply tone mapping
  160768. */
  160769. export class TonemapPostProcess extends PostProcess {
  160770. private _operator;
  160771. /** Defines the required exposure adjustement */
  160772. exposureAdjustment: number;
  160773. /**
  160774. * Gets a string identifying the name of the class
  160775. * @returns "TonemapPostProcess" string
  160776. */
  160777. getClassName(): string;
  160778. /**
  160779. * Creates a new TonemapPostProcess
  160780. * @param name defines the name of the postprocess
  160781. * @param _operator defines the operator to use
  160782. * @param exposureAdjustment defines the required exposure adjustement
  160783. * @param camera defines the camera to use (can be null)
  160784. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  160785. * @param engine defines the hosting engine (can be ignore if camera is set)
  160786. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  160787. */
  160788. constructor(name: string, _operator: TonemappingOperator,
  160789. /** Defines the required exposure adjustement */
  160790. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  160791. }
  160792. }
  160793. declare module BABYLON {
  160794. /** @hidden */
  160795. export var volumetricLightScatteringPixelShader: {
  160796. name: string;
  160797. shader: string;
  160798. };
  160799. }
  160800. declare module BABYLON {
  160801. /** @hidden */
  160802. export var volumetricLightScatteringPassVertexShader: {
  160803. name: string;
  160804. shader: string;
  160805. };
  160806. }
  160807. declare module BABYLON {
  160808. /** @hidden */
  160809. export var volumetricLightScatteringPassPixelShader: {
  160810. name: string;
  160811. shader: string;
  160812. };
  160813. }
  160814. declare module BABYLON {
  160815. /**
  160816. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  160817. */
  160818. export class VolumetricLightScatteringPostProcess extends PostProcess {
  160819. private _volumetricLightScatteringPass;
  160820. private _volumetricLightScatteringRTT;
  160821. private _viewPort;
  160822. private _screenCoordinates;
  160823. private _cachedDefines;
  160824. /**
  160825. * If not undefined, the mesh position is computed from the attached node position
  160826. */
  160827. attachedNode: {
  160828. position: Vector3;
  160829. };
  160830. /**
  160831. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  160832. */
  160833. customMeshPosition: Vector3;
  160834. /**
  160835. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  160836. */
  160837. useCustomMeshPosition: boolean;
  160838. /**
  160839. * If the post-process should inverse the light scattering direction
  160840. */
  160841. invert: boolean;
  160842. /**
  160843. * The internal mesh used by the post-process
  160844. */
  160845. mesh: Mesh;
  160846. /**
  160847. * @hidden
  160848. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  160849. */
  160850. get useDiffuseColor(): boolean;
  160851. set useDiffuseColor(useDiffuseColor: boolean);
  160852. /**
  160853. * Array containing the excluded meshes not rendered in the internal pass
  160854. */
  160855. excludedMeshes: AbstractMesh[];
  160856. /**
  160857. * Controls the overall intensity of the post-process
  160858. */
  160859. exposure: number;
  160860. /**
  160861. * Dissipates each sample's contribution in range [0, 1]
  160862. */
  160863. decay: number;
  160864. /**
  160865. * Controls the overall intensity of each sample
  160866. */
  160867. weight: number;
  160868. /**
  160869. * Controls the density of each sample
  160870. */
  160871. density: number;
  160872. /**
  160873. * @constructor
  160874. * @param name The post-process name
  160875. * @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)
  160876. * @param camera The camera that the post-process will be attached to
  160877. * @param mesh The mesh used to create the light scattering
  160878. * @param samples The post-process quality, default 100
  160879. * @param samplingModeThe post-process filtering mode
  160880. * @param engine The babylon engine
  160881. * @param reusable If the post-process is reusable
  160882. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  160883. */
  160884. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  160885. /**
  160886. * Returns the string "VolumetricLightScatteringPostProcess"
  160887. * @returns "VolumetricLightScatteringPostProcess"
  160888. */
  160889. getClassName(): string;
  160890. private _isReady;
  160891. /**
  160892. * Sets the new light position for light scattering effect
  160893. * @param position The new custom light position
  160894. */
  160895. setCustomMeshPosition(position: Vector3): void;
  160896. /**
  160897. * Returns the light position for light scattering effect
  160898. * @return Vector3 The custom light position
  160899. */
  160900. getCustomMeshPosition(): Vector3;
  160901. /**
  160902. * Disposes the internal assets and detaches the post-process from the camera
  160903. */
  160904. dispose(camera: Camera): void;
  160905. /**
  160906. * Returns the render target texture used by the post-process
  160907. * @return the render target texture used by the post-process
  160908. */
  160909. getPass(): RenderTargetTexture;
  160910. private _meshExcluded;
  160911. private _createPass;
  160912. private _updateMeshScreenCoordinates;
  160913. /**
  160914. * Creates a default mesh for the Volumeric Light Scattering post-process
  160915. * @param name The mesh name
  160916. * @param scene The scene where to create the mesh
  160917. * @return the default mesh
  160918. */
  160919. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  160920. }
  160921. }
  160922. declare module BABYLON {
  160923. /** @hidden */
  160924. export var screenSpaceCurvaturePixelShader: {
  160925. name: string;
  160926. shader: string;
  160927. };
  160928. }
  160929. declare module BABYLON {
  160930. /**
  160931. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  160932. */
  160933. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  160934. /**
  160935. * Defines how much ridge the curvature effect displays.
  160936. */
  160937. ridge: number;
  160938. /**
  160939. * Defines how much valley the curvature effect displays.
  160940. */
  160941. valley: number;
  160942. private _geometryBufferRenderer;
  160943. /**
  160944. * Gets a string identifying the name of the class
  160945. * @returns "ScreenSpaceCurvaturePostProcess" string
  160946. */
  160947. getClassName(): string;
  160948. /**
  160949. * Creates a new instance ScreenSpaceCurvaturePostProcess
  160950. * @param name The name of the effect.
  160951. * @param scene The scene containing the objects to blur according to their velocity.
  160952. * @param options The required width/height ratio to downsize to before computing the render pass.
  160953. * @param camera The camera to apply the render pass to.
  160954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160955. * @param engine The engine which the post process will be applied. (default: current engine)
  160956. * @param reusable If the post process can be reused on the same frame. (default: false)
  160957. * @param textureType Type of textures used when performing the post process. (default: 0)
  160958. * @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)
  160959. */
  160960. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  160961. /**
  160962. * Support test.
  160963. */
  160964. static get IsSupported(): boolean;
  160965. /** @hidden */
  160966. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  160967. }
  160968. }
  160969. declare module BABYLON {
  160970. interface Scene {
  160971. /** @hidden (Backing field) */
  160972. _boundingBoxRenderer: BoundingBoxRenderer;
  160973. /** @hidden (Backing field) */
  160974. _forceShowBoundingBoxes: boolean;
  160975. /**
  160976. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  160977. */
  160978. forceShowBoundingBoxes: boolean;
  160979. /**
  160980. * Gets the bounding box renderer associated with the scene
  160981. * @returns a BoundingBoxRenderer
  160982. */
  160983. getBoundingBoxRenderer(): BoundingBoxRenderer;
  160984. }
  160985. interface AbstractMesh {
  160986. /** @hidden (Backing field) */
  160987. _showBoundingBox: boolean;
  160988. /**
  160989. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  160990. */
  160991. showBoundingBox: boolean;
  160992. }
  160993. /**
  160994. * Component responsible of rendering the bounding box of the meshes in a scene.
  160995. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  160996. */
  160997. export class BoundingBoxRenderer implements ISceneComponent {
  160998. /**
  160999. * The component name helpfull to identify the component in the list of scene components.
  161000. */
  161001. readonly name: string;
  161002. /**
  161003. * The scene the component belongs to.
  161004. */
  161005. scene: Scene;
  161006. /**
  161007. * Color of the bounding box lines placed in front of an object
  161008. */
  161009. frontColor: Color3;
  161010. /**
  161011. * Color of the bounding box lines placed behind an object
  161012. */
  161013. backColor: Color3;
  161014. /**
  161015. * Defines if the renderer should show the back lines or not
  161016. */
  161017. showBackLines: boolean;
  161018. /**
  161019. * Observable raised before rendering a bounding box
  161020. */
  161021. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  161022. /**
  161023. * Observable raised after rendering a bounding box
  161024. */
  161025. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  161026. /**
  161027. * Observable raised after resources are created
  161028. */
  161029. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  161030. /**
  161031. * When false, no bounding boxes will be rendered
  161032. */
  161033. enabled: boolean;
  161034. /**
  161035. * @hidden
  161036. */
  161037. renderList: SmartArray<BoundingBox>;
  161038. private _colorShader;
  161039. private _vertexBuffers;
  161040. private _indexBuffer;
  161041. private _fillIndexBuffer;
  161042. private _fillIndexData;
  161043. /**
  161044. * Instantiates a new bounding box renderer in a scene.
  161045. * @param scene the scene the renderer renders in
  161046. */
  161047. constructor(scene: Scene);
  161048. /**
  161049. * Registers the component in a given scene
  161050. */
  161051. register(): void;
  161052. private _evaluateSubMesh;
  161053. private _preActiveMesh;
  161054. private _prepareResources;
  161055. private _createIndexBuffer;
  161056. /**
  161057. * Rebuilds the elements related to this component in case of
  161058. * context lost for instance.
  161059. */
  161060. rebuild(): void;
  161061. /**
  161062. * @hidden
  161063. */
  161064. reset(): void;
  161065. /**
  161066. * Render the bounding boxes of a specific rendering group
  161067. * @param renderingGroupId defines the rendering group to render
  161068. */
  161069. render(renderingGroupId: number): void;
  161070. /**
  161071. * In case of occlusion queries, we can render the occlusion bounding box through this method
  161072. * @param mesh Define the mesh to render the occlusion bounding box for
  161073. */
  161074. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  161075. /**
  161076. * Dispose and release the resources attached to this renderer.
  161077. */
  161078. dispose(): void;
  161079. }
  161080. }
  161081. declare module BABYLON {
  161082. interface Scene {
  161083. /** @hidden (Backing field) */
  161084. _depthRenderer: {
  161085. [id: string]: DepthRenderer;
  161086. };
  161087. /**
  161088. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  161089. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  161090. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  161091. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  161092. * @returns the created depth renderer
  161093. */
  161094. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  161095. /**
  161096. * Disables a depth renderer for a given camera
  161097. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  161098. */
  161099. disableDepthRenderer(camera?: Nullable<Camera>): void;
  161100. }
  161101. /**
  161102. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  161103. * in several rendering techniques.
  161104. */
  161105. export class DepthRendererSceneComponent implements ISceneComponent {
  161106. /**
  161107. * The component name helpfull to identify the component in the list of scene components.
  161108. */
  161109. readonly name: string;
  161110. /**
  161111. * The scene the component belongs to.
  161112. */
  161113. scene: Scene;
  161114. /**
  161115. * Creates a new instance of the component for the given scene
  161116. * @param scene Defines the scene to register the component in
  161117. */
  161118. constructor(scene: Scene);
  161119. /**
  161120. * Registers the component in a given scene
  161121. */
  161122. register(): void;
  161123. /**
  161124. * Rebuilds the elements related to this component in case of
  161125. * context lost for instance.
  161126. */
  161127. rebuild(): void;
  161128. /**
  161129. * Disposes the component and the associated ressources
  161130. */
  161131. dispose(): void;
  161132. private _gatherRenderTargets;
  161133. private _gatherActiveCameraRenderTargets;
  161134. }
  161135. }
  161136. declare module BABYLON {
  161137. interface AbstractScene {
  161138. /** @hidden (Backing field) */
  161139. _prePassRenderer: Nullable<PrePassRenderer>;
  161140. /**
  161141. * Gets or Sets the current prepass renderer associated to the scene.
  161142. */
  161143. prePassRenderer: Nullable<PrePassRenderer>;
  161144. /**
  161145. * Enables the prepass and associates it with the scene
  161146. * @returns the PrePassRenderer
  161147. */
  161148. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  161149. /**
  161150. * Disables the prepass associated with the scene
  161151. */
  161152. disablePrePassRenderer(): void;
  161153. }
  161154. /**
  161155. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  161156. * in several rendering techniques.
  161157. */
  161158. export class PrePassRendererSceneComponent implements ISceneComponent {
  161159. /**
  161160. * The component name helpful to identify the component in the list of scene components.
  161161. */
  161162. readonly name: string;
  161163. /**
  161164. * The scene the component belongs to.
  161165. */
  161166. scene: Scene;
  161167. /**
  161168. * Creates a new instance of the component for the given scene
  161169. * @param scene Defines the scene to register the component in
  161170. */
  161171. constructor(scene: Scene);
  161172. /**
  161173. * Registers the component in a given scene
  161174. */
  161175. register(): void;
  161176. private _beforeCameraDraw;
  161177. private _afterCameraDraw;
  161178. private _beforeClearStage;
  161179. private _beforeRenderingMeshStage;
  161180. private _afterRenderingMeshStage;
  161181. /**
  161182. * Rebuilds the elements related to this component in case of
  161183. * context lost for instance.
  161184. */
  161185. rebuild(): void;
  161186. /**
  161187. * Disposes the component and the associated ressources
  161188. */
  161189. dispose(): void;
  161190. }
  161191. }
  161192. declare module BABYLON {
  161193. /** @hidden */
  161194. export var fibonacci: {
  161195. name: string;
  161196. shader: string;
  161197. };
  161198. }
  161199. declare module BABYLON {
  161200. /** @hidden */
  161201. export var diffusionProfile: {
  161202. name: string;
  161203. shader: string;
  161204. };
  161205. }
  161206. declare module BABYLON {
  161207. /** @hidden */
  161208. export var subSurfaceScatteringPixelShader: {
  161209. name: string;
  161210. shader: string;
  161211. };
  161212. }
  161213. declare module BABYLON {
  161214. /**
  161215. * Sub surface scattering post process
  161216. */
  161217. export class SubSurfaceScatteringPostProcess extends PostProcess {
  161218. /**
  161219. * Gets a string identifying the name of the class
  161220. * @returns "SubSurfaceScatteringPostProcess" string
  161221. */
  161222. getClassName(): string;
  161223. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  161224. }
  161225. }
  161226. declare module BABYLON {
  161227. /**
  161228. * Contains all parameters needed for the prepass to perform
  161229. * screen space subsurface scattering
  161230. */
  161231. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  161232. /** @hidden */
  161233. static _SceneComponentInitialization: (scene: Scene) => void;
  161234. private _ssDiffusionS;
  161235. private _ssFilterRadii;
  161236. private _ssDiffusionD;
  161237. /**
  161238. * Post process to attach for screen space subsurface scattering
  161239. */
  161240. postProcess: SubSurfaceScatteringPostProcess;
  161241. /**
  161242. * Diffusion profile color for subsurface scattering
  161243. */
  161244. get ssDiffusionS(): number[];
  161245. /**
  161246. * Diffusion profile max color channel value for subsurface scattering
  161247. */
  161248. get ssDiffusionD(): number[];
  161249. /**
  161250. * Diffusion profile filter radius for subsurface scattering
  161251. */
  161252. get ssFilterRadii(): number[];
  161253. /**
  161254. * Is subsurface enabled
  161255. */
  161256. enabled: boolean;
  161257. /**
  161258. * Name of the configuration
  161259. */
  161260. name: string;
  161261. /**
  161262. * Diffusion profile colors for subsurface scattering
  161263. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  161264. * See ...
  161265. * Note that you can only store up to 5 of them
  161266. */
  161267. ssDiffusionProfileColors: Color3[];
  161268. /**
  161269. * Defines the ratio real world => scene units.
  161270. * Used for subsurface scattering
  161271. */
  161272. metersPerUnit: number;
  161273. /**
  161274. * Textures that should be present in the MRT for this effect to work
  161275. */
  161276. readonly texturesRequired: number[];
  161277. private _scene;
  161278. /**
  161279. * Builds a subsurface configuration object
  161280. * @param scene The scene
  161281. */
  161282. constructor(scene: Scene);
  161283. /**
  161284. * Adds a new diffusion profile.
  161285. * Useful for more realistic subsurface scattering on diverse materials.
  161286. * @param color The color of the diffusion profile. Should be the average color of the material.
  161287. * @return The index of the diffusion profile for the material subsurface configuration
  161288. */
  161289. addDiffusionProfile(color: Color3): number;
  161290. /**
  161291. * Creates the sss post process
  161292. * @return The created post process
  161293. */
  161294. createPostProcess(): SubSurfaceScatteringPostProcess;
  161295. /**
  161296. * Deletes all diffusion profiles.
  161297. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  161298. */
  161299. clearAllDiffusionProfiles(): void;
  161300. /**
  161301. * Disposes this object
  161302. */
  161303. dispose(): void;
  161304. /**
  161305. * @hidden
  161306. * https://zero-radiance.github.io/post/sampling-diffusion/
  161307. *
  161308. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  161309. * ------------------------------------------------------------------------------------
  161310. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  161311. * PDF[r, phi, s] = r * R[r, phi, s]
  161312. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  161313. * ------------------------------------------------------------------------------------
  161314. * We importance sample the color channel with the widest scattering distance.
  161315. */
  161316. getDiffusionProfileParameters(color: Color3): number;
  161317. /**
  161318. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  161319. * 'u' is the random number (the value of the CDF): [0, 1).
  161320. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  161321. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  161322. */
  161323. private _sampleBurleyDiffusionProfile;
  161324. }
  161325. }
  161326. declare module BABYLON {
  161327. interface AbstractScene {
  161328. /** @hidden (Backing field) */
  161329. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  161330. /**
  161331. * Gets or Sets the current prepass renderer associated to the scene.
  161332. */
  161333. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  161334. /**
  161335. * Enables the subsurface effect for prepass
  161336. * @returns the SubSurfaceConfiguration
  161337. */
  161338. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  161339. /**
  161340. * Disables the subsurface effect for prepass
  161341. */
  161342. disableSubSurfaceForPrePass(): void;
  161343. }
  161344. /**
  161345. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  161346. * in several rendering techniques.
  161347. */
  161348. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  161349. /**
  161350. * The component name helpful to identify the component in the list of scene components.
  161351. */
  161352. readonly name: string;
  161353. /**
  161354. * The scene the component belongs to.
  161355. */
  161356. scene: Scene;
  161357. /**
  161358. * Creates a new instance of the component for the given scene
  161359. * @param scene Defines the scene to register the component in
  161360. */
  161361. constructor(scene: Scene);
  161362. /**
  161363. * Registers the component in a given scene
  161364. */
  161365. register(): void;
  161366. /**
  161367. * Serializes the component data to the specified json object
  161368. * @param serializationObject The object to serialize to
  161369. */
  161370. serialize(serializationObject: any): void;
  161371. /**
  161372. * Adds all the elements from the container to the scene
  161373. * @param container the container holding the elements
  161374. */
  161375. addFromContainer(container: AbstractScene): void;
  161376. /**
  161377. * Removes all the elements in the container from the scene
  161378. * @param container contains the elements to remove
  161379. * @param dispose if the removed element should be disposed (default: false)
  161380. */
  161381. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  161382. /**
  161383. * Rebuilds the elements related to this component in case of
  161384. * context lost for instance.
  161385. */
  161386. rebuild(): void;
  161387. /**
  161388. * Disposes the component and the associated ressources
  161389. */
  161390. dispose(): void;
  161391. }
  161392. }
  161393. declare module BABYLON {
  161394. /** @hidden */
  161395. export var outlinePixelShader: {
  161396. name: string;
  161397. shader: string;
  161398. };
  161399. }
  161400. declare module BABYLON {
  161401. /** @hidden */
  161402. export var outlineVertexShader: {
  161403. name: string;
  161404. shader: string;
  161405. };
  161406. }
  161407. declare module BABYLON {
  161408. interface Scene {
  161409. /** @hidden */
  161410. _outlineRenderer: OutlineRenderer;
  161411. /**
  161412. * Gets the outline renderer associated with the scene
  161413. * @returns a OutlineRenderer
  161414. */
  161415. getOutlineRenderer(): OutlineRenderer;
  161416. }
  161417. interface AbstractMesh {
  161418. /** @hidden (Backing field) */
  161419. _renderOutline: boolean;
  161420. /**
  161421. * Gets or sets a boolean indicating if the outline must be rendered as well
  161422. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  161423. */
  161424. renderOutline: boolean;
  161425. /** @hidden (Backing field) */
  161426. _renderOverlay: boolean;
  161427. /**
  161428. * Gets or sets a boolean indicating if the overlay must be rendered as well
  161429. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  161430. */
  161431. renderOverlay: boolean;
  161432. }
  161433. /**
  161434. * This class is responsible to draw bothe outline/overlay of meshes.
  161435. * It should not be used directly but through the available method on mesh.
  161436. */
  161437. export class OutlineRenderer implements ISceneComponent {
  161438. /**
  161439. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  161440. */
  161441. private static _StencilReference;
  161442. /**
  161443. * The name of the component. Each component must have a unique name.
  161444. */
  161445. name: string;
  161446. /**
  161447. * The scene the component belongs to.
  161448. */
  161449. scene: Scene;
  161450. /**
  161451. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  161452. */
  161453. zOffset: number;
  161454. private _engine;
  161455. private _effect;
  161456. private _cachedDefines;
  161457. private _savedDepthWrite;
  161458. /**
  161459. * Instantiates a new outline renderer. (There could be only one per scene).
  161460. * @param scene Defines the scene it belongs to
  161461. */
  161462. constructor(scene: Scene);
  161463. /**
  161464. * Register the component to one instance of a scene.
  161465. */
  161466. register(): void;
  161467. /**
  161468. * Rebuilds the elements related to this component in case of
  161469. * context lost for instance.
  161470. */
  161471. rebuild(): void;
  161472. /**
  161473. * Disposes the component and the associated ressources.
  161474. */
  161475. dispose(): void;
  161476. /**
  161477. * Renders the outline in the canvas.
  161478. * @param subMesh Defines the sumesh to render
  161479. * @param batch Defines the batch of meshes in case of instances
  161480. * @param useOverlay Defines if the rendering is for the overlay or the outline
  161481. */
  161482. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  161483. /**
  161484. * Returns whether or not the outline renderer is ready for a given submesh.
  161485. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  161486. * @param subMesh Defines the submesh to check readyness for
  161487. * @param useInstances Defines wheter wee are trying to render instances or not
  161488. * @returns true if ready otherwise false
  161489. */
  161490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  161491. private _beforeRenderingMesh;
  161492. private _afterRenderingMesh;
  161493. }
  161494. }
  161495. declare module BABYLON {
  161496. /**
  161497. * Defines the basic options interface of a Sprite Frame Source Size.
  161498. */
  161499. export interface ISpriteJSONSpriteSourceSize {
  161500. /**
  161501. * number of the original width of the Frame
  161502. */
  161503. w: number;
  161504. /**
  161505. * number of the original height of the Frame
  161506. */
  161507. h: number;
  161508. }
  161509. /**
  161510. * Defines the basic options interface of a Sprite Frame Data.
  161511. */
  161512. export interface ISpriteJSONSpriteFrameData {
  161513. /**
  161514. * number of the x offset of the Frame
  161515. */
  161516. x: number;
  161517. /**
  161518. * number of the y offset of the Frame
  161519. */
  161520. y: number;
  161521. /**
  161522. * number of the width of the Frame
  161523. */
  161524. w: number;
  161525. /**
  161526. * number of the height of the Frame
  161527. */
  161528. h: number;
  161529. }
  161530. /**
  161531. * Defines the basic options interface of a JSON Sprite.
  161532. */
  161533. export interface ISpriteJSONSprite {
  161534. /**
  161535. * string name of the Frame
  161536. */
  161537. filename: string;
  161538. /**
  161539. * ISpriteJSONSpriteFrame basic object of the frame data
  161540. */
  161541. frame: ISpriteJSONSpriteFrameData;
  161542. /**
  161543. * boolean to flag is the frame was rotated.
  161544. */
  161545. rotated: boolean;
  161546. /**
  161547. * boolean to flag is the frame was trimmed.
  161548. */
  161549. trimmed: boolean;
  161550. /**
  161551. * ISpriteJSONSpriteFrame basic object of the source data
  161552. */
  161553. spriteSourceSize: ISpriteJSONSpriteFrameData;
  161554. /**
  161555. * ISpriteJSONSpriteFrame basic object of the source data
  161556. */
  161557. sourceSize: ISpriteJSONSpriteSourceSize;
  161558. }
  161559. /**
  161560. * Defines the basic options interface of a JSON atlas.
  161561. */
  161562. export interface ISpriteJSONAtlas {
  161563. /**
  161564. * Array of objects that contain the frame data.
  161565. */
  161566. frames: Array<ISpriteJSONSprite>;
  161567. /**
  161568. * object basic object containing the sprite meta data.
  161569. */
  161570. meta?: object;
  161571. }
  161572. }
  161573. declare module BABYLON {
  161574. /** @hidden */
  161575. export var spriteMapPixelShader: {
  161576. name: string;
  161577. shader: string;
  161578. };
  161579. }
  161580. declare module BABYLON {
  161581. /** @hidden */
  161582. export var spriteMapVertexShader: {
  161583. name: string;
  161584. shader: string;
  161585. };
  161586. }
  161587. declare module BABYLON {
  161588. /**
  161589. * Defines the basic options interface of a SpriteMap
  161590. */
  161591. export interface ISpriteMapOptions {
  161592. /**
  161593. * Vector2 of the number of cells in the grid.
  161594. */
  161595. stageSize?: Vector2;
  161596. /**
  161597. * Vector2 of the size of the output plane in World Units.
  161598. */
  161599. outputSize?: Vector2;
  161600. /**
  161601. * Vector3 of the position of the output plane in World Units.
  161602. */
  161603. outputPosition?: Vector3;
  161604. /**
  161605. * Vector3 of the rotation of the output plane.
  161606. */
  161607. outputRotation?: Vector3;
  161608. /**
  161609. * number of layers that the system will reserve in resources.
  161610. */
  161611. layerCount?: number;
  161612. /**
  161613. * number of max animation frames a single cell will reserve in resources.
  161614. */
  161615. maxAnimationFrames?: number;
  161616. /**
  161617. * number cell index of the base tile when the system compiles.
  161618. */
  161619. baseTile?: number;
  161620. /**
  161621. * boolean flip the sprite after its been repositioned by the framing data.
  161622. */
  161623. flipU?: boolean;
  161624. /**
  161625. * Vector3 scalar of the global RGB values of the SpriteMap.
  161626. */
  161627. colorMultiply?: Vector3;
  161628. }
  161629. /**
  161630. * Defines the IDisposable interface in order to be cleanable from resources.
  161631. */
  161632. export interface ISpriteMap extends IDisposable {
  161633. /**
  161634. * String name of the SpriteMap.
  161635. */
  161636. name: string;
  161637. /**
  161638. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  161639. */
  161640. atlasJSON: ISpriteJSONAtlas;
  161641. /**
  161642. * Texture of the SpriteMap.
  161643. */
  161644. spriteSheet: Texture;
  161645. /**
  161646. * The parameters to initialize the SpriteMap with.
  161647. */
  161648. options: ISpriteMapOptions;
  161649. }
  161650. /**
  161651. * Class used to manage a grid restricted sprite deployment on an Output plane.
  161652. */
  161653. export class SpriteMap implements ISpriteMap {
  161654. /** The Name of the spriteMap */
  161655. name: string;
  161656. /** The JSON file with the frame and meta data */
  161657. atlasJSON: ISpriteJSONAtlas;
  161658. /** The systems Sprite Sheet Texture */
  161659. spriteSheet: Texture;
  161660. /** Arguments passed with the Constructor */
  161661. options: ISpriteMapOptions;
  161662. /** Public Sprite Storage array, parsed from atlasJSON */
  161663. sprites: Array<ISpriteJSONSprite>;
  161664. /** Returns the Number of Sprites in the System */
  161665. get spriteCount(): number;
  161666. /** Returns the Position of Output Plane*/
  161667. get position(): Vector3;
  161668. /** Returns the Position of Output Plane*/
  161669. set position(v: Vector3);
  161670. /** Returns the Rotation of Output Plane*/
  161671. get rotation(): Vector3;
  161672. /** Returns the Rotation of Output Plane*/
  161673. set rotation(v: Vector3);
  161674. /** Sets the AnimationMap*/
  161675. get animationMap(): RawTexture;
  161676. /** Sets the AnimationMap*/
  161677. set animationMap(v: RawTexture);
  161678. /** Scene that the SpriteMap was created in */
  161679. private _scene;
  161680. /** Texture Buffer of Float32 that holds tile frame data*/
  161681. private _frameMap;
  161682. /** Texture Buffers of Float32 that holds tileMap data*/
  161683. private _tileMaps;
  161684. /** Texture Buffer of Float32 that holds Animation Data*/
  161685. private _animationMap;
  161686. /** Custom ShaderMaterial Central to the System*/
  161687. private _material;
  161688. /** Custom ShaderMaterial Central to the System*/
  161689. private _output;
  161690. /** Systems Time Ticker*/
  161691. private _time;
  161692. /**
  161693. * Creates a new SpriteMap
  161694. * @param name defines the SpriteMaps Name
  161695. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  161696. * @param spriteSheet is the Texture that the Sprites are on.
  161697. * @param options a basic deployment configuration
  161698. * @param scene The Scene that the map is deployed on
  161699. */
  161700. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  161701. /**
  161702. * Returns tileID location
  161703. * @returns Vector2 the cell position ID
  161704. */
  161705. getTileID(): Vector2;
  161706. /**
  161707. * Gets the UV location of the mouse over the SpriteMap.
  161708. * @returns Vector2 the UV position of the mouse interaction
  161709. */
  161710. getMousePosition(): Vector2;
  161711. /**
  161712. * Creates the "frame" texture Buffer
  161713. * -------------------------------------
  161714. * Structure of frames
  161715. * "filename": "Falling-Water-2.png",
  161716. * "frame": {"x":69,"y":103,"w":24,"h":32},
  161717. * "rotated": true,
  161718. * "trimmed": true,
  161719. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  161720. * "sourceSize": {"w":32,"h":32}
  161721. * @returns RawTexture of the frameMap
  161722. */
  161723. private _createFrameBuffer;
  161724. /**
  161725. * Creates the tileMap texture Buffer
  161726. * @param buffer normally and array of numbers, or a false to generate from scratch
  161727. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  161728. * @returns RawTexture of the tileMap
  161729. */
  161730. private _createTileBuffer;
  161731. /**
  161732. * Modifies the data of the tileMaps
  161733. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  161734. * @param pos is the iVector2 Coordinates of the Tile
  161735. * @param tile The SpriteIndex of the new Tile
  161736. */
  161737. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  161738. /**
  161739. * Creates the animationMap texture Buffer
  161740. * @param buffer normally and array of numbers, or a false to generate from scratch
  161741. * @returns RawTexture of the animationMap
  161742. */
  161743. private _createTileAnimationBuffer;
  161744. /**
  161745. * Modifies the data of the animationMap
  161746. * @param cellID is the Index of the Sprite
  161747. * @param _frame is the target Animation frame
  161748. * @param toCell is the Target Index of the next frame of the animation
  161749. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  161750. * @param speed is a global scalar of the time variable on the map.
  161751. */
  161752. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  161753. /**
  161754. * Exports the .tilemaps file
  161755. */
  161756. saveTileMaps(): void;
  161757. /**
  161758. * Imports the .tilemaps file
  161759. * @param url of the .tilemaps file
  161760. */
  161761. loadTileMaps(url: string): void;
  161762. /**
  161763. * Release associated resources
  161764. */
  161765. dispose(): void;
  161766. }
  161767. }
  161768. declare module BABYLON {
  161769. /**
  161770. * Class used to manage multiple sprites of different sizes on the same spritesheet
  161771. * @see https://doc.babylonjs.com/babylon101/sprites
  161772. */
  161773. export class SpritePackedManager extends SpriteManager {
  161774. /** defines the packed manager's name */
  161775. name: string;
  161776. /**
  161777. * Creates a new sprite manager from a packed sprite sheet
  161778. * @param name defines the manager's name
  161779. * @param imgUrl defines the sprite sheet url
  161780. * @param capacity defines the maximum allowed number of sprites
  161781. * @param scene defines the hosting scene
  161782. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  161783. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  161784. * @param samplingMode defines the smapling mode to use with spritesheet
  161785. * @param fromPacked set to true; do not alter
  161786. */
  161787. constructor(
  161788. /** defines the packed manager's name */
  161789. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  161790. }
  161791. }
  161792. declare module BABYLON {
  161793. /**
  161794. * Defines the list of states available for a task inside a AssetsManager
  161795. */
  161796. export enum AssetTaskState {
  161797. /**
  161798. * Initialization
  161799. */
  161800. INIT = 0,
  161801. /**
  161802. * Running
  161803. */
  161804. RUNNING = 1,
  161805. /**
  161806. * Done
  161807. */
  161808. DONE = 2,
  161809. /**
  161810. * Error
  161811. */
  161812. ERROR = 3
  161813. }
  161814. /**
  161815. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  161816. */
  161817. export abstract class AbstractAssetTask {
  161818. /**
  161819. * Task name
  161820. */ name: string;
  161821. /**
  161822. * Callback called when the task is successful
  161823. */
  161824. onSuccess: (task: any) => void;
  161825. /**
  161826. * Callback called when the task is not successful
  161827. */
  161828. onError: (task: any, message?: string, exception?: any) => void;
  161829. /**
  161830. * Creates a new AssetsManager
  161831. * @param name defines the name of the task
  161832. */
  161833. constructor(
  161834. /**
  161835. * Task name
  161836. */ name: string);
  161837. private _isCompleted;
  161838. private _taskState;
  161839. private _errorObject;
  161840. /**
  161841. * Get if the task is completed
  161842. */
  161843. get isCompleted(): boolean;
  161844. /**
  161845. * Gets the current state of the task
  161846. */
  161847. get taskState(): AssetTaskState;
  161848. /**
  161849. * Gets the current error object (if task is in error)
  161850. */
  161851. get errorObject(): {
  161852. message?: string;
  161853. exception?: any;
  161854. };
  161855. /**
  161856. * Internal only
  161857. * @hidden
  161858. */
  161859. _setErrorObject(message?: string, exception?: any): void;
  161860. /**
  161861. * Execute the current task
  161862. * @param scene defines the scene where you want your assets to be loaded
  161863. * @param onSuccess is a callback called when the task is successfully executed
  161864. * @param onError is a callback called if an error occurs
  161865. */
  161866. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161867. /**
  161868. * Execute the current task
  161869. * @param scene defines the scene where you want your assets to be loaded
  161870. * @param onSuccess is a callback called when the task is successfully executed
  161871. * @param onError is a callback called if an error occurs
  161872. */
  161873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161874. /**
  161875. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  161876. * This can be used with failed tasks that have the reason for failure fixed.
  161877. */
  161878. reset(): void;
  161879. private onErrorCallback;
  161880. private onDoneCallback;
  161881. }
  161882. /**
  161883. * Define the interface used by progress events raised during assets loading
  161884. */
  161885. export interface IAssetsProgressEvent {
  161886. /**
  161887. * Defines the number of remaining tasks to process
  161888. */
  161889. remainingCount: number;
  161890. /**
  161891. * Defines the total number of tasks
  161892. */
  161893. totalCount: number;
  161894. /**
  161895. * Defines the task that was just processed
  161896. */
  161897. task: AbstractAssetTask;
  161898. }
  161899. /**
  161900. * Class used to share progress information about assets loading
  161901. */
  161902. export class AssetsProgressEvent implements IAssetsProgressEvent {
  161903. /**
  161904. * Defines the number of remaining tasks to process
  161905. */
  161906. remainingCount: number;
  161907. /**
  161908. * Defines the total number of tasks
  161909. */
  161910. totalCount: number;
  161911. /**
  161912. * Defines the task that was just processed
  161913. */
  161914. task: AbstractAssetTask;
  161915. /**
  161916. * Creates a AssetsProgressEvent
  161917. * @param remainingCount defines the number of remaining tasks to process
  161918. * @param totalCount defines the total number of tasks
  161919. * @param task defines the task that was just processed
  161920. */
  161921. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  161922. }
  161923. /**
  161924. * Define a task used by AssetsManager to load assets into a container
  161925. */
  161926. export class ContainerAssetTask extends AbstractAssetTask {
  161927. /**
  161928. * Defines the name of the task
  161929. */
  161930. name: string;
  161931. /**
  161932. * Defines the list of mesh's names you want to load
  161933. */
  161934. meshesNames: any;
  161935. /**
  161936. * Defines the root url to use as a base to load your meshes and associated resources
  161937. */
  161938. rootUrl: string;
  161939. /**
  161940. * Defines the filename or File of the scene to load from
  161941. */
  161942. sceneFilename: string | File;
  161943. /**
  161944. * Get the loaded asset container
  161945. */
  161946. loadedContainer: AssetContainer;
  161947. /**
  161948. * Gets the list of loaded meshes
  161949. */
  161950. loadedMeshes: Array<AbstractMesh>;
  161951. /**
  161952. * Gets the list of loaded particle systems
  161953. */
  161954. loadedParticleSystems: Array<IParticleSystem>;
  161955. /**
  161956. * Gets the list of loaded skeletons
  161957. */
  161958. loadedSkeletons: Array<Skeleton>;
  161959. /**
  161960. * Gets the list of loaded animation groups
  161961. */
  161962. loadedAnimationGroups: Array<AnimationGroup>;
  161963. /**
  161964. * Callback called when the task is successful
  161965. */
  161966. onSuccess: (task: ContainerAssetTask) => void;
  161967. /**
  161968. * Callback called when the task is successful
  161969. */
  161970. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  161971. /**
  161972. * Creates a new ContainerAssetTask
  161973. * @param name defines the name of the task
  161974. * @param meshesNames defines the list of mesh's names you want to load
  161975. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  161976. * @param sceneFilename defines the filename or File of the scene to load from
  161977. */
  161978. constructor(
  161979. /**
  161980. * Defines the name of the task
  161981. */
  161982. name: string,
  161983. /**
  161984. * Defines the list of mesh's names you want to load
  161985. */
  161986. meshesNames: any,
  161987. /**
  161988. * Defines the root url to use as a base to load your meshes and associated resources
  161989. */
  161990. rootUrl: string,
  161991. /**
  161992. * Defines the filename or File of the scene to load from
  161993. */
  161994. sceneFilename: string | File);
  161995. /**
  161996. * Execute the current task
  161997. * @param scene defines the scene where you want your assets to be loaded
  161998. * @param onSuccess is a callback called when the task is successfully executed
  161999. * @param onError is a callback called if an error occurs
  162000. */
  162001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162002. }
  162003. /**
  162004. * Define a task used by AssetsManager to load meshes
  162005. */
  162006. export class MeshAssetTask extends AbstractAssetTask {
  162007. /**
  162008. * Defines the name of the task
  162009. */
  162010. name: string;
  162011. /**
  162012. * Defines the list of mesh's names you want to load
  162013. */
  162014. meshesNames: any;
  162015. /**
  162016. * Defines the root url to use as a base to load your meshes and associated resources
  162017. */
  162018. rootUrl: string;
  162019. /**
  162020. * Defines the filename or File of the scene to load from
  162021. */
  162022. sceneFilename: string | File;
  162023. /**
  162024. * Gets the list of loaded meshes
  162025. */
  162026. loadedMeshes: Array<AbstractMesh>;
  162027. /**
  162028. * Gets the list of loaded particle systems
  162029. */
  162030. loadedParticleSystems: Array<IParticleSystem>;
  162031. /**
  162032. * Gets the list of loaded skeletons
  162033. */
  162034. loadedSkeletons: Array<Skeleton>;
  162035. /**
  162036. * Gets the list of loaded animation groups
  162037. */
  162038. loadedAnimationGroups: Array<AnimationGroup>;
  162039. /**
  162040. * Callback called when the task is successful
  162041. */
  162042. onSuccess: (task: MeshAssetTask) => void;
  162043. /**
  162044. * Callback called when the task is successful
  162045. */
  162046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  162047. /**
  162048. * Creates a new MeshAssetTask
  162049. * @param name defines the name of the task
  162050. * @param meshesNames defines the list of mesh's names you want to load
  162051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  162052. * @param sceneFilename defines the filename or File of the scene to load from
  162053. */
  162054. constructor(
  162055. /**
  162056. * Defines the name of the task
  162057. */
  162058. name: string,
  162059. /**
  162060. * Defines the list of mesh's names you want to load
  162061. */
  162062. meshesNames: any,
  162063. /**
  162064. * Defines the root url to use as a base to load your meshes and associated resources
  162065. */
  162066. rootUrl: string,
  162067. /**
  162068. * Defines the filename or File of the scene to load from
  162069. */
  162070. sceneFilename: string | File);
  162071. /**
  162072. * Execute the current task
  162073. * @param scene defines the scene where you want your assets to be loaded
  162074. * @param onSuccess is a callback called when the task is successfully executed
  162075. * @param onError is a callback called if an error occurs
  162076. */
  162077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162078. }
  162079. /**
  162080. * Define a task used by AssetsManager to load text content
  162081. */
  162082. export class TextFileAssetTask extends AbstractAssetTask {
  162083. /**
  162084. * Defines the name of the task
  162085. */
  162086. name: string;
  162087. /**
  162088. * Defines the location of the file to load
  162089. */
  162090. url: string;
  162091. /**
  162092. * Gets the loaded text string
  162093. */
  162094. text: string;
  162095. /**
  162096. * Callback called when the task is successful
  162097. */
  162098. onSuccess: (task: TextFileAssetTask) => void;
  162099. /**
  162100. * Callback called when the task is successful
  162101. */
  162102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  162103. /**
  162104. * Creates a new TextFileAssetTask object
  162105. * @param name defines the name of the task
  162106. * @param url defines the location of the file to load
  162107. */
  162108. constructor(
  162109. /**
  162110. * Defines the name of the task
  162111. */
  162112. name: string,
  162113. /**
  162114. * Defines the location of the file to load
  162115. */
  162116. url: string);
  162117. /**
  162118. * Execute the current task
  162119. * @param scene defines the scene where you want your assets to be loaded
  162120. * @param onSuccess is a callback called when the task is successfully executed
  162121. * @param onError is a callback called if an error occurs
  162122. */
  162123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162124. }
  162125. /**
  162126. * Define a task used by AssetsManager to load binary data
  162127. */
  162128. export class BinaryFileAssetTask extends AbstractAssetTask {
  162129. /**
  162130. * Defines the name of the task
  162131. */
  162132. name: string;
  162133. /**
  162134. * Defines the location of the file to load
  162135. */
  162136. url: string;
  162137. /**
  162138. * Gets the lodaded data (as an array buffer)
  162139. */
  162140. data: ArrayBuffer;
  162141. /**
  162142. * Callback called when the task is successful
  162143. */
  162144. onSuccess: (task: BinaryFileAssetTask) => void;
  162145. /**
  162146. * Callback called when the task is successful
  162147. */
  162148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  162149. /**
  162150. * Creates a new BinaryFileAssetTask object
  162151. * @param name defines the name of the new task
  162152. * @param url defines the location of the file to load
  162153. */
  162154. constructor(
  162155. /**
  162156. * Defines the name of the task
  162157. */
  162158. name: string,
  162159. /**
  162160. * Defines the location of the file to load
  162161. */
  162162. url: string);
  162163. /**
  162164. * Execute the current task
  162165. * @param scene defines the scene where you want your assets to be loaded
  162166. * @param onSuccess is a callback called when the task is successfully executed
  162167. * @param onError is a callback called if an error occurs
  162168. */
  162169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162170. }
  162171. /**
  162172. * Define a task used by AssetsManager to load images
  162173. */
  162174. export class ImageAssetTask extends AbstractAssetTask {
  162175. /**
  162176. * Defines the name of the task
  162177. */
  162178. name: string;
  162179. /**
  162180. * Defines the location of the image to load
  162181. */
  162182. url: string;
  162183. /**
  162184. * Gets the loaded images
  162185. */
  162186. image: HTMLImageElement;
  162187. /**
  162188. * Callback called when the task is successful
  162189. */
  162190. onSuccess: (task: ImageAssetTask) => void;
  162191. /**
  162192. * Callback called when the task is successful
  162193. */
  162194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  162195. /**
  162196. * Creates a new ImageAssetTask
  162197. * @param name defines the name of the task
  162198. * @param url defines the location of the image to load
  162199. */
  162200. constructor(
  162201. /**
  162202. * Defines the name of the task
  162203. */
  162204. name: string,
  162205. /**
  162206. * Defines the location of the image to load
  162207. */
  162208. url: string);
  162209. /**
  162210. * Execute the current task
  162211. * @param scene defines the scene where you want your assets to be loaded
  162212. * @param onSuccess is a callback called when the task is successfully executed
  162213. * @param onError is a callback called if an error occurs
  162214. */
  162215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162216. }
  162217. /**
  162218. * Defines the interface used by texture loading tasks
  162219. */
  162220. export interface ITextureAssetTask<TEX extends BaseTexture> {
  162221. /**
  162222. * Gets the loaded texture
  162223. */
  162224. texture: TEX;
  162225. }
  162226. /**
  162227. * Define a task used by AssetsManager to load 2D textures
  162228. */
  162229. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  162230. /**
  162231. * Defines the name of the task
  162232. */
  162233. name: string;
  162234. /**
  162235. * Defines the location of the file to load
  162236. */
  162237. url: string;
  162238. /**
  162239. * Defines if mipmap should not be generated (default is false)
  162240. */
  162241. noMipmap?: boolean | undefined;
  162242. /**
  162243. * Defines if texture must be inverted on Y axis (default is true)
  162244. */
  162245. invertY: boolean;
  162246. /**
  162247. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162248. */
  162249. samplingMode: number;
  162250. /**
  162251. * Gets the loaded texture
  162252. */
  162253. texture: Texture;
  162254. /**
  162255. * Callback called when the task is successful
  162256. */
  162257. onSuccess: (task: TextureAssetTask) => void;
  162258. /**
  162259. * Callback called when the task is successful
  162260. */
  162261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  162262. /**
  162263. * Creates a new TextureAssetTask object
  162264. * @param name defines the name of the task
  162265. * @param url defines the location of the file to load
  162266. * @param noMipmap defines if mipmap should not be generated (default is false)
  162267. * @param invertY defines if texture must be inverted on Y axis (default is true)
  162268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162269. */
  162270. constructor(
  162271. /**
  162272. * Defines the name of the task
  162273. */
  162274. name: string,
  162275. /**
  162276. * Defines the location of the file to load
  162277. */
  162278. url: string,
  162279. /**
  162280. * Defines if mipmap should not be generated (default is false)
  162281. */
  162282. noMipmap?: boolean | undefined,
  162283. /**
  162284. * Defines if texture must be inverted on Y axis (default is true)
  162285. */
  162286. invertY?: boolean,
  162287. /**
  162288. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162289. */
  162290. samplingMode?: number);
  162291. /**
  162292. * Execute the current task
  162293. * @param scene defines the scene where you want your assets to be loaded
  162294. * @param onSuccess is a callback called when the task is successfully executed
  162295. * @param onError is a callback called if an error occurs
  162296. */
  162297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162298. }
  162299. /**
  162300. * Define a task used by AssetsManager to load cube textures
  162301. */
  162302. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  162303. /**
  162304. * Defines the name of the task
  162305. */
  162306. name: string;
  162307. /**
  162308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162309. */
  162310. url: string;
  162311. /**
  162312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162313. */
  162314. extensions?: string[] | undefined;
  162315. /**
  162316. * Defines if mipmaps should not be generated (default is false)
  162317. */
  162318. noMipmap?: boolean | undefined;
  162319. /**
  162320. * Defines the explicit list of files (undefined by default)
  162321. */
  162322. files?: string[] | undefined;
  162323. /**
  162324. * Gets the loaded texture
  162325. */
  162326. texture: CubeTexture;
  162327. /**
  162328. * Callback called when the task is successful
  162329. */
  162330. onSuccess: (task: CubeTextureAssetTask) => void;
  162331. /**
  162332. * Callback called when the task is successful
  162333. */
  162334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  162335. /**
  162336. * Creates a new CubeTextureAssetTask
  162337. * @param name defines the name of the task
  162338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162341. * @param files defines the explicit list of files (undefined by default)
  162342. */
  162343. constructor(
  162344. /**
  162345. * Defines the name of the task
  162346. */
  162347. name: string,
  162348. /**
  162349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162350. */
  162351. url: string,
  162352. /**
  162353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162354. */
  162355. extensions?: string[] | undefined,
  162356. /**
  162357. * Defines if mipmaps should not be generated (default is false)
  162358. */
  162359. noMipmap?: boolean | undefined,
  162360. /**
  162361. * Defines the explicit list of files (undefined by default)
  162362. */
  162363. files?: string[] | undefined);
  162364. /**
  162365. * Execute the current task
  162366. * @param scene defines the scene where you want your assets to be loaded
  162367. * @param onSuccess is a callback called when the task is successfully executed
  162368. * @param onError is a callback called if an error occurs
  162369. */
  162370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162371. }
  162372. /**
  162373. * Define a task used by AssetsManager to load HDR cube textures
  162374. */
  162375. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  162376. /**
  162377. * Defines the name of the task
  162378. */
  162379. name: string;
  162380. /**
  162381. * Defines the location of the file to load
  162382. */
  162383. url: string;
  162384. /**
  162385. * Defines the desired size (the more it increases the longer the generation will be)
  162386. */
  162387. size: number;
  162388. /**
  162389. * Defines if mipmaps should not be generated (default is false)
  162390. */
  162391. noMipmap: boolean;
  162392. /**
  162393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162394. */
  162395. generateHarmonics: boolean;
  162396. /**
  162397. * 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)
  162398. */
  162399. gammaSpace: boolean;
  162400. /**
  162401. * Internal Use Only
  162402. */
  162403. reserved: boolean;
  162404. /**
  162405. * Gets the loaded texture
  162406. */
  162407. texture: HDRCubeTexture;
  162408. /**
  162409. * Callback called when the task is successful
  162410. */
  162411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  162412. /**
  162413. * Callback called when the task is successful
  162414. */
  162415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  162416. /**
  162417. * Creates a new HDRCubeTextureAssetTask object
  162418. * @param name defines the name of the task
  162419. * @param url defines the location of the file to load
  162420. * @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.
  162421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162423. * @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)
  162424. * @param reserved Internal use only
  162425. */
  162426. constructor(
  162427. /**
  162428. * Defines the name of the task
  162429. */
  162430. name: string,
  162431. /**
  162432. * Defines the location of the file to load
  162433. */
  162434. url: string,
  162435. /**
  162436. * Defines the desired size (the more it increases the longer the generation will be)
  162437. */
  162438. size: number,
  162439. /**
  162440. * Defines if mipmaps should not be generated (default is false)
  162441. */
  162442. noMipmap?: boolean,
  162443. /**
  162444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162445. */
  162446. generateHarmonics?: boolean,
  162447. /**
  162448. * 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)
  162449. */
  162450. gammaSpace?: boolean,
  162451. /**
  162452. * Internal Use Only
  162453. */
  162454. reserved?: boolean);
  162455. /**
  162456. * Execute the current task
  162457. * @param scene defines the scene where you want your assets to be loaded
  162458. * @param onSuccess is a callback called when the task is successfully executed
  162459. * @param onError is a callback called if an error occurs
  162460. */
  162461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162462. }
  162463. /**
  162464. * Define a task used by AssetsManager to load Equirectangular cube textures
  162465. */
  162466. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  162467. /**
  162468. * Defines the name of the task
  162469. */
  162470. name: string;
  162471. /**
  162472. * Defines the location of the file to load
  162473. */
  162474. url: string;
  162475. /**
  162476. * Defines the desired size (the more it increases the longer the generation will be)
  162477. */
  162478. size: number;
  162479. /**
  162480. * Defines if mipmaps should not be generated (default is false)
  162481. */
  162482. noMipmap: boolean;
  162483. /**
  162484. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  162485. * but the standard material would require them in Gamma space) (default is true)
  162486. */
  162487. gammaSpace: boolean;
  162488. /**
  162489. * Gets the loaded texture
  162490. */
  162491. texture: EquiRectangularCubeTexture;
  162492. /**
  162493. * Callback called when the task is successful
  162494. */
  162495. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  162496. /**
  162497. * Callback called when the task is successful
  162498. */
  162499. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  162500. /**
  162501. * Creates a new EquiRectangularCubeTextureAssetTask object
  162502. * @param name defines the name of the task
  162503. * @param url defines the location of the file to load
  162504. * @param size defines the desired size (the more it increases the longer the generation will be)
  162505. * If the size is omitted this implies you are using a preprocessed cubemap.
  162506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162507. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  162508. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  162509. * (default is true)
  162510. */
  162511. constructor(
  162512. /**
  162513. * Defines the name of the task
  162514. */
  162515. name: string,
  162516. /**
  162517. * Defines the location of the file to load
  162518. */
  162519. url: string,
  162520. /**
  162521. * Defines the desired size (the more it increases the longer the generation will be)
  162522. */
  162523. size: number,
  162524. /**
  162525. * Defines if mipmaps should not be generated (default is false)
  162526. */
  162527. noMipmap?: boolean,
  162528. /**
  162529. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  162530. * but the standard material would require them in Gamma space) (default is true)
  162531. */
  162532. gammaSpace?: boolean);
  162533. /**
  162534. * Execute the current task
  162535. * @param scene defines the scene where you want your assets to be loaded
  162536. * @param onSuccess is a callback called when the task is successfully executed
  162537. * @param onError is a callback called if an error occurs
  162538. */
  162539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162540. }
  162541. /**
  162542. * This class can be used to easily import assets into a scene
  162543. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  162544. */
  162545. export class AssetsManager {
  162546. private _scene;
  162547. private _isLoading;
  162548. protected _tasks: AbstractAssetTask[];
  162549. protected _waitingTasksCount: number;
  162550. protected _totalTasksCount: number;
  162551. /**
  162552. * Callback called when all tasks are processed
  162553. */
  162554. onFinish: (tasks: AbstractAssetTask[]) => void;
  162555. /**
  162556. * Callback called when a task is successful
  162557. */
  162558. onTaskSuccess: (task: AbstractAssetTask) => void;
  162559. /**
  162560. * Callback called when a task had an error
  162561. */
  162562. onTaskError: (task: AbstractAssetTask) => void;
  162563. /**
  162564. * Callback called when a task is done (whatever the result is)
  162565. */
  162566. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  162567. /**
  162568. * Observable called when all tasks are processed
  162569. */
  162570. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  162571. /**
  162572. * Observable called when a task had an error
  162573. */
  162574. onTaskErrorObservable: Observable<AbstractAssetTask>;
  162575. /**
  162576. * Observable called when all tasks were executed
  162577. */
  162578. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  162579. /**
  162580. * Observable called when a task is done (whatever the result is)
  162581. */
  162582. onProgressObservable: Observable<IAssetsProgressEvent>;
  162583. /**
  162584. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  162585. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  162586. */
  162587. useDefaultLoadingScreen: boolean;
  162588. /**
  162589. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  162590. * when all assets have been downloaded.
  162591. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  162592. */
  162593. autoHideLoadingUI: boolean;
  162594. /**
  162595. * Creates a new AssetsManager
  162596. * @param scene defines the scene to work on
  162597. */
  162598. constructor(scene: Scene);
  162599. /**
  162600. * Add a ContainerAssetTask to the list of active tasks
  162601. * @param taskName defines the name of the new task
  162602. * @param meshesNames defines the name of meshes to load
  162603. * @param rootUrl defines the root url to use to locate files
  162604. * @param sceneFilename defines the filename of the scene file
  162605. * @returns a new ContainerAssetTask object
  162606. */
  162607. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  162608. /**
  162609. * Add a MeshAssetTask to the list of active tasks
  162610. * @param taskName defines the name of the new task
  162611. * @param meshesNames defines the name of meshes to load
  162612. * @param rootUrl defines the root url to use to locate files
  162613. * @param sceneFilename defines the filename of the scene file
  162614. * @returns a new MeshAssetTask object
  162615. */
  162616. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  162617. /**
  162618. * Add a TextFileAssetTask to the list of active tasks
  162619. * @param taskName defines the name of the new task
  162620. * @param url defines the url of the file to load
  162621. * @returns a new TextFileAssetTask object
  162622. */
  162623. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  162624. /**
  162625. * Add a BinaryFileAssetTask to the list of active tasks
  162626. * @param taskName defines the name of the new task
  162627. * @param url defines the url of the file to load
  162628. * @returns a new BinaryFileAssetTask object
  162629. */
  162630. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  162631. /**
  162632. * Add a ImageAssetTask to the list of active tasks
  162633. * @param taskName defines the name of the new task
  162634. * @param url defines the url of the file to load
  162635. * @returns a new ImageAssetTask object
  162636. */
  162637. addImageTask(taskName: string, url: string): ImageAssetTask;
  162638. /**
  162639. * Add a TextureAssetTask to the list of active tasks
  162640. * @param taskName defines the name of the new task
  162641. * @param url defines the url of the file to load
  162642. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162643. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  162644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  162645. * @returns a new TextureAssetTask object
  162646. */
  162647. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  162648. /**
  162649. * Add a CubeTextureAssetTask to the list of active tasks
  162650. * @param taskName defines the name of the new task
  162651. * @param url defines the url of the file to load
  162652. * @param extensions defines the extension to use to load the cube map (can be null)
  162653. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162654. * @param files defines the list of files to load (can be null)
  162655. * @returns a new CubeTextureAssetTask object
  162656. */
  162657. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  162658. /**
  162659. *
  162660. * Add a HDRCubeTextureAssetTask to the list of active tasks
  162661. * @param taskName defines the name of the new task
  162662. * @param url defines the url of the file to load
  162663. * @param size defines the size you want for the cubemap (can be null)
  162664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162665. * @param generateHarmonics defines if you want to automatically generate (true by default)
  162666. * @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)
  162667. * @param reserved Internal use only
  162668. * @returns a new HDRCubeTextureAssetTask object
  162669. */
  162670. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  162671. /**
  162672. *
  162673. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  162674. * @param taskName defines the name of the new task
  162675. * @param url defines the url of the file to load
  162676. * @param size defines the size you want for the cubemap (can be null)
  162677. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162678. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  162679. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  162680. * @returns a new EquiRectangularCubeTextureAssetTask object
  162681. */
  162682. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  162683. /**
  162684. * Remove a task from the assets manager.
  162685. * @param task the task to remove
  162686. */
  162687. removeTask(task: AbstractAssetTask): void;
  162688. private _decreaseWaitingTasksCount;
  162689. private _runTask;
  162690. /**
  162691. * Reset the AssetsManager and remove all tasks
  162692. * @return the current instance of the AssetsManager
  162693. */
  162694. reset(): AssetsManager;
  162695. /**
  162696. * Start the loading process
  162697. * @return the current instance of the AssetsManager
  162698. */
  162699. load(): AssetsManager;
  162700. /**
  162701. * Start the loading process as an async operation
  162702. * @return a promise returning the list of failed tasks
  162703. */
  162704. loadAsync(): Promise<void>;
  162705. }
  162706. }
  162707. declare module BABYLON {
  162708. /**
  162709. * Wrapper class for promise with external resolve and reject.
  162710. */
  162711. export class Deferred<T> {
  162712. /**
  162713. * The promise associated with this deferred object.
  162714. */
  162715. readonly promise: Promise<T>;
  162716. private _resolve;
  162717. private _reject;
  162718. /**
  162719. * The resolve method of the promise associated with this deferred object.
  162720. */
  162721. get resolve(): (value: T | PromiseLike<T>) => void;
  162722. /**
  162723. * The reject method of the promise associated with this deferred object.
  162724. */
  162725. get reject(): (reason?: any) => void;
  162726. /**
  162727. * Constructor for this deferred object.
  162728. */
  162729. constructor();
  162730. }
  162731. }
  162732. declare module BABYLON {
  162733. /**
  162734. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  162735. */
  162736. export class MeshExploder {
  162737. private _centerMesh;
  162738. private _meshes;
  162739. private _meshesOrigins;
  162740. private _toCenterVectors;
  162741. private _scaledDirection;
  162742. private _newPosition;
  162743. private _centerPosition;
  162744. /**
  162745. * Explodes meshes from a center mesh.
  162746. * @param meshes The meshes to explode.
  162747. * @param centerMesh The mesh to be center of explosion.
  162748. */
  162749. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  162750. private _setCenterMesh;
  162751. /**
  162752. * Get class name
  162753. * @returns "MeshExploder"
  162754. */
  162755. getClassName(): string;
  162756. /**
  162757. * "Exploded meshes"
  162758. * @returns Array of meshes with the centerMesh at index 0.
  162759. */
  162760. getMeshes(): Array<Mesh>;
  162761. /**
  162762. * Explodes meshes giving a specific direction
  162763. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  162764. */
  162765. explode(direction?: number): void;
  162766. }
  162767. }
  162768. declare module BABYLON {
  162769. /**
  162770. * Class used to help managing file picking and drag'n'drop
  162771. */
  162772. export class FilesInput {
  162773. /**
  162774. * List of files ready to be loaded
  162775. */
  162776. static get FilesToLoad(): {
  162777. [key: string]: File;
  162778. };
  162779. /**
  162780. * Callback called when a file is processed
  162781. */
  162782. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  162783. /**
  162784. * Function used when loading the scene file
  162785. */
  162786. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  162787. private _engine;
  162788. private _currentScene;
  162789. private _sceneLoadedCallback;
  162790. private _progressCallback;
  162791. private _additionalRenderLoopLogicCallback;
  162792. private _textureLoadingCallback;
  162793. private _startingProcessingFilesCallback;
  162794. private _onReloadCallback;
  162795. private _errorCallback;
  162796. private _elementToMonitor;
  162797. private _sceneFileToLoad;
  162798. private _filesToLoad;
  162799. /**
  162800. * Creates a new FilesInput
  162801. * @param engine defines the rendering engine
  162802. * @param scene defines the hosting scene
  162803. * @param sceneLoadedCallback callback called when scene is loaded
  162804. * @param progressCallback callback called to track progress
  162805. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  162806. * @param textureLoadingCallback callback called when a texture is loading
  162807. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  162808. * @param onReloadCallback callback called when a reload is requested
  162809. * @param errorCallback callback call if an error occurs
  162810. */
  162811. 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>);
  162812. private _dragEnterHandler;
  162813. private _dragOverHandler;
  162814. private _dropHandler;
  162815. /**
  162816. * Calls this function to listen to drag'n'drop events on a specific DOM element
  162817. * @param elementToMonitor defines the DOM element to track
  162818. */
  162819. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  162820. /** Gets the current list of files to load */
  162821. get filesToLoad(): File[];
  162822. /**
  162823. * Release all associated resources
  162824. */
  162825. dispose(): void;
  162826. private renderFunction;
  162827. private drag;
  162828. private drop;
  162829. private _traverseFolder;
  162830. private _processFiles;
  162831. /**
  162832. * Load files from a drop event
  162833. * @param event defines the drop event to use as source
  162834. */
  162835. loadFiles(event: any): void;
  162836. private _processReload;
  162837. /**
  162838. * Reload the current scene from the loaded files
  162839. */
  162840. reload(): void;
  162841. }
  162842. }
  162843. declare module BABYLON {
  162844. /**
  162845. * Defines the root class used to create scene optimization to use with SceneOptimizer
  162846. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162847. */
  162848. export class SceneOptimization {
  162849. /**
  162850. * Defines the priority of this optimization (0 by default which means first in the list)
  162851. */
  162852. priority: number;
  162853. /**
  162854. * Gets a string describing the action executed by the current optimization
  162855. * @returns description string
  162856. */
  162857. getDescription(): string;
  162858. /**
  162859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162860. * @param scene defines the current scene where to apply this optimization
  162861. * @param optimizer defines the current optimizer
  162862. * @returns true if everything that can be done was applied
  162863. */
  162864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162865. /**
  162866. * Creates the SceneOptimization object
  162867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162868. * @param desc defines the description associated with the optimization
  162869. */
  162870. constructor(
  162871. /**
  162872. * Defines the priority of this optimization (0 by default which means first in the list)
  162873. */
  162874. priority?: number);
  162875. }
  162876. /**
  162877. * Defines an optimization used to reduce the size of render target textures
  162878. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162879. */
  162880. export class TextureOptimization extends SceneOptimization {
  162881. /**
  162882. * Defines the priority of this optimization (0 by default which means first in the list)
  162883. */
  162884. priority: number;
  162885. /**
  162886. * 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
  162887. */
  162888. maximumSize: number;
  162889. /**
  162890. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162891. */
  162892. step: number;
  162893. /**
  162894. * Gets a string describing the action executed by the current optimization
  162895. * @returns description string
  162896. */
  162897. getDescription(): string;
  162898. /**
  162899. * Creates the TextureOptimization object
  162900. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162901. * @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
  162902. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162903. */
  162904. constructor(
  162905. /**
  162906. * Defines the priority of this optimization (0 by default which means first in the list)
  162907. */
  162908. priority?: number,
  162909. /**
  162910. * 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
  162911. */
  162912. maximumSize?: number,
  162913. /**
  162914. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162915. */
  162916. step?: number);
  162917. /**
  162918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162919. * @param scene defines the current scene where to apply this optimization
  162920. * @param optimizer defines the current optimizer
  162921. * @returns true if everything that can be done was applied
  162922. */
  162923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162924. }
  162925. /**
  162926. * Defines an optimization used to increase or decrease the rendering resolution
  162927. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162928. */
  162929. export class HardwareScalingOptimization extends SceneOptimization {
  162930. /**
  162931. * Defines the priority of this optimization (0 by default which means first in the list)
  162932. */
  162933. priority: number;
  162934. /**
  162935. * Defines the maximum scale to use (2 by default)
  162936. */
  162937. maximumScale: number;
  162938. /**
  162939. * Defines the step to use between two passes (0.5 by default)
  162940. */
  162941. step: number;
  162942. private _currentScale;
  162943. private _directionOffset;
  162944. /**
  162945. * Gets a string describing the action executed by the current optimization
  162946. * @return description string
  162947. */
  162948. getDescription(): string;
  162949. /**
  162950. * Creates the HardwareScalingOptimization object
  162951. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162952. * @param maximumScale defines the maximum scale to use (2 by default)
  162953. * @param step defines the step to use between two passes (0.5 by default)
  162954. */
  162955. constructor(
  162956. /**
  162957. * Defines the priority of this optimization (0 by default which means first in the list)
  162958. */
  162959. priority?: number,
  162960. /**
  162961. * Defines the maximum scale to use (2 by default)
  162962. */
  162963. maximumScale?: number,
  162964. /**
  162965. * Defines the step to use between two passes (0.5 by default)
  162966. */
  162967. step?: number);
  162968. /**
  162969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162970. * @param scene defines the current scene where to apply this optimization
  162971. * @param optimizer defines the current optimizer
  162972. * @returns true if everything that can be done was applied
  162973. */
  162974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162975. }
  162976. /**
  162977. * Defines an optimization used to remove shadows
  162978. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162979. */
  162980. export class ShadowsOptimization extends SceneOptimization {
  162981. /**
  162982. * Gets a string describing the action executed by the current optimization
  162983. * @return description string
  162984. */
  162985. getDescription(): string;
  162986. /**
  162987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162988. * @param scene defines the current scene where to apply this optimization
  162989. * @param optimizer defines the current optimizer
  162990. * @returns true if everything that can be done was applied
  162991. */
  162992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162993. }
  162994. /**
  162995. * Defines an optimization used to turn post-processes off
  162996. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162997. */
  162998. export class PostProcessesOptimization extends SceneOptimization {
  162999. /**
  163000. * Gets a string describing the action executed by the current optimization
  163001. * @return description string
  163002. */
  163003. getDescription(): string;
  163004. /**
  163005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163006. * @param scene defines the current scene where to apply this optimization
  163007. * @param optimizer defines the current optimizer
  163008. * @returns true if everything that can be done was applied
  163009. */
  163010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163011. }
  163012. /**
  163013. * Defines an optimization used to turn lens flares off
  163014. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163015. */
  163016. export class LensFlaresOptimization extends SceneOptimization {
  163017. /**
  163018. * Gets a string describing the action executed by the current optimization
  163019. * @return description string
  163020. */
  163021. getDescription(): string;
  163022. /**
  163023. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163024. * @param scene defines the current scene where to apply this optimization
  163025. * @param optimizer defines the current optimizer
  163026. * @returns true if everything that can be done was applied
  163027. */
  163028. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163029. }
  163030. /**
  163031. * Defines an optimization based on user defined callback.
  163032. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163033. */
  163034. export class CustomOptimization extends SceneOptimization {
  163035. /**
  163036. * Callback called to apply the custom optimization.
  163037. */
  163038. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  163039. /**
  163040. * Callback called to get custom description
  163041. */
  163042. onGetDescription: () => string;
  163043. /**
  163044. * Gets a string describing the action executed by the current optimization
  163045. * @returns description string
  163046. */
  163047. getDescription(): string;
  163048. /**
  163049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163050. * @param scene defines the current scene where to apply this optimization
  163051. * @param optimizer defines the current optimizer
  163052. * @returns true if everything that can be done was applied
  163053. */
  163054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163055. }
  163056. /**
  163057. * Defines an optimization used to turn particles off
  163058. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163059. */
  163060. export class ParticlesOptimization extends SceneOptimization {
  163061. /**
  163062. * Gets a string describing the action executed by the current optimization
  163063. * @return description string
  163064. */
  163065. getDescription(): string;
  163066. /**
  163067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163068. * @param scene defines the current scene where to apply this optimization
  163069. * @param optimizer defines the current optimizer
  163070. * @returns true if everything that can be done was applied
  163071. */
  163072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163073. }
  163074. /**
  163075. * Defines an optimization used to turn render targets off
  163076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163077. */
  163078. export class RenderTargetsOptimization extends SceneOptimization {
  163079. /**
  163080. * Gets a string describing the action executed by the current optimization
  163081. * @return description string
  163082. */
  163083. getDescription(): string;
  163084. /**
  163085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163086. * @param scene defines the current scene where to apply this optimization
  163087. * @param optimizer defines the current optimizer
  163088. * @returns true if everything that can be done was applied
  163089. */
  163090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163091. }
  163092. /**
  163093. * Defines an optimization used to merge meshes with compatible materials
  163094. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163095. */
  163096. export class MergeMeshesOptimization extends SceneOptimization {
  163097. private static _UpdateSelectionTree;
  163098. /**
  163099. * Gets or sets a boolean which defines if optimization octree has to be updated
  163100. */
  163101. static get UpdateSelectionTree(): boolean;
  163102. /**
  163103. * Gets or sets a boolean which defines if optimization octree has to be updated
  163104. */
  163105. static set UpdateSelectionTree(value: boolean);
  163106. /**
  163107. * Gets a string describing the action executed by the current optimization
  163108. * @return description string
  163109. */
  163110. getDescription(): string;
  163111. private _canBeMerged;
  163112. /**
  163113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163114. * @param scene defines the current scene where to apply this optimization
  163115. * @param optimizer defines the current optimizer
  163116. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  163117. * @returns true if everything that can be done was applied
  163118. */
  163119. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  163120. }
  163121. /**
  163122. * Defines a list of options used by SceneOptimizer
  163123. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163124. */
  163125. export class SceneOptimizerOptions {
  163126. /**
  163127. * Defines the target frame rate to reach (60 by default)
  163128. */
  163129. targetFrameRate: number;
  163130. /**
  163131. * Defines the interval between two checkes (2000ms by default)
  163132. */
  163133. trackerDuration: number;
  163134. /**
  163135. * Gets the list of optimizations to apply
  163136. */
  163137. optimizations: SceneOptimization[];
  163138. /**
  163139. * Creates a new list of options used by SceneOptimizer
  163140. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  163141. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  163142. */
  163143. constructor(
  163144. /**
  163145. * Defines the target frame rate to reach (60 by default)
  163146. */
  163147. targetFrameRate?: number,
  163148. /**
  163149. * Defines the interval between two checkes (2000ms by default)
  163150. */
  163151. trackerDuration?: number);
  163152. /**
  163153. * Add a new optimization
  163154. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  163155. * @returns the current SceneOptimizerOptions
  163156. */
  163157. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  163158. /**
  163159. * Add a new custom optimization
  163160. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  163161. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  163162. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163163. * @returns the current SceneOptimizerOptions
  163164. */
  163165. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  163166. /**
  163167. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  163168. * @param targetFrameRate defines the target frame rate (60 by default)
  163169. * @returns a SceneOptimizerOptions object
  163170. */
  163171. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163172. /**
  163173. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  163174. * @param targetFrameRate defines the target frame rate (60 by default)
  163175. * @returns a SceneOptimizerOptions object
  163176. */
  163177. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163178. /**
  163179. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  163180. * @param targetFrameRate defines the target frame rate (60 by default)
  163181. * @returns a SceneOptimizerOptions object
  163182. */
  163183. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163184. }
  163185. /**
  163186. * Class used to run optimizations in order to reach a target frame rate
  163187. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163188. */
  163189. export class SceneOptimizer implements IDisposable {
  163190. private _isRunning;
  163191. private _options;
  163192. private _scene;
  163193. private _currentPriorityLevel;
  163194. private _targetFrameRate;
  163195. private _trackerDuration;
  163196. private _currentFrameRate;
  163197. private _sceneDisposeObserver;
  163198. private _improvementMode;
  163199. /**
  163200. * Defines an observable called when the optimizer reaches the target frame rate
  163201. */
  163202. onSuccessObservable: Observable<SceneOptimizer>;
  163203. /**
  163204. * Defines an observable called when the optimizer enables an optimization
  163205. */
  163206. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  163207. /**
  163208. * Defines an observable called when the optimizer is not able to reach the target frame rate
  163209. */
  163210. onFailureObservable: Observable<SceneOptimizer>;
  163211. /**
  163212. * Gets a boolean indicating if the optimizer is in improvement mode
  163213. */
  163214. get isInImprovementMode(): boolean;
  163215. /**
  163216. * Gets the current priority level (0 at start)
  163217. */
  163218. get currentPriorityLevel(): number;
  163219. /**
  163220. * Gets the current frame rate checked by the SceneOptimizer
  163221. */
  163222. get currentFrameRate(): number;
  163223. /**
  163224. * Gets or sets the current target frame rate (60 by default)
  163225. */
  163226. get targetFrameRate(): number;
  163227. /**
  163228. * Gets or sets the current target frame rate (60 by default)
  163229. */
  163230. set targetFrameRate(value: number);
  163231. /**
  163232. * Gets or sets the current interval between two checks (every 2000ms by default)
  163233. */
  163234. get trackerDuration(): number;
  163235. /**
  163236. * Gets or sets the current interval between two checks (every 2000ms by default)
  163237. */
  163238. set trackerDuration(value: number);
  163239. /**
  163240. * Gets the list of active optimizations
  163241. */
  163242. get optimizations(): SceneOptimization[];
  163243. /**
  163244. * Creates a new SceneOptimizer
  163245. * @param scene defines the scene to work on
  163246. * @param options defines the options to use with the SceneOptimizer
  163247. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  163248. * @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)
  163249. */
  163250. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  163251. /**
  163252. * Stops the current optimizer
  163253. */
  163254. stop(): void;
  163255. /**
  163256. * Reset the optimizer to initial step (current priority level = 0)
  163257. */
  163258. reset(): void;
  163259. /**
  163260. * Start the optimizer. By default it will try to reach a specific framerate
  163261. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  163262. */
  163263. start(): void;
  163264. private _checkCurrentState;
  163265. /**
  163266. * Release all resources
  163267. */
  163268. dispose(): void;
  163269. /**
  163270. * Helper function to create a SceneOptimizer with one single line of code
  163271. * @param scene defines the scene to work on
  163272. * @param options defines the options to use with the SceneOptimizer
  163273. * @param onSuccess defines a callback to call on success
  163274. * @param onFailure defines a callback to call on failure
  163275. * @returns the new SceneOptimizer object
  163276. */
  163277. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  163278. }
  163279. }
  163280. declare module BABYLON {
  163281. /**
  163282. * Class used to serialize a scene into a string
  163283. */
  163284. export class SceneSerializer {
  163285. /**
  163286. * Clear cache used by a previous serialization
  163287. */
  163288. static ClearCache(): void;
  163289. /**
  163290. * Serialize a scene into a JSON compatible object
  163291. * @param scene defines the scene to serialize
  163292. * @returns a JSON compatible object
  163293. */
  163294. static Serialize(scene: Scene): any;
  163295. /**
  163296. * Serialize a mesh into a JSON compatible object
  163297. * @param toSerialize defines the mesh to serialize
  163298. * @param withParents defines if parents must be serialized as well
  163299. * @param withChildren defines if children must be serialized as well
  163300. * @returns a JSON compatible object
  163301. */
  163302. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  163303. }
  163304. }
  163305. declare module BABYLON {
  163306. /**
  163307. * This represents the different options available for the video capture.
  163308. */
  163309. export interface VideoRecorderOptions {
  163310. /** Defines the mime type of the video. */
  163311. mimeType: string;
  163312. /** Defines the FPS the video should be recorded at. */
  163313. fps: number;
  163314. /** Defines the chunk size for the recording data. */
  163315. recordChunckSize: number;
  163316. /** The audio tracks to attach to the recording. */
  163317. audioTracks?: MediaStreamTrack[];
  163318. }
  163319. /**
  163320. * This can help with recording videos from BabylonJS.
  163321. * This is based on the available WebRTC functionalities of the browser.
  163322. *
  163323. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  163324. */
  163325. export class VideoRecorder {
  163326. private static readonly _defaultOptions;
  163327. /**
  163328. * Returns whether or not the VideoRecorder is available in your browser.
  163329. * @param engine Defines the Babylon Engine.
  163330. * @returns true if supported otherwise false.
  163331. */
  163332. static IsSupported(engine: Engine): boolean;
  163333. private readonly _options;
  163334. private _canvas;
  163335. private _mediaRecorder;
  163336. private _recordedChunks;
  163337. private _fileName;
  163338. private _resolve;
  163339. private _reject;
  163340. /**
  163341. * True when a recording is already in progress.
  163342. */
  163343. get isRecording(): boolean;
  163344. /**
  163345. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  163346. * @param engine Defines the BabylonJS Engine you wish to record.
  163347. * @param options Defines options that can be used to customize the capture.
  163348. */
  163349. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  163350. /**
  163351. * Stops the current recording before the default capture timeout passed in the startRecording function.
  163352. */
  163353. stopRecording(): void;
  163354. /**
  163355. * Starts recording the canvas for a max duration specified in parameters.
  163356. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  163357. * If null no automatic download will start and you can rely on the promise to get the data back.
  163358. * @param maxDuration Defines the maximum recording time in seconds.
  163359. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  163360. * @return A promise callback at the end of the recording with the video data in Blob.
  163361. */
  163362. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  163363. /**
  163364. * Releases internal resources used during the recording.
  163365. */
  163366. dispose(): void;
  163367. private _handleDataAvailable;
  163368. private _handleError;
  163369. private _handleStop;
  163370. }
  163371. }
  163372. declare module BABYLON {
  163373. /**
  163374. * Class containing a set of static utilities functions for screenshots
  163375. */
  163376. export class ScreenshotTools {
  163377. /**
  163378. * Captures a screenshot of the current rendering
  163379. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163380. * @param engine defines the rendering engine
  163381. * @param camera defines the source camera
  163382. * @param size This parameter can be set to a single number or to an object with the
  163383. * following (optional) properties: precision, width, height. If a single number is passed,
  163384. * it will be used for both width and height. If an object is passed, the screenshot size
  163385. * will be derived from the parameters. The precision property is a multiplier allowing
  163386. * rendering at a higher or lower resolution
  163387. * @param successCallback defines the callback receives a single parameter which contains the
  163388. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  163389. * src parameter of an <img> to display it
  163390. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163391. * Check your browser for supported MIME types
  163392. * @param forceDownload force the system to download the image even if a successCallback is provided
  163393. */
  163394. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  163395. /**
  163396. * Captures a screenshot of the current rendering
  163397. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163398. * @param engine defines the rendering engine
  163399. * @param camera defines the source camera
  163400. * @param size This parameter can be set to a single number or to an object with the
  163401. * following (optional) properties: precision, width, height. If a single number is passed,
  163402. * it will be used for both width and height. If an object is passed, the screenshot size
  163403. * will be derived from the parameters. The precision property is a multiplier allowing
  163404. * rendering at a higher or lower resolution
  163405. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163406. * Check your browser for supported MIME types
  163407. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163408. * to the src parameter of an <img> to display it
  163409. */
  163410. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  163411. /**
  163412. * 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)
  163413. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163414. * @param engine defines the rendering engine
  163415. * @param camera defines the source camera
  163416. * @param width defines the expected width
  163417. * @param height defines the expected height
  163418. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163419. * Check your browser for supported MIME types
  163420. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163421. * to the src parameter of an <img> to display it
  163422. */
  163423. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  163424. /**
  163425. * Generates an image screenshot from the specified camera.
  163426. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163427. * @param engine The engine to use for rendering
  163428. * @param camera The camera to use for rendering
  163429. * @param size This parameter can be set to a single number or to an object with the
  163430. * following (optional) properties: precision, width, height. If a single number is passed,
  163431. * it will be used for both width and height. If an object is passed, the screenshot size
  163432. * will be derived from the parameters. The precision property is a multiplier allowing
  163433. * rendering at a higher or lower resolution
  163434. * @param successCallback The callback receives a single parameter which contains the
  163435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  163436. * src parameter of an <img> to display it
  163437. * @param mimeType The MIME type of the screenshot image (default: image/png).
  163438. * Check your browser for supported MIME types
  163439. * @param samples Texture samples (default: 1)
  163440. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  163441. * @param fileName A name for for the downloaded file.
  163442. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  163443. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  163444. */
  163445. 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;
  163446. /**
  163447. * Generates an image screenshot from the specified camera.
  163448. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163449. * @param engine The engine to use for rendering
  163450. * @param camera The camera to use for rendering
  163451. * @param size This parameter can be set to a single number or to an object with the
  163452. * following (optional) properties: precision, width, height. If a single number is passed,
  163453. * it will be used for both width and height. If an object is passed, the screenshot size
  163454. * will be derived from the parameters. The precision property is a multiplier allowing
  163455. * rendering at a higher or lower resolution
  163456. * @param mimeType The MIME type of the screenshot image (default: image/png).
  163457. * Check your browser for supported MIME types
  163458. * @param samples Texture samples (default: 1)
  163459. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  163460. * @param fileName A name for for the downloaded file.
  163461. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  163462. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163463. * to the src parameter of an <img> to display it
  163464. */
  163465. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  163466. /**
  163467. * Gets height and width for screenshot size
  163468. * @private
  163469. */
  163470. private static _getScreenshotSize;
  163471. }
  163472. }
  163473. declare module BABYLON {
  163474. /**
  163475. * Interface for a data buffer
  163476. */
  163477. export interface IDataBuffer {
  163478. /**
  163479. * Reads bytes from the data buffer.
  163480. * @param byteOffset The byte offset to read
  163481. * @param byteLength The byte length to read
  163482. * @returns A promise that resolves when the bytes are read
  163483. */
  163484. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  163485. /**
  163486. * The byte length of the buffer.
  163487. */
  163488. readonly byteLength: number;
  163489. }
  163490. /**
  163491. * Utility class for reading from a data buffer
  163492. */
  163493. export class DataReader {
  163494. /**
  163495. * The data buffer associated with this data reader.
  163496. */
  163497. readonly buffer: IDataBuffer;
  163498. /**
  163499. * The current byte offset from the beginning of the data buffer.
  163500. */
  163501. byteOffset: number;
  163502. private _dataView;
  163503. private _dataByteOffset;
  163504. /**
  163505. * Constructor
  163506. * @param buffer The buffer to read
  163507. */
  163508. constructor(buffer: IDataBuffer);
  163509. /**
  163510. * Loads the given byte length.
  163511. * @param byteLength The byte length to load
  163512. * @returns A promise that resolves when the load is complete
  163513. */
  163514. loadAsync(byteLength: number): Promise<void>;
  163515. /**
  163516. * Read a unsigned 32-bit integer from the currently loaded data range.
  163517. * @returns The 32-bit integer read
  163518. */
  163519. readUint32(): number;
  163520. /**
  163521. * Read a byte array from the currently loaded data range.
  163522. * @param byteLength The byte length to read
  163523. * @returns The byte array read
  163524. */
  163525. readUint8Array(byteLength: number): Uint8Array;
  163526. /**
  163527. * Read a string from the currently loaded data range.
  163528. * @param byteLength The byte length to read
  163529. * @returns The string read
  163530. */
  163531. readString(byteLength: number): string;
  163532. /**
  163533. * Skips the given byte length the currently loaded data range.
  163534. * @param byteLength The byte length to skip
  163535. */
  163536. skipBytes(byteLength: number): void;
  163537. }
  163538. }
  163539. declare module BABYLON {
  163540. /**
  163541. * Class for storing data to local storage if available or in-memory storage otherwise
  163542. */
  163543. export class DataStorage {
  163544. private static _Storage;
  163545. private static _GetStorage;
  163546. /**
  163547. * Reads a string from the data storage
  163548. * @param key The key to read
  163549. * @param defaultValue The value if the key doesn't exist
  163550. * @returns The string value
  163551. */
  163552. static ReadString(key: string, defaultValue: string): string;
  163553. /**
  163554. * Writes a string to the data storage
  163555. * @param key The key to write
  163556. * @param value The value to write
  163557. */
  163558. static WriteString(key: string, value: string): void;
  163559. /**
  163560. * Reads a boolean from the data storage
  163561. * @param key The key to read
  163562. * @param defaultValue The value if the key doesn't exist
  163563. * @returns The boolean value
  163564. */
  163565. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  163566. /**
  163567. * Writes a boolean to the data storage
  163568. * @param key The key to write
  163569. * @param value The value to write
  163570. */
  163571. static WriteBoolean(key: string, value: boolean): void;
  163572. /**
  163573. * Reads a number from the data storage
  163574. * @param key The key to read
  163575. * @param defaultValue The value if the key doesn't exist
  163576. * @returns The number value
  163577. */
  163578. static ReadNumber(key: string, defaultValue: number): number;
  163579. /**
  163580. * Writes a number to the data storage
  163581. * @param key The key to write
  163582. * @param value The value to write
  163583. */
  163584. static WriteNumber(key: string, value: number): void;
  163585. }
  163586. }
  163587. declare module BABYLON {
  163588. /**
  163589. * Class used to record delta files between 2 scene states
  163590. */
  163591. export class SceneRecorder {
  163592. private _trackedScene;
  163593. private _savedJSON;
  163594. /**
  163595. * Track a given scene. This means the current scene state will be considered the original state
  163596. * @param scene defines the scene to track
  163597. */
  163598. track(scene: Scene): void;
  163599. /**
  163600. * Get the delta between current state and original state
  163601. * @returns a string containing the delta
  163602. */
  163603. getDelta(): any;
  163604. private _compareArray;
  163605. private _compareObjects;
  163606. private _compareCollections;
  163607. private static GetShadowGeneratorById;
  163608. /**
  163609. * Apply a given delta to a given scene
  163610. * @param deltaJSON defines the JSON containing the delta
  163611. * @param scene defines the scene to apply the delta to
  163612. */
  163613. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  163614. private static _ApplyPropertiesToEntity;
  163615. private static _ApplyDeltaForEntity;
  163616. }
  163617. }
  163618. declare module BABYLON {
  163619. /**
  163620. * A 3D trajectory consisting of an order list of vectors describing a
  163621. * path of motion through 3D space.
  163622. */
  163623. export class Trajectory {
  163624. private _points;
  163625. private readonly _segmentLength;
  163626. /**
  163627. * Serialize to JSON.
  163628. * @returns serialized JSON string
  163629. */
  163630. serialize(): string;
  163631. /**
  163632. * Deserialize from JSON.
  163633. * @param json serialized JSON string
  163634. * @returns deserialized Trajectory
  163635. */
  163636. static Deserialize(json: string): Trajectory;
  163637. /**
  163638. * Create a new empty Trajectory.
  163639. * @param segmentLength radius of discretization for Trajectory points
  163640. */
  163641. constructor(segmentLength?: number);
  163642. /**
  163643. * Get the length of the Trajectory.
  163644. * @returns length of the Trajectory
  163645. */
  163646. getLength(): number;
  163647. /**
  163648. * Append a new point to the Trajectory.
  163649. * NOTE: This implementation has many allocations.
  163650. * @param point point to append to the Trajectory
  163651. */
  163652. add(point: DeepImmutable<Vector3>): void;
  163653. /**
  163654. * Create a new Trajectory with a segment length chosen to make it
  163655. * probable that the new Trajectory will have a specified number of
  163656. * segments. This operation is imprecise.
  163657. * @param targetResolution number of segments desired
  163658. * @returns new Trajectory with approximately the requested number of segments
  163659. */
  163660. resampleAtTargetResolution(targetResolution: number): Trajectory;
  163661. /**
  163662. * Convert Trajectory segments into tokenized representation. This
  163663. * representation is an array of numbers where each nth number is the
  163664. * index of the token which is most similar to the nth segment of the
  163665. * Trajectory.
  163666. * @param tokens list of vectors which serve as discrete tokens
  163667. * @returns list of indices of most similar token per segment
  163668. */
  163669. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  163670. private static _forwardDir;
  163671. private static _inverseFromVec;
  163672. private static _upDir;
  163673. private static _fromToVec;
  163674. private static _lookMatrix;
  163675. /**
  163676. * Transform the rotation (i.e., direction) of a segment to isolate
  163677. * the relative transformation represented by the segment. This operation
  163678. * may or may not succeed due to singularities in the equations that define
  163679. * motion relativity in this context.
  163680. * @param priorVec the origin of the prior segment
  163681. * @param fromVec the origin of the current segment
  163682. * @param toVec the destination of the current segment
  163683. * @param result reference to output variable
  163684. * @returns whether or not transformation was successful
  163685. */
  163686. private static _transformSegmentDirToRef;
  163687. private static _bestMatch;
  163688. private static _score;
  163689. private static _bestScore;
  163690. /**
  163691. * Determine which token vector is most similar to the
  163692. * segment vector.
  163693. * @param segment segment vector
  163694. * @param tokens token vector list
  163695. * @returns index of the most similar token to the segment
  163696. */
  163697. private static _tokenizeSegment;
  163698. }
  163699. /**
  163700. * Class representing a set of known, named trajectories to which Trajectories can be
  163701. * added and using which Trajectories can be recognized.
  163702. */
  163703. export class TrajectoryClassifier {
  163704. private _maximumAllowableMatchCost;
  163705. private _vector3Alphabet;
  163706. private _levenshteinAlphabet;
  163707. private _nameToDescribedTrajectory;
  163708. /**
  163709. * Serialize to JSON.
  163710. * @returns JSON serialization
  163711. */
  163712. serialize(): string;
  163713. /**
  163714. * Deserialize from JSON.
  163715. * @param json JSON serialization
  163716. * @returns deserialized TrajectorySet
  163717. */
  163718. static Deserialize(json: string): TrajectoryClassifier;
  163719. /**
  163720. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  163721. * VERY naive, need to be generating these things from known
  163722. * sets. Better version later, probably eliminating this one.
  163723. * @returns auto-generated TrajectorySet
  163724. */
  163725. static Generate(): TrajectoryClassifier;
  163726. private constructor();
  163727. /**
  163728. * Add a new Trajectory to the set with a given name.
  163729. * @param trajectory new Trajectory to be added
  163730. * @param classification name to which to add the Trajectory
  163731. */
  163732. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  163733. /**
  163734. * Remove a known named trajectory and all Trajectories associated with it.
  163735. * @param classification name to remove
  163736. * @returns whether anything was removed
  163737. */
  163738. deleteClassification(classification: string): boolean;
  163739. /**
  163740. * Attempt to recognize a Trajectory from among all the classifications
  163741. * already known to the classifier.
  163742. * @param trajectory Trajectory to be recognized
  163743. * @returns classification of Trajectory if recognized, null otherwise
  163744. */
  163745. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  163746. }
  163747. }
  163748. declare module BABYLON {
  163749. /**
  163750. * An interface for all Hit test features
  163751. */
  163752. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  163753. /**
  163754. * Triggered when new babylon (transformed) hit test results are available
  163755. */
  163756. onHitTestResultObservable: Observable<T[]>;
  163757. }
  163758. /**
  163759. * Options used for hit testing
  163760. */
  163761. export interface IWebXRLegacyHitTestOptions {
  163762. /**
  163763. * Only test when user interacted with the scene. Default - hit test every frame
  163764. */
  163765. testOnPointerDownOnly?: boolean;
  163766. /**
  163767. * The node to use to transform the local results to world coordinates
  163768. */
  163769. worldParentNode?: TransformNode;
  163770. }
  163771. /**
  163772. * Interface defining the babylon result of raycasting/hit-test
  163773. */
  163774. export interface IWebXRLegacyHitResult {
  163775. /**
  163776. * Transformation matrix that can be applied to a node that will put it in the hit point location
  163777. */
  163778. transformationMatrix: Matrix;
  163779. /**
  163780. * The native hit test result
  163781. */
  163782. xrHitResult: XRHitResult | XRHitTestResult;
  163783. }
  163784. /**
  163785. * The currently-working hit-test module.
  163786. * Hit test (or Ray-casting) is used to interact with the real world.
  163787. * For further information read here - https://github.com/immersive-web/hit-test
  163788. */
  163789. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  163790. /**
  163791. * options to use when constructing this feature
  163792. */
  163793. readonly options: IWebXRLegacyHitTestOptions;
  163794. private _direction;
  163795. private _mat;
  163796. private _onSelectEnabled;
  163797. private _origin;
  163798. /**
  163799. * The module's name
  163800. */
  163801. static readonly Name: string;
  163802. /**
  163803. * The (Babylon) version of this module.
  163804. * This is an integer representing the implementation version.
  163805. * This number does not correspond to the WebXR specs version
  163806. */
  163807. static readonly Version: number;
  163808. /**
  163809. * Populated with the last native XR Hit Results
  163810. */
  163811. lastNativeXRHitResults: XRHitResult[];
  163812. /**
  163813. * Triggered when new babylon (transformed) hit test results are available
  163814. */
  163815. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  163816. /**
  163817. * Creates a new instance of the (legacy version) hit test feature
  163818. * @param _xrSessionManager an instance of WebXRSessionManager
  163819. * @param options options to use when constructing this feature
  163820. */
  163821. constructor(_xrSessionManager: WebXRSessionManager,
  163822. /**
  163823. * options to use when constructing this feature
  163824. */
  163825. options?: IWebXRLegacyHitTestOptions);
  163826. /**
  163827. * execute a hit test with an XR Ray
  163828. *
  163829. * @param xrSession a native xrSession that will execute this hit test
  163830. * @param xrRay the ray (position and direction) to use for ray-casting
  163831. * @param referenceSpace native XR reference space to use for the hit-test
  163832. * @param filter filter function that will filter the results
  163833. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163834. */
  163835. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  163836. /**
  163837. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  163838. * @param event the (select) event to use to select with
  163839. * @param referenceSpace the reference space to use for this hit test
  163840. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163841. */
  163842. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  163843. /**
  163844. * attach this feature
  163845. * Will usually be called by the features manager
  163846. *
  163847. * @returns true if successful.
  163848. */
  163849. attach(): boolean;
  163850. /**
  163851. * detach this feature.
  163852. * Will usually be called by the features manager
  163853. *
  163854. * @returns true if successful.
  163855. */
  163856. detach(): boolean;
  163857. /**
  163858. * Dispose this feature and all of the resources attached
  163859. */
  163860. dispose(): void;
  163861. protected _onXRFrame(frame: XRFrame): void;
  163862. private _onHitTestResults;
  163863. private _onSelect;
  163864. }
  163865. }
  163866. declare module BABYLON {
  163867. /**
  163868. * Options used for hit testing (version 2)
  163869. */
  163870. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  163871. /**
  163872. * Do not create a permanent hit test. Will usually be used when only
  163873. * transient inputs are needed.
  163874. */
  163875. disablePermanentHitTest?: boolean;
  163876. /**
  163877. * Enable transient (for example touch-based) hit test inspections
  163878. */
  163879. enableTransientHitTest?: boolean;
  163880. /**
  163881. * Offset ray for the permanent hit test
  163882. */
  163883. offsetRay?: Vector3;
  163884. /**
  163885. * Offset ray for the transient hit test
  163886. */
  163887. transientOffsetRay?: Vector3;
  163888. /**
  163889. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  163890. */
  163891. useReferenceSpace?: boolean;
  163892. /**
  163893. * Override the default entity type(s) of the hit-test result
  163894. */
  163895. entityTypes?: XRHitTestTrackableType[];
  163896. }
  163897. /**
  163898. * Interface defining the babylon result of hit-test
  163899. */
  163900. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  163901. /**
  163902. * The input source that generated this hit test (if transient)
  163903. */
  163904. inputSource?: XRInputSource;
  163905. /**
  163906. * Is this a transient hit test
  163907. */
  163908. isTransient?: boolean;
  163909. /**
  163910. * Position of the hit test result
  163911. */
  163912. position: Vector3;
  163913. /**
  163914. * Rotation of the hit test result
  163915. */
  163916. rotationQuaternion: Quaternion;
  163917. /**
  163918. * The native hit test result
  163919. */
  163920. xrHitResult: XRHitTestResult;
  163921. }
  163922. /**
  163923. * The currently-working hit-test module.
  163924. * Hit test (or Ray-casting) is used to interact with the real world.
  163925. * For further information read here - https://github.com/immersive-web/hit-test
  163926. *
  163927. * Tested on chrome (mobile) 80.
  163928. */
  163929. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  163930. /**
  163931. * options to use when constructing this feature
  163932. */
  163933. readonly options: IWebXRHitTestOptions;
  163934. private _tmpMat;
  163935. private _tmpPos;
  163936. private _tmpQuat;
  163937. private _transientXrHitTestSource;
  163938. private _xrHitTestSource;
  163939. private initHitTestSource;
  163940. /**
  163941. * The module's name
  163942. */
  163943. static readonly Name: string;
  163944. /**
  163945. * The (Babylon) version of this module.
  163946. * This is an integer representing the implementation version.
  163947. * This number does not correspond to the WebXR specs version
  163948. */
  163949. static readonly Version: number;
  163950. /**
  163951. * When set to true, each hit test will have its own position/rotation objects
  163952. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  163953. * the developers will clone them or copy them as they see fit.
  163954. */
  163955. autoCloneTransformation: boolean;
  163956. /**
  163957. * Triggered when new babylon (transformed) hit test results are available
  163958. * Note - this will be called when results come back from the device. It can be an empty array!!
  163959. */
  163960. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  163961. /**
  163962. * Use this to temporarily pause hit test checks.
  163963. */
  163964. paused: boolean;
  163965. /**
  163966. * Creates a new instance of the hit test feature
  163967. * @param _xrSessionManager an instance of WebXRSessionManager
  163968. * @param options options to use when constructing this feature
  163969. */
  163970. constructor(_xrSessionManager: WebXRSessionManager,
  163971. /**
  163972. * options to use when constructing this feature
  163973. */
  163974. options?: IWebXRHitTestOptions);
  163975. /**
  163976. * attach this feature
  163977. * Will usually be called by the features manager
  163978. *
  163979. * @returns true if successful.
  163980. */
  163981. attach(): boolean;
  163982. /**
  163983. * detach this feature.
  163984. * Will usually be called by the features manager
  163985. *
  163986. * @returns true if successful.
  163987. */
  163988. detach(): boolean;
  163989. /**
  163990. * Dispose this feature and all of the resources attached
  163991. */
  163992. dispose(): void;
  163993. protected _onXRFrame(frame: XRFrame): void;
  163994. private _processWebXRHitTestResult;
  163995. }
  163996. }
  163997. declare module BABYLON {
  163998. /**
  163999. * Configuration options of the anchor system
  164000. */
  164001. export interface IWebXRAnchorSystemOptions {
  164002. /**
  164003. * a node that will be used to convert local to world coordinates
  164004. */
  164005. worldParentNode?: TransformNode;
  164006. /**
  164007. * If set to true a reference of the created anchors will be kept until the next session starts
  164008. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  164009. */
  164010. doNotRemoveAnchorsOnSessionEnded?: boolean;
  164011. }
  164012. /**
  164013. * A babylon container for an XR Anchor
  164014. */
  164015. export interface IWebXRAnchor {
  164016. /**
  164017. * A babylon-assigned ID for this anchor
  164018. */
  164019. id: number;
  164020. /**
  164021. * Transformation matrix to apply to an object attached to this anchor
  164022. */
  164023. transformationMatrix: Matrix;
  164024. /**
  164025. * The native anchor object
  164026. */
  164027. xrAnchor: XRAnchor;
  164028. /**
  164029. * if defined, this object will be constantly updated by the anchor's position and rotation
  164030. */
  164031. attachedNode?: TransformNode;
  164032. /**
  164033. * Remove this anchor from the scene
  164034. */
  164035. remove(): void;
  164036. }
  164037. /**
  164038. * An implementation of the anchor system for WebXR.
  164039. * For further information see https://github.com/immersive-web/anchors/
  164040. */
  164041. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  164042. private _options;
  164043. private _lastFrameDetected;
  164044. private _trackedAnchors;
  164045. private _referenceSpaceForFrameAnchors;
  164046. private _futureAnchors;
  164047. /**
  164048. * The module's name
  164049. */
  164050. static readonly Name: string;
  164051. /**
  164052. * The (Babylon) version of this module.
  164053. * This is an integer representing the implementation version.
  164054. * This number does not correspond to the WebXR specs version
  164055. */
  164056. static readonly Version: number;
  164057. /**
  164058. * Observers registered here will be executed when a new anchor was added to the session
  164059. */
  164060. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  164061. /**
  164062. * Observers registered here will be executed when an anchor was removed from the session
  164063. */
  164064. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  164065. /**
  164066. * Observers registered here will be executed when an existing anchor updates
  164067. * This can execute N times every frame
  164068. */
  164069. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  164070. /**
  164071. * Set the reference space to use for anchor creation, when not using a hit test.
  164072. * Will default to the session's reference space if not defined
  164073. */
  164074. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  164075. /**
  164076. * constructs a new anchor system
  164077. * @param _xrSessionManager an instance of WebXRSessionManager
  164078. * @param _options configuration object for this feature
  164079. */
  164080. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  164081. private _tmpVector;
  164082. private _tmpQuaternion;
  164083. private _populateTmpTransformation;
  164084. /**
  164085. * Create a new anchor point using a hit test result at a specific point in the scene
  164086. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  164087. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  164088. *
  164089. * @param hitTestResult The hit test result to use for this anchor creation
  164090. * @param position an optional position offset for this anchor
  164091. * @param rotationQuaternion an optional rotation offset for this anchor
  164092. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  164093. */
  164094. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  164095. /**
  164096. * Add a new anchor at a specific position and rotation
  164097. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  164098. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  164099. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  164100. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  164101. *
  164102. * @param position the position in which to add an anchor
  164103. * @param rotationQuaternion an optional rotation for the anchor transformation
  164104. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  164105. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  164106. */
  164107. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  164108. /**
  164109. * Get the list of anchors currently being tracked by the system
  164110. */
  164111. get anchors(): IWebXRAnchor[];
  164112. /**
  164113. * detach this feature.
  164114. * Will usually be called by the features manager
  164115. *
  164116. * @returns true if successful.
  164117. */
  164118. detach(): boolean;
  164119. /**
  164120. * Dispose this feature and all of the resources attached
  164121. */
  164122. dispose(): void;
  164123. protected _onXRFrame(frame: XRFrame): void;
  164124. /**
  164125. * avoiding using Array.find for global support.
  164126. * @param xrAnchor the plane to find in the array
  164127. */
  164128. private _findIndexInAnchorArray;
  164129. private _updateAnchorWithXRFrame;
  164130. private _createAnchorAtTransformation;
  164131. }
  164132. }
  164133. declare module BABYLON {
  164134. /**
  164135. * Options used in the plane detector module
  164136. */
  164137. export interface IWebXRPlaneDetectorOptions {
  164138. /**
  164139. * The node to use to transform the local results to world coordinates
  164140. */
  164141. worldParentNode?: TransformNode;
  164142. /**
  164143. * If set to true a reference of the created planes will be kept until the next session starts
  164144. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  164145. */
  164146. doNotRemovePlanesOnSessionEnded?: boolean;
  164147. /**
  164148. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  164149. */
  164150. preferredDetectorOptions?: XRGeometryDetectorOptions;
  164151. }
  164152. /**
  164153. * A babylon interface for a WebXR plane.
  164154. * A Plane is actually a polygon, built from N points in space
  164155. *
  164156. * Supported in chrome 79, not supported in canary 81 ATM
  164157. */
  164158. export interface IWebXRPlane {
  164159. /**
  164160. * a babylon-assigned ID for this polygon
  164161. */
  164162. id: number;
  164163. /**
  164164. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  164165. */
  164166. polygonDefinition: Array<Vector3>;
  164167. /**
  164168. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  164169. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  164170. */
  164171. transformationMatrix: Matrix;
  164172. /**
  164173. * the native xr-plane object
  164174. */
  164175. xrPlane: XRPlane;
  164176. }
  164177. /**
  164178. * The plane detector is used to detect planes in the real world when in AR
  164179. * For more information see https://github.com/immersive-web/real-world-geometry/
  164180. */
  164181. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  164182. private _options;
  164183. private _detectedPlanes;
  164184. private _enabled;
  164185. private _lastFrameDetected;
  164186. /**
  164187. * The module's name
  164188. */
  164189. static readonly Name: string;
  164190. /**
  164191. * The (Babylon) version of this module.
  164192. * This is an integer representing the implementation version.
  164193. * This number does not correspond to the WebXR specs version
  164194. */
  164195. static readonly Version: number;
  164196. /**
  164197. * Observers registered here will be executed when a new plane was added to the session
  164198. */
  164199. onPlaneAddedObservable: Observable<IWebXRPlane>;
  164200. /**
  164201. * Observers registered here will be executed when a plane is no longer detected in the session
  164202. */
  164203. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  164204. /**
  164205. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  164206. * This can execute N times every frame
  164207. */
  164208. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  164209. /**
  164210. * construct a new Plane Detector
  164211. * @param _xrSessionManager an instance of xr Session manager
  164212. * @param _options configuration to use when constructing this feature
  164213. */
  164214. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  164215. /**
  164216. * detach this feature.
  164217. * Will usually be called by the features manager
  164218. *
  164219. * @returns true if successful.
  164220. */
  164221. detach(): boolean;
  164222. /**
  164223. * Dispose this feature and all of the resources attached
  164224. */
  164225. dispose(): void;
  164226. /**
  164227. * Check if the needed objects are defined.
  164228. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  164229. */
  164230. isCompatible(): boolean;
  164231. protected _onXRFrame(frame: XRFrame): void;
  164232. private _init;
  164233. private _updatePlaneWithXRPlane;
  164234. /**
  164235. * avoiding using Array.find for global support.
  164236. * @param xrPlane the plane to find in the array
  164237. */
  164238. private _findIndexInPlaneArray;
  164239. }
  164240. }
  164241. declare module BABYLON {
  164242. /**
  164243. * Options interface for the background remover plugin
  164244. */
  164245. export interface IWebXRBackgroundRemoverOptions {
  164246. /**
  164247. * Further background meshes to disable when entering AR
  164248. */
  164249. backgroundMeshes?: AbstractMesh[];
  164250. /**
  164251. * flags to configure the removal of the environment helper.
  164252. * If not set, the entire background will be removed. If set, flags should be set as well.
  164253. */
  164254. environmentHelperRemovalFlags?: {
  164255. /**
  164256. * Should the skybox be removed (default false)
  164257. */
  164258. skyBox?: boolean;
  164259. /**
  164260. * Should the ground be removed (default false)
  164261. */
  164262. ground?: boolean;
  164263. };
  164264. /**
  164265. * don't disable the environment helper
  164266. */
  164267. ignoreEnvironmentHelper?: boolean;
  164268. }
  164269. /**
  164270. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  164271. */
  164272. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  164273. /**
  164274. * read-only options to be used in this module
  164275. */
  164276. readonly options: IWebXRBackgroundRemoverOptions;
  164277. /**
  164278. * The module's name
  164279. */
  164280. static readonly Name: string;
  164281. /**
  164282. * The (Babylon) version of this module.
  164283. * This is an integer representing the implementation version.
  164284. * This number does not correspond to the WebXR specs version
  164285. */
  164286. static readonly Version: number;
  164287. /**
  164288. * registered observers will be triggered when the background state changes
  164289. */
  164290. onBackgroundStateChangedObservable: Observable<boolean>;
  164291. /**
  164292. * constructs a new background remover module
  164293. * @param _xrSessionManager the session manager for this module
  164294. * @param options read-only options to be used in this module
  164295. */
  164296. constructor(_xrSessionManager: WebXRSessionManager,
  164297. /**
  164298. * read-only options to be used in this module
  164299. */
  164300. options?: IWebXRBackgroundRemoverOptions);
  164301. /**
  164302. * attach this feature
  164303. * Will usually be called by the features manager
  164304. *
  164305. * @returns true if successful.
  164306. */
  164307. attach(): boolean;
  164308. /**
  164309. * detach this feature.
  164310. * Will usually be called by the features manager
  164311. *
  164312. * @returns true if successful.
  164313. */
  164314. detach(): boolean;
  164315. /**
  164316. * Dispose this feature and all of the resources attached
  164317. */
  164318. dispose(): void;
  164319. protected _onXRFrame(_xrFrame: XRFrame): void;
  164320. private _setBackgroundState;
  164321. }
  164322. }
  164323. declare module BABYLON {
  164324. /**
  164325. * Options for the controller physics feature
  164326. */
  164327. export class IWebXRControllerPhysicsOptions {
  164328. /**
  164329. * Should the headset get its own impostor
  164330. */
  164331. enableHeadsetImpostor?: boolean;
  164332. /**
  164333. * Optional parameters for the headset impostor
  164334. */
  164335. headsetImpostorParams?: {
  164336. /**
  164337. * The type of impostor to create. Default is sphere
  164338. */
  164339. impostorType: number;
  164340. /**
  164341. * the size of the impostor. Defaults to 10cm
  164342. */
  164343. impostorSize?: number | {
  164344. width: number;
  164345. height: number;
  164346. depth: number;
  164347. };
  164348. /**
  164349. * Friction definitions
  164350. */
  164351. friction?: number;
  164352. /**
  164353. * Restitution
  164354. */
  164355. restitution?: number;
  164356. };
  164357. /**
  164358. * The physics properties of the future impostors
  164359. */
  164360. physicsProperties?: {
  164361. /**
  164362. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  164363. * Note that this requires a physics engine that supports mesh impostors!
  164364. */
  164365. useControllerMesh?: boolean;
  164366. /**
  164367. * The type of impostor to create. Default is sphere
  164368. */
  164369. impostorType?: number;
  164370. /**
  164371. * the size of the impostor. Defaults to 10cm
  164372. */
  164373. impostorSize?: number | {
  164374. width: number;
  164375. height: number;
  164376. depth: number;
  164377. };
  164378. /**
  164379. * Friction definitions
  164380. */
  164381. friction?: number;
  164382. /**
  164383. * Restitution
  164384. */
  164385. restitution?: number;
  164386. };
  164387. /**
  164388. * the xr input to use with this pointer selection
  164389. */
  164390. xrInput: WebXRInput;
  164391. }
  164392. /**
  164393. * Add physics impostor to your webxr controllers,
  164394. * including naive calculation of their linear and angular velocity
  164395. */
  164396. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  164397. private readonly _options;
  164398. private _attachController;
  164399. private _controllers;
  164400. private _debugMode;
  164401. private _delta;
  164402. private _headsetImpostor?;
  164403. private _headsetMesh?;
  164404. private _lastTimestamp;
  164405. private _tmpQuaternion;
  164406. private _tmpVector;
  164407. /**
  164408. * The module's name
  164409. */
  164410. static readonly Name: string;
  164411. /**
  164412. * The (Babylon) version of this module.
  164413. * This is an integer representing the implementation version.
  164414. * This number does not correspond to the webxr specs version
  164415. */
  164416. static readonly Version: number;
  164417. /**
  164418. * Construct a new Controller Physics Feature
  164419. * @param _xrSessionManager the corresponding xr session manager
  164420. * @param _options options to create this feature with
  164421. */
  164422. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  164423. /**
  164424. * @hidden
  164425. * enable debugging - will show console outputs and the impostor mesh
  164426. */
  164427. _enablePhysicsDebug(): void;
  164428. /**
  164429. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  164430. * @param xrController the controller to add
  164431. */
  164432. addController(xrController: WebXRInputSource): void;
  164433. /**
  164434. * attach this feature
  164435. * Will usually be called by the features manager
  164436. *
  164437. * @returns true if successful.
  164438. */
  164439. attach(): boolean;
  164440. /**
  164441. * detach this feature.
  164442. * Will usually be called by the features manager
  164443. *
  164444. * @returns true if successful.
  164445. */
  164446. detach(): boolean;
  164447. /**
  164448. * Get the headset impostor, if enabled
  164449. * @returns the impostor
  164450. */
  164451. getHeadsetImpostor(): PhysicsImpostor | undefined;
  164452. /**
  164453. * Get the physics impostor of a specific controller.
  164454. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  164455. * @param controller the controller or the controller id of which to get the impostor
  164456. * @returns the impostor or null
  164457. */
  164458. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  164459. /**
  164460. * Update the physics properties provided in the constructor
  164461. * @param newProperties the new properties object
  164462. */
  164463. setPhysicsProperties(newProperties: {
  164464. impostorType?: number;
  164465. impostorSize?: number | {
  164466. width: number;
  164467. height: number;
  164468. depth: number;
  164469. };
  164470. friction?: number;
  164471. restitution?: number;
  164472. }): void;
  164473. protected _onXRFrame(_xrFrame: any): void;
  164474. private _detachController;
  164475. }
  164476. }
  164477. declare module BABYLON {
  164478. /**
  164479. * A babylon interface for a "WebXR" feature point.
  164480. * Represents the position and confidence value of a given feature point.
  164481. */
  164482. export interface IWebXRFeaturePoint {
  164483. /**
  164484. * Represents the position of the feature point in world space.
  164485. */
  164486. position: Vector3;
  164487. /**
  164488. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  164489. */
  164490. confidenceValue: number;
  164491. }
  164492. /**
  164493. * The feature point system is used to detect feature points from real world geometry.
  164494. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  164495. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  164496. */
  164497. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  164498. private _enabled;
  164499. private _featurePointCloud;
  164500. /**
  164501. * The module's name
  164502. */
  164503. static readonly Name: string;
  164504. /**
  164505. * The (Babylon) version of this module.
  164506. * This is an integer representing the implementation version.
  164507. * This number does not correspond to the WebXR specs version
  164508. */
  164509. static readonly Version: number;
  164510. /**
  164511. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  164512. * Will notify the observers about which feature points have been added.
  164513. */
  164514. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  164515. /**
  164516. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  164517. * Will notify the observers about which feature points have been updated.
  164518. */
  164519. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  164520. /**
  164521. * The current feature point cloud maintained across frames.
  164522. */
  164523. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  164524. /**
  164525. * construct the feature point system
  164526. * @param _xrSessionManager an instance of xr Session manager
  164527. */
  164528. constructor(_xrSessionManager: WebXRSessionManager);
  164529. /**
  164530. * Detach this feature.
  164531. * Will usually be called by the features manager
  164532. *
  164533. * @returns true if successful.
  164534. */
  164535. detach(): boolean;
  164536. /**
  164537. * Dispose this feature and all of the resources attached
  164538. */
  164539. dispose(): void;
  164540. /**
  164541. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  164542. */
  164543. protected _onXRFrame(frame: XRFrame): void;
  164544. /**
  164545. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  164546. */
  164547. private _init;
  164548. }
  164549. }
  164550. declare module BABYLON {
  164551. /**
  164552. * Configuration interface for the hand tracking feature
  164553. */
  164554. export interface IWebXRHandTrackingOptions {
  164555. /**
  164556. * The xrInput that will be used as source for new hands
  164557. */
  164558. xrInput: WebXRInput;
  164559. /**
  164560. * Configuration object for the joint meshes
  164561. */
  164562. jointMeshes?: {
  164563. /**
  164564. * Should the meshes created be invisible (defaults to false)
  164565. */
  164566. invisible?: boolean;
  164567. /**
  164568. * A source mesh to be used to create instances. Defaults to a sphere.
  164569. * This mesh will be the source for all other (25) meshes.
  164570. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  164571. */
  164572. sourceMesh?: Mesh;
  164573. /**
  164574. * This function will be called after a mesh was created for a specific joint.
  164575. * Using this function you can either manipulate the instance or return a new mesh.
  164576. * When returning a new mesh the instance created before will be disposed
  164577. */
  164578. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  164579. /**
  164580. * Should the source mesh stay visible. Defaults to false
  164581. */
  164582. keepOriginalVisible?: boolean;
  164583. /**
  164584. * Scale factor for all instances (defaults to 2)
  164585. */
  164586. scaleFactor?: number;
  164587. /**
  164588. * Should each instance have its own physics impostor
  164589. */
  164590. enablePhysics?: boolean;
  164591. /**
  164592. * If enabled, override default physics properties
  164593. */
  164594. physicsProps?: {
  164595. friction?: number;
  164596. restitution?: number;
  164597. impostorType?: number;
  164598. };
  164599. /**
  164600. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  164601. */
  164602. disableDefaultHandMesh?: boolean;
  164603. /**
  164604. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  164605. */
  164606. handMeshes?: {
  164607. right: AbstractMesh;
  164608. left: AbstractMesh;
  164609. };
  164610. /**
  164611. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  164612. */
  164613. rigMapping?: {
  164614. right: string[];
  164615. left: string[];
  164616. };
  164617. };
  164618. }
  164619. /**
  164620. * Parts of the hands divided to writs and finger names
  164621. */
  164622. export const enum HandPart {
  164623. /**
  164624. * HandPart - Wrist
  164625. */
  164626. WRIST = "wrist",
  164627. /**
  164628. * HandPart - The THumb
  164629. */
  164630. THUMB = "thumb",
  164631. /**
  164632. * HandPart - Index finger
  164633. */
  164634. INDEX = "index",
  164635. /**
  164636. * HandPart - Middle finger
  164637. */
  164638. MIDDLE = "middle",
  164639. /**
  164640. * HandPart - Ring finger
  164641. */
  164642. RING = "ring",
  164643. /**
  164644. * HandPart - Little finger
  164645. */
  164646. LITTLE = "little"
  164647. }
  164648. /**
  164649. * Representing a single hand (with its corresponding native XRHand object)
  164650. */
  164651. export class WebXRHand implements IDisposable {
  164652. /** the controller to which the hand correlates */
  164653. readonly xrController: WebXRInputSource;
  164654. /** the meshes to be used to track the hand joints */
  164655. readonly trackedMeshes: AbstractMesh[];
  164656. private _handMesh?;
  164657. private _rigMapping?;
  164658. private _scene;
  164659. private _defaultHandMesh;
  164660. private _transformNodeMapping;
  164661. /**
  164662. * Hand-parts definition (key is HandPart)
  164663. */
  164664. handPartsDefinition: {
  164665. [key: string]: number[];
  164666. };
  164667. /**
  164668. * Observers will be triggered when the mesh for this hand was initialized.
  164669. */
  164670. onHandMeshReadyObservable: Observable<WebXRHand>;
  164671. /**
  164672. * Populate the HandPartsDefinition object.
  164673. * This is called as a side effect since certain browsers don't have XRHand defined.
  164674. */
  164675. private generateHandPartsDefinition;
  164676. /**
  164677. * Construct a new hand object
  164678. * @param xrController the controller to which the hand correlates
  164679. * @param trackedMeshes the meshes to be used to track the hand joints
  164680. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  164681. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  164682. * @param disableDefaultHandMesh should the default mesh creation be disabled
  164683. */
  164684. constructor(
  164685. /** the controller to which the hand correlates */
  164686. xrController: WebXRInputSource,
  164687. /** the meshes to be used to track the hand joints */
  164688. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  164689. /**
  164690. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  164691. */
  164692. get handMesh(): AbstractMesh | undefined;
  164693. /**
  164694. * Update this hand from the latest xr frame
  164695. * @param xrFrame xrFrame to update from
  164696. * @param referenceSpace The current viewer reference space
  164697. * @param scaleFactor optional scale factor for the meshes
  164698. */
  164699. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  164700. /**
  164701. * Get meshes of part of the hand
  164702. * @param part the part of hand to get
  164703. * @returns An array of meshes that correlate to the hand part requested
  164704. */
  164705. getHandPartMeshes(part: HandPart): AbstractMesh[];
  164706. /**
  164707. * Dispose this Hand object
  164708. */
  164709. dispose(): void;
  164710. private _generateDefaultHandMesh;
  164711. }
  164712. /**
  164713. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  164714. */
  164715. export class WebXRHandTracking extends WebXRAbstractFeature {
  164716. /**
  164717. * options to use when constructing this feature
  164718. */
  164719. readonly options: IWebXRHandTrackingOptions;
  164720. private static _idCounter;
  164721. /**
  164722. * The module's name
  164723. */
  164724. static readonly Name: string;
  164725. /**
  164726. * The (Babylon) version of this module.
  164727. * This is an integer representing the implementation version.
  164728. * This number does not correspond to the WebXR specs version
  164729. */
  164730. static readonly Version: number;
  164731. /**
  164732. * This observable will notify registered observers when a new hand object was added and initialized
  164733. */
  164734. onHandAddedObservable: Observable<WebXRHand>;
  164735. /**
  164736. * This observable will notify its observers right before the hand object is disposed
  164737. */
  164738. onHandRemovedObservable: Observable<WebXRHand>;
  164739. private _hands;
  164740. /**
  164741. * Creates a new instance of the hit test feature
  164742. * @param _xrSessionManager an instance of WebXRSessionManager
  164743. * @param options options to use when constructing this feature
  164744. */
  164745. constructor(_xrSessionManager: WebXRSessionManager,
  164746. /**
  164747. * options to use when constructing this feature
  164748. */
  164749. options: IWebXRHandTrackingOptions);
  164750. /**
  164751. * Check if the needed objects are defined.
  164752. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  164753. */
  164754. isCompatible(): boolean;
  164755. /**
  164756. * attach this feature
  164757. * Will usually be called by the features manager
  164758. *
  164759. * @returns true if successful.
  164760. */
  164761. attach(): boolean;
  164762. /**
  164763. * detach this feature.
  164764. * Will usually be called by the features manager
  164765. *
  164766. * @returns true if successful.
  164767. */
  164768. detach(): boolean;
  164769. /**
  164770. * Dispose this feature and all of the resources attached
  164771. */
  164772. dispose(): void;
  164773. /**
  164774. * Get the hand object according to the controller id
  164775. * @param controllerId the controller id to which we want to get the hand
  164776. * @returns null if not found or the WebXRHand object if found
  164777. */
  164778. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  164779. /**
  164780. * Get a hand object according to the requested handedness
  164781. * @param handedness the handedness to request
  164782. * @returns null if not found or the WebXRHand object if found
  164783. */
  164784. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  164785. protected _onXRFrame(_xrFrame: XRFrame): void;
  164786. private _attachHand;
  164787. private _detachHand;
  164788. }
  164789. }
  164790. declare module BABYLON {
  164791. /**
  164792. * Options used in the mesh detector module
  164793. */
  164794. export interface IWebXRMeshDetectorOptions {
  164795. /**
  164796. * The node to use to transform the local results to world coordinates
  164797. */
  164798. worldParentNode?: TransformNode;
  164799. /**
  164800. * If set to true a reference of the created meshes will be kept until the next session starts
  164801. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  164802. */
  164803. doNotRemoveMeshesOnSessionEnded?: boolean;
  164804. /**
  164805. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  164806. */
  164807. preferredDetectorOptions?: XRGeometryDetectorOptions;
  164808. /**
  164809. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  164810. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  164811. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  164812. */
  164813. convertCoordinateSystems?: boolean;
  164814. }
  164815. /**
  164816. * A babylon interface for a XR mesh's vertex data.
  164817. *
  164818. * Currently not supported by WebXR, available only with BabylonNative
  164819. */
  164820. export interface IWebXRVertexData {
  164821. /**
  164822. * A babylon-assigned ID for this mesh
  164823. */
  164824. id: number;
  164825. /**
  164826. * Data required for constructing a mesh in Babylon.js.
  164827. */
  164828. xrMesh: XRMesh;
  164829. /**
  164830. * The node to use to transform the local results to world coordinates.
  164831. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  164832. */
  164833. worldParentNode?: TransformNode;
  164834. /**
  164835. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  164836. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164837. */
  164838. positions?: Float32Array;
  164839. /**
  164840. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  164841. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164842. */
  164843. indices?: Uint32Array;
  164844. /**
  164845. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  164846. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  164847. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  164848. */
  164849. normals?: Float32Array;
  164850. /**
  164851. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  164852. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  164853. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164854. */
  164855. transformationMatrix?: Matrix;
  164856. }
  164857. /**
  164858. * The mesh detector is used to detect meshes in the real world when in AR
  164859. */
  164860. export class WebXRMeshDetector extends WebXRAbstractFeature {
  164861. private _options;
  164862. private _detectedMeshes;
  164863. /**
  164864. * The module's name
  164865. */
  164866. static readonly Name: string;
  164867. /**
  164868. * The (Babylon) version of this module.
  164869. * This is an integer representing the implementation version.
  164870. * This number does not correspond to the WebXR specs version
  164871. */
  164872. static readonly Version: number;
  164873. /**
  164874. * Observers registered here will be executed when a new mesh was added to the session
  164875. */
  164876. onMeshAddedObservable: Observable<IWebXRVertexData>;
  164877. /**
  164878. * Observers registered here will be executed when a mesh is no longer detected in the session
  164879. */
  164880. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  164881. /**
  164882. * Observers registered here will be executed when an existing mesh updates
  164883. */
  164884. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  164885. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  164886. detach(): boolean;
  164887. dispose(): void;
  164888. protected _onXRFrame(frame: XRFrame): void;
  164889. private _init;
  164890. private _updateVertexDataWithXRMesh;
  164891. }
  164892. }
  164893. declare module BABYLON {
  164894. /**
  164895. * Options interface for the background remover plugin
  164896. */
  164897. export interface IWebXRImageTrackingOptions {
  164898. /**
  164899. * A required array with images to track
  164900. */
  164901. images: {
  164902. /**
  164903. * The source of the image. can be a URL or an image bitmap
  164904. */
  164905. src: string | ImageBitmap;
  164906. /**
  164907. * The estimated width in the real world (in meters)
  164908. */
  164909. estimatedRealWorldWidth: number;
  164910. }[];
  164911. }
  164912. /**
  164913. * An object representing an image tracked by the system
  164914. */
  164915. export interface IWebXRTrackedImage {
  164916. /**
  164917. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  164918. */
  164919. id: number;
  164920. /**
  164921. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  164922. */
  164923. emulated?: boolean;
  164924. /**
  164925. * Just in case it is needed - the image bitmap that is being tracked
  164926. */
  164927. originalBitmap: ImageBitmap;
  164928. /**
  164929. * The native XR result image tracking result, untouched
  164930. */
  164931. xrTrackingResult?: XRImageTrackingResult;
  164932. /**
  164933. * Width in real world (meters)
  164934. */
  164935. realWorldWidth?: number;
  164936. /**
  164937. * A transformation matrix of this current image in the current reference space.
  164938. */
  164939. transformationMatrix: Matrix;
  164940. /**
  164941. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  164942. */
  164943. ratio?: number;
  164944. }
  164945. /**
  164946. * Image tracking for immersive AR sessions.
  164947. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  164948. */
  164949. export class WebXRImageTracking extends WebXRAbstractFeature {
  164950. /**
  164951. * read-only options to be used in this module
  164952. */
  164953. readonly options: IWebXRImageTrackingOptions;
  164954. /**
  164955. * The module's name
  164956. */
  164957. static readonly Name: string;
  164958. /**
  164959. * The (Babylon) version of this module.
  164960. * This is an integer representing the implementation version.
  164961. * This number does not correspond to the WebXR specs version
  164962. */
  164963. static readonly Version: number;
  164964. /**
  164965. * This will be triggered if the underlying system deems an image untrackable.
  164966. * The index is the index of the image from the array used to initialize the feature.
  164967. */
  164968. onUntrackableImageFoundObservable: Observable<number>;
  164969. /**
  164970. * An image was deemed trackable, and the system will start tracking it.
  164971. */
  164972. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  164973. /**
  164974. * The image was found and its state was updated.
  164975. */
  164976. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  164977. private _trackedImages;
  164978. private _originalTrackingRequest;
  164979. /**
  164980. * constructs the image tracking feature
  164981. * @param _xrSessionManager the session manager for this module
  164982. * @param options read-only options to be used in this module
  164983. */
  164984. constructor(_xrSessionManager: WebXRSessionManager,
  164985. /**
  164986. * read-only options to be used in this module
  164987. */
  164988. options: IWebXRImageTrackingOptions);
  164989. /**
  164990. * attach this feature
  164991. * Will usually be called by the features manager
  164992. *
  164993. * @returns true if successful.
  164994. */
  164995. attach(): boolean;
  164996. /**
  164997. * detach this feature.
  164998. * Will usually be called by the features manager
  164999. *
  165000. * @returns true if successful.
  165001. */
  165002. detach(): boolean;
  165003. /**
  165004. * Check if the needed objects are defined.
  165005. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  165006. */
  165007. isCompatible(): boolean;
  165008. /**
  165009. * Get a tracked image by its ID.
  165010. *
  165011. * @param id the id of the image to load (position in the init array)
  165012. * @returns a trackable image, if exists in this location
  165013. */
  165014. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  165015. /**
  165016. * Dispose this feature and all of the resources attached
  165017. */
  165018. dispose(): void;
  165019. /**
  165020. * Extends the session init object if needed
  165021. * @returns augmentation object fo the xr session init object.
  165022. */
  165023. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  165024. protected _onXRFrame(_xrFrame: XRFrame): void;
  165025. private _init;
  165026. }
  165027. }
  165028. declare module BABYLON {
  165029. /**
  165030. * The motion controller class for all microsoft mixed reality controllers
  165031. */
  165032. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  165033. protected readonly _mapping: {
  165034. defaultButton: {
  165035. valueNodeName: string;
  165036. unpressedNodeName: string;
  165037. pressedNodeName: string;
  165038. };
  165039. defaultAxis: {
  165040. valueNodeName: string;
  165041. minNodeName: string;
  165042. maxNodeName: string;
  165043. };
  165044. buttons: {
  165045. "xr-standard-trigger": {
  165046. rootNodeName: string;
  165047. componentProperty: string;
  165048. states: string[];
  165049. };
  165050. "xr-standard-squeeze": {
  165051. rootNodeName: string;
  165052. componentProperty: string;
  165053. states: string[];
  165054. };
  165055. "xr-standard-touchpad": {
  165056. rootNodeName: string;
  165057. labelAnchorNodeName: string;
  165058. touchPointNodeName: string;
  165059. };
  165060. "xr-standard-thumbstick": {
  165061. rootNodeName: string;
  165062. componentProperty: string;
  165063. states: string[];
  165064. };
  165065. };
  165066. axes: {
  165067. "xr-standard-touchpad": {
  165068. "x-axis": {
  165069. rootNodeName: string;
  165070. };
  165071. "y-axis": {
  165072. rootNodeName: string;
  165073. };
  165074. };
  165075. "xr-standard-thumbstick": {
  165076. "x-axis": {
  165077. rootNodeName: string;
  165078. };
  165079. "y-axis": {
  165080. rootNodeName: string;
  165081. };
  165082. };
  165083. };
  165084. };
  165085. /**
  165086. * The base url used to load the left and right controller models
  165087. */
  165088. static MODEL_BASE_URL: string;
  165089. /**
  165090. * The name of the left controller model file
  165091. */
  165092. static MODEL_LEFT_FILENAME: string;
  165093. /**
  165094. * The name of the right controller model file
  165095. */
  165096. static MODEL_RIGHT_FILENAME: string;
  165097. profileId: string;
  165098. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  165099. protected _getFilenameAndPath(): {
  165100. filename: string;
  165101. path: string;
  165102. };
  165103. protected _getModelLoadingConstraints(): boolean;
  165104. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165105. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165106. protected _updateModel(): void;
  165107. }
  165108. }
  165109. declare module BABYLON {
  165110. /**
  165111. * The motion controller class for oculus touch (quest, rift).
  165112. * This class supports legacy mapping as well the standard xr mapping
  165113. */
  165114. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  165115. private _forceLegacyControllers;
  165116. private _modelRootNode;
  165117. /**
  165118. * The base url used to load the left and right controller models
  165119. */
  165120. static MODEL_BASE_URL: string;
  165121. /**
  165122. * The name of the left controller model file
  165123. */
  165124. static MODEL_LEFT_FILENAME: string;
  165125. /**
  165126. * The name of the right controller model file
  165127. */
  165128. static MODEL_RIGHT_FILENAME: string;
  165129. /**
  165130. * Base Url for the Quest controller model.
  165131. */
  165132. static QUEST_MODEL_BASE_URL: string;
  165133. profileId: string;
  165134. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  165135. protected _getFilenameAndPath(): {
  165136. filename: string;
  165137. path: string;
  165138. };
  165139. protected _getModelLoadingConstraints(): boolean;
  165140. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165141. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165142. protected _updateModel(): void;
  165143. /**
  165144. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  165145. * between the touch and touch 2.
  165146. */
  165147. private _isQuest;
  165148. }
  165149. }
  165150. declare module BABYLON {
  165151. /**
  165152. * The motion controller class for the standard HTC-Vive controllers
  165153. */
  165154. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  165155. private _modelRootNode;
  165156. /**
  165157. * The base url used to load the left and right controller models
  165158. */
  165159. static MODEL_BASE_URL: string;
  165160. /**
  165161. * File name for the controller model.
  165162. */
  165163. static MODEL_FILENAME: string;
  165164. profileId: string;
  165165. /**
  165166. * Create a new Vive motion controller object
  165167. * @param scene the scene to use to create this controller
  165168. * @param gamepadObject the corresponding gamepad object
  165169. * @param handedness the handedness of the controller
  165170. */
  165171. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  165172. protected _getFilenameAndPath(): {
  165173. filename: string;
  165174. path: string;
  165175. };
  165176. protected _getModelLoadingConstraints(): boolean;
  165177. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165178. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165179. protected _updateModel(): void;
  165180. }
  165181. }
  165182. declare module BABYLON {
  165183. /**
  165184. * A cursor which tracks a point on a path
  165185. */
  165186. export class PathCursor {
  165187. private path;
  165188. /**
  165189. * Stores path cursor callbacks for when an onchange event is triggered
  165190. */
  165191. private _onchange;
  165192. /**
  165193. * The value of the path cursor
  165194. */
  165195. value: number;
  165196. /**
  165197. * The animation array of the path cursor
  165198. */
  165199. animations: Animation[];
  165200. /**
  165201. * Initializes the path cursor
  165202. * @param path The path to track
  165203. */
  165204. constructor(path: Path2);
  165205. /**
  165206. * Gets the cursor point on the path
  165207. * @returns A point on the path cursor at the cursor location
  165208. */
  165209. getPoint(): Vector3;
  165210. /**
  165211. * Moves the cursor ahead by the step amount
  165212. * @param step The amount to move the cursor forward
  165213. * @returns This path cursor
  165214. */
  165215. moveAhead(step?: number): PathCursor;
  165216. /**
  165217. * Moves the cursor behind by the step amount
  165218. * @param step The amount to move the cursor back
  165219. * @returns This path cursor
  165220. */
  165221. moveBack(step?: number): PathCursor;
  165222. /**
  165223. * Moves the cursor by the step amount
  165224. * If the step amount is greater than one, an exception is thrown
  165225. * @param step The amount to move the cursor
  165226. * @returns This path cursor
  165227. */
  165228. move(step: number): PathCursor;
  165229. /**
  165230. * Ensures that the value is limited between zero and one
  165231. * @returns This path cursor
  165232. */
  165233. private ensureLimits;
  165234. /**
  165235. * Runs onchange callbacks on change (used by the animation engine)
  165236. * @returns This path cursor
  165237. */
  165238. private raiseOnChange;
  165239. /**
  165240. * Executes a function on change
  165241. * @param f A path cursor onchange callback
  165242. * @returns This path cursor
  165243. */
  165244. onchange(f: (cursor: PathCursor) => void): PathCursor;
  165245. }
  165246. }
  165247. declare module BABYLON {
  165248. /** @hidden */
  165249. export var blurPixelShader: {
  165250. name: string;
  165251. shader: string;
  165252. };
  165253. }
  165254. declare module BABYLON {
  165255. /** @hidden */
  165256. export var pointCloudVertexDeclaration: {
  165257. name: string;
  165258. shader: string;
  165259. };
  165260. }
  165261. // Mixins
  165262. interface Window {
  165263. mozIndexedDB: IDBFactory;
  165264. webkitIndexedDB: IDBFactory;
  165265. msIndexedDB: IDBFactory;
  165266. webkitURL: typeof URL;
  165267. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165268. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  165269. WebGLRenderingContext: WebGLRenderingContext;
  165270. MSGesture: MSGesture;
  165271. CANNON: any;
  165272. AudioContext: AudioContext;
  165273. webkitAudioContext: AudioContext;
  165274. PointerEvent: any;
  165275. Math: Math;
  165276. Uint8Array: Uint8ArrayConstructor;
  165277. Float32Array: Float32ArrayConstructor;
  165278. mozURL: typeof URL;
  165279. msURL: typeof URL;
  165280. VRFrameData: any; // WebVR, from specs 1.1
  165281. DracoDecoderModule: any;
  165282. setImmediate(handler: (...args: any[]) => void): number;
  165283. }
  165284. interface HTMLCanvasElement {
  165285. requestPointerLock(): void;
  165286. msRequestPointerLock?(): void;
  165287. mozRequestPointerLock?(): void;
  165288. webkitRequestPointerLock?(): void;
  165289. /** Track wether a record is in progress */
  165290. isRecording: boolean;
  165291. /** Capture Stream method defined by some browsers */
  165292. captureStream(fps?: number): MediaStream;
  165293. }
  165294. interface CanvasRenderingContext2D {
  165295. msImageSmoothingEnabled: boolean;
  165296. }
  165297. interface MouseEvent {
  165298. mozMovementX: number;
  165299. mozMovementY: number;
  165300. webkitMovementX: number;
  165301. webkitMovementY: number;
  165302. msMovementX: number;
  165303. msMovementY: number;
  165304. }
  165305. interface Navigator {
  165306. mozGetVRDevices: (any: any) => any;
  165307. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165308. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165309. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165310. webkitGetGamepads(): Gamepad[];
  165311. msGetGamepads(): Gamepad[];
  165312. webkitGamepads(): Gamepad[];
  165313. }
  165314. interface HTMLVideoElement {
  165315. mozSrcObject: any;
  165316. }
  165317. interface Math {
  165318. fround(x: number): number;
  165319. imul(a: number, b: number): number;
  165320. log2(x: number): number;
  165321. }
  165322. interface WebGLRenderingContext {
  165323. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  165324. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  165325. vertexAttribDivisor(index: number, divisor: number): void;
  165326. createVertexArray(): any;
  165327. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  165328. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  165329. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  165330. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  165331. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  165332. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  165333. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  165334. // Queries
  165335. createQuery(): WebGLQuery;
  165336. deleteQuery(query: WebGLQuery): void;
  165337. beginQuery(target: number, query: WebGLQuery): void;
  165338. endQuery(target: number): void;
  165339. getQueryParameter(query: WebGLQuery, pname: number): any;
  165340. getQuery(target: number, pname: number): any;
  165341. MAX_SAMPLES: number;
  165342. RGBA8: number;
  165343. READ_FRAMEBUFFER: number;
  165344. DRAW_FRAMEBUFFER: number;
  165345. UNIFORM_BUFFER: number;
  165346. HALF_FLOAT_OES: number;
  165347. RGBA16F: number;
  165348. RGBA32F: number;
  165349. R32F: number;
  165350. RG32F: number;
  165351. RGB32F: number;
  165352. R16F: number;
  165353. RG16F: number;
  165354. RGB16F: number;
  165355. RED: number;
  165356. RG: number;
  165357. R8: number;
  165358. RG8: number;
  165359. UNSIGNED_INT_24_8: number;
  165360. DEPTH24_STENCIL8: number;
  165361. MIN: number;
  165362. MAX: number;
  165363. /* Multiple Render Targets */
  165364. drawBuffers(buffers: number[]): void;
  165365. readBuffer(src: number): void;
  165366. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  165367. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  165368. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  165369. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  165370. // Occlusion Query
  165371. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  165372. ANY_SAMPLES_PASSED: number;
  165373. QUERY_RESULT_AVAILABLE: number;
  165374. QUERY_RESULT: number;
  165375. }
  165376. interface WebGLProgram {
  165377. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  165378. }
  165379. interface EXT_disjoint_timer_query {
  165380. QUERY_COUNTER_BITS_EXT: number;
  165381. TIME_ELAPSED_EXT: number;
  165382. TIMESTAMP_EXT: number;
  165383. GPU_DISJOINT_EXT: number;
  165384. QUERY_RESULT_EXT: number;
  165385. QUERY_RESULT_AVAILABLE_EXT: number;
  165386. queryCounterEXT(query: WebGLQuery, target: number): void;
  165387. createQueryEXT(): WebGLQuery;
  165388. beginQueryEXT(target: number, query: WebGLQuery): void;
  165389. endQueryEXT(target: number): void;
  165390. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  165391. deleteQueryEXT(query: WebGLQuery): void;
  165392. }
  165393. interface WebGLUniformLocation {
  165394. _currentState: any;
  165395. }
  165396. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  165397. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  165398. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  165399. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  165400. interface WebGLRenderingContext {
  165401. readonly RASTERIZER_DISCARD: number;
  165402. readonly DEPTH_COMPONENT24: number;
  165403. readonly TEXTURE_3D: number;
  165404. readonly TEXTURE_2D_ARRAY: number;
  165405. readonly TEXTURE_COMPARE_FUNC: number;
  165406. readonly TEXTURE_COMPARE_MODE: number;
  165407. readonly COMPARE_REF_TO_TEXTURE: number;
  165408. readonly TEXTURE_WRAP_R: number;
  165409. readonly HALF_FLOAT: number;
  165410. readonly RGB8: number;
  165411. readonly RED_INTEGER: number;
  165412. readonly RG_INTEGER: number;
  165413. readonly RGB_INTEGER: number;
  165414. readonly RGBA_INTEGER: number;
  165415. readonly R8_SNORM: number;
  165416. readonly RG8_SNORM: number;
  165417. readonly RGB8_SNORM: number;
  165418. readonly RGBA8_SNORM: number;
  165419. readonly R8I: number;
  165420. readonly RG8I: number;
  165421. readonly RGB8I: number;
  165422. readonly RGBA8I: number;
  165423. readonly R8UI: number;
  165424. readonly RG8UI: number;
  165425. readonly RGB8UI: number;
  165426. readonly RGBA8UI: number;
  165427. readonly R16I: number;
  165428. readonly RG16I: number;
  165429. readonly RGB16I: number;
  165430. readonly RGBA16I: number;
  165431. readonly R16UI: number;
  165432. readonly RG16UI: number;
  165433. readonly RGB16UI: number;
  165434. readonly RGBA16UI: number;
  165435. readonly R32I: number;
  165436. readonly RG32I: number;
  165437. readonly RGB32I: number;
  165438. readonly RGBA32I: number;
  165439. readonly R32UI: number;
  165440. readonly RG32UI: number;
  165441. readonly RGB32UI: number;
  165442. readonly RGBA32UI: number;
  165443. readonly RGB10_A2UI: number;
  165444. readonly R11F_G11F_B10F: number;
  165445. readonly RGB9_E5: number;
  165446. readonly RGB10_A2: number;
  165447. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  165448. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  165449. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  165450. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  165451. readonly DEPTH_COMPONENT32F: number;
  165452. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  165453. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  165454. 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;
  165455. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  165456. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  165457. readonly TRANSFORM_FEEDBACK: number;
  165458. readonly INTERLEAVED_ATTRIBS: number;
  165459. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  165460. createTransformFeedback(): WebGLTransformFeedback;
  165461. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  165462. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  165463. beginTransformFeedback(primitiveMode: number): void;
  165464. endTransformFeedback(): void;
  165465. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  165466. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165467. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165468. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165469. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  165470. }
  165471. interface ImageBitmap {
  165472. readonly width: number;
  165473. readonly height: number;
  165474. close(): void;
  165475. }
  165476. interface WebGLQuery extends WebGLObject {
  165477. }
  165478. declare var WebGLQuery: {
  165479. prototype: WebGLQuery;
  165480. new(): WebGLQuery;
  165481. };
  165482. interface WebGLSampler extends WebGLObject {
  165483. }
  165484. declare var WebGLSampler: {
  165485. prototype: WebGLSampler;
  165486. new(): WebGLSampler;
  165487. };
  165488. interface WebGLSync extends WebGLObject {
  165489. }
  165490. declare var WebGLSync: {
  165491. prototype: WebGLSync;
  165492. new(): WebGLSync;
  165493. };
  165494. interface WebGLTransformFeedback extends WebGLObject {
  165495. }
  165496. declare var WebGLTransformFeedback: {
  165497. prototype: WebGLTransformFeedback;
  165498. new(): WebGLTransformFeedback;
  165499. };
  165500. interface WebGLVertexArrayObject extends WebGLObject {
  165501. }
  165502. declare var WebGLVertexArrayObject: {
  165503. prototype: WebGLVertexArrayObject;
  165504. new(): WebGLVertexArrayObject;
  165505. };
  165506. interface Navigator {
  165507. readonly gpu: GPU | undefined;
  165508. }
  165509. interface GPUColorDict {
  165510. a: number;
  165511. b: number;
  165512. g: number;
  165513. r: number;
  165514. }
  165515. type GPUColor = [number, number, number, number] | GPUColorDict;
  165516. interface GPUOrigin2DDict {
  165517. x?: number;
  165518. y?: number;
  165519. }
  165520. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  165521. interface GPUOrigin3DDict {
  165522. x?: number;
  165523. y?: number;
  165524. z?: number;
  165525. }
  165526. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  165527. interface GPUExtent3DDict {
  165528. width: number;
  165529. height: number;
  165530. depth: number;
  165531. }
  165532. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  165533. type GPUBindingResource =
  165534. | GPUSampler
  165535. | GPUTextureView
  165536. | GPUBufferBinding;
  165537. type GPUExtensionName =
  165538. | "texture-compression-bc"
  165539. | "timestamp-query"
  165540. | "pipeline-statistics-query"
  165541. | "depth-clamping"
  165542. | "depth24unorm-stencil8"
  165543. | "depth32float-stencil8";
  165544. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  165545. type GPUBindingType =
  165546. | "uniform-buffer"
  165547. | "storage-buffer"
  165548. | "readonly-storage-buffer"
  165549. | "sampler"
  165550. | "comparison-sampler"
  165551. | "sampled-texture"
  165552. | "readonly-storage-texture"
  165553. | "writeonly-storage-texture";
  165554. type GPUBlendFactor =
  165555. | "zero"
  165556. | "one"
  165557. | "src-color"
  165558. | "one-minus-src-color"
  165559. | "src-alpha"
  165560. | "one-minus-src-alpha"
  165561. | "dst-color"
  165562. | "one-minus-dst-color"
  165563. | "dst-alpha"
  165564. | "one-minus-dst-alpha"
  165565. | "src-alpha-saturated"
  165566. | "blend-color"
  165567. | "one-minus-blend-color";
  165568. type GPUBlendOperation =
  165569. | "add"
  165570. | "subtract"
  165571. | "reverse-subtract"
  165572. | "min"
  165573. | "max";
  165574. type GPUCompareFunction =
  165575. | "never"
  165576. | "less"
  165577. | "equal"
  165578. | "less-equal"
  165579. | "greater"
  165580. | "not-equal"
  165581. | "greater-equal"
  165582. | "always";
  165583. type GPUCullMode = "none" | "front" | "back";
  165584. type GPUFilterMode = "nearest" | "linear";
  165585. type GPUFrontFace = "ccw" | "cw";
  165586. type GPUIndexFormat = "uint16" | "uint32";
  165587. type GPUInputStepMode = "vertex" | "instance";
  165588. type GPULoadOp = "load";
  165589. type GPUPrimitiveTopology =
  165590. | "point-list"
  165591. | "line-list"
  165592. | "line-strip"
  165593. | "triangle-list"
  165594. | "triangle-strip";
  165595. type GPUStencilOperation =
  165596. | "keep"
  165597. | "zero"
  165598. | "replace"
  165599. | "invert"
  165600. | "increment-clamp"
  165601. | "decrement-clamp"
  165602. | "increment-wrap"
  165603. | "decrement-wrap";
  165604. type GPUStoreOp = "store" | "clear";
  165605. type GPUTextureDimension = "1d" | "2d" | "3d";
  165606. type GPUTextureFormat =
  165607. | "r8unorm"
  165608. | "r8snorm"
  165609. | "r8uint"
  165610. | "r8sint"
  165611. | "r16uint"
  165612. | "r16sint"
  165613. | "r16float"
  165614. | "rg8unorm"
  165615. | "rg8snorm"
  165616. | "rg8uint"
  165617. | "rg8sint"
  165618. | "r32uint"
  165619. | "r32sint"
  165620. | "r32float"
  165621. | "rg16uint"
  165622. | "rg16sint"
  165623. | "rg16float"
  165624. | "rgba8unorm"
  165625. | "rgba8unorm-srgb"
  165626. | "rgba8snorm"
  165627. | "rgba8uint"
  165628. | "rgba8sint"
  165629. | "bgra8unorm"
  165630. | "bgra8unorm-srgb"
  165631. | "rgb9e5ufloat"
  165632. | "rgb10a2unorm"
  165633. | "rg11b10ufloat"
  165634. | "rg32uint"
  165635. | "rg32sint"
  165636. | "rg32float"
  165637. | "rgba16uint"
  165638. | "rgba16sint"
  165639. | "rgba16float"
  165640. | "rgba32uint"
  165641. | "rgba32sint"
  165642. | "rgba32float"
  165643. | "stencil8"
  165644. | "depth16unorm"
  165645. | "depth24plus"
  165646. | "depth24plus-stencil8"
  165647. | "depth32float"
  165648. | "bc1-rgba-unorm"
  165649. | "bc1-rgba-unorm-srgb"
  165650. | "bc2-rgba-unorm"
  165651. | "bc2-rgba-unorm-srgb"
  165652. | "bc3-rgba-unorm"
  165653. | "bc3-rgba-unorm-srgb"
  165654. | "bc4-r-unorm"
  165655. | "bc4-r-snorm"
  165656. | "bc5-rg-unorm"
  165657. | "bc5-rg-snorm"
  165658. | "bc6h-rgb-ufloat"
  165659. | "bc6h-rgb-float"
  165660. | "bc7-rgba-unorm"
  165661. | "bc7-rgba-unorm-srgb"
  165662. | "depth24unorm-stencil8"
  165663. | "depth32float-stencil8";
  165664. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  165665. type GPUTextureViewDimension =
  165666. | "1d"
  165667. | "2d"
  165668. | "2d-array"
  165669. | "cube"
  165670. | "cube-array"
  165671. | "3d";
  165672. type GPUVertexFormat =
  165673. | "uchar2"
  165674. | "uchar4"
  165675. | "char2"
  165676. | "char4"
  165677. | "uchar2norm"
  165678. | "uchar4norm"
  165679. | "char2norm"
  165680. | "char4norm"
  165681. | "ushort2"
  165682. | "ushort4"
  165683. | "short2"
  165684. | "short4"
  165685. | "ushort2norm"
  165686. | "ushort4norm"
  165687. | "short2norm"
  165688. | "short4norm"
  165689. | "half2"
  165690. | "half4"
  165691. | "float"
  165692. | "float2"
  165693. | "float3"
  165694. | "float4"
  165695. | "uint"
  165696. | "uint2"
  165697. | "uint3"
  165698. | "uint4"
  165699. | "int"
  165700. | "int2"
  165701. | "int3"
  165702. | "int4";
  165703. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  165704. type GPUBufferUsageFlags = number;
  165705. type GPUColorWriteFlags = number;
  165706. type GPUShaderStageFlags = number;
  165707. type GPUTextureUsageFlags = number;
  165708. type GPUMapModeFlags = number;
  165709. interface GPUBindGroupEntry {
  165710. binding: number;
  165711. resource: GPUBindingResource;
  165712. }
  165713. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  165714. layout: GPUBindGroupLayout;
  165715. entries: Iterable<GPUBindGroupEntry>;
  165716. }
  165717. interface GPUBindGroupLayoutEntry {
  165718. binding: number;
  165719. visibility: GPUShaderStageFlags;
  165720. type: GPUBindingType;
  165721. hasDynamicOffset?: boolean;
  165722. minBufferBindingSize?: number;
  165723. viewDimension?: GPUTextureViewDimension;
  165724. textureComponentType?: GPUTextureComponentType;
  165725. storageTextureFormat?: GPUTextureFormat;
  165726. }
  165727. interface GPUBindGroupLayoutDescriptor
  165728. extends GPUObjectDescriptorBase {
  165729. entries: Iterable<GPUBindGroupLayoutEntry>;
  165730. }
  165731. interface GPUBlendDescriptor {
  165732. dstFactor?: GPUBlendFactor;
  165733. operation?: GPUBlendOperation;
  165734. srcFactor?: GPUBlendFactor;
  165735. }
  165736. interface GPUColorStateDescriptor {
  165737. format: GPUTextureFormat;
  165738. alphaBlend?: GPUBlendDescriptor;
  165739. colorBlend?: GPUBlendDescriptor;
  165740. writeMask?: GPUColorWriteFlags;
  165741. }
  165742. interface GPUBufferBinding {
  165743. buffer: GPUBuffer;
  165744. offset?: number;
  165745. size?: number;
  165746. }
  165747. interface GPUTextureDataLayout {
  165748. offset?: number;
  165749. bytesPerRow: number;
  165750. rowsPerImage?: number;
  165751. }
  165752. interface GPUBufferCopyView extends GPUTextureDataLayout {
  165753. buffer: GPUBuffer;
  165754. }
  165755. interface GPUTextureCopyView {
  165756. texture: GPUTexture;
  165757. mipLevel?: number;
  165758. origin?: GPUOrigin3D;
  165759. }
  165760. interface GPUImageBitmapCopyView {
  165761. imageBitmap: ImageBitmap;
  165762. origin?: GPUOrigin2D;
  165763. }
  165764. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  165765. size: number;
  165766. usage: GPUBufferUsageFlags;
  165767. mappedAtCreation?: boolean;
  165768. }
  165769. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  165770. label?: string;
  165771. measureExecutionTime?: boolean;
  165772. }
  165773. interface GPUComputePipelineDescriptor
  165774. extends GPUPipelineDescriptorBase {
  165775. computeStage: GPUProgrammableStageDescriptor;
  165776. }
  165777. interface GPUDepthStencilStateDescriptor {
  165778. format: GPUTextureFormat;
  165779. depthWriteEnabled?: boolean;
  165780. depthCompare?: GPUCompareFunction;
  165781. stencilFront?: GPUStencilStateFaceDescriptor;
  165782. stencilBack?: GPUStencilStateFaceDescriptor;
  165783. stencilReadMask?: number;
  165784. stencilWriteMask?: number;
  165785. }
  165786. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  165787. extensions?: Iterable<GPUExtensionName>;
  165788. limits?: GPULimits;
  165789. }
  165790. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  165791. initialValue?: number;
  165792. label?: string;
  165793. signalQueue?: GPUQueue;
  165794. }
  165795. interface GPUVertexAttributeDescriptor {
  165796. format: GPUVertexFormat;
  165797. offset: number;
  165798. shaderLocation: number;
  165799. }
  165800. interface GPUVertexBufferLayoutDescriptor {
  165801. arrayStride: number;
  165802. stepMode?: GPUInputStepMode;
  165803. attributes: Iterable<GPUVertexAttributeDescriptor>;
  165804. }
  165805. interface GPUVertexStateDescriptor {
  165806. indexFormat?: GPUIndexFormat;
  165807. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  165808. }
  165809. interface GPULimits {
  165810. maxBindGroups?: number;
  165811. maxDynamicUniformBuffersPerPipelineLayout?: number;
  165812. maxDynamicStorageBuffersPerPipelineLayout?: number;
  165813. maxSampledTexturesPerShaderStage?: number;
  165814. maxSamplersPerShaderStage?: number;
  165815. maxStorageBuffersPerShaderStage?: number;
  165816. maxStorageTexturesPerShaderStage?: number;
  165817. maxUniformBuffersPerShaderStage?: number;
  165818. maxUniformBufferBindingSize?: number;
  165819. }
  165820. interface GPUPipelineDescriptorBase {
  165821. label?: string;
  165822. layout?: GPUPipelineLayout;
  165823. }
  165824. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  165825. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  165826. }
  165827. interface GPUProgrammableStageDescriptor {
  165828. module: GPUShaderModule;
  165829. entryPoint: string;
  165830. }
  165831. interface GPURasterizationStateDescriptor {
  165832. frontFace?: GPUFrontFace;
  165833. cullMode?: GPUCullMode;
  165834. clampDepth?: boolean;
  165835. depthBias?: number;
  165836. depthBiasSlopeScale?: number;
  165837. depthBiasClamp?: number;
  165838. }
  165839. interface GPURenderPassColorAttachmentDescriptor {
  165840. attachment: GPUTextureView;
  165841. resolveTarget?: GPUTextureView;
  165842. loadValue: GPULoadOp | GPUColor;
  165843. storeOp?: GPUStoreOp;
  165844. }
  165845. interface GPURenderPassDepthStencilAttachmentDescriptor {
  165846. attachment: GPUTextureView;
  165847. depthLoadValue: GPULoadOp | number;
  165848. depthStoreOp: GPUStoreOp;
  165849. depthReadOnly?: boolean;
  165850. stencilLoadValue: GPULoadOp | number;
  165851. stencilStoreOp: GPUStoreOp;
  165852. stencilReadOnly?: boolean;
  165853. }
  165854. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  165855. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  165856. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  165857. }
  165858. interface GPURenderPipelineDescriptor
  165859. extends GPUPipelineDescriptorBase {
  165860. vertexStage: GPUProgrammableStageDescriptor;
  165861. fragmentStage?: GPUProgrammableStageDescriptor;
  165862. primitiveTopology: GPUPrimitiveTopology;
  165863. rasterizationState?: GPURasterizationStateDescriptor;
  165864. colorStates: Iterable<GPUColorStateDescriptor>;
  165865. depthStencilState?: GPUDepthStencilStateDescriptor;
  165866. vertexState?: GPUVertexStateDescriptor;
  165867. sampleCount?: number;
  165868. sampleMask?: number;
  165869. alphaToCoverageEnabled?: boolean;
  165870. }
  165871. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  165872. addressModeU?: GPUAddressMode;
  165873. addressModeV?: GPUAddressMode;
  165874. addressModeW?: GPUAddressMode;
  165875. magFilter?: GPUFilterMode;
  165876. minFilter?: GPUFilterMode;
  165877. mipmapFilter?: GPUFilterMode;
  165878. lodMinClamp?: number;
  165879. lodMaxClamp?: number;
  165880. compare?: GPUCompareFunction;
  165881. maxAnisotropy?: number;
  165882. }
  165883. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  165884. code: Uint32Array | string;
  165885. label?: string;
  165886. sourceMap?: object;
  165887. }
  165888. interface GPUStencilStateFaceDescriptor {
  165889. compare?: GPUCompareFunction;
  165890. depthFailOp?: GPUStencilOperation;
  165891. passOp?: GPUStencilOperation;
  165892. failOp?: GPUStencilOperation;
  165893. }
  165894. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  165895. device: GPUDevice;
  165896. format: GPUTextureFormat;
  165897. usage?: GPUTextureUsageFlags;
  165898. }
  165899. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  165900. size: GPUExtent3D;
  165901. mipLevelCount?: number;
  165902. sampleCount?: number;
  165903. dimension?: GPUTextureDimension;
  165904. format: GPUTextureFormat;
  165905. usage: GPUTextureUsageFlags;
  165906. }
  165907. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  165908. format?: GPUTextureFormat;
  165909. dimension?: GPUTextureViewDimension;
  165910. aspect?: GPUTextureAspect;
  165911. baseArrayLayer?: number;
  165912. baseMipLevel?: number;
  165913. arrayLayerCount?: number;
  165914. mipLevelCount?: number;
  165915. }
  165916. declare class GPUAdapter {
  165917. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  165918. private __brand: void;
  165919. readonly name: string;
  165920. readonly extensions: GPUExtensionName[];
  165921. readonly limits: Required<GPULimits>;
  165922. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  165923. }
  165924. declare class GPUBindGroup implements GPUObjectBase {
  165925. private __brand: void;
  165926. label: string | undefined;
  165927. }
  165928. declare class GPUBindGroupLayout implements GPUObjectBase {
  165929. private __brand: void;
  165930. label: string | undefined;
  165931. }
  165932. declare class GPUBuffer implements GPUObjectBase {
  165933. private __brand: void;
  165934. label: string | undefined;
  165935. destroy(): void;
  165936. unmap(): void;
  165937. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  165938. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  165939. }
  165940. declare class GPUCommandBuffer implements GPUObjectBase {
  165941. private __brand: void;
  165942. label: string | undefined;
  165943. readonly executionTime: Promise<number>;
  165944. }
  165945. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  165946. declare class GPUCommandEncoder implements GPUObjectBase {
  165947. private __brand: void;
  165948. label: string | undefined;
  165949. beginComputePass(
  165950. descriptor?: GPUComputePassDescriptor
  165951. ): GPUComputePassEncoder;
  165952. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  165953. copyBufferToBuffer(
  165954. source: GPUBuffer,
  165955. sourceOffset: number,
  165956. destination: GPUBuffer,
  165957. destinationOffset: number,
  165958. size: number
  165959. ): void;
  165960. copyBufferToTexture(
  165961. source: GPUBufferCopyView,
  165962. destination: GPUTextureCopyView,
  165963. copySize: GPUExtent3D
  165964. ): void;
  165965. copyTextureToBuffer(
  165966. source: GPUTextureCopyView,
  165967. destination: GPUBufferCopyView,
  165968. copySize: GPUExtent3D
  165969. ): void;
  165970. copyTextureToTexture(
  165971. source: GPUTextureCopyView,
  165972. destination: GPUTextureCopyView,
  165973. copySize: GPUExtent3D
  165974. ): void;
  165975. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  165976. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165977. popDebugGroup(): void;
  165978. pushDebugGroup(groupLabel: string): void;
  165979. insertDebugMarker(markerLabel: string): void;
  165980. }
  165981. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  165982. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  165983. private __brand: void;
  165984. label: string | undefined;
  165985. setBindGroup(
  165986. index: number,
  165987. bindGroup: GPUBindGroup,
  165988. dynamicOffsets?: Iterable<number>
  165989. ): void;
  165990. popDebugGroup(): void;
  165991. pushDebugGroup(groupLabel: string): void;
  165992. insertDebugMarker(markerLabel: string): void;
  165993. setPipeline(pipeline: GPUComputePipeline): void;
  165994. dispatch(x: number, y?: number, z?: number): void;
  165995. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165996. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165997. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165998. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165999. endPass(): void;
  166000. }
  166001. declare class GPUComputePipeline implements GPUPipelineBase {
  166002. private __brand: void;
  166003. label: string | undefined;
  166004. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166005. }
  166006. interface GPUObjectBase {
  166007. label: string | undefined;
  166008. }
  166009. interface GPUObjectDescriptorBase {
  166010. label?: string;
  166011. }
  166012. // SwapChain / CanvasContext
  166013. declare class GPUCanvasContext {
  166014. private __brand: void;
  166015. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  166016. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  166017. }
  166018. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  166019. private __brand: void;
  166020. label: string | undefined;
  166021. readonly adapter: GPUAdapter;
  166022. readonly extensions: GPUExtensionName[];
  166023. readonly limits: Required<GPULimits>;
  166024. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  166025. createBindGroupLayout(
  166026. descriptor: GPUBindGroupLayoutDescriptor
  166027. ): GPUBindGroupLayout;
  166028. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  166029. createPipelineLayout(
  166030. descriptor: GPUPipelineLayoutDescriptor
  166031. ): GPUPipelineLayout;
  166032. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  166033. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  166034. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  166035. createComputePipeline(
  166036. descriptor: GPUComputePipelineDescriptor
  166037. ): GPUComputePipeline;
  166038. createRenderPipeline(
  166039. descriptor: GPURenderPipelineDescriptor
  166040. ): GPURenderPipeline;
  166041. createReadyComputePipeline(
  166042. descriptor: GPUComputePipelineDescriptor
  166043. ): Promise<GPUComputePipeline>;
  166044. createReadyRenderPipeline(
  166045. descriptor: GPURenderPipelineDescriptor
  166046. ): Promise<GPURenderPipeline>;
  166047. createCommandEncoder(
  166048. descriptor?: GPUCommandEncoderDescriptor
  166049. ): GPUCommandEncoder;
  166050. createRenderBundleEncoder(
  166051. descriptor: GPURenderBundleEncoderDescriptor
  166052. ): GPURenderBundleEncoder;
  166053. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  166054. defaultQueue: GPUQueue;
  166055. pushErrorScope(filter: GPUErrorFilter): void;
  166056. popErrorScope(): Promise<GPUError | null>;
  166057. onuncapturederror: Event | undefined;
  166058. readonly lost: Promise<GPUDeviceLostInfo>;
  166059. }
  166060. declare class GPUFence implements GPUObjectBase {
  166061. private __brand: void;
  166062. label: string | undefined;
  166063. getCompletedValue(): number;
  166064. onCompletion(completionValue: number): Promise<void>;
  166065. }
  166066. interface GPUPipelineBase extends GPUObjectBase {
  166067. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166068. }
  166069. declare class GPUPipelineLayout implements GPUObjectBase {
  166070. private __brand: void;
  166071. label: string | undefined;
  166072. }
  166073. interface GPUProgrammablePassEncoder {
  166074. setBindGroup(
  166075. index: number,
  166076. bindGroup: GPUBindGroup,
  166077. dynamicOffsets?: Iterable<number>
  166078. ): void;
  166079. popDebugGroup(): void;
  166080. pushDebugGroup(groupLabel: string): void;
  166081. insertDebugMarker(markerLabel: string): void;
  166082. }
  166083. declare class GPUQueue implements GPUObjectBase {
  166084. private __brand: void;
  166085. label: string | undefined;
  166086. signal(fence: GPUFence, signalValue: number): void;
  166087. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  166088. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  166089. writeBuffer(buffer: GPUBuffer,
  166090. bufferOffset: number,
  166091. data: BufferSource | ArrayBuffer,
  166092. dataOffset?: number,
  166093. size?: number): void;
  166094. writeTexture(destination: GPUTextureCopyView,
  166095. data: BufferSource | ArrayBuffer,
  166096. dataLayout: GPUTextureDataLayout,
  166097. size: GPUExtent3D): void;
  166098. copyImageBitmapToTexture(
  166099. source: GPUImageBitmapCopyView,
  166100. destination: GPUTextureCopyView,
  166101. copySize: GPUExtent3D
  166102. ): void;
  166103. }
  166104. type GPUQueryType =
  166105. | "occlusion"
  166106. | "timestamp"
  166107. | "pipeline-statistics";
  166108. type GPUPipelineStatisticName =
  166109. | "vertex-shader-invocations"
  166110. | "clipper-invocations"
  166111. | "clipper-primitives-out"
  166112. | "fragment-shader-invocations"
  166113. | "compute-shader-invocations";
  166114. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  166115. type: GPUQueryType;
  166116. count: number;
  166117. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  166118. }
  166119. declare class GPUQuerySet implements GPUObjectBase {
  166120. private __brand: void;
  166121. label: string | undefined;
  166122. destroy(): void;
  166123. }
  166124. interface GPURenderEncoderBase {
  166125. setPipeline(pipeline: GPURenderPipeline): void;
  166126. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  166127. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166128. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  166129. draw(
  166130. vertexCount: number,
  166131. instanceCount?: number,
  166132. firstVertex?: number,
  166133. firstInstance?: number
  166134. ): void;
  166135. drawIndexed(
  166136. indexCount: number,
  166137. instanceCount?: number,
  166138. firstIndex?: number,
  166139. baseVertex?: number,
  166140. firstInstance?: number
  166141. ): void;
  166142. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166143. drawIndexedIndirect(
  166144. indirectBuffer: GPUBuffer,
  166145. indirectOffset: number
  166146. ): void;
  166147. }
  166148. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  166149. private __brand: void;
  166150. label: string | undefined;
  166151. setBindGroup(
  166152. index: number,
  166153. bindGroup: GPUBindGroup,
  166154. dynamicOffsets?: Iterable<number>
  166155. ): void;
  166156. popDebugGroup(): void;
  166157. pushDebugGroup(groupLabel: string): void;
  166158. insertDebugMarker(markerLabel: string): void;
  166159. setPipeline(pipeline: GPURenderPipeline): void;
  166160. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  166161. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166162. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  166163. draw(
  166164. vertexCount: number,
  166165. instanceCount?: number,
  166166. firstVertex?: number,
  166167. firstInstance?: number
  166168. ): void;
  166169. drawIndexed(
  166170. indexCount: number,
  166171. instanceCount?: number,
  166172. firstIndex?: number,
  166173. baseVertex?: number,
  166174. firstInstance?: number
  166175. ): void;
  166176. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166177. drawIndexedIndirect(
  166178. indirectBuffer: GPUBuffer,
  166179. indirectOffset: number
  166180. ): void;
  166181. setViewport(
  166182. x: number,
  166183. y: number,
  166184. width: number,
  166185. height: number,
  166186. minDepth: number,
  166187. maxDepth: number
  166188. ): void;
  166189. setScissorRect(x: number, y: number, width: number, height: number): void;
  166190. setBlendColor(color: GPUColor): void;
  166191. setStencilReference(reference: number): void;
  166192. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  166193. beginOcclusionQuery(queryIndex: number): void;
  166194. endOcclusionQuery(): void;
  166195. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166196. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166197. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  166198. endPass(): void;
  166199. }
  166200. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  166201. declare class GPURenderBundle implements GPUObjectBase {
  166202. private __brand: void;
  166203. label: string | undefined;
  166204. }
  166205. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  166206. private __brand: void;
  166207. label: string | undefined;
  166208. setBindGroup(
  166209. index: number,
  166210. bindGroup: GPUBindGroup,
  166211. dynamicOffsets?: Iterable<number>
  166212. ): void;
  166213. popDebugGroup(): void;
  166214. pushDebugGroup(groupLabel: string): void;
  166215. insertDebugMarker(markerLabel: string): void;
  166216. setPipeline(pipeline: GPURenderPipeline): void;
  166217. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  166218. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166219. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  166220. draw(
  166221. vertexCount: number,
  166222. instanceCount?: number,
  166223. firstVertex?: number,
  166224. firstInstance?: number
  166225. ): void;
  166226. drawIndexed(
  166227. indexCount: number,
  166228. instanceCount?: number,
  166229. firstIndex?: number,
  166230. baseVertex?: number,
  166231. firstInstance?: number
  166232. ): void;
  166233. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166234. drawIndexedIndirect(
  166235. indirectBuffer: GPUBuffer,
  166236. indirectOffset: number
  166237. ): void;
  166238. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  166239. }
  166240. interface GPURenderBundleEncoderDescriptor
  166241. extends GPUObjectDescriptorBase {
  166242. colorFormats: Iterable<GPUTextureFormat>;
  166243. depthStencilFormat?: GPUTextureFormat;
  166244. sampleCount?: number;
  166245. }
  166246. declare class GPURenderPipeline implements GPUPipelineBase {
  166247. private __brand: void;
  166248. label: string | undefined;
  166249. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166250. }
  166251. declare class GPUSampler implements GPUObjectBase {
  166252. private __brand: void;
  166253. label: string | undefined;
  166254. }
  166255. type GPUCompilationMessageType =
  166256. | "error"
  166257. | "warning"
  166258. | "info";
  166259. interface GPUCompilationMessage {
  166260. readonly message: string;
  166261. readonly type: GPUCompilationMessageType;
  166262. readonly lineNum: number;
  166263. readonly linePos: number;
  166264. }
  166265. interface GPUCompilationInfo {
  166266. readonly messages: readonly GPUCompilationMessage[];
  166267. }
  166268. declare class GPUShaderModule implements GPUObjectBase {
  166269. private __brand: void;
  166270. label: string | undefined;
  166271. compilationInfo(): Promise<GPUCompilationInfo>;
  166272. }
  166273. declare class GPUSwapChain implements GPUObjectBase {
  166274. private __brand: void;
  166275. label: string | undefined;
  166276. getCurrentTexture(): GPUTexture;
  166277. }
  166278. declare class GPUTexture implements GPUObjectBase {
  166279. private __brand: void;
  166280. label: string | undefined;
  166281. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  166282. destroy(): void;
  166283. }
  166284. declare class GPUTextureView implements GPUObjectBase {
  166285. private __brand: void;
  166286. label: string | undefined;
  166287. }
  166288. type GPUPowerPreference = "low-power" | "high-performance";
  166289. interface GPURequestAdapterOptions {
  166290. powerPreference?: GPUPowerPreference;
  166291. }
  166292. declare class GPU {
  166293. private __brand: void;
  166294. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  166295. }
  166296. // ****************************************************************************
  166297. // ERROR SCOPES
  166298. // ****************************************************************************
  166299. type GPUErrorFilter = "out-of-memory" | "validation";
  166300. declare class GPUOutOfMemoryError {
  166301. private __brand: void;
  166302. constructor();
  166303. }
  166304. declare class GPUValidationError {
  166305. private __brand: void;
  166306. constructor(message: string);
  166307. readonly message: string;
  166308. }
  166309. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  166310. // ****************************************************************************
  166311. // TELEMETRY
  166312. // ****************************************************************************
  166313. declare class GPUUncapturedErrorEvent extends Event {
  166314. private __brand: void;
  166315. constructor(
  166316. type: string,
  166317. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  166318. );
  166319. readonly error: GPUError;
  166320. }
  166321. interface GPUUncapturedErrorEventInit extends EventInit {
  166322. error: GPUError;
  166323. }
  166324. declare class GPUDeviceLostInfo {
  166325. private __brand: void;
  166326. readonly message: string;
  166327. }
  166328. // Type definitions for WebVR API
  166329. // Project: https://w3c.github.io/webvr/
  166330. // Definitions by: six a <https://github.com/lostfictions>
  166331. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  166332. interface VRDisplay extends EventTarget {
  166333. /**
  166334. * Dictionary of capabilities describing the VRDisplay.
  166335. */
  166336. readonly capabilities: VRDisplayCapabilities;
  166337. /**
  166338. * z-depth defining the far plane of the eye view frustum
  166339. * enables mapping of values in the render target depth
  166340. * attachment to scene coordinates. Initially set to 10000.0.
  166341. */
  166342. depthFar: number;
  166343. /**
  166344. * z-depth defining the near plane of the eye view frustum
  166345. * enables mapping of values in the render target depth
  166346. * attachment to scene coordinates. Initially set to 0.01.
  166347. */
  166348. depthNear: number;
  166349. /**
  166350. * An identifier for this distinct VRDisplay. Used as an
  166351. * association point in the Gamepad API.
  166352. */
  166353. readonly displayId: number;
  166354. /**
  166355. * A display name, a user-readable name identifying it.
  166356. */
  166357. readonly displayName: string;
  166358. readonly isConnected: boolean;
  166359. readonly isPresenting: boolean;
  166360. /**
  166361. * If this VRDisplay supports room-scale experiences, the optional
  166362. * stage attribute contains details on the room-scale parameters.
  166363. */
  166364. readonly stageParameters: VRStageParameters | null;
  166365. /**
  166366. * Passing the value returned by `requestAnimationFrame` to
  166367. * `cancelAnimationFrame` will unregister the callback.
  166368. * @param handle Define the hanle of the request to cancel
  166369. */
  166370. cancelAnimationFrame(handle: number): void;
  166371. /**
  166372. * Stops presenting to the VRDisplay.
  166373. * @returns a promise to know when it stopped
  166374. */
  166375. exitPresent(): Promise<void>;
  166376. /**
  166377. * Return the current VREyeParameters for the given eye.
  166378. * @param whichEye Define the eye we want the parameter for
  166379. * @returns the eye parameters
  166380. */
  166381. getEyeParameters(whichEye: string): VREyeParameters;
  166382. /**
  166383. * Populates the passed VRFrameData with the information required to render
  166384. * the current frame.
  166385. * @param frameData Define the data structure to populate
  166386. * @returns true if ok otherwise false
  166387. */
  166388. getFrameData(frameData: VRFrameData): boolean;
  166389. /**
  166390. * Get the layers currently being presented.
  166391. * @returns the list of VR layers
  166392. */
  166393. getLayers(): VRLayer[];
  166394. /**
  166395. * Return a VRPose containing the future predicted pose of the VRDisplay
  166396. * when the current frame will be presented. The value returned will not
  166397. * change until JavaScript has returned control to the browser.
  166398. *
  166399. * The VRPose will contain the position, orientation, velocity,
  166400. * and acceleration of each of these properties.
  166401. * @returns the pose object
  166402. */
  166403. getPose(): VRPose;
  166404. /**
  166405. * Return the current instantaneous pose of the VRDisplay, with no
  166406. * prediction applied.
  166407. * @returns the current instantaneous pose
  166408. */
  166409. getImmediatePose(): VRPose;
  166410. /**
  166411. * The callback passed to `requestAnimationFrame` will be called
  166412. * any time a new frame should be rendered. When the VRDisplay is
  166413. * presenting the callback will be called at the native refresh
  166414. * rate of the HMD. When not presenting this function acts
  166415. * identically to how window.requestAnimationFrame acts. Content should
  166416. * make no assumptions of frame rate or vsync behavior as the HMD runs
  166417. * asynchronously from other displays and at differing refresh rates.
  166418. * @param callback Define the eaction to run next frame
  166419. * @returns the request handle it
  166420. */
  166421. requestAnimationFrame(callback: FrameRequestCallback): number;
  166422. /**
  166423. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  166424. * Repeat calls while already presenting will update the VRLayers being displayed.
  166425. * @param layers Define the list of layer to present
  166426. * @returns a promise to know when the request has been fulfilled
  166427. */
  166428. requestPresent(layers: VRLayer[]): Promise<void>;
  166429. /**
  166430. * Reset the pose for this display, treating its current position and
  166431. * orientation as the "origin/zero" values. VRPose.position,
  166432. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  166433. * updated when calling resetPose(). This should be called in only
  166434. * sitting-space experiences.
  166435. */
  166436. resetPose(): void;
  166437. /**
  166438. * The VRLayer provided to the VRDisplay will be captured and presented
  166439. * in the HMD. Calling this function has the same effect on the source
  166440. * canvas as any other operation that uses its source image, and canvases
  166441. * created without preserveDrawingBuffer set to true will be cleared.
  166442. * @param pose Define the pose to submit
  166443. */
  166444. submitFrame(pose?: VRPose): void;
  166445. }
  166446. declare var VRDisplay: {
  166447. prototype: VRDisplay;
  166448. new(): VRDisplay;
  166449. };
  166450. interface VRLayer {
  166451. leftBounds?: number[] | Float32Array | null;
  166452. rightBounds?: number[] | Float32Array | null;
  166453. source?: HTMLCanvasElement | null;
  166454. }
  166455. interface VRDisplayCapabilities {
  166456. readonly canPresent: boolean;
  166457. readonly hasExternalDisplay: boolean;
  166458. readonly hasOrientation: boolean;
  166459. readonly hasPosition: boolean;
  166460. readonly maxLayers: number;
  166461. }
  166462. interface VREyeParameters {
  166463. /** @deprecated */
  166464. readonly fieldOfView: VRFieldOfView;
  166465. readonly offset: Float32Array;
  166466. readonly renderHeight: number;
  166467. readonly renderWidth: number;
  166468. }
  166469. interface VRFieldOfView {
  166470. readonly downDegrees: number;
  166471. readonly leftDegrees: number;
  166472. readonly rightDegrees: number;
  166473. readonly upDegrees: number;
  166474. }
  166475. interface VRFrameData {
  166476. readonly leftProjectionMatrix: Float32Array;
  166477. readonly leftViewMatrix: Float32Array;
  166478. readonly pose: VRPose;
  166479. readonly rightProjectionMatrix: Float32Array;
  166480. readonly rightViewMatrix: Float32Array;
  166481. readonly timestamp: number;
  166482. }
  166483. interface VRPose {
  166484. readonly angularAcceleration: Float32Array | null;
  166485. readonly angularVelocity: Float32Array | null;
  166486. readonly linearAcceleration: Float32Array | null;
  166487. readonly linearVelocity: Float32Array | null;
  166488. readonly orientation: Float32Array | null;
  166489. readonly position: Float32Array | null;
  166490. readonly timestamp: number;
  166491. }
  166492. interface VRStageParameters {
  166493. sittingToStandingTransform?: Float32Array;
  166494. sizeX?: number;
  166495. sizeY?: number;
  166496. }
  166497. interface Navigator {
  166498. getVRDisplays(): Promise<VRDisplay[]>;
  166499. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  166500. }
  166501. interface Window {
  166502. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  166503. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  166504. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  166505. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  166506. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  166507. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  166508. }
  166509. interface Gamepad {
  166510. readonly displayId: number;
  166511. }
  166512. /**
  166513. * Available session modes
  166514. */
  166515. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  166516. /**
  166517. * Reference space types
  166518. */
  166519. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  166520. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  166521. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  166522. /**
  166523. * Handedness types
  166524. */
  166525. type XRHandedness = "none" | "left" | "right";
  166526. /**
  166527. * InputSource target ray modes
  166528. */
  166529. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  166530. /**
  166531. * Eye types
  166532. */
  166533. type XREye = "none" | "left" | "right";
  166534. /**
  166535. * Type of XR events available
  166536. */
  166537. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  166538. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  166539. type XRPlaneSet = Set<XRPlane>;
  166540. type XRAnchorSet = Set<XRAnchor>;
  166541. type XREventHandler = (callback: any) => void;
  166542. interface XRLayer extends EventTarget {}
  166543. interface XRSessionInit {
  166544. optionalFeatures?: string[];
  166545. requiredFeatures?: string[];
  166546. trackedImages?: XRTrackedImageInit[];
  166547. }
  166548. interface XRSessionEvent extends Event {
  166549. readonly session: XRSession;
  166550. }
  166551. interface XRSystem {
  166552. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  166553. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  166554. }
  166555. interface XRViewport {
  166556. readonly x: number;
  166557. readonly y: number;
  166558. readonly width: number;
  166559. readonly height: number;
  166560. }
  166561. interface XRWebGLLayerInit {
  166562. antialias?: boolean;
  166563. depth?: boolean;
  166564. stencil?: boolean;
  166565. alpha?: boolean;
  166566. multiview?: boolean;
  166567. framebufferScaleFactor?: number;
  166568. }
  166569. declare class XRWebGLLayer {
  166570. static getNativeFramebufferScaleFactor(session: XRSession): number;
  166571. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  166572. readonly antialias: boolean;
  166573. readonly framebuffer: WebGLFramebuffer;
  166574. readonly framebufferWidth: number;
  166575. readonly framebufferHeight: number;
  166576. readonly ignoreDepthValues: boolean;
  166577. getViewport: (view: XRView) => XRViewport;
  166578. }
  166579. // tslint:disable-next-line no-empty-interface
  166580. interface XRSpace extends EventTarget {}
  166581. interface XRRenderState {
  166582. readonly baseLayer?: XRWebGLLayer;
  166583. readonly depthFar: number;
  166584. readonly depthNear: number;
  166585. readonly inlineVerticalFieldOfView?: number;
  166586. }
  166587. interface XRRenderStateInit extends XRRenderState {
  166588. baseLayer: XRWebGLLayer;
  166589. depthFar: number;
  166590. depthNear: number;
  166591. inlineVerticalFieldOfView?: number;
  166592. layers?: XRLayer[];
  166593. }
  166594. interface XRReferenceSpace extends XRSpace {
  166595. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  166596. onreset: XREventHandler;
  166597. }
  166598. interface XRBoundedReferenceSpace extends XRSpace {
  166599. readonly boundsGeometry: DOMPointReadOnly[];
  166600. }
  166601. interface XRInputSource {
  166602. readonly handedness: XRHandedness;
  166603. readonly targetRayMode: XRTargetRayMode;
  166604. readonly targetRaySpace: XRSpace;
  166605. readonly gripSpace?: XRSpace;
  166606. readonly gamepad?: Gamepad;
  166607. readonly profiles: Array<string>;
  166608. readonly hand?: XRHand;
  166609. }
  166610. interface XRPose {
  166611. readonly transform: XRRigidTransform;
  166612. readonly emulatedPosition: boolean;
  166613. }
  166614. interface XRWorldInformation {
  166615. detectedPlanes?: XRPlaneSet;
  166616. }
  166617. interface XRFrame {
  166618. readonly session: XRSession;
  166619. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  166620. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  166621. // AR
  166622. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  166623. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  166624. // Anchors
  166625. trackedAnchors?: XRAnchorSet;
  166626. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  166627. // World geometries
  166628. worldInformation?: XRWorldInformation;
  166629. // Hand tracking
  166630. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  166631. // Image tracking
  166632. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  166633. }
  166634. interface XRInputSourceEvent extends Event {
  166635. readonly frame: XRFrame;
  166636. readonly inputSource: XRInputSource;
  166637. }
  166638. type XRInputSourceArray = XRInputSource[];
  166639. interface XRSession {
  166640. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  166641. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  166642. /**
  166643. * Returns a list of this session's XRInputSources, each representing an input device
  166644. * used to control the camera and/or scene.
  166645. */
  166646. readonly inputSources: Array<XRInputSource>;
  166647. /**
  166648. * object which contains options affecting how the imagery is rendered.
  166649. * This includes things such as the near and far clipping planes
  166650. */
  166651. readonly renderState: XRRenderState;
  166652. readonly visibilityState: XRVisibilityState;
  166653. /**
  166654. * Removes a callback from the animation frame painting callback from
  166655. * XRSession's set of animation frame rendering callbacks, given the
  166656. * identifying handle returned by a previous call to requestAnimationFrame().
  166657. */
  166658. cancelAnimationFrame: (handle: number) => void;
  166659. /**
  166660. * Ends the WebXR session. Returns a promise which resolves when the
  166661. * session has been shut down.
  166662. */
  166663. end(): Promise<void>;
  166664. /**
  166665. * Schedules the specified method to be called the next time the user agent
  166666. * is working on rendering an animation frame for the WebXR device. Returns an
  166667. * integer value which can be used to identify the request for the purposes of
  166668. * canceling the callback using cancelAnimationFrame(). This method is comparable
  166669. * to the Window.requestAnimationFrame() method.
  166670. */
  166671. requestAnimationFrame: XRFrameRequestCallback;
  166672. /**
  166673. * Requests that a new XRReferenceSpace of the specified type be created.
  166674. * Returns a promise which resolves with the XRReferenceSpace or
  166675. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  166676. * the requested space type isn't supported by the device.
  166677. */
  166678. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  166679. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  166680. onend: XREventHandler;
  166681. oninputsourceschange: XREventHandler;
  166682. onselect: XREventHandler;
  166683. onselectstart: XREventHandler;
  166684. onselectend: XREventHandler;
  166685. onsqueeze: XREventHandler;
  166686. onsqueezestart: XREventHandler;
  166687. onsqueezeend: XREventHandler;
  166688. onvisibilitychange: XREventHandler;
  166689. // hit test
  166690. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  166691. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  166692. // legacy AR hit test
  166693. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  166694. // legacy plane detection
  166695. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  166696. // image tracking
  166697. getTrackedImageScores?(): XRImageTrackingScore[];
  166698. }
  166699. interface XRViewerPose extends XRPose {
  166700. readonly views: Array<XRView>;
  166701. }
  166702. declare class XRRigidTransform {
  166703. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  166704. position: DOMPointReadOnly;
  166705. orientation: DOMPointReadOnly;
  166706. matrix: Float32Array;
  166707. inverse: XRRigidTransform;
  166708. }
  166709. interface XRView {
  166710. readonly eye: XREye;
  166711. readonly projectionMatrix: Float32Array;
  166712. readonly transform: XRRigidTransform;
  166713. readonly recommendedViewportScale?: number;
  166714. requestViewportScale(scale: number): void;
  166715. }
  166716. interface XRInputSourceChangeEvent extends Event {
  166717. session: XRSession;
  166718. removed: Array<XRInputSource>;
  166719. added: Array<XRInputSource>;
  166720. }
  166721. // Experimental/Draft features
  166722. declare class XRRay {
  166723. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  166724. origin: DOMPointReadOnly;
  166725. direction: DOMPointReadOnly;
  166726. matrix: Float32Array;
  166727. }
  166728. declare enum XRHitTestTrackableType {
  166729. "point",
  166730. "plane",
  166731. "mesh",
  166732. }
  166733. interface XRHitResult {
  166734. hitMatrix: Float32Array;
  166735. }
  166736. interface XRTransientInputHitTestResult {
  166737. readonly inputSource: XRInputSource;
  166738. readonly results: Array<XRHitTestResult>;
  166739. }
  166740. interface XRHitTestResult {
  166741. getPose(baseSpace: XRSpace): XRPose | undefined;
  166742. // When anchor system is enabled
  166743. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  166744. }
  166745. interface XRHitTestSource {
  166746. cancel(): void;
  166747. }
  166748. interface XRTransientInputHitTestSource {
  166749. cancel(): void;
  166750. }
  166751. interface XRHitTestOptionsInit {
  166752. space: XRSpace;
  166753. entityTypes?: Array<XRHitTestTrackableType>;
  166754. offsetRay?: XRRay;
  166755. }
  166756. interface XRTransientInputHitTestOptionsInit {
  166757. profile: string;
  166758. entityTypes?: Array<XRHitTestTrackableType>;
  166759. offsetRay?: XRRay;
  166760. }
  166761. interface XRAnchor {
  166762. anchorSpace: XRSpace;
  166763. delete(): void;
  166764. }
  166765. interface XRPlane {
  166766. orientation: "Horizontal" | "Vertical";
  166767. planeSpace: XRSpace;
  166768. polygon: Array<DOMPointReadOnly>;
  166769. lastChangedTime: number;
  166770. }
  166771. interface XRJointSpace extends XRSpace {}
  166772. interface XRJointPose extends XRPose {
  166773. radius: number | undefined;
  166774. }
  166775. interface XRHand extends Iterable<XRJointSpace> {
  166776. readonly length: number;
  166777. [index: number]: XRJointSpace;
  166778. readonly WRIST: number;
  166779. readonly THUMB_METACARPAL: number;
  166780. readonly THUMB_PHALANX_PROXIMAL: number;
  166781. readonly THUMB_PHALANX_DISTAL: number;
  166782. readonly THUMB_PHALANX_TIP: number;
  166783. readonly INDEX_METACARPAL: number;
  166784. readonly INDEX_PHALANX_PROXIMAL: number;
  166785. readonly INDEX_PHALANX_INTERMEDIATE: number;
  166786. readonly INDEX_PHALANX_DISTAL: number;
  166787. readonly INDEX_PHALANX_TIP: number;
  166788. readonly MIDDLE_METACARPAL: number;
  166789. readonly MIDDLE_PHALANX_PROXIMAL: number;
  166790. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  166791. readonly MIDDLE_PHALANX_DISTAL: number;
  166792. readonly MIDDLE_PHALANX_TIP: number;
  166793. readonly RING_METACARPAL: number;
  166794. readonly RING_PHALANX_PROXIMAL: number;
  166795. readonly RING_PHALANX_INTERMEDIATE: number;
  166796. readonly RING_PHALANX_DISTAL: number;
  166797. readonly RING_PHALANX_TIP: number;
  166798. readonly LITTLE_METACARPAL: number;
  166799. readonly LITTLE_PHALANX_PROXIMAL: number;
  166800. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  166801. readonly LITTLE_PHALANX_DISTAL: number;
  166802. readonly LITTLE_PHALANX_TIP: number;
  166803. }
  166804. type XRImageTrackingState = "tracked" | "emulated";
  166805. type XRImageTrackingScore = "untrackable" | "trackable";
  166806. interface XRTrackedImageInit {
  166807. image: ImageBitmap;
  166808. widthInMeters: number;
  166809. }
  166810. interface XRImageTrackingResult {
  166811. readonly imageSpace: XRSpace;
  166812. readonly index: number;
  166813. readonly trackingState: XRImageTrackingState;
  166814. readonly measuredWidthInMeters: number;
  166815. }
  166816. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  166817. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  166818. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  166819. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  166820. interface XRSceneObject {
  166821. type: XRSceneObjectType;
  166822. }
  166823. interface XRFieldOfView {
  166824. angleLeft: number;
  166825. angleRight: number;
  166826. angleUp: number;
  166827. angleDown: number;
  166828. }
  166829. interface XRFrustum {
  166830. position: DOMPointReadOnly;
  166831. orientation: DOMPointReadOnly;
  166832. fieldOfView: XRFieldOfView;
  166833. farDistance: number;
  166834. }
  166835. interface XRPlane {
  166836. parentSceneObject?: XRSceneObject;
  166837. }
  166838. interface XRMesh {
  166839. meshSpace: XRSpace;
  166840. positions: Float32Array;
  166841. indices: Uint32Array;
  166842. normals?: Float32Array;
  166843. lastChangedTime: number;
  166844. parentSceneObject?: XRSceneObject;
  166845. }
  166846. interface XRFrustumDetectionBoundary {
  166847. type: "frustum";
  166848. frustum: XRFrustum;
  166849. }
  166850. interface XRSphereDetectionBoundary {
  166851. type: "sphere";
  166852. radius: number;
  166853. }
  166854. interface XRBoxDetectionBoundary {
  166855. type: "box";
  166856. extent: DOMPointReadOnly;
  166857. }
  166858. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  166859. interface XRGeometryDetectorOptions {
  166860. detectionBoundary?: XRDetectionBoundary;
  166861. updateInterval?: number;
  166862. }
  166863. interface XRSession {
  166864. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  166865. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166866. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  166867. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166868. }
  166869. interface XRFrame {
  166870. featurePointCloud?: Array<number>;
  166871. }
  166872. type XRMeshSet = Set<XRMesh>;
  166873. interface XRWorldInformation {
  166874. detectedMeshes?: XRMeshSet;
  166875. }